diff options
Diffstat (limited to 'fnl/config')
-rw-r--r-- | fnl/config/lsp/diagnostics.fnl | 32 | ||||
-rw-r--r-- | fnl/config/lsp/handlers.fnl | 59 | ||||
-rw-r--r-- | fnl/config/lsp/keymaps.fnl | 22 | ||||
-rw-r--r-- | fnl/config/lsp/lspconfig.fnl | 40 | ||||
-rw-r--r-- | fnl/config/lsp/mason-lspconfig.fnl | 47 | ||||
-rw-r--r-- | fnl/config/lsp/mason-null-ls.fnl | 20 | ||||
-rw-r--r-- | fnl/config/lsp/servers.fnl | 18 |
7 files changed, 114 insertions, 124 deletions
diff --git a/fnl/config/lsp/diagnostics.fnl b/fnl/config/lsp/diagnostics.fnl new file mode 100644 index 0000000..adf098d --- /dev/null +++ b/fnl/config/lsp/diagnostics.fnl @@ -0,0 +1,32 @@ +;; Handlers for the requests and responses from and to the lsp server. +(module config.lsp.handlers {autoload {util config.util nvim aniseed.nvim}}) + +(def- signs [{:name :DiagnosticSignError :text ""} + {:name :DiagnosticSignWarn :text ""} + {:name :DiagnosticSignHint :text ""} + {:name :DiagnosticSignInfo :text ""}]) + +(defn- apply-signs [] (each [_ sign (ipairs signs)] + (vim.fn.sign_define sign.name + {:texthl sign.name + :text sign.text + :numhl ""}))) + +(def- config {:virtual_text false + :signs {:active signs} + :update_in_insert false + :underline true + :severity_sort true + :float {:focusable false + :style :minimal + :border :rounded + :source :always + :header "" + :prefix ""}}) + +(defn setup [] (apply-signs) (vim.diagnostic.config config) + (set vim.lsp.handlers.textDocument/hover + (vim.lsp.with {:border :rounded :width 60})) + (set vim.lsp.handlers.textDocument/signatureHelp + (vim.lsp.with vim.lsp.handlers.signature_help + {:border :rounded :width 60}))) diff --git a/fnl/config/lsp/handlers.fnl b/fnl/config/lsp/handlers.fnl deleted file mode 100644 index 96b50e6..0000000 --- a/fnl/config/lsp/handlers.fnl +++ /dev/null @@ -1,59 +0,0 @@ -;; Handlers for the requests and responses from and to the lsp server. -(module config.lsp.handlers {autoload {util config.util nvim aniseed.nvim}}) - -(def- signs [{:name :DiagnosticSignError :text ""} - {:name :DiagnosticSignWarn :text ""} - {:name :DiagnosticSignHint :text ""} - {:name :DiagnosticSignInfo :text ""}]) - -(defn- apply-signs [] (each [_ sign (ipairs signs)] - (vim.fn.sign_define sign.name - {:texthl sign.name - :text sign.text - :numhl ""}))) - -(def- config {:virtual_text false - :signs {:active signs} - :update_in_insert true - :underline true - :severity_sort true - :float {:focusable false - :style :minimal - :border :rounded - :source :always - :header "" - :prefix ""}}) - -(defn setup [] (apply-signs) (vim.diagnostic.config config) - (set vim.lsp.handlers.textDocument/hover - (vim.lsp.with {:border :rounded :width 60})) - (set vim.lsp.handlers.textDocument/signatureHelp - (vim.lsp.with vim.lsp.handlers.signature_help - {:border :rounded :width 60}))) - -(defn- lsp-keymaps [bufnr] - (let [opts {:noremap true :silent true}] - (nvim.buf_set_keymap bufnr :n :gD - "<cmd>lua vim.lsp.buf.declaration()<CR>" opts) - (nvim.buf_set_keymap bufnr :n :gd - "<cmd>lua vim.lsp.buf.definition()<CR>" opts) - (nvim.buf_set_keymap bufnr :n :gI - "<cmd>lua vim.lsp.buf.implementation()<CR>" opts) - (nvim.buf_set_keymap bufnr :n :gr - "<cmd>lua vim.lsp.buf.references()<CR>" opts) - (nvim.buf_set_keymap bufnr :n :gl - "<cmd>lua vim.diagnostic.open_float()<CR>" opts) - (nvim.buf_set_keymap bufnr :n :gs - "<cmd>lua vim.lsp.buf.signature_help()<CR>" opts))) - -(defn on-attach [client bufnr] (if (= client.name :html) - (set client.server_capabilities.document_formatting - false)) - (lsp-keymaps bufnr)) - -(defn capabilities [] - (let [capabilities (vim.lsp.protocol.make_client_capabilities)] - (set capabilities.textDocument.completion.completionItem.snippetSupport - true) - (let [cmp-nvim-lsp (util.prequire :cmp_nvim_lsp)] - (cmp-nvim-lsp.default_capabilities capabilities)))) diff --git a/fnl/config/lsp/keymaps.fnl b/fnl/config/lsp/keymaps.fnl new file mode 100644 index 0000000..56a84a3 --- /dev/null +++ b/fnl/config/lsp/keymaps.fnl @@ -0,0 +1,22 @@ +;; Key mappings for lsp. +(module config.lsp.keymaps {autoload {nvim aniseed.nvim}}) + +(defn keymaps [bufnr] (let [opts {:noremap true :silent true}] + (nvim.buf_set_keymap bufnr :n :gD + "<cmd>lua vim.lsp.buf.declaration()<CR>" + opts) + (nvim.buf_set_keymap bufnr :n :gd + "<cmd>lua vim.lsp.buf.definition()<CR>" + opts) + (nvim.buf_set_keymap bufnr :n :gI + "<cmd>lua vim.lsp.buf.implementation()<CR>" + opts) + (nvim.buf_set_keymap bufnr :n :gr + "<cmd>lua vim.lsp.buf.references()<CR>" + opts) + (nvim.buf_set_keymap bufnr :n :gl + "<cmd>lua vim.diagnostic.open_float()<CR>" + opts) + (nvim.buf_set_keymap bufnr :n :gs + "<cmd>lua vim.lsp.buf.signature_help()<CR>" + opts))) diff --git a/fnl/config/lsp/lspconfig.fnl b/fnl/config/lsp/lspconfig.fnl new file mode 100644 index 0000000..c9baba7 --- /dev/null +++ b/fnl/config/lsp/lspconfig.fnl @@ -0,0 +1,40 @@ +;; Setup of lsps. +(module config.lsp.lspconfig {autoload {util config.util lsp config.lsp.keymaps}}) + +(defn on-attach [client bufnr] (if (= client.name :html) + (set client.server_capabilities.document_formatting + false)) + (lsp.keymaps bufnr)) + +(defn capabilities [] + (let [capabilities (vim.lsp.protocol.make_client_capabilities)] + (set capabilities.textDocument.completion.completionItem.snippetSupport + true) + (let [cmp-nvim-lsp (util.prequire :cmp_nvim_lsp)] + (cmp-nvim-lsp.default_capabilities capabilities)))) + +(defn- handler-opts [] {:on_attach on-attach :capabilities (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- 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) + :sumneko_lua (sumneko-lua-opts) + :rust_analyzer (rust-opts) + _ (handler-opts))) + +(let [lspconfig (util.prequire :lspconfig) servers (require :config.lsp.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 index 8aeaff1..5180549 100644 --- a/fnl/config/lsp/mason-lspconfig.fnl +++ b/fnl/config/lsp/mason-lspconfig.fnl @@ -1,51 +1,8 @@ -;; TBD +;; Automatic installation and updating of some lsps. (module config.lsp.mason-lspconfig {autoload {util config.util}}) -(def- servers [:bashls - :clangd - :cssls - :dockerls - :hls - :html - :jsonls - :rust_analyzer - :sqls - :sumneko_lua - :taplo - :terraformls - :texlab - :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- 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) - :sumneko_lua (sumneko-lua-opts) - :rust_analyzer (rust-opts) - _ (handler-opts))) +(def- servers (require :config.lsp.servers)) (def- opts {:ensure_installed servers :automatic_installation true}) (util.setup :mason-lspconfig opts) - -(let [lspconfig (util.prequire :lspconfig)] - (each [_ server (ipairs servers)] - (let [server-config (. lspconfig server)] - (server-config.setup (get-server-opts server))))) diff --git a/fnl/config/lsp/mason-null-ls.fnl b/fnl/config/lsp/mason-null-ls.fnl deleted file mode 100644 index 5200cea..0000000 --- a/fnl/config/lsp/mason-null-ls.fnl +++ /dev/null @@ -1,20 +0,0 @@ -;; Ensure that tools needed for null-ls are installed. -(module config.mason-null-ls {autoload {util config.util}}) - -(def- opts {:ensure_installed [:cpplint - :fnlfmt - :gitlint - :hadolint - :jsonlint - :prettier - :rustfmt - :shellcheck - :shfmt - :sqlfluff - :stylua - :terraform-fmt - :yamllint] - :auto_update true - :automatic_installation true}) - -(util.setup :mason-null-ls opts) diff --git a/fnl/config/lsp/servers.fnl b/fnl/config/lsp/servers.fnl new file mode 100644 index 0000000..0d50953 --- /dev/null +++ b/fnl/config/lsp/servers.fnl @@ -0,0 +1,18 @@ +;; List of lsp that should be automatically installed and supported. + +[:bashls + :clangd + :cssls + :dockerls + :hls + :html + :jsonls + :rust_analyzer + :sqls + :sumneko_lua + :taplo + :terraformls + :texlab + :tflint + :yamlls + :zk] |