Random NVIM refactorings, sorry those accumulated

This commit is contained in:
Tobias Manske 2023-03-25 13:42:53 +01:00
parent 72edd200c7
commit 94e3626ed3
Signed by: tobias
GPG Key ID: 9164B527694A0709
2 changed files with 60 additions and 34 deletions

View File

@ -71,10 +71,14 @@ require('packer').startup(function(use)
-- Fuzzy Finder (files, lsp, etc) -- Fuzzy Finder (files, lsp, etc)
use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } 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 -- 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-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 'scrooloose/nerdtree'
use 'jistr/vim-nerdtree-tabs' use 'jistr/vim-nerdtree-tabs'
@ -116,6 +120,17 @@ require('packer').startup(function(use)
end 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' use 'majutsushi/tagbar'
@ -142,9 +157,6 @@ require('packer').startup(function(use)
} }
use 'johann2357/nvim-smartbufs' use 'johann2357/nvim-smartbufs'
-- Latex preview
use { 'xuhdev/vim-latex-live-preview', ft = 'tex', bufread = true }
-- LTeX local code actions -- LTeX local code actions
use { "barreiroleo/ltex-extra.nvim" } use { "barreiroleo/ltex-extra.nvim" }
@ -206,6 +218,8 @@ vim.api.nvim_create_autocmd('BufWritePost', {
-- Set highlight on search -- Set highlight on search
vim.o.hlsearch = false vim.o.hlsearch = false
vim.o.scrolloff = 7
-- Make line numbers default -- Make line numbers default
vim.wo.number = true vim.wo.number = true
@ -378,11 +392,12 @@ require('telescope').setup {
pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'fzf')
require("telescope").load_extension("ui-select") require("telescope").load_extension("ui-select")
require("telescope").load_extension("luasnip")
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) helpers.nmap('<leader>?', require('telescope.builtin').oldfiles, '[?] Find recently opened files')
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) helpers.nmap('<leader><space>', require('telescope.builtin').buffers, '[ ] Find existing buffers')
vim.keymap.set('n', '<leader>/', function() helpers.nmap('<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc. -- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10, winblend = 10,
@ -390,14 +405,15 @@ vim.keymap.set('n', '<leader>/', function()
}) })
end, { desc = '[/] Fuzzily search in current buffer]' }) end, { desc = '[/] Fuzzily search in current buffer]' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) helpers.nmap('<leader>sf', require('telescope.builtin').find_files, '[S]earch [F]iles')
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) helpers.nmap('<leader>sh', require('telescope.builtin').help_tags, '[S]earch [H]elp')
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) helpers.nmap('<leader>sw', require('telescope.builtin').grep_string, '[S]earch current [W]ord')
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) helpers.nmap('<leader>sg', require('telescope.builtin').live_grep, '[S]earch by [G]rep')
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) helpers.nmap('<leader>sd', require('telescope.builtin').diagnostics, '[S]earch [D]iagnostics')
vim.keymap.set('n', '<leader>sk', require('telescope.builtin').keymaps, { desc = '[S]earch [K]eymaps' }) helpers.nmap('<leader>sk', require('telescope.builtin').keymaps, '[S]earch [K]eymaps')
vim.keymap.set('n', '<leader>sb', require('telescope.builtin').buffers, { desc = '[S]earch [B]uffers' }) helpers.nmap('<leader>sb', require('telescope.builtin').buffers, '[S]earch [B]uffers')
vim.keymap.set('n', '<leader>st', "<ESC>:TodoTelescope keywords=TODO,FIXME<CR>", { desc = '[S]earch [T]odos' }) helpers.nmap('<leader>st', "<ESC>:TodoTelescope keywords=TODO,FIXME<CR>", '[S]earch [T]odos')
helpers.nmap('<leader>ss', require('telescope').extensions.luasnip.luasnip, '[S]how [S]nippets')
-- [[ Configure Treesitter ]] -- [[ Configure Treesitter ]]
@ -469,9 +485,6 @@ require("todo-comments").setup {
-- refer to the configuration section below -- refer to the configuration section below
} }
local nmap = function(keys, func, desc)
vim.keymap.set('n', keys, func, { desc = desc })
end
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
@ -502,32 +515,37 @@ vim.keymap.set('n', '<S-P>', '<Plug>yankstack_substitute_newer_paste')
vim.keymap.set('n', '<C-P>', '<Plug>yankstack_substitute_older_paste') vim.keymap.set('n', '<C-P>', '<Plug>yankstack_substitute_older_paste')
vim.cmd [[
let g:livepreview_cursorhold_recompile = 0
]]
-- Window movement -- Window movement
vim.keymap.set('n', '<C-h>', '<C-w>h') vim.keymap.set('n', '<C-h>', '<C-w>h')
vim.keymap.set('n', '<C-j>', '<C-w>j') vim.keymap.set('n', '<C-j>', '<C-w>j')
vim.keymap.set('n', '<C-k>', '<C-w>k') vim.keymap.set('n', '<C-k>', '<C-w>k')
vim.keymap.set('n', '<C-l>', '<C-w>l') vim.keymap.set('n', '<C-l>', '<C-w>l')
nmap('<Leader>1', function() require("nvim-smartbufs").goto_buffer(1) end, "Go to buffer 1") vim.keymap.set("n", "]t", function()
nmap('<Leader>2', function() require("nvim-smartbufs").goto_buffer(2) end, "Go to buffer 2") require("todo-comments").jump_next()
nmap('<Leader>3', function() require("nvim-smartbufs").goto_buffer(3) end, "Go to buffer 3") end, { desc = "Next todo comment" })
nmap('<Leader>4', function() require("nvim-smartbufs").goto_buffer(4) end, "Go to buffer 4")
nmap('<Leader>5', function() require("nvim-smartbufs").goto_buffer(5) end, "Go to buffer 5") vim.keymap.set("n", "[t", function()
nmap('<Leader>6', function() require("nvim-smartbufs").goto_buffer(6) end, "Go to buffer 6") require("todo-comments").jump_prev()
nmap('<Leader>7', function() require("nvim-smartbufs").goto_buffer(7) end, "Go to buffer 7") end, { desc = "Previous todo comment" })
nmap('<Leader>8', function() require("nvim-smartbufs").goto_buffer(8) end, "Go to buffer 8")
nmap('<Leader>9', function() require("nvim-smartbufs").goto_buffer(9) end, "Go to buffer 9")
helpers.nmap('<Leader>1', function() require("nvim-smartbufs").goto_buffer(1) end, "Go to buffer 1")
helpers.nmap('<Leader>2', function() require("nvim-smartbufs").goto_buffer(2) end, "Go to buffer 2")
helpers.nmap('<Leader>3', function() require("nvim-smartbufs").goto_buffer(3) end, "Go to buffer 3")
helpers.nmap('<Leader>4', function() require("nvim-smartbufs").goto_buffer(4) end, "Go to buffer 4")
helpers.nmap('<Leader>5', function() require("nvim-smartbufs").goto_buffer(5) end, "Go to buffer 5")
helpers.nmap('<Leader>6', function() require("nvim-smartbufs").goto_buffer(6) end, "Go to buffer 6")
helpers.nmap('<Leader>7', function() require("nvim-smartbufs").goto_buffer(7) end, "Go to buffer 7")
helpers.nmap('<Leader>8', function() require("nvim-smartbufs").goto_buffer(8) end, "Go to buffer 8")
helpers.nmap('<Leader>9', function() require("nvim-smartbufs").goto_buffer(9) end, "Go to buffer 9")
-- " Improved :bnext :bprev behavior (without considering terminal buffers) -- " Improved :bnext :bprev behavior (without considering terminal buffers)
nmap('<Right>', require("nvim-smartbufs").goto_next_buffer, 'Go to next buffer') helpers.nmap('<Right>', require("nvim-smartbufs").goto_next_buffer, 'Go to next buffer')
nmap('<Left>', require("nvim-smartbufs").goto_prev_buffer, 'Go to previous buffer') helpers.nmap('<Left>', require("nvim-smartbufs").goto_prev_buffer, 'Go to previous buffer')
-- " Delete current buffer and goes back to the previous one -- " Delete current buffer and goes back to the previous one
nmap('<Leader>qb', require("nvim-smartbufs").close_current_buffer, 'Close current buffer') helpers.nmap('<Leader>qb', require("nvim-smartbufs").close_current_buffer, 'Close current buffer')
-- LSP settings. -- LSP settings.
@ -605,6 +623,8 @@ local servers = {
rust_analyzer = {}, rust_analyzer = {},
yamlls = {}, yamlls = {},
texlab = {}, -- latex texlab = {}, -- latex
terraformls = {},
tflint = {},
ltex = { ltex = {
ltex = { ltex = {
language = 'en-US', language = 'en-US',
@ -681,8 +701,10 @@ mason_null_ls.setup {
null_ls.setup { null_ls.setup {
sources = { sources = {
null_ls.builtins.code_actions.gitsigns, null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.diagnostics.chktex,
}, },
on_attach = on_attach, on_attach = on_attach,
root_dir = function(_) return nil end,
} }
mason_null_ls.setup_handlers() mason_null_ls.setup_handlers()

View File

@ -17,4 +17,8 @@ function helpers.diagnostic_on_cursor_hold(bufnr)
}) })
end end
function helpers.nmap(keys, command, description)
vim.keymap.set('n', keys, command, { desc = description })
end
return helpers return helpers