extract lsp.fnl from init.fnl, remove ale
change
commit 5691e95ffd9f9353248b4a2516b78ba847663196
author Alpha Chen <alpha@kejadlen.dev>
date
parent cb106c18
diff --git a/nvim/fnl/ale.fnl b/nvim/fnl/ale.fnl
deleted file mode 100644
index f9bc85ae..00000000
--- a/nvim/fnl/ale.fnl
+++ /dev/null
@@ -1,11 +0,0 @@
-(set vim.g.omnifunc "ale#completion#OmniFunc")
-(set vim.g.ale_fix_on_save 1)
-(set vim.g.ale_floating_preview 1)
-(set vim.g.ale_floating_window_border
-     ["│" "─" "╭" "╮" "╯" "╰" "│" "─"])
-(vim.keymap.set :n :gd "<Plug>(ale_go_to_definition)" {:noremap true})
-(vim.keymap.set :n :gr "<Plug>(ale_find_references)" {:noremap true})
-(vim.keymap.set :n :K "<Plug>(ale_hover)" {:noremap true})
-(vim.keymap.set :n :<C-k> "<Plug>(ale_previous_wrap)" {:silent true})
-(vim.keymap.set :n :<C-j> "<Plug>(ale_next_wrap)" {:silent true})
-
diff --git a/nvim/fnl/init.fnl b/nvim/fnl/init.fnl
index b6ec0045..c5ee9a75 100644
--- a/nvim/fnl/init.fnl
+++ b/nvim/fnl/init.fnl
@@ -68,14 +68,13 @@
       cb #(pcall require (.. :ftplugin. (vim.fn.expand :<amatch>)))]
   (nvim_create_autocmd :FileType {:callback cb :group au-group}))
 
-;; (require :ale)
+(require :fzf)
+(require :lsp)
 
 ;;; diagnostic
 
 (vim.diagnostic.config {:float {:source :if_many :border :rounded}})
 
-(require :fzf)
-
 ;;; lightline
 
 ;; https://github.com/itchyny/lightline.vim/issues/168#issuecomment-232183744
@@ -87,74 +86,6 @@
     (tset palette f :middle [[:NONE :NONE :NONE :NONE]]))
   (tset vim.g palette-key palette))
 
-;;; lspconfig
-
-;; (vim.lsp.set_log_level :debug)
-
-;; default hover windows to have borders
-(let [{: handlers : with} vim.lsp
-      {: hover} handlers]
-  (tset handlers :textDocument/hover (with hover {:border :rounded}))
-  (tset handlers :textDocument/signatureHelp (with hover {:border :rounded})))
-
-(let [opts {:noremap true :silent true}]
-  (vim.keymap.set :n :<leader>e vim.diagnostic.open_float opts)
-  (vim.keymap.set :n "[d" vim.diagnostic.goto_prev opts)
-  (vim.keymap.set :n "]d" vim.diagnostic.goto_next opts)
-  (vim.keymap.set :n :<leader>q vim.diagnostic.setloclist opts))
-
-(fn on-attach [client bufnr]
-  (vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc")
-  (let [bufopts {:noremap true :silent true :buffer bufnr}]
-    (vim.keymap.set :n :gD vim.lsp.buf.declaration bufopts)
-    (vim.keymap.set :n :gd vim.lsp.buf.definition bufopts)
-    (vim.keymap.set :n :K vim.lsp.buf.hover bufopts)
-    (vim.keymap.set :n :gi vim.lsp.buf.implementation bufopts)
-    (vim.keymap.set :n :<C-k> vim.lsp.buf.signature_help bufopts)
-    (vim.keymap.set :n :<leader>wa vim.lsp.buf.add_workspace_folder bufopts)
-    (vim.keymap.set :n :<leader>wr vim.lsp.buf.remove_workspace_folder bufopts)
-    (vim.keymap.set :n :<leader>wl
-                    (fn []
-                      (print (vim.inspect (vim.lsp.buf.list_workspace_folders))))
-                    bufopts)
-    (vim.keymap.set :n :<leader>D vim.lsp.buf.type_definition bufopts)
-    (vim.keymap.set :n :<leader>rn vim.lsp.buf.rename bufopts)
-    (vim.keymap.set :n :<leader>ca vim.lsp.buf.code_action bufopts)
-    (vim.keymap.set :n :gr vim.lsp.buf.references bufopts)
-    (vim.keymap.set :n :<leader>lf vim.lsp.buf.formatting bufopts)))
-
-(let [{: efm : rust_analyzer : tsserver} (require :lspconfig)
-      fmt (fn [formatCommand formatStdin]
-            {: formatCommand : formatStdin})
-      lint (fn [lintCommand lintFormats lintStdin]
-             {: lintCommand : lintFormats : lintStdin})
-      prettier (fmt "prettier --stdin-filepath ${INPUT}" true)
-      ;; https://github.com/alexaandru/nvim-config/blob/master/fnl/config/efm.fnl
-      fennelFmt (fmt "fnlfmt /dev/stdin" true)
-      fennelLint (lint "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1"
-                       ["%f:%l: %m"] true)
-      fennel [fennelFmt fennelLint]]
-  ((. efm :setup) {:on_attach on-attach
-                   :init_options {:documentFormatting true
-                                  :hover true
-                                  :documentSymbol true
-                                  :codeAction true
-                                  :completion true}
-                   :settings {:languages {:javascript [prettier]
-                                          :typescript [prettier]
-                                          :typescriptreact [prettier]
-                                          : fennel}}
-                   :filetypes [:javascript
-                               :typescript
-                               :typescriptreact
-                               :fennel]})
-  ((. rust_analyzer :setup) {:on_attach on-attach
-                             :settings {:rust-analyzer {:checkOnSave {:command :clippy}}}})
-  ((. tsserver :setup) {:on_attach (fn [client bufnr]
-                                     (on-attach client bufnr)
-                                     (set client.resolved_capabilities.document_formatting
-                                          false))}))
-
 ;;; netrw
 
 ;; https://github.com/tpope/vim-vinegar/issues/13
diff --git a/nvim/fnl/lsp.fnl b/nvim/fnl/lsp.fnl
new file mode 100644
index 00000000..4ecb5ef5
--- /dev/null
+++ b/nvim/fnl/lsp.fnl
@@ -0,0 +1,67 @@
+;; (vim.lsp.set_log_level :debug)
+
+;; default hover windows to have borders
+(let [{: handlers : with} vim.lsp
+      {: hover} handlers]
+  (tset handlers :textDocument/hover (with hover {:border :rounded}))
+  (tset handlers :textDocument/signatureHelp (with hover {:border :rounded})))
+
+(let [opts {:noremap true :silent true}]
+  (vim.keymap.set :n :<leader>e vim.diagnostic.open_float opts)
+  (vim.keymap.set :n "[d" vim.diagnostic.goto_prev opts)
+  (vim.keymap.set :n "]d" vim.diagnostic.goto_next opts)
+  (vim.keymap.set :n :<leader>q vim.diagnostic.setloclist opts))
+
+(fn on-attach [client bufnr]
+  (vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc")
+  (let [bufopts {:noremap true :silent true :buffer bufnr}]
+    (vim.keymap.set :n :gD vim.lsp.buf.declaration bufopts)
+    (vim.keymap.set :n :gd vim.lsp.buf.definition bufopts)
+    (vim.keymap.set :n :K vim.lsp.buf.hover bufopts)
+    (vim.keymap.set :n :gi vim.lsp.buf.implementation bufopts)
+    (vim.keymap.set :n :<C-k> vim.lsp.buf.signature_help bufopts)
+    (vim.keymap.set :n :<leader>wa vim.lsp.buf.add_workspace_folder bufopts)
+    (vim.keymap.set :n :<leader>wr vim.lsp.buf.remove_workspace_folder bufopts)
+    (vim.keymap.set :n :<leader>wl
+                    (fn []
+                      (print (vim.inspect (vim.lsp.buf.list_workspace_folders))))
+                    bufopts)
+    (vim.keymap.set :n :<leader>D vim.lsp.buf.type_definition bufopts)
+    (vim.keymap.set :n :<leader>rn vim.lsp.buf.rename bufopts)
+    (vim.keymap.set :n :<leader>ca vim.lsp.buf.code_action bufopts)
+    (vim.keymap.set :n :gr vim.lsp.buf.references bufopts)
+    (vim.keymap.set :n :<leader>lf vim.lsp.buf.formatting bufopts)))
+
+(let [{: efm : rust_analyzer : tsserver} (require :lspconfig)
+      fmt (fn [formatCommand formatStdin]
+            {: formatCommand : formatStdin})
+      lint (fn [lintCommand lintFormats lintStdin]
+             {: lintCommand : lintFormats : lintStdin})
+      prettier (fmt "prettier --stdin-filepath ${INPUT}" true)
+      ;; https://github.com/alexaandru/nvim-config/blob/master/fnl/config/efm.fnl
+      fennelFmt (fmt "fnlfmt /dev/stdin" true)
+      fennelLint (lint "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1"
+                       ["%f:%l: %m"] true)
+      fennel [fennelFmt fennelLint]]
+  ((. efm :setup) {:on_attach on-attach
+                   :init_options {:documentFormatting true
+                                  :hover true
+                                  :documentSymbol true
+                                  :codeAction true
+                                  :completion true}
+                   :settings {:languages {:javascript [prettier]
+                                          :typescript [prettier]
+                                          :typescriptreact [prettier]
+                                          : fennel}}
+                   :filetypes [:javascript
+                               :typescript
+                               :typescriptreact
+                               :fennel]})
+  ((. rust_analyzer :setup) {:on_attach on-attach
+                             :settings {:rust-analyzer {:checkOnSave {:command :clippy}}}})
+  ((. tsserver :setup) {:on_attach (fn [client bufnr]
+                                     (on-attach client bufnr)
+                                     (set client.resolved_capabilities.document_formatting
+                                          false))}))
+
+