diff options
Diffstat (limited to 'fnl/plugins/lsp/lspconfig.fnl')
-rw-r--r-- | fnl/plugins/lsp/lspconfig.fnl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl new file mode 100644 index 0000000..b2ee792 --- /dev/null +++ b/fnl/plugins/lsp/lspconfig.fnl @@ -0,0 +1,42 @@ +;; Setup of lsps. + +(fn on-attach [] + (vim.api.nvim_create_autocmd :LspAttach + {:callback (fn [args] + (let [keymaps (require :plugins.lsp.keymaps) + bufnr (. args :buf)] + (keymaps.on-attach bufnr)))})) + +(fn capabilities [] + (let [cmp-lsp (require :cmp_nvim_lsp)] + (cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities)))) + +(fn mason-opts [servers] + {:ensure_installed (vim.tbl_keys servers) :automatic_installation true}) + +(fn setup [] + + (let [diagnostics (require :plugins.lsp.diagnostics) + lspconfig (require :lspconfig) + mason-lspconfig (require :mason-lspconfig) + servers (require :plugins.lsp.servers)] + (diagnostics.setup) + (on-attach) + (mason-lspconfig.setup (mason-opts servers)) + (mason-lspconfig.setup_handlers [(fn [server-name] + (let [server-config (. lspconfig + server-name) + opts (or (. servers server-name) + {})] + (tset opts :capabilities + (capabilities)) + (server-config.setup opts)))]))) + +{1 :neovim/nvim-lspconfig + :event :BufReadPre + :dependencies [:mason.nvim + :williamboman/mason-lspconfig.nvim + :b0o/SchemaStore.nvim + :hrsh7th/cmp-nvim-lsp] + :config (fn [] + (setup))} |