diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2023-01-08 02:49:49 +0100 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2023-01-08 02:49:49 +0100 |
commit | 86fc163e549d78136855ac2b45e91ffb2f43affc (patch) | |
tree | 20fab78a2ff2635af5ac95f2b2a11d9d07ace0e1 /fnl/config/lsp/lspconfig.fnl | |
parent | 0d7f782cb4e68cff000beb00e8ab64308a66f3f0 (diff) |
Refactor config loading
Diffstat (limited to 'fnl/config/lsp/lspconfig.fnl')
-rw-r--r-- | fnl/config/lsp/lspconfig.fnl | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/fnl/config/lsp/lspconfig.fnl b/fnl/config/lsp/lspconfig.fnl index b7143ab..74faa26 100644 --- a/fnl/config/lsp/lspconfig.fnl +++ b/fnl/config/lsp/lspconfig.fnl @@ -1,30 +1,40 @@ ;; Setup of lsps. -(module config.lsp.lspconfig - {autoload {nvim aniseed.nvim - util config.util - keymaps config.lsp.keymaps}}) -(defn- on-attach [] - (nvim.create_autocmd :LspAttach - {:callback (fn [args] - (let [bufnr (. args :buf)] - (keymaps.on-attach bufnr)))})) +(fn on-attach [] + (vim.api.nvim_create_autocmd :LspAttach + {:callback (fn [args] + (let [keymaps (require :config.lsp.keymaps) + bufnr (. args :buf)] + (keymaps.on-attach bufnr)))})) -(defn- capabilities [] - (let [cmp-lsp (util.prequire :cmp_nvim_lsp)] +(fn capabilities [] + (let [cmp-lsp (require :cmp_nvim_lsp)] (cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities)))) -(defn- mason-opts [servers] +(fn mason-opts [servers] {:ensure_installed (vim.tbl_keys servers) :automatic_installation true}) -(let [lspconfig (util.prequire :lspconfig) - mason-lspconfig (util.prequire :mason-lspconfig) - servers (require :config.lsp.servers)] - (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)))])) +(fn setup [] + (require :config.lsp.diagnostics) + (let [lspconfig (require :lspconfig) + mason-lspconfig (require :mason-lspconfig) + servers (require :config.lsp.servers)] + (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))} |