From 7351263ba396bf11bb5358044e9116ada8417c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Vulquin?= Date: Wed, 7 Aug 2024 19:58:38 +0200 Subject: nvim: move lsp into a single file Also I removed the workspaces stuff. I don't use them. --- dot_config/nvim/fnl/plugins/lsp.fnl | 54 ++++++++++++++++++++++++++++++ dot_config/nvim/fnl/plugins/lsp/attach.fnl | 31 ----------------- dot_config/nvim/fnl/plugins/lsp/init.fnl | 30 ----------------- 3 files changed, 54 insertions(+), 61 deletions(-) create mode 100644 dot_config/nvim/fnl/plugins/lsp.fnl delete mode 100644 dot_config/nvim/fnl/plugins/lsp/attach.fnl delete mode 100644 dot_config/nvim/fnl/plugins/lsp/init.fnl (limited to 'dot_config/nvim/fnl') diff --git a/dot_config/nvim/fnl/plugins/lsp.fnl b/dot_config/nvim/fnl/plugins/lsp.fnl new file mode 100644 index 0000000..963c1b7 --- /dev/null +++ b/dot_config/nvim/fnl/plugins/lsp.fnl @@ -0,0 +1,54 @@ +(import-macros {:mixed-table · : recc} :toast.macros) +(local {: assoc : map} (require :toast.core)) +(local {: insert} (require :toast.table)) +(local {: executable?} (require :toast.nvim)) + +(fn gopts [plist] + {:clangd {} + :clojure_lsp {:root_dir (plist :project.clj :deps.edn :bb.edn :build.boot :shadow-cljs.edn :.git)} + :denols {:autostart false + :root_dir (plist :deno.json :deno.jsonc)} + :gopls {} + :ltex {} + :lua_ls {} + :pyright {} + :ruff {:cmd [:ruff :server :--preview]} + :texlab {:filetypes [:tex :plaintex :bib :latex]} + :tsserver {:autostart false + :root_dir (plist :tsconfig.json :package.json)} + :zls {}}) + +; default on-attach +(fn attach [c b] + (let [lsp vim.lsp + lbf lsp.buf + ll [;groups + (· "" & :group :+lsp) + (· :w & :group :+workspace) + ; actions + (· :D lbf.declaration & :desc "goto declaration") + (· :d lbf.definition & :desc "goto definition") + (· :k lbf.hover & :desc "hover") + (· :K lbf.signature_help & :desc "signature help") + (· :i lbf.implementation & :desc "goto implementation") + (· :t lbf.type_definition & :desc "goto type definition") + (· :r lbf.rename & :desc "rename") + (· :c lbf.code_action & :desc "code action") + (· :R lbf.reference & :desc "list references")] + ll (map #(assoc $ 1 (.. : (. $ 1))) ll)] + (vim.api.nvim_buf_set_option b :omnifunc :v:lua.vim.lsp.omnifunc) + (recc :which-key :add + (· (insert ll + (· :F #(vim.lsp.buf.format {:async true}) & + :desc "run format")) & + :buffer b)))) + +[(· :neovim/nvim-lspconfig & + :config (fn [_ opts] + (each [k v (pairs opts)] + (let [s (. (require :lspconfig) k) + c (or v.cmd s.document_config.default_config.cmd) + att (or v.on_attach attach)] + (when (executable? (. c 1)) + (s.setup (assoc v :on_attach att)))))) + :opts #(gopts (partial recc :lspconfig.util :root_pattern)))] diff --git a/dot_config/nvim/fnl/plugins/lsp/attach.fnl b/dot_config/nvim/fnl/plugins/lsp/attach.fnl deleted file mode 100644 index ed2eb2d..0000000 --- a/dot_config/nvim/fnl/plugins/lsp/attach.fnl +++ /dev/null @@ -1,31 +0,0 @@ -(import-macros {:mixed-table · : recc} :toast.macros) -(local {: assoc : map} (require :toast.core)) -(local {: insert} (require :toast.table)) - -(fn [c b] - (let [lsp vim.lsp - lbf lsp.buf - ll [(· "" & :group :+lsp) - (· :w & :group :+workspace) - - (· :D lbf.declaration & :desc "goto declaration") - (· :d lbf.definition & :desc "goto definition") - (· :k lbf.hover & :desc "hover") - (· :K lbf.signature_help & :desc "signature help") - (· :i lbf.implementation & :desc "goto implementation") - (· :t lbf.type_definition & :desc "goto type definition") - (· :r lbf.rename & :desc "rename") - (· :c lbf.code_action & :desc "code action") - (· :R lbf.reference & :desc "list references") - - (· :wa lbf.add_workspace_folder & :desc "add folder") - (· :wr lbf.remove_workspace_folder & :desc "remove folder") - (· :wl #(vim.print (lbf.list_workspace_folders))) & - :desc "list folders"] - ll (map #(assoc $ 1 (.. : (. $ 1))) ll)] - (vim.api.nvim_buf_set_option b :omnifunc :v:lua.vim.lsp.omnifunc) - (recc :which-key :add - (· (insert ll - (· :F #(vim.lsp.buf.format {:async true}) & - :desc "run format")) & - :buffer b)))) diff --git a/dot_config/nvim/fnl/plugins/lsp/init.fnl b/dot_config/nvim/fnl/plugins/lsp/init.fnl deleted file mode 100644 index 518f335..0000000 --- a/dot_config/nvim/fnl/plugins/lsp/init.fnl +++ /dev/null @@ -1,30 +0,0 @@ -(import-macros {:mixed-table · : recc} :toast.macros) -(local {: assoc} (require :toast.core)) -(local {: executable?} (require :toast.nvim)) - -(fn gopts [plist] - {:clangd {} - :clojure_lsp {:root_dir (plist :project.clj :deps.edn :bb.edn :build.boot :shadow-cljs.edn :.git)} - :denols {:autostart false - :root_dir (plist :deno.json :deno.jsonc)} - :gopls {} - :ltex {} - :lua_ls {} - :pyright {} - :ruff {:cmd [:ruff :server :--preview]} - :texlab {:filetypes [:tex :plaintex :bib :latex]} - :tsserver {:autostart false - :root_dir (plist :tsconfig.json :package.json)} - :zls {}}) - -(local attach (require :plugins.lsp.attach)) - -[(· :neovim/nvim-lspconfig & - :config (fn [_ opts] - (each [k v (pairs opts)] - (let [s (. (require :lspconfig) k) - c (or v.cmd s.document_config.default_config.cmd) - att (or v.on_attach attach)] - (when (executable? (. c 1)) - (s.setup (assoc v :on_attach att)))))) - :opts #(gopts (partial recc :lspconfig.util :root_pattern)))] -- cgit v1.2.3