From 076805ccf4983657a8a9a485341a1b85e01cc1a6 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 7 Jan 2024 11:50:34 +0100 Subject: Move mason-lspconfig logic to a separate file --- fnl/plugins/lsp/lspconfig.fnl | 24 +++--------------------- fnl/plugins/lsp/mason-lspconfig.fnl | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 fnl/plugins/lsp/mason-lspconfig.fnl diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl index 6e2ace4..e498056 100644 --- a/fnl/plugins/lsp/lspconfig.fnl +++ b/fnl/plugins/lsp/lspconfig.fnl @@ -7,32 +7,14 @@ buffer (. args :buf)] (keymaps.on-attach buffer)))})) -(fn capabilities [] - (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 setup-mason-lspconfig [] - (let [mason-lspconfig (require :mason-lspconfig) - servers (require :plugins.lsp.servers)] - (mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers) - :automatic_installation true - :handlers [handlers]}))) - (fn config [] (on-attach) (let [diagnostics (require :plugins.lsp.diagnostics) + mason-lspconfig (require :plugins.lsp.mason-lspconfig) ui (require :lspconfig.ui.windows)] - (diagnostics.setup) (set ui.default_options.border :single) - (setup-mason-lspconfig))) + (diagnostics.setup) + (mason-lspconfig.setup))) {1 :neovim/nvim-lspconfig :event :BufReadPost diff --git a/fnl/plugins/lsp/mason-lspconfig.fnl b/fnl/plugins/lsp/mason-lspconfig.fnl new file mode 100644 index 0000000..3e34c32 --- /dev/null +++ b/fnl/plugins/lsp/mason-lspconfig.fnl @@ -0,0 +1,22 @@ +;; Mason lspconfig setup + +(fn capabilities [] + (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 setup [] + (let [mason-lspconfig (require :mason-lspconfig) + servers (require :plugins.lsp.servers)] + (mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers) + :automatic_installation true + :handlers [handlers]}))) + +{: setup} -- cgit v1.2.3-70-g09d2