Configuration for my NixOS based systems and Home Manager
at shizuri 89 lines 3.2 kB view raw
1local capabilities = require('cmp_nvim_lsp').default_capabilities() 2-- ######################## 3-- #### Set up LSPs #### 4-- ######################## 5 6vim.lsp.config("*", { 7 capabilities = capabilities 8}) 9 10local servers = { 11 "pylsp", "lua_ls", "janet_lsp", 12 --"htmx", 13 "nil_ls", "bzl", "buf_ls", "crystalline", "dockerls", 14 "erlangls", "elixirls", "fortls", "gleam", "gopls", "hls", "jsonls", 15 "vimls", "asm_lsp", "ccls", "pyright", 16 "ruff", "clojure_lsp", "guile_ls", 17 -- Of course the Java-based ones are verbose af 18 "kotlin_language_server", "java_language_server", "jsonls", "pest_ls", 19 "ocamllsp", "reason_ls", "racket_langserver", "rust_analyzer", 20 "scheme_langserver", "sqls", "thriftls", "tinymist", "vhdl_ls", "yamlls", 21 "zls", "ts_ls", "eslint", "metals", "futhark_lsp", "roc_ls", "sourcekit" 22 -- disabled because it's broken 23 -- "scheme_langserver", 24} 25vim.lsp.enable(servers) 26 27local on_attach = function(ev) 28 -- Enable completion triggered by <c-x><x-o> 29 vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' 30 31 local opts = { noremap = true, silent = true, buffer = ev.buf } 32 local protocol = require("vim.lsp.protocol") 33 -- Mappings. 34 -- See `:help vim.lsp.*` for documentation on any of the below functions 35 vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) 36 vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 37 vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) 38 vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) 39 vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts) 40 vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts) 41 vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts) 42 vim.keymap.set("n", "<space>wl", function() 43 print(vim.inspect(vim.lsp.buf.list_workspace_folders())) 44 end, opts) 45 vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts) 46 vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts) 47 vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts) 48 vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) 49 vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts) 50 vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) 51 vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) 52 vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts) 53 vim.keymap.set("n", "<space>f", 54 function() vim.lsp.buf.format { async = true } end, opts) 55 vim.keymap.set("n", "<space>s", vim.lsp.buf.workspace_symbol, opts) 56 57 -- require'completion'.on_attach(client, bufnr) 58 protocol.CompletionItemKind = { 59 "", -- Text 60 "", -- Method 61 "𝑓", -- Function 62 "", -- Constructor 63 "", -- Field 64 "", -- Variable 65 "", -- Class 66 "", -- Interface 67 "", -- Module 68 "", -- Property 69 "", -- Unit 70 "", -- Value 71 "", -- Enum 72 "", -- Keyword 73 "", -- Snippet 74 "", -- Color 75 "", -- File 76 "", -- Reference 77 "", -- Folder 78 "", -- EnumMember 79 "", -- Constant 80 "", -- Struct 81 "", -- Event 82 "", -- Operator 83 "" -- TypeParameter 84 } 85end 86vim.api.nvim_create_autocmd('LspAttach', { 87 group = vim.api.nvim_create_augroup('UserLspConfig', {}), 88 callback = on_attach 89})