summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloé Vulquin <code@toast.bunkerlabs.net>2024-08-07 19:58:38 +0200
committerChloé Vulquin <code@toast.bunkerlabs.net>2024-08-07 19:58:38 +0200
commit7351263ba396bf11bb5358044e9116ada8417c65 (patch)
treedafd53700f217eed1639bc67ad3fbe379630a365
parentnvim/lsp: correct wrong ordering (diff)
nvim: move lsp into a single file
Also I removed the workspaces stuff. I don't use them.
-rw-r--r--dot_config/nvim/.chezmoiremove3
-rw-r--r--dot_config/nvim/fnl/plugins/lsp.fnl (renamed from dot_config/nvim/fnl/plugins/lsp/attach.fnl)41
-rw-r--r--dot_config/nvim/fnl/plugins/lsp/init.fnl30
-rw-r--r--dot_config/nvim/lua/plugins/lsp.lua45
-rw-r--r--dot_config/nvim/lua/plugins/lsp/attach.lua26
-rw-r--r--dot_config/nvim/lua/plugins/lsp/init.lua28
6 files changed, 80 insertions, 93 deletions
diff --git a/dot_config/nvim/.chezmoiremove b/dot_config/nvim/.chezmoiremove
index 2aff3b4..cd3efb1 100644
--- a/dot_config/nvim/.chezmoiremove
+++ b/dot_config/nvim/.chezmoiremove
@@ -6,3 +6,6 @@ lua/plugins/bindings/
fnl/plugins/lsp/capabilities.fnl
lua/plugins/lsp/capabilities.lua
+
+fnl/plugins/lsp/
+lua/plugins/lsp/
diff --git a/dot_config/nvim/fnl/plugins/lsp/attach.fnl b/dot_config/nvim/fnl/plugins/lsp.fnl
index ed2eb2d..963c1b7 100644
--- a/dot_config/nvim/fnl/plugins/lsp/attach.fnl
+++ b/dot_config/nvim/fnl/plugins/lsp.fnl
@@ -1,13 +1,31 @@
(import-macros {:mixed-table · : recc} :toast.macros)
(local {: assoc : map} (require :toast.core))
(local {: insert} (require :toast.table))
+(local {: executable?} (require :toast.nvim))
-(fn [c b]
+(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 [(· "" & :group :+lsp)
+ 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")
@@ -16,12 +34,7 @@
(· :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"]
+ (· :R lbf.reference & :desc "list references")]
ll (map #(assoc $ 1 (.. :<localleader><localleader> (. $ 1))) ll)]
(vim.api.nvim_buf_set_option b :omnifunc :v:lua.vim.lsp.omnifunc)
(recc :which-key :add
@@ -29,3 +42,13 @@
(· :<leader>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/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)))]
diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua
new file mode 100644
index 0000000..314cc6b
--- /dev/null
+++ b/dot_config/nvim/lua/plugins/lsp.lua
@@ -0,0 +1,45 @@
+-- [nfnl] Compiled from fnl/plugins/lsp.fnl by https://github.com/Olical/nfnl, do not edit.
+local _local_1_ = require("toast.core")
+local assoc = _local_1_["assoc"]
+local map = _local_1_["map"]
+local _local_2_ = require("toast.table")
+local insert = _local_2_["insert"]
+local _local_3_ = require("toast.nvim")
+local executable_3f = _local_3_["executable?"]
+local function gopts(plist)
+ return {clangd = {}, clojure_lsp = {root_dir = plist("project.clj", "deps.edn", "bb.edn", "build.boot", "shadow-cljs.edn", ".git")}, denols = {root_dir = plist("deno.json", "deno.jsonc"), autostart = false}, gopls = {}, ltex = {}, lua_ls = {}, pyright = {}, ruff = {cmd = {"ruff", "server", "--preview"}}, texlab = {filetypes = {"tex", "plaintex", "bib", "latex"}}, tsserver = {root_dir = plist("tsconfig.json", "package.json"), autostart = false}, zls = {}}
+end
+local function attach(c, b)
+ local lsp = vim.lsp
+ local lbf = lsp.buf
+ local 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"}}
+ local ll0
+ local function _4_(_241)
+ return assoc(_241, 1, ("<localleader><localleader>" .. _241[1]))
+ end
+ ll0 = map(_4_, ll)
+ vim.api.nvim_buf_set_option(b, "omnifunc", "v:lua.vim.lsp.omnifunc")
+ local function _5_()
+ return vim.lsp.buf.format({async = true})
+ end
+ return require("which-key").add({insert(ll0, {"<leader>F", _5_, desc = "run format"}), buffer = b})
+end
+local function _6_(_, opts)
+ for k, v in pairs(opts) do
+ local s = require("lspconfig")[k]
+ local c = (v.cmd or s.document_config.default_config.cmd)
+ local att = (v.on_attach or attach)
+ if executable_3f(c[1]) then
+ s.setup(assoc(v, "on_attach", att))
+ else
+ end
+ end
+ return nil
+end
+local function _8_()
+ local function _9_(...)
+ return require("lspconfig.util").root_pattern(...)
+ end
+ return gopts(_9_)
+end
+return {{"neovim/nvim-lspconfig", config = _6_, opts = _8_}}
diff --git a/dot_config/nvim/lua/plugins/lsp/attach.lua b/dot_config/nvim/lua/plugins/lsp/attach.lua
deleted file mode 100644
index 607bea7..0000000
--- a/dot_config/nvim/lua/plugins/lsp/attach.lua
+++ /dev/null
@@ -1,26 +0,0 @@
--- [nfnl] Compiled from fnl/plugins/lsp/attach.fnl by https://github.com/Olical/nfnl, do not edit.
-local _local_1_ = require("toast.core")
-local assoc = _local_1_["assoc"]
-local map = _local_1_["map"]
-local _local_2_ = require("toast.table")
-local insert = _local_2_["insert"]
-local function _3_(c, b)
- local lsp = vim.lsp
- local lbf = lsp.buf
- local ll
- local function _4_()
- return vim.print(lbf.list_workspace_folders())
- end
- 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", _4_}, __fnl_global___26, "desc", "list folders"}
- local ll0
- local function _5_(_241)
- return assoc(_241, 1, ("<localleader><localleader>" .. _241[1]))
- end
- ll0 = map(_5_, ll)
- vim.api.nvim_buf_set_option(b, "omnifunc", "v:lua.vim.lsp.omnifunc")
- local function _6_()
- return vim.lsp.buf.format({async = true})
- end
- return require("which-key").add({insert(ll0, {"<leader>F", _6_, desc = "run format"}), buffer = b})
-end
-return _3_
diff --git a/dot_config/nvim/lua/plugins/lsp/init.lua b/dot_config/nvim/lua/plugins/lsp/init.lua
deleted file mode 100644
index c397190..0000000
--- a/dot_config/nvim/lua/plugins/lsp/init.lua
+++ /dev/null
@@ -1,28 +0,0 @@
--- [nfnl] Compiled from fnl/plugins/lsp/init.fnl by https://github.com/Olical/nfnl, do not edit.
-local _local_1_ = require("toast.core")
-local assoc = _local_1_["assoc"]
-local _local_2_ = require("toast.nvim")
-local executable_3f = _local_2_["executable?"]
-local function gopts(plist)
- return {clangd = {}, clojure_lsp = {root_dir = plist("project.clj", "deps.edn", "bb.edn", "build.boot", "shadow-cljs.edn", ".git")}, denols = {root_dir = plist("deno.json", "deno.jsonc"), autostart = false}, gopls = {}, ltex = {}, lua_ls = {}, pyright = {}, ruff = {cmd = {"ruff", "server", "--preview"}}, texlab = {filetypes = {"tex", "plaintex", "bib", "latex"}}, tsserver = {root_dir = plist("tsconfig.json", "package.json"), autostart = false}, zls = {}}
-end
-local attach = require("plugins.lsp.attach")
-local function _3_(_, opts)
- for k, v in pairs(opts) do
- local s = require("lspconfig")[k]
- local c = (v.cmd or s.document_config.default_config.cmd)
- local att = (v.on_attach or attach)
- if executable_3f(c[1]) then
- s.setup(assoc(v, "on_attach", att))
- else
- end
- end
- return nil
-end
-local function _5_()
- local function _6_(...)
- return require("lspconfig.util").root_pattern(...)
- end
- return gopts(_6_)
-end
-return {{"neovim/nvim-lspconfig", config = _3_, opts = _5_}}