diff --git a/home/.config/nvim/lua/autocmd.lua b/home/.config/nvim/lua/autocmd.lua index 643cb4e..85dc192 100644 --- a/home/.config/nvim/lua/autocmd.lua +++ b/home/.config/nvim/lua/autocmd.lua @@ -1,20 +1,20 @@ local definitions = { -- ':h hex-editing' - binary = { - {'BufReadPre' , '*.bin,*.exe', 'let &bin=1'}, - {'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'}, - {'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'}, - {'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'}, - {'BufWritePre' , '*.bin,*.exe', 'endif'}, - {'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'}, - {'BufWritePost', '*.bin,*.exe', 'set nomod | endif'} - }, + -- binary = { + -- {'BufReadPre' , '*.bin,*.exe', 'let &bin=1'}, + -- {'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'}, + -- {'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'}, + -- {'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'}, + -- {'BufWritePre' , '*.bin,*.exe', 'endif'}, + -- {'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'}, + -- {'BufWritePost', '*.bin,*.exe', 'set nomod | endif'} + -- }, -- Auto-hide UI elements in specific buffers - buf = { - {'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'}, - -- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]} - }, + -- buf = { + -- {'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'}, + -- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]} + -- }, wins = { -- Equalize window dimensions when resizing vim window @@ -22,15 +22,7 @@ local definitions = { -- Force writing shada on leaving nvim {'VimLeave', '*', [[if has('nvim') | wshada! | else | wviminfo! | endif]]}, -- Check if file changed when its window is focus, more eager than 'autoread' - {'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'} + -- {'FocusGained', '* checktime'} }, yank = { diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 65960bf..82daf07 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -76,15 +76,16 @@ wk.register({ -- Switch between tabs and spaces [''] = { function() - if vim.opt.expandtab == true then - vim.api.nvim_command('set noexpandtab nosmarttab softtabstop& shiftwidth&') - vim.api.nvim_command('echomsg "Switched to indent with tabs"') + if vim.opt.expandtab:get() then + vim.opt.expandtab = false + vim.opt.smarttab = false + vim.opt.softtabstop = 0 -- reset to default + print('Switched to indent with tabs') else vim.opt.expandtab = true vim.opt.smarttab = true - vim.opt.softtabstop = 4 - vim.opt.shiftwidth = 4 - vim.api.nvim_command('echomsg "Switched to indent with 4 spaces"') + vim.opt.softtabstop = -1 -- fallback to shiftwidth + print('Switched to indent with spaces') end end, 'Switch indent style' diff --git a/home/.config/nvim/lua/modules/lsp.lua b/home/.config/nvim/lua/modules/lsp.lua index 696e960..bee141b 100644 --- a/home/.config/nvim/lua/modules/lsp.lua +++ b/home/.config/nvim/lua/modules/lsp.lua @@ -107,7 +107,7 @@ function M.lsp_conf() -- if p then lua_lib_path[p] = true 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/*/start/*') -- end diff --git a/home/.config/nvim/lua/modules/pack.lua b/home/.config/nvim/lua/modules/pack.lua index 328928f..dd1af08 100644 --- a/home/.config/nvim/lua/modules/pack.lua +++ b/home/.config/nvim/lua/modules/pack.lua @@ -54,7 +54,7 @@ packer.init { _G.packer_compile_on_save = function() local file = fn.expand('%:p') 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 vim.api.nvim_command('source | PackerCompile') diff --git a/home/.config/nvim/lua/modules/tools.lua b/home/.config/nvim/lua/modules/tools.lua index 1082732..bd73d52 100644 --- a/home/.config/nvim/lua/modules/tools.lua +++ b/home/.config/nvim/lua/modules/tools.lua @@ -1,7 +1,9 @@ local M = {} function M.telescope_conf() - require('telescope').setup { + local telescope = require('telescope') + + telescope.setup { defaults = { prompt_prefix = '  ', selection_caret = ' ', @@ -43,9 +45,9 @@ function M.telescope_conf() } } } - require('telescope').load_extension('projects') - require('telescope').load_extension('project') - require('telescope').load_extension('fzf') + telescope.load_extension('projects') + telescope.load_extension('project') + telescope.load_extension('fzf') -- wrap lines inside preview pane vim.api.nvim_command('autocmd User TelescopePreviewerLoaded setlocal wrap') @@ -302,4 +304,27 @@ function M.session_conf() } 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 diff --git a/home/.config/nvim/lua/modules/ui.lua b/home/.config/nvim/lua/modules/ui.lua index 9fc1c63..29d7070 100644 --- a/home/.config/nvim/lua/modules/ui.lua +++ b/home/.config/nvim/lua/modules/ui.lua @@ -389,7 +389,7 @@ function M.nvimtree_conf() lsp_diagnostics = true, update_focused_file = { enable = true, - update_cwd = false, + update_cwd = true, ignore_list = {} }, system_open = { diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 617e0c7..d723762 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -20,6 +20,7 @@ function M.disable_default_plugins() vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwSettings = 1 vim.g.loaded_netrwFileHandlers = 1 + vim.g.did_load_filetypes = 1 -- use filetype.nvim instead end function M.load_options() @@ -131,9 +132,9 @@ function M.load_options() -- opt.numberwidth = 6 -- 4 spaces = 1 tab - opt.tabstop = 4 - opt.softtabstop = 4 opt.shiftwidth = 4 + opt.tabstop = 4 + opt.softtabstop = -1 -- fallback to 'shiftwidth' opt.smarttab = true opt.expandtab = true opt.smartindent = true diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index a806d81..4824bf8 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -62,11 +62,6 @@ return packer.startup(function(use) 'RRethy/vim-illuminate', 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 -- 'Olical/conjure', -- ft = {'clojure', 'fennel', 'scheme'}, @@ -78,6 +73,11 @@ return packer.startup(function(use) event = 'BufRead', config = editor.treesitter_conf } + use { + 'lukas-reineke/indent-blankline.nvim', + after = 'nvim-treesitter', + config = editor.blankline_conf + } use { 'p00f/nvim-ts-rainbow', after = 'nvim-treesitter', @@ -103,10 +103,7 @@ return packer.startup(function(use) after = 'nvim-treesitter', config = editor.matchup_conf } - use { - 'machakann/vim-sandwich', - keys = 's' - } + use {'machakann/vim-sandwich', keys = 's'} use { 'phaazon/hop.nvim', cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'}, @@ -128,7 +125,7 @@ return packer.startup(function(use) } use { 'editorconfig/editorconfig-vim', - ft = {'go', 'rust', 'python', 'c', 'cpp', 'javascript', 'typescript', 'vim', 'zig'} + event = {'BufNewFile', 'BufRead'} } use { -- TODO: move to nvim-parinfer (lua) 'eraserhd/parinfer-rust', @@ -220,7 +217,7 @@ return packer.startup(function(use) -- run = './install.sh', -- 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 {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}} use { @@ -327,11 +324,6 @@ return packer.startup(function(use) ft = 'org', config = tools.orgmode_conf } - use { -- TODO: config - 'lervag/vimtex', - ft = 'tex', - setup = tools.vimtext_conf - } use { 'windwp/nvim-spectre', event = {'BufRead', 'BufNewFile'}, @@ -384,10 +376,15 @@ return packer.startup(function(use) event = 'BufEnter', 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 -- 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 packer.install()