diff --git a/nvim/fnl/fzf.fnl b/nvim/fnl/fzf.fnl index 469e198..6e8fe76 100644 --- a/nvim/fnl/fzf.fnl +++ b/nvim/fnl/fzf.fnl @@ -1,5 +1,3 @@ -;;; fzf - ;; https://github.com/junegunn/fzf/blob/master/README-VIM.md (fn init-keymaps [] diff --git a/nvim/fnl/lsp.fnl b/nvim/fnl/lsp.fnl index 4ecb5ef..068c565 100644 --- a/nvim/fnl/lsp.fnl +++ b/nvim/fnl/lsp.fnl @@ -1,10 +1,18 @@ -;; (vim.lsp.set_log_level :debug) +(local {: lsp} vim) + +(fn fmt [formatCommand formatStdin] + {: formatCommand : formatStdin}) + +(fn lint [lintCommand lintFormats lintStdin] + {: lintCommand : lintFormats : lintStdin}) + +;; (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 [{: hover} lsp.handlers] + (tset lsp.handlers :textDocument/hover (lsp.with hover {:border :rounded})) + (tset lsp.handlers :textDocument/signatureHelp + (lsp.with hover {:border :rounded}))) (let [opts {:noremap true :silent true}] (vim.keymap.set :n :e vim.diagnostic.open_float opts) @@ -13,55 +21,52 @@ (vim.keymap.set :n :q vim.diagnostic.setloclist opts)) (fn on-attach [client bufnr] - (vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc") + (vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.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 : vim.lsp.buf.signature_help bufopts) - (vim.keymap.set :n :wa vim.lsp.buf.add_workspace_folder bufopts) - (vim.keymap.set :n :wr vim.lsp.buf.remove_workspace_folder bufopts) + (vim.keymap.set :n :gD lsp.buf.declaration bufopts) + (vim.keymap.set :n :gd lsp.buf.definition bufopts) + (vim.keymap.set :n :K lsp.buf.hover bufopts) + (vim.keymap.set :n :gi lsp.buf.implementation bufopts) + (vim.keymap.set :n : lsp.buf.signature_help bufopts) + (vim.keymap.set :n :wa lsp.buf.add_workspace_folder bufopts) + (vim.keymap.set :n :wr lsp.buf.remove_workspace_folder bufopts) (vim.keymap.set :n :wl (fn [] - (print (vim.inspect (vim.lsp.buf.list_workspace_folders)))) + (print (vim.inspect (lsp.buf.list_workspace_folders)))) bufopts) - (vim.keymap.set :n :D vim.lsp.buf.type_definition bufopts) - (vim.keymap.set :n :rn vim.lsp.buf.rename bufopts) - (vim.keymap.set :n :ca vim.lsp.buf.code_action bufopts) - (vim.keymap.set :n :gr vim.lsp.buf.references bufopts) - (vim.keymap.set :n :lf vim.lsp.buf.formatting bufopts))) + (vim.keymap.set :n :D lsp.buf.type_definition bufopts) + (vim.keymap.set :n :rn lsp.buf.rename bufopts) + (vim.keymap.set :n :ca lsp.buf.code_action bufopts) + (vim.keymap.set :n :gr lsp.buf.references bufopts) + (vim.keymap.set :n :lf lsp.buf.formatting bufopts))) + +(local prettier (fmt "prettier --stdin-filepath ${INPUT}" true)) +(local fennel [(fmt "fnlfmt /dev/stdin" true) + (lint "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1" + ["%f:%l: %m"] true)]) + +(local efm-setup + {:on_attach on-attach + :init_options {:documentFormatting true + :hover true + :documentSymbol true + :codeAction true + :completion true} + :settings {:languages {: fennel + :javascript [prettier] + :typescript [prettier] + :typescriptreact [prettier]}} + :filetypes [:fennel :javascript :typescript :typescriptreact]}) -(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))})) +(local tsserver-attach (fn [client bufnr] + (on-attach client bufnr) + ;; use prettier for formatting via efm + (set client.resolved_capabilities.document_formatting + false))) +(let [{: efm : rust_analyzer : tsserver} (require :lspconfig)] + (efm.setup efm-setup) + (rust_analyzer.setup {:on_attach on-attach + :settings {:rust-analyzer {:checkOnSave {:command :clippy}}}}) + (tsserver.setup {:on_attach tsserver-attach}))