diff options
author | Gustaf Rydholm <gustaf@nexure.io> | 2022-05-31 23:23:19 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf@nexure.io> | 2022-05-31 23:23:19 +0200 |
commit | ba831c90acd7240d6982802e37d61a8bd25d4112 (patch) | |
tree | 42bd0f64da33e9feb977e88dbf8f425c32b8a22b /fnl/config | |
parent | 9d193be266500f7f69b78fbd80f99e87c87a52fc (diff) |
Add default lang servers to install if not present
Diffstat (limited to 'fnl/config')
-rw-r--r-- | fnl/config/lsp/lsp-installer.fnl | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/fnl/config/lsp/lsp-installer.fnl b/fnl/config/lsp/lsp-installer.fnl index 0b9ebe4..d6d1497 100644 --- a/fnl/config/lsp/lsp-installer.fnl +++ b/fnl/config/lsp/lsp-installer.fnl @@ -1,32 +1,55 @@ ;; Loads default handlers and specific language settings. (module config.lsp.lsp-installer {autoload {util util}}) -(def handler-opts (let [handlers (require :config.lsp.handlers)] - {:on_attach handlers.on-attach - :capabilities (handlers.capabilities)})) +(def- default-servers [:bashls + :clangd + :cssls + :dockerls + :html + :hls + :jsonls + :pyright + :rust_analyzer + :terraformls + :texlab + :tflint + :yamlls + :zk]) -(defn- jsonls-opts [] - (let [jsonls-opts (require :config.lsp.settings.jsonls)] - (vim.tbl_deep_extend :force jsonls-opts handler-opts))) +(defn- merge [default-servers installed-servers] + (let [servers default-servers] + (each [_ server (ipairs installed-servers)] + (if (. servers server.name) + (tset servers (+ (length servers) 1) server.name))) + servers)) -(defn- sumneko-lua-opts [] - (let [sumneko-lua (require :config.lsp.settings.sumneko-lua)] - (vim.tbl_deep_extend :force sumneko-lua.opts handler-opts))) +(def- handler-opts + (let [handlers (require :config.lsp.handlers)] + {:on_attach handlers.on-attach :capabilities (handlers.capabilities)})) -(defn- pyright-opts [] - (let [pyright (require :config.lsp.settings.pyright)] - (vim.tbl_deep_extend :force pyright.opts handler-opts))) +(def- jsonls-opts [] + (let [jsonls-opts (require :config.lsp.settings.jsonls)] + (vim.tbl_deep_extend :force jsonls-opts handler-opts))) + +(def- sumneko-lua-opts [] + (let [sumneko-lua (require :config.lsp.settings.sumneko-lua)] + (vim.tbl_deep_extend :force sumneko-lua.opts handler-opts))) + +(def- pyright-opts [] + (let [pyright (require :config.lsp.settings.pyright)] + (vim.tbl_deep_extend :force pyright.opts handler-opts))) (defn- get-server-opts [server] - (match server.name - :jsonls (jsonls-opts) - :pyright (pyright-opts) - :sumneko_lua (sumneko-lua-opts) + (match server + :jsonls jsonls-opts + :pyright pyright-opts + :sumneko_lua sumneko-lua-opts _ handler-opts)) (let [lsp-installer (util.load-plugin :nvim-lsp-installer) lspconfig (util.load-plugin :lspconfig)] - (lsp-installer.setup) - (each [_ server (ipairs (lsp-installer.get_installed_servers))] - (let [server-config (. lspconfig server.name)] - (server-config.setup (get-server-opts server))))) + (let [servers (merge default-servers (lsp-installer.get_installed_servers))] + (lsp-installer.setup {:ensure_installed servers}) + (each [_ server (pairs servers)] + (let [server-config (. lspconfig server)] + (server-config.setup (get-server-opts server)))))) |