diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-05-01 23:06:03 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-05-01 23:06:03 +0200 |
commit | f845a7b0588559750b1cb7eede1b3aecb450cdfe (patch) | |
tree | 1c2028e77ef60fb5a00e0abce46a0d4bf66d76d9 /fnl/config/lsp | |
parent | 609daf2f632e907f0aed920084b51f608a63edf7 (diff) |
style: fmt with fnlfmt
Diffstat (limited to 'fnl/config/lsp')
-rw-r--r-- | fnl/config/lsp/handlers.fnl | 106 | ||||
-rw-r--r-- | fnl/config/lsp/init.fnl | 3 | ||||
-rw-r--r-- | fnl/config/lsp/lsp-installer.fnl | 35 | ||||
-rw-r--r-- | fnl/config/lsp/null-ls.fnl | 49 | ||||
-rw-r--r-- | fnl/config/lsp/settings/jsonls.fnl | 21 | ||||
-rw-r--r-- | fnl/config/lsp/settings/pyright.fnl | 6 | ||||
-rw-r--r-- | fnl/config/lsp/settings/sumneko-lua.fnl | 38 |
7 files changed, 113 insertions, 145 deletions
diff --git a/fnl/config/lsp/handlers.fnl b/fnl/config/lsp/handlers.fnl index 34e1ac7..04f8297 100644 --- a/fnl/config/lsp/handlers.fnl +++ b/fnl/config/lsp/handlers.fnl @@ -1,66 +1,60 @@ ;; Handlers for the requests and responses from and to the lsp server. -(module config.lsp.handlers - {autoload {util util - nvim aniseed.nvim}}) +(module config.lsp.handlers {autoload {util util nvim aniseed.nvim}}) -(def- signs - [{:name :DiagnosticSignError :text ""} - {:name :DiagnosticSignWarn :text ""} - {:name :DiagnosticSignHint :text ""} - {:name :DiagnosticSignInfo :text ""}]) +(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 ""}))) +(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 ""}}) +(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})) - (set vim.lsp.handlers.textDocument/signatureHelp - (vim.lsp.with vim.lsp.handlers.signature_help {:border :rounded}))) +(defn setup [] (apply-signs) (vim.diagnostic.config config) + (set vim.lsp.handlers.textDocument/hover + (vim.lsp.with {:border :rounded})) + (set vim.lsp.handlers.textDocument/signatureHelp + (vim.lsp.with vim.lsp.handlers.signature_help {:border :rounded}))) (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 :K "<cmd>lua vim.lsp.buf.hover()<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 :<leader>q - "<cmd>lua vim.diagnostic.setloclist()<CR>" opts))) + (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 :K "<cmd>lua vim.lsp.buf.hover()<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 :<leader>q + "<cmd>lua vim.diagnostic.setloclist()<CR>" opts))) -(defn on-attach [client bufnr] - (if (= client.name :html) - (set client.resolved_capabilities.document_formatting false)) - (lsp-keymaps bufnr)) +(defn on-attach [client bufnr] (if (= client.name :html) + (set client.resolved_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.load-plugin :cmp_nvim_lsp)] - (cmp-nvim-lsp.update_capabilities capabilities)))) + (let [capabilities (vim.lsp.protocol.make_client_capabilities)] + (set capabilities.textDocument.completion.completionItem.snippetSupport + true) + (let [cmp-nvim-lsp (util.load-plugin :cmp_nvim_lsp)] + (cmp-nvim-lsp.update_capabilities capabilities)))) diff --git a/fnl/config/lsp/init.fnl b/fnl/config/lsp/init.fnl index 8e23202..5ec20c1 100644 --- a/fnl/config/lsp/init.fnl +++ b/fnl/config/lsp/init.fnl @@ -1,6 +1,5 @@ ;; Loads the LSP functionality. -(module config.lsp.init - {autoload {util util}}) +(module config.lsp.init {autoload {util util}}) (let [_ (util.load-plugin :lspconfig)] (require :config.lsp.lsp-installer) diff --git a/fnl/config/lsp/lsp-installer.fnl b/fnl/config/lsp/lsp-installer.fnl index 42115c0..af9a4e8 100644 --- a/fnl/config/lsp/lsp-installer.fnl +++ b/fnl/config/lsp/lsp-installer.fnl @@ -1,33 +1,30 @@ ;; Loads default handlers and specific language settings. -(module config.lsp.lsp-installer - {autoload {util util}}) +(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 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))) + (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))) + (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))) + (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) + :jsonls (jsonls-opts) + :pyright (pyright-opts) + :sumneko_lua (sumneko-lua-opts) _ handler-opts)) (let [lsp-installer (util.load-plugin :nvim-lsp-installer)] - (lsp-installer.on_server_ready - (fn [server] - (let [opts (get-server-opts server)] - (server:setup opts))))) + (lsp-installer.on_server_ready (fn [server] + (let [opts (get-server-opts server)] + (server:setup opts))))) diff --git a/fnl/config/lsp/null-ls.fnl b/fnl/config/lsp/null-ls.fnl index 0d24373..b4b75c6 100644 --- a/fnl/config/lsp/null-ls.fnl +++ b/fnl/config/lsp/null-ls.fnl @@ -1,32 +1,27 @@ ;; Adds LSP diagnostics and formatting. -(module config.lsp.null-ls - {autoload {util util}}) +(module config.lsp.null-ls {autoload {util util}}) (let [null-ls (util.load-plugin :null-ls)] (let [formatting null-ls.builtins.formatting diagnostics null-ls.builtins.diagnostics] - (null-ls.setup - {:debug false - :sources [diagnostics.flake8 - diagnostics.golangci_lint - diagnostics.jsonlint - diagnostics.shellcheck - diagnostics.yamllint - (formatting.black.with - {:extra_args [:--fast]}) - formatting.erlfmt - formatting.fnlfmt - formatting.fourmolu - formatting.gofmt - formatting.goimports - formatting.nixfmt - (formatting.prettier.with - {:extra_args - [:--no-semi - :--single-quote - :--jsx-single-quote]}) - formatting.rustfmt - formatting.shfmt - formatting.sqlformat - formatting.stylua - formatting.terraform_fmt]}))) + (null-ls.setup {:debug false + :sources [diagnostics.flake8 + diagnostics.golangci_lint + diagnostics.jsonlint + diagnostics.shellcheck + diagnostics.yamllint + (formatting.black.with {:extra_args [:--fast]}) + formatting.erlfmt + formatting.fnlfmt + formatting.fourmolu + formatting.gofmt + formatting.goimports + formatting.nixfmt + (formatting.prettier.with {:extra_args [:--no-semi + :--single-quote + :--jsx-single-quote]}) + formatting.rustfmt + formatting.shfmt + formatting.sqlformat + formatting.stylua + formatting.terraform_fmt]}))) diff --git a/fnl/config/lsp/settings/jsonls.fnl b/fnl/config/lsp/settings/jsonls.fnl index f8dfdc2..18d9256 100644 --- a/fnl/config/lsp/settings/jsonls.fnl +++ b/fnl/config/lsp/settings/jsonls.fnl @@ -1,17 +1,10 @@ ;; Json schema store catalog language server. -(module config.lsp.settings.jsonls - {autoload {util util}}) +(module config.lsp.settings.jsonls {autoload {util util}}) (let [schemastore (util.load-plugin :schemastore)] - {:init_options - {:providerFormatter false} - :settings - {:json - {:schemas - (schemastore.json.schemas)}} - :setup - {:commands - {:Format - [(fn [] - (vim.lsp.buf.range_formatting - [] [0 0] [(vim.fn.line "$" 0)]))]}}}) + {:init_options {:providerFormatter false} + :settings {:json {:schemas (schemastore.json.schemas)}} + :setup {:commands {:Format [(fn [] + (vim.lsp.buf.range_formatting [] [0 0] + [(vim.fn.line "$" + 0)]))]}}}) diff --git a/fnl/config/lsp/settings/pyright.fnl b/fnl/config/lsp/settings/pyright.fnl index b1fa064..639ecff 100644 --- a/fnl/config/lsp/settings/pyright.fnl +++ b/fnl/config/lsp/settings/pyright.fnl @@ -1,8 +1,4 @@ ;; Config for pyright language server. (module config.lsp.settings.pyright) -(def opts - {:settings - {:python - {:analysis - {:typeCheckingMode :off}}}}) +(def opts {:settings {:python {:analysis {:typeCheckingMode :off}}}}) diff --git a/fnl/config/lsp/settings/sumneko-lua.fnl b/fnl/config/lsp/settings/sumneko-lua.fnl index d40fe9b..0f20f53 100644 --- a/fnl/config/lsp/settings/sumneko-lua.fnl +++ b/fnl/config/lsp/settings/sumneko-lua.fnl @@ -2,28 +2,22 @@ (module config.lsp.settings.sumneko-lua) (def- workspace - {:library {(vim.fn.expand "$VIMRUNTIME/lua") true - (vim.fn.expand "$VIMRUNTIME/lua/vim/lsp") true}}) + {:library {(vim.fn.expand :$VIMRUNTIME/lua) true + (vim.fn.expand :$VIMRUNTIME/lua/vim/lsp) true}}) -(def- diagnostics - {:globals ["vim" - "map" - "filter" - "range" - "reduce" - "head" - "tail" - "nth" - "use" - "describe" - "it" - "dump"]}) +(def- diagnostics {:globals [:vim + :map + :filter + :range + :reduce + :head + :tail + :nth + :use + :describe + :it + :dump]}) -(def- runtime - {:version "LuaJIT" - :path (vim.split package.path ";")}) +(def- runtime {:version :LuaJIT :path (vim.split package.path ";")}) -(def opts - {:settings {:Lua {:diagnostics diagnostics - :workspace workspace - :runtime runtime}}}) +(def opts {:settings {:Lua {: diagnostics : workspace : runtime}}}) |