diff --git a/home/editor/neovim/default.nix b/home/editor/neovim/default.nix index 0e737c1..9453089 100644 --- a/home/editor/neovim/default.nix +++ b/home/editor/neovim/default.nix @@ -9,8 +9,11 @@ undotree telescope-nvim nvim-cmp + cmp-nvim-lsp nvim-lspconfig lsp-zero-nvim + vim-floaterm + luasnip (nvim-treesitter.withPlugins (p: [ p.tree-sitter-nix p.tree-sitter-go diff --git a/home/editor/neovim/keybinds.lua b/home/editor/neovim/keybinds.lua index 131e566..1dc44b4 100644 --- a/home/editor/neovim/keybinds.lua +++ b/home/editor/neovim/keybinds.lua @@ -1 +1,18 @@ -- Keybinds + +-- Term +vim.g.floaterm_keymap_toggle = 'ft' + +-- Tabs +vim.keymap.set('n', 'n', ':tabnew', + { silent = true, desc = '[N]ew tab' }) +vim.keymap.set('n', 'p', ':tabnext', + { silent = true, desc = '[p]Next tab' }) +vim.keymap.set('n', 'P', ':tabprev', + { silent = true, desc = '[P]Previous tab' }) + +-- Telescope +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, + { desc = '[?] FInd recently opened files' }) +vim.keymap.set('n', 'ff', require('telescope.builtin').find_files, + { desc = '[F]ind [F]iles' }) diff --git a/home/editor/neovim/plugins.lua b/home/editor/neovim/plugins.lua index bd64eb7..3b6a859 100644 --- a/home/editor/neovim/plugins.lua +++ b/home/editor/neovim/plugins.lua @@ -1,3 +1,51 @@ -- Plugins -require('lsp-zero') -require('lspconfig').gopls.setup({}) + +-- LSP stuff +local lsp_zero = require('lsp-zero') + +lsp_zero.on_attach(function(client, bufnr) + lsp_zero.default_keymaps({buffer = bufnr}) +end) + +require('lspconfig').gopls.setup({ + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + } + } +}) + +-- Cmp +local cmp = require('cmp') +local cmp_action = lsp_zero.cmp_action() + +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + -- Enter to confirm completion + [''] = cmp.mapping.confirm({select = false}), + -- Ctrl+Space to open completion menu + [''] = cmp.mapping.complete(), + -- Move between snippet placeholders + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + -- Scroll in completion docs + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + }) +}) + +-- Telescope +require('telescope').setup({ + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + } + }, +})