diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-01-07 01:28:22 +0100 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-01-07 01:28:22 +0100 |
commit | 81b0fdd14fab1dfdd5b43fd5dc520709800d78a0 (patch) | |
tree | f4a7b8b050c4ed359133ac183053194c0773d96d /fnl/plugins/lsp/lspconfig.fnl | |
parent | f005ce541335fb936a85e9997513e94067ef07ae (diff) |
Refactor lspconfig
Diffstat (limited to 'fnl/plugins/lsp/lspconfig.fnl')
-rw-r--r-- | fnl/plugins/lsp/lspconfig.fnl | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl index cca52a4..84c460f 100644 --- a/fnl/plugins/lsp/lspconfig.fnl +++ b/fnl/plugins/lsp/lspconfig.fnl @@ -11,32 +11,34 @@ (let [cmp-lsp (require :cmp_nvim_lsp)] (cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities)))) +(fn handlers [server] + (let [servers (require :plugins.lsp.servers) + lspconfig (require :lspconfig)] + (let [config (. lspconfig server) + opts (or (. servers server) {})] + (tset opts :capabilities (capabilities)) + (config.setup opts)))) + (fn mason-opts [servers] - {:ensure_installed (vim.tbl_keys servers) :automatic_installation true}) + (let [servers (require :plugins.lsp.servers)] + {:ensure_installed (vim.tbl_keys servers) + :automatic_installation true + :handlers [handlers]})) (fn config [] + (on-attach) (let [diagnostics (require :plugins.lsp.diagnostics) - lspconfig (require :lspconfig) lspconfig-win (require :lspconfig.ui.windows) - mason-lspconfig (require :mason-lspconfig) - servers (require :plugins.lsp.servers)] + mason-lspconfig (require :mason-lspconfig)] (diagnostics.setup) - (on-attach) (set lspconfig-win.default_options.border :single) - (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)))]))) + (mason-lspconfig.setup (mason-opts)) + (mason-lspconfig.setup_handlers [setup-handler]))) {1 :neovim/nvim-lspconfig :event :BufReadPost :dependencies [:mason.nvim :williamboman/mason-lspconfig.nvim - :b0o/SchemaStore.nvim + :b0o/schemastore.nvim :hrsh7th/cmp-nvim-lsp] : config} |