[neovim] lspconfig for 0.11+
change osqllkomulupruwprppyymxquutqwrlt
commit 5b485798420876d8c0669f49020d24f4220ca2b6
author Alpha Chen <alpha@kejadlen.dev>
date
parent unmqtrqr
diff --git a/.config/nvim/fnl/lsp.fnl b/.config/nvim/fnl/lsp.fnl
index 95ddc07c..ed4d4df8 100644
--- a/.config/nvim/fnl/lsp.fnl
+++ b/.config/nvim/fnl/lsp.fnl
@@ -1,18 +1,10 @@
-;; Per-directory LSP usage:
-;;
-;; .envrc:
-;;   use vim
-;;
-;; $ rake init:local-nvim[DIR]
-
-(local lspconfig (require :lspconfig))
-(local {:api {:nvim_create_autocmd nvim-create-autocmd} : iter : lsp} vim)
+(local {:api {:nvim_create_autocmd nvim-create-autocmd} : keymap : iter : lsp}
+       vim)
 
 ; (lsp.set_log_level :debug)
 
 ;; set up key mappings
-(let [{: keymap} vim
-      opts {:noremap true :silent true}
+(let [opts {:noremap true :silent true}
       callback (fn []
                  (keymap.set :n :<leader>e vim.diagnostic.open_float opts)
                  (keymap.set :n :<leader>q vim.diagnostic.setloclist opts)
@@ -20,32 +12,23 @@
                  (keymap.set :n :gqq #(lsp.buf.format {:async true}) opts))]
   (nvim-create-autocmd :LspAttach {: callback}))
 
-;;; basic lsps
-
-(lspconfig.ansiblels.setup {})
-(lspconfig.fennel_ls.setup {})
-(lspconfig.ruby_lsp.setup {})
-(lspconfig.rust_analyzer.setup {})
-(lspconfig.terraformls.setup {})
-(lspconfig.ts_ls.setup {})
-
-(let [{: setup} lspconfig.yamlls
-      schemas {"https://json.schemastore.org/github-workflow.json" :/.github/workflows/*}]
-  (setup {:settings {:yaml {: schemas}}}))
-
-;;; python
+;; TODO figure out which should be globally enabled
+(lsp.enable :ansiblels)
+(lsp.enable :efm)
+(lsp.enable :fennel_ls)
+(lsp.enable :pyright)
+(lsp.enable :ruby_lsp)
+(lsp.enable :ruff)
+(lsp.enable :rust_analyzer)
+(lsp.enable :terraformls)
+(lsp.enable :ts_ls)
 
-;; only enable pyright/ruff if they're there
-(lspconfig.pyright.setup {:autostart false})
-(lspconfig.ruff.setup {:autostart false})
-(nvim-create-autocmd :FileType
-                     {:pattern :python
-                      :callback #(each [_ lsp (ipairs [:pyright :ruff])]
-                                   (if (= (vim.fn.executable lsp) 1)
-                                       (vim.cmd :LspStart lsp)))})
+;;; configs
 
-;;; efm-langserver
+(let [schemas {"https://json.schemastore.org/github-workflow.json" :/.github/workflows/*}]
+  (lsp.config :yamlls {:settings {:yaml {: schemas}}}))
 
+;; efm-langserver
 (let [fmt #{:formatCommand $1 :formatStdin true}
       lint #{:lintCommand $1 :lintFormats $2 :lintStdin true}
       fennel [(fmt "fnlfmt /dev/stdin")
@@ -63,16 +46,17 @@
            :formatCanRange true
            :rootMarkers [:.prettierrc.json]}]
       yaml [(fmt "yamlfmt -in")]]
-  (lspconfig.efm.setup {:init_options {:documentFormatting true
-                                       :hover true
-                                       :documentSymbol true
-                                       :codeAction true
-                                       :completion true}
-                        :settings {:languages {: fennel
-                                               : js
-                                               :typescript js
-                                               :typescriptreact js
-                                               : yaml}
-                                   ;; since otherwise eslint goes haywire
-                                   :lintDebounce 1000000000}
-                        :filetypes [:fennel :typescriptreact :yaml]}))
+  (lsp.config :efm
+              {:init_options {:documentFormatting true
+                              :hover true
+                              :documentSymbol true
+                              :codeAction true
+                              :completion true}
+               :settings {:languages {: fennel
+                                      : js
+                                      :typescript js
+                                      :typescriptreact js
+                                      : yaml}
+                          ;; since otherwise eslint goes haywire
+                          :lintDebounce 1000000000}
+               :filetypes [:fennel :typescriptreact :yaml]}))