diff options
| author | 2024-08-06 14:11:59 +0200 | |
|---|---|---|
| committer | 2024-08-06 14:11:59 +0200 | |
| commit | 7425eda3e544fcb1ce81a09c5ff49d839e58ac94 (patch) | |
| tree | e74368e016160f5c7aa5b532b46c9190e21fc32e /dot_config/nvim/fnl | |
| parent | nvim: expand .lua gitattributes, mark as non-diffable (diff) | |
nvim: rework lsp module
There's still some improvements to be made, but this is cleaner.
We lose global caps defaults, but those made no sense to begin with.
We do also lose caps overrides, I'll add them back in if I need them.
In the process, we gain `every?` and `executable?`.
There's also a misc comp print vim.inspect to vim.print change.
Diffstat (limited to '')
| -rw-r--r-- | dot_config/nvim/fnl/plugins/lsp/attach.fnl | 4 | ||||
| -rw-r--r-- | dot_config/nvim/fnl/plugins/lsp/capabilities.fnl | 1 | ||||
| -rw-r--r-- | dot_config/nvim/fnl/plugins/lsp/init.fnl | 19 | ||||
| -rw-r--r-- | dot_config/nvim/fnl/toast/core.fnl | 8 | ||||
| -rw-r--r-- | dot_config/nvim/fnl/toast/nvim.fnl | 7 |
5 files changed, 24 insertions, 15 deletions
diff --git a/dot_config/nvim/fnl/plugins/lsp/attach.fnl b/dot_config/nvim/fnl/plugins/lsp/attach.fnl index 83a68aa..ed2eb2d 100644 --- a/dot_config/nvim/fnl/plugins/lsp/attach.fnl +++ b/dot_config/nvim/fnl/plugins/lsp/attach.fnl @@ -20,8 +20,8 @@ (· :wa lbf.add_workspace_folder & :desc "add folder") (· :wr lbf.remove_workspace_folder & :desc "remove folder") - (· :wl #(print (vim.inspect (lbf.list_workspace_folders))) & - :desc "list folders")] + (· :wl #(vim.print (lbf.list_workspace_folders))) & + :desc "list folders"] 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 diff --git a/dot_config/nvim/fnl/plugins/lsp/capabilities.fnl b/dot_config/nvim/fnl/plugins/lsp/capabilities.fnl deleted file mode 100644 index 607602c..0000000 --- a/dot_config/nvim/fnl/plugins/lsp/capabilities.fnl +++ /dev/null @@ -1 +0,0 @@ -nil diff --git a/dot_config/nvim/fnl/plugins/lsp/init.fnl b/dot_config/nvim/fnl/plugins/lsp/init.fnl index 445eae1..0522c32 100644 --- a/dot_config/nvim/fnl/plugins/lsp/init.fnl +++ b/dot_config/nvim/fnl/plugins/lsp/init.fnl @@ -1,4 +1,6 @@ (import-macros {:mixed-table · : recc} :toast.macros) +(local {: assoc} (require :toast.core)) +(local {: executable?} (require :toast.nvim)) (fn gopts [plist] {:clangd {} @@ -16,20 +18,13 @@ :zls {}}) (local attach (require :plugins.lsp.attach)) -(local caps (require :plugins.lsp.capabilities)) [(· :neovim/nvim-lspconfig & :config (fn [_ opts] (each [k v (pairs opts)] - (set v.on_attach (or attach v.on_attach)) - (when (= :table (type caps)) - (set v.capabilities (or v.capabilities caps))) (let [s (. (require :lspconfig) k) - c (or v.cmd s.document_config.default_config.cmd)] - (when (not= 0 (vim.fn.executable (. c 1))) - (s.setup v))))) - :opts (fn [] - (let [plist (fn [...] - (local p (recc :lspconfig.util :root_pattern ...)) - #(p $))] - (gopts plist))))] + c (or v.cmd s.document_config.default_config.cmd) + att (or attach v.on_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/toast/core.fnl b/dot_config/nvim/fnl/toast/core.fnl index 2a426d1..82b0c40 100644 --- a/dot_config/nvim/fnl/toast/core.fnl +++ b/dot_config/nvim/fnl/toast/core.fnl @@ -19,6 +19,13 @@ "Returns true if the argument is a number." (= :number (type n))) +(fn every? [pred xs] + "Returns true if (pred x) is logical true for every x in xs, else false." + (accumulate [pass true + _ x (ipairs xs) + &until (not pass)] + (pred x))) + ; sequences (fn drop [n xs] "Returns a table of all but the first n elements in xs." @@ -81,6 +88,7 @@ : empty? : nil? : number? + : every? ; sequences : drop : first diff --git a/dot_config/nvim/fnl/toast/nvim.fnl b/dot_config/nvim/fnl/toast/nvim.fnl new file mode 100644 index 0000000..fddc0e7 --- /dev/null +++ b/dot_config/nvim/fnl/toast/nvim.fnl @@ -0,0 +1,7 @@ +(local {: every?} (require :toast.core)) + +(fn executable? [& paths] + "Check if every argument specified is an executable that neovim can resolve." + (every? #(not= 0 (vim.fn.executable $)) paths)) + +{: executable?} |
