neovim: bunch of changes again

- Fix commit 8a8e0db586 : vim.opt is a table, so it should have been
  vim.o -> vim.opt:get()
- Add filetype.nvim (improved startup time)
- Drop vimtex. Potentially will switch to tex.nvim
- Re-compile packer only inside '/modules' directory (less eager)
This commit is contained in:
FollieHiyuki 2021-10-09 22:56:39 +07:00
parent ee9a615cfe
commit a2a7caa279
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
8 changed files with 70 additions and 54 deletions

View File

@ -1,20 +1,20 @@
local definitions = { local definitions = {
-- ':h hex-editing' -- ':h hex-editing'
binary = { -- binary = {
{'BufReadPre' , '*.bin,*.exe', 'let &bin=1'}, -- {'BufReadPre' , '*.bin,*.exe', 'let &bin=1'},
{'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'}, -- {'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'},
{'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'}, -- {'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'},
{'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'}, -- {'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'},
{'BufWritePre' , '*.bin,*.exe', 'endif'}, -- {'BufWritePre' , '*.bin,*.exe', 'endif'},
{'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'}, -- {'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'},
{'BufWritePost', '*.bin,*.exe', 'set nomod | endif'} -- {'BufWritePost', '*.bin,*.exe', 'set nomod | endif'}
}, -- },
-- Auto-hide UI elements in specific buffers -- Auto-hide UI elements in specific buffers
buf = { -- buf = {
{'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'}, -- {'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'},
-- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]} -- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]}
}, -- },
wins = { wins = {
-- Equalize window dimensions when resizing vim window -- Equalize window dimensions when resizing vim window
@ -22,15 +22,7 @@ local definitions = {
-- Force writing shada on leaving nvim -- Force writing shada on leaving nvim
{'VimLeave', '*', [[if has('nvim') | wshada! | else | wviminfo! | endif]]}, {'VimLeave', '*', [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread' -- Check if file changed when its window is focus, more eager than 'autoread'
{'FocusGained', '* checktime'} -- {'FocusGained', '* checktime'}
},
ft = {
{'BufNewFile,BufRead', '*.md,*.mkd', 'setfiletype markdown'},
{'BufNewFile,BufRead', '*.toml', 'setfiletype toml'},
{'BufNewFile,BufRead', '*.rasi', 'setfiletype css'},
{'BufNewFile,BufRead', 'vifmrc,*.vifm', 'setfiletype vim'},
{'BufNewFile,BufRead', '*.log,*_log,*.LO,G*_LOG', 'setfiletype log'}
}, },
yank = { yank = {

View File

@ -76,15 +76,16 @@ wk.register({
-- Switch between tabs and spaces -- Switch between tabs and spaces
['<A-t>'] = { ['<A-t>'] = {
function() function()
if vim.opt.expandtab == true then if vim.opt.expandtab:get() then
vim.api.nvim_command('set noexpandtab nosmarttab softtabstop& shiftwidth&') vim.opt.expandtab = false
vim.api.nvim_command('echomsg "Switched to indent with tabs"') vim.opt.smarttab = false
vim.opt.softtabstop = 0 -- reset to default
print('Switched to indent with tabs')
else else
vim.opt.expandtab = true vim.opt.expandtab = true
vim.opt.smarttab = true vim.opt.smarttab = true
vim.opt.softtabstop = 4 vim.opt.softtabstop = -1 -- fallback to shiftwidth
vim.opt.shiftwidth = 4 print('Switched to indent with spaces')
vim.api.nvim_command('echomsg "Switched to indent with 4 spaces"')
end end
end, end,
'Switch indent style' 'Switch indent style'

View File

@ -107,7 +107,7 @@ function M.lsp_conf()
-- if p then lua_lib_path[p] = true end -- if p then lua_lib_path[p] = true end
-- end -- end
-- end -- end
-- for _, site in pairs(vim.split(vim.opt.packpath, ',')) do -- for _, site in pairs(vim.split(vim.opt.packpath:get(), ',')) do
-- add(site .. '/pack/*/opt/*') -- add(site .. '/pack/*/opt/*')
-- add(site .. '/pack/*/start/*') -- add(site .. '/pack/*/start/*')
-- end -- end

View File

@ -54,7 +54,7 @@ packer.init {
_G.packer_compile_on_save = function() _G.packer_compile_on_save = function()
local file = fn.expand('%:p') local file = fn.expand('%:p')
local filename = fn.expand('%:p:t') local filename = fn.expand('%:p:t')
local config_dir = fn.stdpath('config') .. '/lua' local config_dir = fn.stdpath('config') .. '/lua/modules'
if file:match(config_dir) and filename ~= 'pack.lua' then if file:match(config_dir) and filename ~= 'pack.lua' then
vim.api.nvim_command('source <afile> | PackerCompile') vim.api.nvim_command('source <afile> | PackerCompile')

View File

@ -1,7 +1,9 @@
local M = {} local M = {}
function M.telescope_conf() function M.telescope_conf()
require('telescope').setup { local telescope = require('telescope')
telescope.setup {
defaults = { defaults = {
prompt_prefix = '', prompt_prefix = '',
selection_caret = '', selection_caret = '',
@ -43,9 +45,9 @@ function M.telescope_conf()
} }
} }
} }
require('telescope').load_extension('projects') telescope.load_extension('projects')
require('telescope').load_extension('project') telescope.load_extension('project')
require('telescope').load_extension('fzf') telescope.load_extension('fzf')
-- wrap lines inside preview pane -- wrap lines inside preview pane
vim.api.nvim_command('autocmd User TelescopePreviewerLoaded setlocal wrap') vim.api.nvim_command('autocmd User TelescopePreviewerLoaded setlocal wrap')
@ -302,4 +304,27 @@ function M.session_conf()
} }
end end
function M.filetype_conf()
require('filetype').setup({
overrides = {
extensions = {
md = 'markdown',
mkd = 'markdown',
toml = 'toml',
rasi = 'css',
vifm = 'vim',
log = 'log',
LO = 'log'
},
literal = {
vifmrc = 'vim'
},
complex = {
['*_log'] = 'log',
['G*_LOG'] = 'log'
}
}
})
end
return M return M

View File

@ -389,7 +389,7 @@ function M.nvimtree_conf()
lsp_diagnostics = true, lsp_diagnostics = true,
update_focused_file = { update_focused_file = {
enable = true, enable = true,
update_cwd = false, update_cwd = true,
ignore_list = {} ignore_list = {}
}, },
system_open = { system_open = {

View File

@ -20,6 +20,7 @@ function M.disable_default_plugins()
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
vim.g.loaded_netrwSettings = 1 vim.g.loaded_netrwSettings = 1
vim.g.loaded_netrwFileHandlers = 1 vim.g.loaded_netrwFileHandlers = 1
vim.g.did_load_filetypes = 1 -- use filetype.nvim instead
end end
function M.load_options() function M.load_options()
@ -131,9 +132,9 @@ function M.load_options()
-- opt.numberwidth = 6 -- opt.numberwidth = 6
-- 4 spaces = 1 tab -- 4 spaces = 1 tab
opt.tabstop = 4
opt.softtabstop = 4
opt.shiftwidth = 4 opt.shiftwidth = 4
opt.tabstop = 4
opt.softtabstop = -1 -- fallback to 'shiftwidth'
opt.smarttab = true opt.smarttab = true
opt.expandtab = true opt.expandtab = true
opt.smartindent = true opt.smartindent = true

View File

@ -62,11 +62,6 @@ return packer.startup(function(use)
'RRethy/vim-illuminate', 'RRethy/vim-illuminate',
event = 'CursorHold' event = 'CursorHold'
} }
use {
'lukas-reineke/indent-blankline.nvim',
after = 'nvim-treesitter',
config = editor.blankline_conf
}
-- use { -- TODO: config (lua -> fennel) + learn clojure, fennel, guile scheme -- use { -- TODO: config (lua -> fennel) + learn clojure, fennel, guile scheme
-- 'Olical/conjure', -- 'Olical/conjure',
-- ft = {'clojure', 'fennel', 'scheme'}, -- ft = {'clojure', 'fennel', 'scheme'},
@ -78,6 +73,11 @@ return packer.startup(function(use)
event = 'BufRead', event = 'BufRead',
config = editor.treesitter_conf config = editor.treesitter_conf
} }
use {
'lukas-reineke/indent-blankline.nvim',
after = 'nvim-treesitter',
config = editor.blankline_conf
}
use { use {
'p00f/nvim-ts-rainbow', 'p00f/nvim-ts-rainbow',
after = 'nvim-treesitter', after = 'nvim-treesitter',
@ -103,10 +103,7 @@ return packer.startup(function(use)
after = 'nvim-treesitter', after = 'nvim-treesitter',
config = editor.matchup_conf config = editor.matchup_conf
} }
use { use {'machakann/vim-sandwich', keys = 's'}
'machakann/vim-sandwich',
keys = 's'
}
use { use {
'phaazon/hop.nvim', 'phaazon/hop.nvim',
cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'}, cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'},
@ -128,7 +125,7 @@ return packer.startup(function(use)
} }
use { use {
'editorconfig/editorconfig-vim', 'editorconfig/editorconfig-vim',
ft = {'go', 'rust', 'python', 'c', 'cpp', 'javascript', 'typescript', 'vim', 'zig'} event = {'BufNewFile', 'BufRead'}
} }
use { -- TODO: move to nvim-parinfer (lua) use { -- TODO: move to nvim-parinfer (lua)
'eraserhd/parinfer-rust', 'eraserhd/parinfer-rust',
@ -220,7 +217,7 @@ return packer.startup(function(use)
-- run = './install.sh', -- run = './install.sh',
-- config = completion.tabnine_conf -- config = completion.tabnine_conf
-- } -- }
use {'kdheepak/cmp-latex-symbols', after = {'nvim-cmp', 'vimtex'}} use {'kdheepak/cmp-latex-symbols', after = 'nvim-cmp'}
-- use {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp'} -- use {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp'}
-- use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}} -- use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}}
use { use {
@ -327,11 +324,6 @@ return packer.startup(function(use)
ft = 'org', ft = 'org',
config = tools.orgmode_conf config = tools.orgmode_conf
} }
use { -- TODO: config
'lervag/vimtex',
ft = 'tex',
setup = tools.vimtext_conf
}
use { use {
'windwp/nvim-spectre', 'windwp/nvim-spectre',
event = {'BufRead', 'BufNewFile'}, event = {'BufRead', 'BufNewFile'},
@ -384,10 +376,15 @@ return packer.startup(function(use)
event = 'BufEnter', event = 'BufEnter',
config = tools.session_conf config = tools.session_conf
} }
use { -- Replace default filetype.vim
'nathom/filetype.nvim',
config = tools.filetype_conf
}
use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
-- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, -- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*,
-- nvim-bqf, nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers -- nvim-bqf, nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers,
-- tex.nvim, telescope-lsp-handlers.nvim
-- Install plugins if missing -- Install plugins if missing
packer.install() packer.install()