Improve neovim config

This commit is contained in:
Torjus Håkestad 2024-02-28 03:40:13 +01:00
parent e129a4c8f6
commit f5619a9593
3 changed files with 70 additions and 2 deletions

View File

@ -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

View File

@ -1 +1,18 @@
-- Keybinds
-- Term
vim.g.floaterm_keymap_toggle = '<leader>ft'
-- Tabs
vim.keymap.set('n', '<leader>n', ':tabnew<CR>',
{ silent = true, desc = '[N]ew tab' })
vim.keymap.set('n', '<leader>p', ':tabnext<CR>',
{ silent = true, desc = '[p]Next tab' })
vim.keymap.set('n', '<leader>P', ':tabprev<CR>',
{ silent = true, desc = '[P]Previous tab' })
-- Telescope
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles,
{ desc = '[?] FInd recently opened files' })
vim.keymap.set('n', '<leader>ff', require('telescope.builtin').find_files,
{ desc = '[F]ind [F]iles' })

View File

@ -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
['<CR>'] = cmp.mapping.confirm({select = false}),
-- Ctrl+Space to open completion menu
['<C-Space>'] = cmp.mapping.complete(),
-- Move between snippet placeholders
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
-- Scroll in completion docs
['<C-k>'] = cmp.mapping.scroll_docs(-4),
['<C-j>'] = 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",
}
},
})