diff --git a/home.nix b/home.nix index 9055dc8..28bcd20 100644 --- a/home.nix +++ b/home.nix @@ -31,6 +31,7 @@ in libreoffice nodePackages.pyright neofetch + gopls ]; }; @@ -56,6 +57,10 @@ in vim-commentary vim-sleuth gitsigns-nvim + nvim-cmp + cmp-nvim-lsp + friendly-snippets + neodev-nvim ]; extraLuaConfig = builtins.readFile ./neovim.lua; }; @@ -72,7 +77,7 @@ in id = 0; isDefault = true; settings = firefoxSettings; - extensions = firefox-addons.default; # TODO: recursive + extensions = firefox-addons.default; }; sue = { id = 1; @@ -124,30 +129,35 @@ in extraConfig = "User root"; matchBlocks = { - "github.com" = lib.hm.dag.entryBefore [ "*" ] { + gitlab-sue = lib.hm.dag.entryBefore [ "*" ] { + hostname = "gitlab.com"; + identityFile = "~/.ssh/sue_ed25519"; + identitiesOnly = true; + }; + github = lib.hm.dag.entryBefore [ "*" ] { hostname = "github.com"; user = "pizzapim"; identitiesOnly = true; }; - "lewis" = lib.hm.dag.entryBefore [ "*" ] { + lewis = lib.hm.dag.entryBefore [ "*" ] { hostname = "lewis.hyp"; }; - "atlas" = lib.hm.dag.entryBefore [ "*" ] { + atlas = lib.hm.dag.entryBefore [ "*" ] { hostname = "atlas.hyp"; }; - "jefke" = lib.hm.dag.entryBefore [ "*" ] { + jefke = lib.hm.dag.entryBefore [ "*" ] { hostname = "jefke.hyp"; }; - "hermes" = lib.hm.dag.entryBefore [ "*" ] { + hermes = lib.hm.dag.entryBefore [ "*" ] { hostname = "hermes.dmz"; }; - "maestro" = lib.hm.dag.entryBefore [ "*" ] { + maestro = lib.hm.dag.entryBefore [ "*" ] { hostname = "maestro.dmz"; }; - "bancomart" = lib.hm.dag.entryBefore [ "*" ] { + bancomart = lib.hm.dag.entryBefore [ "*" ] { hostname = "bancomart.dmz"; }; - "handjecontantje" = lib.hm.dag.entryBefore [ "*" ] { + handjecontantje = lib.hm.dag.entryBefore [ "*" ] { hostname = "handjecontantje.dmz"; }; }; diff --git a/neovim.lua b/neovim.lua index 47c0c50..918c3f2 100644 --- a/neovim.lua +++ b/neovim.lua @@ -10,22 +10,38 @@ vim.wo.cursorline = true --[ LSPCONFIG ]-- -local opts = { noremap=true, silent=true } -local on_attach = function(client, bufnr) - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - local bufopts = { noremap=true, silent=true, buffer=bufnr } - vim.keymap.set('n', 'D', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'h', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'i', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', 's', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'c', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'fmt', function() vim.lsp.buf.format { async = true } end, bufopts) +local on_attach = function(_, bufnr) + + local bufmap = function(keys, func) + vim.keymap.set('n', keys, func, { buffer = bufnr }) + end + + bufmap('r', vim.lsp.buf.rename) + bufmap('a', vim.lsp.buf.code_action) + + bufmap('gd', vim.lsp.buf.definition) + bufmap('gD', vim.lsp.buf.declaration) + bufmap('gI', vim.lsp.buf.implementation) + bufmap('D', vim.lsp.buf.type_definition) + + bufmap('gr', require('telescope.builtin').lsp_references) + bufmap('s', require('telescope.builtin').lsp_document_symbols) + bufmap('S', require('telescope.builtin').lsp_dynamic_workspace_symbols) + + bufmap('K', vim.lsp.buf.hover) + + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, {}) end -require'lspconfig'.nil_ls.setup{ on_attach = on_attach } -require'lspconfig'.pyright.setup{} +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +require('neodev').setup() +require'lspconfig'.nil_ls.setup{ on_attach = on_attach, capabilities = capabilities } +require'lspconfig'.pyright.setup{ on_attach = on_attach, capabilities = capabilities } +require'lspconfig'.gopls.setup{ on_attach = on_attach, capabilities = capabilities } --[ LEAP ]-- @@ -69,3 +85,40 @@ vim.cmd([[autocmd FileType nix setlocal commentstring=#\ %s]]) --[ GITSIGNS ]-- require("gitsigns").setup() + +--[ CMP ]-- + +-- For snippets: look at https://github.com/vimjoyer/nvim-nix-video/blob/main/nvim/plugin/cmp.lua + +local cmp = require('cmp') + +cmp.setup { + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + }, +}