diff --git a/nvim/init.lua b/nvim/init.lua index 43cb048..70809f8 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -71,10 +71,14 @@ require('packer').startup(function(use) -- Fuzzy Finder (files, lsp, etc) use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } - use { 'nvim-telescope/telescope-ui-select.nvim' } -- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable 'make' == 1 } + use { 'nvim-telescope/telescope-ui-select.nvim' } + use { + "benfowler/telescope-luasnip.nvim", + -- module = "telescope._extensions.luasnip", -- if you wish to lazy-load + } use 'scrooloose/nerdtree' use 'jistr/vim-nerdtree-tabs' @@ -116,6 +120,17 @@ require('packer').startup(function(use) end } + use { + "folke/trouble.nvim", + requires = "nvim-tree/nvim-web-devicons", + config = function() + require("trouble").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end + } use 'majutsushi/tagbar' @@ -142,9 +157,6 @@ require('packer').startup(function(use) } use 'johann2357/nvim-smartbufs' - -- Latex preview - use { 'xuhdev/vim-latex-live-preview', ft = 'tex', bufread = true } - -- LTeX local code actions use { "barreiroleo/ltex-extra.nvim" } @@ -206,6 +218,8 @@ vim.api.nvim_create_autocmd('BufWritePost', { -- Set highlight on search vim.o.hlsearch = false +vim.o.scrolloff = 7 + -- Make line numbers default vim.wo.number = true @@ -378,11 +392,12 @@ require('telescope').setup { pcall(require('telescope').load_extension, 'fzf') require("telescope").load_extension("ui-select") +require("telescope").load_extension("luasnip") -- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() +helpers.nmap('?', require('telescope.builtin').oldfiles, '[?] Find recently opened files') +helpers.nmap('', require('telescope.builtin').buffers, '[ ] Find existing buffers') +helpers.nmap('/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, @@ -390,14 +405,15 @@ vim.keymap.set('n', '/', function() }) end, { desc = '[/] Fuzzily search in current buffer]' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sk', require('telescope.builtin').keymaps, { desc = '[S]earch [K]eymaps' }) -vim.keymap.set('n', 'sb', require('telescope.builtin').buffers, { desc = '[S]earch [B]uffers' }) -vim.keymap.set('n', 'st', ":TodoTelescope keywords=TODO,FIXME", { desc = '[S]earch [T]odos' }) +helpers.nmap('sf', require('telescope.builtin').find_files, '[S]earch [F]iles') +helpers.nmap('sh', require('telescope.builtin').help_tags, '[S]earch [H]elp') +helpers.nmap('sw', require('telescope.builtin').grep_string, '[S]earch current [W]ord') +helpers.nmap('sg', require('telescope.builtin').live_grep, '[S]earch by [G]rep') +helpers.nmap('sd', require('telescope.builtin').diagnostics, '[S]earch [D]iagnostics') +helpers.nmap('sk', require('telescope.builtin').keymaps, '[S]earch [K]eymaps') +helpers.nmap('sb', require('telescope.builtin').buffers, '[S]earch [B]uffers') +helpers.nmap('st', ":TodoTelescope keywords=TODO,FIXME", '[S]earch [T]odos') +helpers.nmap('ss', require('telescope').extensions.luasnip.luasnip, '[S]how [S]nippets') -- [[ Configure Treesitter ]] @@ -469,9 +485,6 @@ require("todo-comments").setup { -- refer to the configuration section below } -local nmap = function(keys, func, desc) - vim.keymap.set('n', keys, func, { desc = desc }) -end -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) @@ -502,32 +515,37 @@ vim.keymap.set('n', '', 'yankstack_substitute_newer_paste') vim.keymap.set('n', '', 'yankstack_substitute_older_paste') -vim.cmd [[ - let g:livepreview_cursorhold_recompile = 0 -]] - -- Window movement vim.keymap.set('n', '', 'h') vim.keymap.set('n', '', 'j') vim.keymap.set('n', '', 'k') vim.keymap.set('n', '', 'l') -nmap('1', function() require("nvim-smartbufs").goto_buffer(1) end, "Go to buffer 1") -nmap('2', function() require("nvim-smartbufs").goto_buffer(2) end, "Go to buffer 2") -nmap('3', function() require("nvim-smartbufs").goto_buffer(3) end, "Go to buffer 3") -nmap('4', function() require("nvim-smartbufs").goto_buffer(4) end, "Go to buffer 4") -nmap('5', function() require("nvim-smartbufs").goto_buffer(5) end, "Go to buffer 5") -nmap('6', function() require("nvim-smartbufs").goto_buffer(6) end, "Go to buffer 6") -nmap('7', function() require("nvim-smartbufs").goto_buffer(7) end, "Go to buffer 7") -nmap('8', function() require("nvim-smartbufs").goto_buffer(8) end, "Go to buffer 8") -nmap('9', function() require("nvim-smartbufs").goto_buffer(9) end, "Go to buffer 9") +vim.keymap.set("n", "]t", function() + require("todo-comments").jump_next() +end, { desc = "Next todo comment" }) + +vim.keymap.set("n", "[t", function() + require("todo-comments").jump_prev() +end, { desc = "Previous todo comment" }) + + +helpers.nmap('1', function() require("nvim-smartbufs").goto_buffer(1) end, "Go to buffer 1") +helpers.nmap('2', function() require("nvim-smartbufs").goto_buffer(2) end, "Go to buffer 2") +helpers.nmap('3', function() require("nvim-smartbufs").goto_buffer(3) end, "Go to buffer 3") +helpers.nmap('4', function() require("nvim-smartbufs").goto_buffer(4) end, "Go to buffer 4") +helpers.nmap('5', function() require("nvim-smartbufs").goto_buffer(5) end, "Go to buffer 5") +helpers.nmap('6', function() require("nvim-smartbufs").goto_buffer(6) end, "Go to buffer 6") +helpers.nmap('7', function() require("nvim-smartbufs").goto_buffer(7) end, "Go to buffer 7") +helpers.nmap('8', function() require("nvim-smartbufs").goto_buffer(8) end, "Go to buffer 8") +helpers.nmap('9', function() require("nvim-smartbufs").goto_buffer(9) end, "Go to buffer 9") -- " Improved :bnext :bprev behavior (without considering terminal buffers) -nmap('', require("nvim-smartbufs").goto_next_buffer, 'Go to next buffer') -nmap('', require("nvim-smartbufs").goto_prev_buffer, 'Go to previous buffer') +helpers.nmap('', require("nvim-smartbufs").goto_next_buffer, 'Go to next buffer') +helpers.nmap('', require("nvim-smartbufs").goto_prev_buffer, 'Go to previous buffer') -- " Delete current buffer and goes back to the previous one -nmap('qb', require("nvim-smartbufs").close_current_buffer, 'Close current buffer') +helpers.nmap('qb', require("nvim-smartbufs").close_current_buffer, 'Close current buffer') -- LSP settings. @@ -605,6 +623,8 @@ local servers = { rust_analyzer = {}, yamlls = {}, texlab = {}, -- latex + terraformls = {}, + tflint = {}, ltex = { ltex = { language = 'en-US', @@ -681,8 +701,10 @@ mason_null_ls.setup { null_ls.setup { sources = { null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.diagnostics.chktex, }, on_attach = on_attach, + root_dir = function(_) return nil end, } mason_null_ls.setup_handlers() diff --git a/nvim/lua/helpers.lua b/nvim/lua/helpers.lua index 11ed4ba..577b03d 100644 --- a/nvim/lua/helpers.lua +++ b/nvim/lua/helpers.lua @@ -17,4 +17,8 @@ function helpers.diagnostic_on_cursor_hold(bufnr) }) end +function helpers.nmap(keys, command, description) + vim.keymap.set('n', keys, command, { desc = description }) +end + return helpers