From 68d40b380ac5d9b1dbd992a168168d6a14bb0bb6 Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Tue, 20 Dec 2022 15:50:16 +1000 Subject: [PATCH] make lsp look nicer --- home/profiles/nvim/default.nix | 61 ++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/home/profiles/nvim/default.nix b/home/profiles/nvim/default.nix index ab53920b..8ef77295 100644 --- a/home/profiles/nvim/default.nix +++ b/home/profiles/nvim/default.nix @@ -345,10 +345,16 @@ in nnoremap vrn :lua vim.lsp.buf.rename() nnoremap vh :lua vim.lsp.buf.hover() nnoremap vca :lua vim.lsp.buf.code_action() - nnoremap vsd :lua rim.lsp.diagnostic.show_line_diagnostics(); vim.lsp.util.show_line_diagnostics() + nnoremap vsd :lua vim.lsp.util.show_line_diagnostics() nnoremap vn :lua vim.lsp.diagnostic.goto_next() - nnoremap vll :call LspLocationList() nnoremap va :lua require('telescope.builtin').lsp_code_actions(require('telescope.themes').get_cursor()) + " lspsaga stuff doesn't work + " nnoremap vd :call Lspsaga peek_definition + " nnoremap vrn :call Lspsaga rename + " nnoremap vh :call Lspsaga hover_doc + " nnoremap vca :call Lspsaga code_action + " nnoremap vsd :call Lspsaga show_line_diagnostics + " nnoremap vn :call Lspsaga diagnostic_jump_prev " dashboard let g:dashboard_custom_header = [ @@ -431,6 +437,33 @@ in end end + vim.diagnostic.config({ + signs = true, + update_in_insert = false, + underline = false, + severity_sort = true, + float = { + focusable = false, + style = 'minimal', + border = 'rounded', + source = 'always', + }, + }) + + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( + vim.lsp.handlers.hover, + { + border = 'rounded', + } + ) + + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( + vim.lsp.handlers.signature_help, + { + border = 'rounded', + } + ) + vim.api.nvim_set_keymap('n', 'vt', ':call v:lua.toggle_diagnostics()', {noremap = true, silent = true}) -- autopairs @@ -534,11 +567,11 @@ in null_ls.setup({ sources = { null_ls.builtins.diagnostics.shellcheck, + null_ls.builtins.diagnostics.proselint.with({ filetypes = { "vimwiki", "mail", }, }), -- null_ls.builtins.code_actions.statix, -- null_ls.builtins.diagnostics.clj_kondo, -- null_ls.builtins.formatting.isort, -- null_ls.builtins.formatting.black, - -- null_ls.builtins.code_actions.proselint, }, }) @@ -548,11 +581,25 @@ in local format = require("lsp-format") local navic = require("nvim-navic") + -- lspsaga, code_action lightbulb is annoying + -- local saga = require('lspsaga') + -- saga.init_lsp_saga({ + -- code_action_lightbulb = { + -- enable = true, + -- enable_in_insert = true, + -- cache_code_action = true, + -- sign = true, + -- update_time = 150, + -- sign_priority = 4, + -- virtual_text = false, + -- }, + -- }) + local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) local lspconfig = require('lspconfig') - local servers = { 'clojure_lsp', 'terraform_lsp', 'zls', 'pyright', 'rust_analyzer', 'tsserver' } + local servers = { 'clojure_lsp', 'terraform_lsp', 'zls', 'pyright', 'rust_analyzer', 'tsserver', 'sumneko_lua' } for _, lsp in ipairs(servers) do lspconfig[lsp].setup { on_attach = function(client, bufnr) @@ -768,6 +815,7 @@ in python-with-my-packages nodejs clojure-lsp + clojure rnix-lsp terraform-lsp rust-analyzer @@ -780,6 +828,7 @@ in statix nodePackages.typescript nodePackages.typescript-language-server + sumneko-lua-language-server ]; plugins = with pkgs.vimPlugins // customPlugins; [ @@ -795,7 +844,7 @@ in undotree telescope-nvim plenary-nvim - nvim-gps + nvim-navic nvim-treesitter nvim-treesitter-context my-fterm @@ -806,6 +855,7 @@ in nvim-peekup zen-mode-nvim twilight-nvim + lspsaga-nvim # language vim-nix @@ -854,7 +904,6 @@ in vim-tidal # experimental nvim-luapad - nvim-navic scnvim leap vim-beancount