nvim: some tweaks
- plugins.lua: put autocmd into autocmd.lua file - options.lua: put options, variables into tables
This commit is contained in:
parent
aa3aef4942
commit
ba7f43532a
|
@ -39,5 +39,5 @@
|
|||
zathura-pdf-mupdf, openssh-client-default, river, btop, zellij,
|
||||
alacritty, unifont, python3-dev, py3-requests, py3-proxmoxer,
|
||||
rofi-calc, rofi-wayland, rofi-file-browser-extended, rofi-emoji,
|
||||
automake, autoconf, libtool, mbuffer
|
||||
automake, autoconf, libtool, mbuffer, onefetch
|
||||
state: present
|
||||
|
|
|
@ -7,5 +7,5 @@ require('user.keymap').setup()
|
|||
vim.defer_fn(function()
|
||||
local plugins = require('user.plugins')
|
||||
plugins.ensure_plugins()
|
||||
plugins.load_commands()
|
||||
plugins.make_commands()
|
||||
end, 0)
|
||||
|
|
|
@ -43,6 +43,10 @@ local augroups = {
|
|||
{ 'User', 'AlphaReady', 'set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2' },
|
||||
-- Wrap in Telescope preview window
|
||||
{ 'User', 'TelescopePreviewerLoaded', 'setlocal wrap' },
|
||||
-- Packer compile on save
|
||||
-- { 'BufWritePost', '*.lua', 'lua require("user.plugins").compile_on_save()' },
|
||||
-- Packer compile ahead to bytecode and print a notification when done
|
||||
{ 'User', 'PackerCompileDone', 'lua require("user.plugins").on_compile_done()' },
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ local sources = {
|
|||
-- codespell = { command = linters_path .. '/codespell/venv/bin/codespell' },
|
||||
},
|
||||
diagnostics = {
|
||||
'yamllint',
|
||||
-- 'yamllint',
|
||||
'shellcheck',
|
||||
-- codespell = { command = linters_path .. '/codespell/venv/bin/codespell' },
|
||||
cspell = {
|
||||
|
|
|
@ -99,11 +99,9 @@ function M.on_compile_done()
|
|||
vim.notify('packer.compile: Complete', vim.log.levels.DEBUG, { title = 'packer.nvim' })
|
||||
end
|
||||
|
||||
function M.load_commands()
|
||||
local exec = vim.api.nvim_exec
|
||||
|
||||
function M.make_commands()
|
||||
-- Don't define PackerInstall, PackerUpdate and PackerProfile
|
||||
exec(
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
command! -nargs=+ -complete=customlist,v:lua.require'packer.snapshot'.completion.create PackerSnapshot lua require('packer').snapshot(<f-args>)
|
||||
command! -nargs=+ -complete=customlist,v:lua.require'packer.snapshot'.completion.rollback PackerSnapshotRollback lua require('packer').rollback(<f-args>)
|
||||
|
@ -116,28 +114,6 @@ function M.load_commands()
|
|||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Compile on save
|
||||
-- exec(
|
||||
-- [[
|
||||
-- augroup packer_compile_on_save
|
||||
-- autocmd!
|
||||
-- autocmd BufWritePost *.lua lua require('user.plugins').compile_on_save()
|
||||
-- augroup END
|
||||
-- ]],
|
||||
-- false
|
||||
-- )
|
||||
|
||||
-- Compile ahead to bytecode and print a notification when done
|
||||
exec(
|
||||
[[
|
||||
augroup packer_on_compile_done
|
||||
autocmd!
|
||||
autocmd User PackerCompileDone lua require('user.plugins').on_compile_done()
|
||||
augroup END
|
||||
]],
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,178 +1,189 @@
|
|||
local g, opt = vim.g, vim.opt
|
||||
|
||||
local function disable_default_plugins()
|
||||
g.loaded_gzip = 1
|
||||
g.loaded_tar = 1
|
||||
g.loaded_tarPlugin = 1
|
||||
g.loaded_zip = 1
|
||||
g.loaded_zipPlugin = 1
|
||||
g.loaded_getscript = 1
|
||||
g.loaded_getscriptPlugin = 1
|
||||
g.loaded_vimball = 1
|
||||
g.loaded_vimballPlugin = 1
|
||||
g.loaded_matchit = 1
|
||||
g.loaded_matchparen = 1
|
||||
g.loaded_2html_plugin = 1
|
||||
g.loaded_logiPat = 1
|
||||
g.loaded_rrhelper = 1
|
||||
g.loaded_netrw = 1
|
||||
g.loaded_netrwPlugin = 1
|
||||
g.loaded_netrwSettings = 1
|
||||
g.loaded_netrwFileHandlers = 1
|
||||
g.loaded_python_provider = 0 -- disable python2 support
|
||||
end
|
||||
|
||||
local function load_options()
|
||||
-- Set colorscheme
|
||||
vim.api.nvim_command('colorscheme {{ theme }}')
|
||||
local global_vars = {
|
||||
-- Disable default vim plugins
|
||||
loaded_gzip = 1,
|
||||
loaded_tar = 1,
|
||||
loaded_tarPlugin = 1,
|
||||
loaded_zip = 1,
|
||||
loaded_zipPlugin = 1,
|
||||
loaded_getscript = 1,
|
||||
loaded_getscriptPlugin = 1,
|
||||
loaded_vimball = 1,
|
||||
loaded_vimballPlugin = 1,
|
||||
loaded_matchit = 1,
|
||||
loaded_matchparen = 1,
|
||||
loaded_2html_plugin = 1,
|
||||
loaded_logiPat = 1,
|
||||
loaded_rrhelper = 1,
|
||||
loaded_netrw = 1,
|
||||
loaded_netrwPlugin = 1,
|
||||
loaded_netrwSettings = 1,
|
||||
loaded_netrwFileHandlers = 1,
|
||||
|
||||
-- Leader keys
|
||||
g.mapleader = ' '
|
||||
g.maplocalleader = ','
|
||||
-- Python path
|
||||
g.python3_host_prog = '/usr/bin/python3'
|
||||
opt.pyxversion = 3
|
||||
mapleader = ' ',
|
||||
maplocalleader = ',',
|
||||
-- TeX flavor
|
||||
g.tex_flavor = 'latex'
|
||||
tex_flavor = 'latex',
|
||||
|
||||
-- Custom variables
|
||||
border_style = 'rounded',
|
||||
}
|
||||
|
||||
local vim_options = {
|
||||
-- General settings
|
||||
opt.termguicolors = true
|
||||
opt.mouse = 'nv'
|
||||
opt.errorbells = false
|
||||
opt.visualbell = false
|
||||
-- opt.hidden = true
|
||||
opt.fileformats = 'unix'
|
||||
opt.magic = true
|
||||
opt.virtualedit = 'block'
|
||||
opt.encoding = 'utf-8'
|
||||
opt.fileencoding = 'utf-8'
|
||||
opt.clipboard = 'unnamedplus'
|
||||
opt.wildignorecase = true
|
||||
opt.wildignore =
|
||||
'.git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**'
|
||||
-- opt.history = 10000
|
||||
-- opt.showmode = false
|
||||
opt.jumpoptions = 'stack'
|
||||
opt.formatoptions = '1jcroql'
|
||||
opt.shortmess = 'aoOTIcF'
|
||||
-- opt.startofline = false
|
||||
opt.wrap = false
|
||||
opt.sidescrolloff = 4
|
||||
opt.scrolloff = 4
|
||||
opt.whichwrap = '<,>,[,],~'
|
||||
-- opt.ruler = true
|
||||
-- opt.display = 'lastline'
|
||||
-- opt.colorcolumn = '80'
|
||||
-- opt.cursorcolumn = true
|
||||
opt.cursorline = true
|
||||
opt.cursorlineopt = 'number'
|
||||
-- opt.backspace = 'indent,eol,start'
|
||||
opt.showcmd = false
|
||||
-- opt.inccommand = 'nosplit'
|
||||
-- opt.cmdheight = 2
|
||||
-- opt.cmdwinheight = 6
|
||||
opt.showtabline = 2
|
||||
-- opt.laststatus = 2
|
||||
-- opt.textwidth = 80
|
||||
opt.synmaxcol = 2500
|
||||
opt.shell = 'sh'
|
||||
opt.grepformat = '%f:%l:%c:%m'
|
||||
opt.grepprg = 'rg --hidden --vimgrep --smart-case --'
|
||||
opt.diffopt = 'filler,iwhite,internal,algorithm:patience'
|
||||
termguicolors = true,
|
||||
mouse = 'nv',
|
||||
errorbells = false,
|
||||
visualbell = false,
|
||||
-- hidden = true,
|
||||
fileformats = 'unix',
|
||||
magic = true,
|
||||
virtualedit = 'block',
|
||||
encoding = 'utf-8',
|
||||
fileencoding = 'utf-8',
|
||||
clipboard = 'unnamedplus',
|
||||
wildignorecase = true,
|
||||
wildignore =
|
||||
'.git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**',
|
||||
-- history = 10000,
|
||||
-- showmode = false,
|
||||
jumpoptions = 'stack',
|
||||
formatoptions = '1jcroql',
|
||||
shortmess = 'aoOTIcF',
|
||||
-- startofline = false,
|
||||
wrap = false,
|
||||
sidescrolloff = 4,
|
||||
scrolloff = 4,
|
||||
whichwrap = '<,>,[,],~',
|
||||
-- ruler = true,
|
||||
-- display = 'lastline',
|
||||
-- colorcolumn = '80',
|
||||
-- cursorcolumn = true,
|
||||
cursorline = true,
|
||||
cursorlineopt = 'number',
|
||||
-- backspace = 'indent,eol,start',
|
||||
showcmd = false,
|
||||
-- inccommand = 'nosplit',
|
||||
-- cmdheight = 2,
|
||||
-- cmdwinheight = 6,
|
||||
showtabline = 2,
|
||||
-- laststatus = 2,
|
||||
-- textwidth = 80,
|
||||
synmaxcol = 2500,
|
||||
shell = 'sh',
|
||||
grepformat = '%f:%l:%c:%m',
|
||||
grepprg = 'rg --hidden --vimgrep --smart-case --',
|
||||
diffopt = 'filler,iwhite,internal,algorithm:patience',
|
||||
|
||||
-- CVE-2019-12735 (it is patched, but just to be cautious)
|
||||
-- I don't use modeline personally anyway
|
||||
opt.modeline = false
|
||||
opt.modelines = 0
|
||||
modeline = false,
|
||||
modelines = 0,
|
||||
|
||||
-- Spell checking, dictionary
|
||||
-- opt.spell = true
|
||||
opt.spellfile = vim.fn.stdpath('config') .. '/spell/en.utf-8.add'
|
||||
-- opt.dictionary = { '/usr/share/dict/american-english' }
|
||||
-- spell = true,
|
||||
-- spellfile = vim.fn.stdpath('config') .. '/spell/en.utf-8.add',
|
||||
-- dictionary = { '/usr/share/dict/american-english' },
|
||||
|
||||
-- Transparency
|
||||
opt.pumblend = 0
|
||||
opt.winblend = 0
|
||||
pumblend = 0,
|
||||
winblend = 0,
|
||||
|
||||
-- Conceal
|
||||
opt.conceallevel = 2
|
||||
opt.concealcursor = 'niv'
|
||||
opt.foldenable = false
|
||||
opt.foldlevelstart = 99
|
||||
conceallevel = 2,
|
||||
concealcursor = 'niv',
|
||||
foldenable = false,
|
||||
foldlevelstart = 99,
|
||||
|
||||
-- Case insensitive
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.infercase = true
|
||||
ignorecase = true,
|
||||
smartcase = true,
|
||||
infercase = true,
|
||||
|
||||
-- Searching
|
||||
-- opt.incsearch = true
|
||||
opt.hlsearch = true
|
||||
-- opt.wrapscan = true
|
||||
-- incsearch = true,
|
||||
hlsearch = true,
|
||||
-- wrapscan = true,
|
||||
|
||||
-- Update time
|
||||
-- opt.timeout = true
|
||||
-- opt.ttimeout = true
|
||||
opt.timeoutlen = 500
|
||||
opt.ttimeoutlen = 25
|
||||
opt.updatetime = 150
|
||||
opt.redrawtime = 1500
|
||||
opt.lazyredraw = true
|
||||
-- timeout = true,
|
||||
-- ttimeout = true,
|
||||
timeoutlen = 500,
|
||||
ttimeoutlen = 25,
|
||||
updatetime = 150,
|
||||
redrawtime = 1500,
|
||||
lazyredraw = true,
|
||||
|
||||
-- No swapfile
|
||||
opt.backup = false
|
||||
opt.writebackup = false
|
||||
opt.swapfile = false
|
||||
backup = false,
|
||||
writebackup = false,
|
||||
swapfile = false,
|
||||
|
||||
-- Completion menu
|
||||
-- opt.wildmenu = true
|
||||
opt.wildmode = 'full'
|
||||
opt.complete = '.,w,b,k'
|
||||
opt.completeopt = 'menu,menuone,noselect'
|
||||
opt.pumheight = 16
|
||||
opt.helpheight = 12
|
||||
opt.previewheight = 12
|
||||
-- wildmenu = true,
|
||||
wildmode = 'full',
|
||||
complete = '.,w,b,k',
|
||||
completeopt = 'menu,menuone,noselect',
|
||||
pumheight = 16,
|
||||
helpheight = 12,
|
||||
previewheight = 12,
|
||||
|
||||
-- Window rules
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
opt.switchbuf = 'useopen'
|
||||
opt.winwidth = 30
|
||||
opt.winminwidth = 10
|
||||
opt.equalalways = false
|
||||
splitbelow = true,
|
||||
splitright = true,
|
||||
switchbuf = 'useopen',
|
||||
winwidth = 30,
|
||||
winminwidth = 10,
|
||||
equalalways = false,
|
||||
|
||||
-- Left column
|
||||
opt.signcolumn = 'auto:4'
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
-- opt.numberwidth = 6
|
||||
signcolumn = 'auto:4',
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
-- numberwidth = 6,
|
||||
|
||||
-- 4 spaces = 1 tab
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.softtabstop = -1 -- fallback to 'shiftwidth'
|
||||
opt.smarttab = true
|
||||
opt.expandtab = true
|
||||
opt.smartindent = true
|
||||
-- opt.autoindent = true
|
||||
opt.shiftround = true
|
||||
shiftwidth = 4,
|
||||
tabstop = 4,
|
||||
softtabstop = -1, -- fallback to 'shiftwidth'
|
||||
smarttab = true,
|
||||
expandtab = true,
|
||||
smartindent = true,
|
||||
-- autoindent = true,
|
||||
shiftround = true,
|
||||
|
||||
-- Trailings, line break
|
||||
opt.list = true
|
||||
opt.listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←'
|
||||
opt.showbreak = '↳ '
|
||||
-- opt.linebreak = true
|
||||
-- opt.breakat = [[\ \ ;:,!?]]
|
||||
opt.breakindent = true
|
||||
-- opt.breakindentopt = 'shift:4,min:20'
|
||||
list = true,
|
||||
listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←',
|
||||
showbreak = '↳ ',
|
||||
-- linebreak = true,
|
||||
-- breakat = [[\ \ ;:,!?]],
|
||||
breakindent = true,
|
||||
-- breakindentopt = 'shift:4,min:20',
|
||||
|
||||
-- Undo file path
|
||||
opt.undofile = true
|
||||
-- opt.undodir = vim.fn.stdpath('data') .. '/undo'
|
||||
undofile = true,
|
||||
-- undodir = vim.fn.stdpath('data') .. '/undo',
|
||||
}
|
||||
|
||||
-- Custom variables
|
||||
g.border_style = 'rounded'
|
||||
local function load_options(vars, opts)
|
||||
-- Set colorscheme
|
||||
vim.api.nvim_command('colorscheme {{ theme }}')
|
||||
|
||||
-- Only use python3
|
||||
vim.opt.pyxversion = 3
|
||||
vim.g.python3_host_prog = '/usr/bin/python3'
|
||||
vim.g.loaded_python_provider = 0 -- disable python2 support
|
||||
|
||||
-- Load global variables
|
||||
for k, v in pairs(vars) do
|
||||
vim.g[k] = v
|
||||
end
|
||||
|
||||
-- Load editor options
|
||||
for k, v in pairs(opts) do
|
||||
vim.opt[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
disable_default_plugins()
|
||||
load_options()
|
||||
load_options(global_vars, vim_options)
|
||||
|
|
Loading…
Reference in New Issue