From b74c9dd22e632bbe720587db92966c4d6811b766 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 11 Apr 2022 18:52:34 +0200 Subject: style: format with fnlfmt --- fnl/config/lsp/handlers.fnl | 117 ++++++++++++++++---------------- fnl/config/lsp/init.fnl | 9 ++- fnl/config/lsp/lsp-installer.fnl | 34 ++++------ fnl/config/lsp/null-ls.fnl | 47 ++++++------- fnl/config/lsp/settings/jsonls.fnl | 22 +++--- fnl/config/lsp/settings/pyright.fnl | 6 +- fnl/config/lsp/settings/sumneko-lua.fnl | 30 ++++---- 7 files changed, 127 insertions(+), 138 deletions(-) (limited to 'fnl/config/lsp') diff --git a/fnl/config/lsp/handlers.fnl b/fnl/config/lsp/handlers.fnl index 950f3fb..1e3785b 100644 --- a/fnl/config/lsp/handlers.fnl +++ b/fnl/config/lsp/handlers.fnl @@ -1,60 +1,61 @@ -(module config.lsp.handlers - {autoload {util 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"} )) - (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 "lua vim.lsp.buf.declaration()" opts) - (nvim.buf_set_keymap bufnr :n :gd "lua vim.lsp.buf.definition()" opts) - (nvim.buf_set_keymap bufnr :n :K "lua vim.lsp.buf.hover()" opts) - (nvim.buf_set_keymap bufnr :n :gI "lua vim.lsp.buf.implementation()" opts) - (nvim.buf_set_keymap bufnr :n :gr "lua vim.lsp.buf.references()" opts) - (nvim.buf_set_keymap bufnr :n :gl "lua vim.diagnostic.open_float()" opts) - (nvim.buf_set_keymap bufnr :n :q "lua vim.diagnostic.setloclist()" opts))) - -(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)) - capabilities)) +(module config.lsp.handlers {autoload {util 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})) + (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 + "lua vim.lsp.buf.declaration()" opts) + (nvim.buf_set_keymap bufnr :n :gd + "lua vim.lsp.buf.definition()" opts) + (nvim.buf_set_keymap bufnr :n :K "lua vim.lsp.buf.hover()" + opts) + (nvim.buf_set_keymap bufnr :n :gI + "lua vim.lsp.buf.implementation()" opts) + (nvim.buf_set_keymap bufnr :n :gr + "lua vim.lsp.buf.references()" opts) + (nvim.buf_set_keymap bufnr :n :gl + "lua vim.diagnostic.open_float()" opts) + (nvim.buf_set_keymap bufnr :n :q + "lua vim.diagnostic.setloclist()" opts))) + +(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)) + capabilities)) (setup) diff --git a/fnl/config/lsp/init.fnl b/fnl/config/lsp/init.fnl index b26dd7a..c4a461d 100644 --- a/fnl/config/lsp/init.fnl +++ b/fnl/config/lsp/init.fnl @@ -1,8 +1,7 @@ ;; Loads the LSP module. -(module config.lsp.init - {autoload {util util}}) +(module config.lsp.init {autoload {util util}}) (let [_ (util.load-plugin :lspconfig)] - (require :config.lsp.lsp-installer) - (require :config.lsp.handlers) - (require :config.lsp.null-ls)) + (require :config.lsp.lsp-installer) + (require :config.lsp.handlers) + (require :config.lsp.null-ls)) diff --git a/fnl/config/lsp/lsp-installer.fnl b/fnl/config/lsp/lsp-installer.fnl index 3649566..9522ef1 100644 --- a/fnl/config/lsp/lsp-installer.fnl +++ b/fnl/config/lsp/lsp-installer.fnl @@ -1,26 +1,22 @@ ;; LSP installer. -(module config.lsp.lsp-installer - {autoload {util util}}) +(module config.lsp.lsp-installer {autoload {util util}}) -(def- opts - (let [handlers (require :config.lsp.handlers)] - {:on_attach: handlers.on_attach - :capabilities handlers.capabilities})) +(def- opts (let [handlers (require :config.lsp.handlers)] + {"on_attach:" handlers.on_attach + :capabilities handlers.capabilities})) (defn- get-server-opts [server] - (when (= server.name :jsonls) - (let [jsonls-opts (require :config.lsp.settings.jsonls)] - (vim.tbl_deep_extend :force jsonls-opts opts))) - (when (= server.name :sumneko_lua) - (let [sumneko-lua-opts (require :config.lsp.settings.sumneko-lua)] - (vim.tbl_deep_extend :force sumneko-lua-opts.settings opts))) - (when (= server.name :pyright) - (let [pyright-opts (require :config.lsp.settings.pyright)] - (vim.tbl_deep_extend :force pyright-opts.settings opts))) - opts) - + (when (= server.name :jsonls) + (let [jsonls-opts (require :config.lsp.settings.jsonls)] + (vim.tbl_deep_extend :force jsonls-opts opts))) + (when (= server.name :sumneko_lua) + (let [sumneko-lua-opts (require :config.lsp.settings.sumneko-lua)] + (vim.tbl_deep_extend :force sumneko-lua-opts.settings opts))) + (when (= server.name :pyright) + (let [pyright-opts (require :config.lsp.settings.pyright)] + (vim.tbl_deep_extend :force pyright-opts.settings opts))) 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))))) + (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 c5b4aef..f046ee8 100644 --- a/fnl/config/lsp/null-ls.fnl +++ b/fnl/config/lsp/null-ls.fnl @@ -1,29 +1,26 @@ ;; 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 + (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.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.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 c1cb710..73e8975 100644 --- a/fnl/config/lsp/settings/jsonls.fnl +++ b/fnl/config/lsp/settings/jsonls.fnl @@ -1,16 +1,12 @@ ;; 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)] - (schemastore.setup - {: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) ]))]}}})) + (schemastore.setup {: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 bb39ab5..7269469 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 settings - {:settings - {:python - {:analysis - {:typeCheckingMode "off"}}}}) +(def settings {:settings {:python {:analysis {:typeCheckingMode :off}}}}) diff --git a/fnl/config/lsp/settings/sumneko-lua.fnl b/fnl/config/lsp/settings/sumneko-lua.fnl index e39c801..cc8e9ab 100644 --- a/fnl/config/lsp/settings/sumneko-lua.fnl +++ b/fnl/config/lsp/settings/sumneko-lua.fnl @@ -1,19 +1,23 @@ ;; Config for a Lua language server. (module config.lsp.settings.sumneko-lua) -(def- workspace - {:library {(vim.fn.expand "$VIMRUNTIME/lua") true - (vim.fn.expand "$VIMRUNTIME/lua/vim/lsp") true}}) +(def- workspace + {: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 settings - {:settings { - :Lua { - :diagnostics diagnostics - :workspace workspace}}}) +(def settings {:settings {:Lua {: diagnostics : workspace}}}) -- cgit v1.2.3-70-g09d2