diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-07-27 00:32:49 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-07-27 00:32:49 +0200 |
commit | 5cc2e3d846c693e615af88ed7678422edadd3a04 (patch) | |
tree | 65044c6c6670137cb119c34713258c1f0325285f /fnl/config/lsp | |
parent | 9af69c1df30ccb99e2f34632c3809987b22c98b4 (diff) |
Replace lsp-installer with mason
Diffstat (limited to 'fnl/config/lsp')
-rw-r--r-- | fnl/config/lsp/init.fnl | 3 | ||||
-rw-r--r-- | fnl/config/lsp/lsp-installer.fnl | 62 | ||||
-rw-r--r-- | fnl/config/lsp/mason-lspconfig.fnl | 56 | ||||
-rw-r--r-- | fnl/config/lsp/mason.fnl | 9 |
4 files changed, 67 insertions, 63 deletions
diff --git a/fnl/config/lsp/init.fnl b/fnl/config/lsp/init.fnl index c20b93c..6c7f823 100644 --- a/fnl/config/lsp/init.fnl +++ b/fnl/config/lsp/init.fnl @@ -1,7 +1,8 @@ ;; Loads the LSP functionality. (module config.lsp.init {autoload {: util}}) -(require :config.lsp.lsp-installer) +(require :config.lsp.mason) +(require :config.lsp.mason-lspconfig) (let [handlers (require :config.lsp.handlers)] (handlers.setup)) diff --git a/fnl/config/lsp/lsp-installer.fnl b/fnl/config/lsp/lsp-installer.fnl deleted file mode 100644 index 1ad0af7..0000000 --- a/fnl/config/lsp/lsp-installer.fnl +++ /dev/null @@ -1,62 +0,0 @@ -;; Loads default handlers and specific language settings. -(module config.lsp.lsp-installer {autoload {: util}}) - -(def- default-servers {:bashls true - :clangd true - :cssls true - :dockerls true - :html true - :hls true - :jsonls true - :pyright true - :rust_analyzer true - :terraformls true - :texlab true - :tflint true - :yamlls true - :taplo true - :zk true}) - -(defn- merge [default-servers installed-servers] - (let [servers default-servers] - (each [_ server (ipairs installed-servers)] - (if (not= (. servers server.name) true) - (tset servers server.name true))) - (icollect [k (pairs servers)] - k))) - -(defn- handler-opts [] - (let [handlers (require :config.lsp.handlers)] - {:on_attach handlers.on-attach :capabilities (handlers.capabilities)})) - -(defn- jsonls-opts [] - (let [jsonls-opts (require :config.lsp.settings.jsonls)] - (vim.tbl_deep_extend :force jsonls-opts (handler-opts)))) - -(defn- sumneko-lua-opts [] - (let [sumneko-lua (require :config.lsp.settings.sumneko-lua)] - (vim.tbl_deep_extend :force sumneko-lua.opts (handler-opts)))) - -(defn- pyright-opts [] - (let [pyright (require :config.lsp.settings.pyright)] - (vim.tbl_deep_extend :force pyright.opts (handler-opts)))) - -(defn- rust-opts [] - (let [rust (require :config.lsp.settings.rust)] - (vim.tbl_deep_extend :force rust.opts (handler-opts)))) - -(defn- get-server-opts [server] - (match server - :jsonls (jsonls-opts) - :pyright (pyright-opts) - :sumneko_lua (sumneko-lua-opts) - :rust_analyzer (rust-opts) - _ (handler-opts))) - -(let [lsp-installer (util.load-plugin :nvim-lsp-installer) - lspconfig (util.load-plugin :lspconfig)] - (let [servers (merge default-servers (lsp-installer.get_installed_servers))] - (lsp-installer.setup {:ensure_installed servers}) - (each [_ server (ipairs servers)] - (let [server-config (. lspconfig server)] - (server-config.setup (get-server-opts server)))))) diff --git a/fnl/config/lsp/mason-lspconfig.fnl b/fnl/config/lsp/mason-lspconfig.fnl new file mode 100644 index 0000000..704761d --- /dev/null +++ b/fnl/config/lsp/mason-lspconfig.fnl @@ -0,0 +1,56 @@ +;; TBD +(module config.lsp.mason-lspconfig {autoload {: util}}) + +(def- servers [:bashls + :clangd + :cssls + :dockerls + :html + :hls + :jsonls + :pyright + :rust_analyzer + :taplo + :terraformls + :texlab + :sumneko_lua + :tflint + :yamlls + :zk]) + +(defn- handler-opts [] + (let [handlers (require :config.lsp.handlers)] + {:on_attach handlers.on-attach :capabilities (handlers.capabilities)})) + +(defn- jsonls-opts [] + (let [jsonls-opts (require :config.lsp.settings.jsonls)] + (vim.tbl_deep_extend :force jsonls-opts (handler-opts)))) + +(defn- sumneko-lua-opts [] + (let [sumneko-lua (require :config.lsp.settings.sumneko-lua)] + (vim.tbl_deep_extend :force sumneko-lua.opts (handler-opts)))) + +(defn- pyright-opts [] + (let [pyright (require :config.lsp.settings.pyright)] + (vim.tbl_deep_extend :force pyright.opts (handler-opts)))) + +(defn- rust-opts [] + (let [rust (require :config.lsp.settings.rust)] + (vim.tbl_deep_extend :force rust.opts (handler-opts)))) + +(defn- get-server-opts [server] + (match server + :jsonls (jsonls-opts) + :pyright (pyright-opts) + :sumneko_lua (sumneko-lua-opts) + :rust_analyzer (rust-opts) + _ (handler-opts))) + +(def- opts {:ensure_installed servers :automatic_installation true}) + +(util.use-config :mason-lspconfig opts) + +(let [lspconfig (util.load-plugin :lspconfig)] + (each [_ server (ipairs servers)] + (let [server-config (. lspconfig server)] + (server-config.setup (get-server-opts server))))) diff --git a/fnl/config/lsp/mason.fnl b/fnl/config/lsp/mason.fnl new file mode 100644 index 0000000..66963cb --- /dev/null +++ b/fnl/config/lsp/mason.fnl @@ -0,0 +1,9 @@ +;; Mason manages external tooling, e.g. lsp, formatters, and linters. +(module config.lsp.mason {autoload {: util}}) + +(def- opts {:ui {:icons {:package_installed "✓" + :package_pending "➜" + :package_uninstalled "✗"}} + :max_concurrent_installers 10}) + +(util.use-config :mason opts) |