diff options
Diffstat (limited to 'dot_config/nvim/lua/plugins/lsp')
| -rw-r--r-- | dot_config/nvim/lua/plugins/lsp/attach.lua | 36 | ||||
| -rw-r--r-- | dot_config/nvim/lua/plugins/lsp/capabilities.lua | 1 | ||||
| -rw-r--r-- | dot_config/nvim/lua/plugins/lsp/init.lua | 41 |
3 files changed, 78 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/plugins/lsp/attach.lua b/dot_config/nvim/lua/plugins/lsp/attach.lua new file mode 100644 index 0000000..66d5a44 --- /dev/null +++ b/dot_config/nvim/lua/plugins/lsp/attach.lua @@ -0,0 +1,36 @@ +return function(c, b) + local lsp = vim.lsp + local lbf = lsp.buf + local wk = require 'which-key' + vim.api.nvim_buf_set_option(b, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + wk.register({ + name = '+lsp', + D = {lbf.declaration, 'goto declaration'}, + d = {lbf.definition, 'goto definition'}, + k = {lbf.hover, 'hover'}, + K = {lbf.signature_help, 'signature help'}, + i = {lbf.implementation, 'goto implementation'}, + t = {lbf.type_definition, 'goto type definition'}, + r = {lbf.rename, 'rename'}, + c = {lbf.code_action, 'code action'}, + R = {lbf.references, 'list references'}, + w = { + name = '+workspace', + a = {lbf.add_workspace_folder, 'add folder'}, + r = {lbf.remove_workspace_folder, 'remove folder'}, + l = { + function() print(vim.inspect(lbf.list_workspace_folders())) end, + 'list folders' + }, + }, + }, { + prefix = '<localleader><localleader>', + buffer = b, + }) + wk.register({ + ['<leader>F'] = { + function() vim.lsp.buf.format {async = true} end, + 'run format', + }, + }, { buffer = b }) +end diff --git a/dot_config/nvim/lua/plugins/lsp/capabilities.lua b/dot_config/nvim/lua/plugins/lsp/capabilities.lua new file mode 100644 index 0000000..15e53c4 --- /dev/null +++ b/dot_config/nvim/lua/plugins/lsp/capabilities.lua @@ -0,0 +1 @@ +return nil diff --git a/dot_config/nvim/lua/plugins/lsp/init.lua b/dot_config/nvim/lua/plugins/lsp/init.lua new file mode 100644 index 0000000..01fb34a --- /dev/null +++ b/dot_config/nvim/lua/plugins/lsp/init.lua @@ -0,0 +1,41 @@ +local attach = require 'plugins.lsp.attach' +local caps = require 'plugins.lsp.capabilities' + +return { + { + 'neovim/nvim-lspconfig', + config = function(_, opts) + for k, v in pairs(opts) do + v.on_attach = v.on_attach or attach + if type(caps) == 'table' then + v.capabilities = v.capabilities or caps + end + local s = require 'lspconfig'[k] + local c = v.cmd or s.document_config.default_config.cmd + if vim.fn.executable(c[1]) ~= 0 then + s.setup(v) + end + end + end, + opts = function() + local plist = function(...) + local p = require 'lspconfig.util'.root_pattern(...) + return function(f) return p(f) end + end + return { + clojure_lsp = { + root_dir = plist('project.clj', 'deps.edn', 'bb.edn', 'build.boot', 'shadow-cljs.edn', '.git'), + }, + denols = { + root_dir = plist('deno.json', 'deno.jsonc'), + }, + gopls = {}, + ltex = {}, + lua_ls = {}, + tsserver = { + root_dir = plist('tsconfig.json', 'package.json'), + }, + } + end + }, +} |
