more neovim and lsp things

main
Alpha Chen 2 months ago
parent d284c2bada
commit c4007cb1f2
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -1,22 +0,0 @@
(set vim.bo.formatprg "fnlfmt /dev/stdin")
;; https://github.com/rktjmp/hotpot.nvim/discussions/93#discussioncomment-4362209
(vim.cmd "iabbrev <buffer> <expr> lambda v:lua.iab_lambda()")
;; fnlfmt: skip
(fn _G.iab_lambda []
(let [line (vim.fn.getline :.)
col (vim.fn.col :.)
;; a b c \lambda
;; ^ check here (may not exist)
;; but dont do anything if that under runs the first character
offset (- col (length :lambda) 1)]
(match [(< 0 offset) (string.sub line offset offset)]
;; replace term codes so the expr actually runs backspace, not inserts the string
[true :\] (vim.api.nvim_replace_termcodes :<bs>λ true false true)
[false _] :lambda)))
; (let [{: nvim_create_autocmd : nvim_command} vim.api]
; (nvim_create_autocmd :BufWritePre
; {:callback #(nvim_command "normal migggqG`i")}))

@ -1,2 +0,0 @@
(set vim.g.ale_fixers ["rustfmt"])
(set vim.g.ale_rust_cargo_use_clippy (vim.fn.executable "cargo-clippy"))

@ -47,7 +47,7 @@
;; highlight
(set vim.o.hlsearch true)
(vim.keymap.set :n :<leader>/ ":nohlsearch<cr>")
(let [{: nvim_command : nvim_create_autocmd : nvim_create_augroup} vim.api
(let [{: nvim_create_autocmd : nvim_create_augroup} vim.api
au-group (nvim_create_augroup :nvim-hl-on-yank {})
cb #(vim.highlight.on_yank {:higroup :Search :timeout 100})]
(nvim_create_autocmd :TextYankPost {:callback cb :group au-group}))
@ -93,14 +93,6 @@
(set vim.g.do_filetype_lua true)
(vim.filetype.add {:extension {:ua :uiua}})
;;; ftplugins in fennel
;; https://github.com/rktjmp/hotpot.nvim/discussions/41#discussioncomment-3050564
(let [{: nvim_create_autocmd : nvim_create_augroup} vim.api
au-group (nvim_create_augroup :hotpot-ft {})
cb #(pcall require (.. :ftplugin. (vim.fn.expand :<amatch>)))]
(nvim_create_autocmd :FileType {:callback cb :group au-group}))
(require :fzf)
(require :lsp)

@ -6,7 +6,7 @@
;; $ rake init:local-nvim[DIR]
(local lspconfig (require :lspconfig))
(local {: iter : lsp} vim)
(local {:api {:nvim_create_autocmd nvim-create-autocmd} : iter : lsp} vim)
; (lsp.set_log_level :debug)
@ -17,20 +17,35 @@
(lsp.with hover {:border :rounded})))
;; set up key mappings
(let [{: nvim_create_autocmd} vim.api
(let [{: keymap} vim
opts {:noremap true :silent true}
callback (fn []
(vim.keymap.set :n :<leader>e vim.diagnostic.open_float opts)
(vim.keymap.set :n :<leader>q vim.diagnostic.setloclist opts)
(keymap.set :n :<leader>e vim.diagnostic.open_float opts)
(keymap.set :n :<leader>q vim.diagnostic.setloclist opts)
;; for back-compat - remove once muscle memory has been remapped gd to CTRL+]
(vim.keymap.set :n :gd lsp.buf.definition opts)
(keymap.set :n :gd lsp.buf.definition opts)
;; switch out formatting a single line for formatting the whole file instead
(vim.keymap.set :n :gqq #(lsp.buf.format {:async true}) opts))]
(nvim_create_autocmd :LspAttach {: callback}))
(keymap.set :n :gqq #(lsp.buf.format {:async true}) opts))]
(nvim-create-autocmd :LspAttach {: callback}))
(lspconfig.pyright.setup {})
;;; basic lsps
(lspconfig.ansiblels.setup {})
(lspconfig.fennel_ls.setup {:settings {:fennel-ls {:extra-globals "hs spoon vim"}}})
(lspconfig.ruff.setup {})
(lspconfig.terraformls.setup {})
(lspconfig.yamlls.setup {:settings {:yaml {:schemas {"https://json.schemastore.org/github-workflow.json" :/.github/workflows/*}}}})
;;; pyright
(lspconfig.pyright.setup {:autostart false})
(nvim-create-autocmd :FileType
{:pattern :python
:callback #(if (= (vim.fn.executable :pyright) 1)
(vim.cmd :LspStart))})
(let [{: setup} lspconfig.yamlls
schemas {"https://json.schemastore.org/github-workflow.json" :/.github/workflows/*}]
(setup {:settings {:yaml {: schemas}}}))
;;; efm-langserver
@ -44,35 +59,22 @@
"$(realpath --relative-to . ${INPUT})"
:2>&1])
(: :join " ")) ["%f:%l: %m"])]
js []
yaml [(fmt "yamlfmt -in")]]
(lspconfig.efm.setup {:init_options {:documentFormatting true
:hover true
:documentSymbol true
:codeAction true
:completion true}
:settings {:languages {: fennel : yaml}}
:settings {:languages {: fennel
: js
:typescript js
:typescriptreact js
: yaml}
;; since otherwise eslint goes haywire
:lintDebounce 1000000000}
:filetypes [:fennel :yaml]}))
; :settings {:languages {: fennel
; : js
; :typescript js
; :typescriptreact js
; :vue [(fmt "prettier --stdin-filepath ${INPUT}")]
; :yaml [(fmt "yamlfmt -in")]}
; :lintDebounce 1000000000}
; :filetypes [:fennel
; :javascript
; :typescript
; :typescriptreact
; :vue
; :yaml]}))
; (fn on-attach [_client bufnr])
; (let [bufopts {:noremap true :silent true :buffer bufnr}]
; (vim.keymap.set :n :gd lsp.buf.definition bufopts) ; here for back-compat - remove once muscle memory has been remapped to CTRL+]
; (vim.keymap.set :n :gqq #(lsp.buf.format {:async true}) bufopts)))
; (fn on-attach-do [...]
; (let [fns [...]] ; https://benaiah.me/posts/everything-you-didnt-want-to-know-about-lua-multivals/
; (fn [client bufnr]
@ -94,13 +96,6 @@
; (let [{: setup} (. lspconfig lsp)]
; (setup (or config {:on_attach on-attach}))))
;
; ;; efm-langserver things
; (local fmt #{:formatCommand $1 :formatStdin true})
; (local lint #{:lintCommand $1 :lintFormats $2 :lintStdin true})
;
; (local fennel-lint
; "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1")
;
; (local eslint
; {:lintCommand "eslint -f visualstudio --stdin --stdin-filename ${INPUT}"
; :lintIgnoreExitCode true
@ -109,40 +104,8 @@
;
; (local eslintd-fmt
; (fmt "eslint_d --stdin --fix-to-stdout --stdin-filename=${INPUT}"))
;
; ;; setup efm
; (let [fennel [(fmt "fnlfmt /dev/stdin") (lint fennel-lint ["%f:%l: %m"])]
; js [eslint eslintd-fmt]]
; (setup-lsp :efm {:on_attach (on-attach-do enable-fmt)
; :init_options {:documentFormatting true
; :hover true
; :documentSymbol true
; :codeAction true
; :completion true}
; :settings {:languages {: fennel
; : js
; :typescript js
; :typescriptreact js
; :vue [(fmt "prettier --stdin-filepath ${INPUT}")]
; :yaml [(fmt "yamlfmt -in")]}
; :lintDebounce 1000000000}
; :filetypes [:fennel
; :javascript
; :typescript
; :typescriptreact
; :vue
; :yaml]}))
;
; (setup-lsp :ansiblels)
; (setup-lsp :elmls)
; (setup-lsp :fennel_ls {:settings {:fennel-ls {:extra-globals "hs spoon vim"}}})
;
; (setup-lsp :pyright
; {:on_attach on-attach
; :settings {:python {:analysis {:autoImportCompletions true}}}})
;
; (setup-lsp :ruby_lsp)
; (setup-lsp :ruff {:on_attach (on-attach-do enable-fmt)})
;
; (setup-lsp :rust_analyzer
; {:on_attach on-attach
@ -175,4 +138,4 @@
; (let []
; (setup-lsp :ruby_ls {:on_attach (on-attach-do request-diagnostics)})))
{: setup-lsp}
; {: setup-lsp}

Loading…
Cancel
Save