neovim things

pull/2/head
Alpha Chen 2 years ago
parent a48943c99d
commit f642c81295
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -1,5 +1,22 @@
(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")}))

@ -30,10 +30,12 @@
(vim.keymap.set :i "\\\\" "<esc>:write<cr>")
;; highlight
(set vim.o.hlsearch false)
; (vim.keymap.set :n :<leader>/ ":nohlsearch<cr>")
;; TODO
; au TextYankPost * silent! lua vim.highlight.on_yank()
(set vim.o.hlsearch true)
(vim.keymap.set :n :<leader>/ ":nohlsearch<cr>")
(let [{: nvim_command : 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 250})]
(nvim_create_autocmd :TextYankPost {:callback cb :group au-group}))
;; non-shifted shortcuts for moving the cursor to the start/end of the current line
(vim.keymap.set :n :H "^")
@ -125,7 +127,7 @@
;;; treesitter
(let [configs (require :nvim-treesitter.configs)
{: setup} configs]
(setup {:ensure_installed [:fennel :hcl :lua :python :ruby :rust :typescript]
(setup {:ensure_installed [:fennel :hcl :lua :python :query :ruby :rust :typescript]
:sync_install false
:highlight {:enable true :additional_vim_regex_highlighting false}
;; disabling since this is super annoying in Ruby

@ -30,8 +30,7 @@
:filetypes [:fennel]
:root_dir #(lspconfig.util.find_git_ancestor $1)
:settings {}}})
(tset configs :steep
{:default_config {:cmd ["steep langserver"]
(tset configs :steep {:default_config {:cmd ["steep langserver"]
:filetypes [:ruby]
:root_dir #(lspconfig.util.find_git_ancestor $1)
:settings {}}}))
@ -87,21 +86,26 @@
(let [{: setup} (. lspconfig lsp)]
(setup (or config {:on_attach on-attach}))))
(let [fmt #{:formatCommand $1 :formatStdin true}
lint #{:lintCommand $1 :lintFormats $2 :lintStdin true}
fennel-lint "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1"
fennel [(fmt "fnlfmt /dev/stdin") (lint fennel-lint ["%f:%l: %m"])]
eslint {:lintCommand "eslint -f visualstudio --stdin --stdin-filename ${INPUT}"
(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 fennel [(fmt "fnlfmt /dev/stdin") (lint fennel-lint ["%f:%l: %m"])])
(local eslint
{:lintCommand "eslint -f visualstudio --stdin --stdin-filename ${INPUT}"
:lintIgnoreExitCode true
:lintStdin true
:lintFormats ["%f(%l,%c): %tarning %m" "%f(%l,%c): %rror %m"]}
prettier (fmt "prettier --stdin-filepath ${INPUT}")
javascript [eslint prettier]
black (fmt "black --quiet -")
; flake8 (lint "flake8 --stdin-display-name ${INPUT} -" ["%f:%l:%c: %m"])
isort (fmt "isort --quiet --profile black -")
python [black isort]]
(setup-lsp :efm {:on_attach on-attach
:lintFormats ["%f(%l,%c): %tarning %m" "%f(%l,%c): %rror %m"]})
(local prettier (fmt "prettier --stdin-filepath ${INPUT}"))
(local javascript [eslint prettier])
(local black (fmt "black --quiet -"))
(local flake8 (lint "flake8 --stdin-display-name ${INPUT} -" ["%f:%l:%c: %m"]))
(local isort (fmt "isort --quiet --profile black -"))
(local python [black isort])
(setup-lsp :efm {:on_attach on-attach
:init_options {:documentFormatting true
:hover true
:documentSymbol true
@ -119,20 +123,44 @@
:python
:typescriptreact
:vue]})
(setup-lsp :elmls)
(setup-lsp :fennel-ls)
(setup-lsp :pylsp {:on_attach (on-attach-do attach-navic disable-fmt)})
(setup-lsp :pyright
(setup-lsp :elmls)
(setup-lsp :fennel-ls)
(setup-lsp :pylsp {:on_attach (on-attach-do attach-navic disable-fmt)})
(setup-lsp :pyright
{:on_attach on-attach
:settings {:python {:analysis {:autoImportCompletions true}}}})
(setup-lsp :rust_analyzer
(setup-lsp :rust_analyzer
{:on_attach on-attach
:cmd [:rustup :run :stable :rust-analyzer]
:settings {:rust-analyzer {:checkOnSave {:command :clippy}}}})
(setup-lsp :tsserver {:on_attach (on-attach-do attach-navic disable-fmt)})
; (setup-lsp :ruby_ls)
; (setup-lsp :typeprof)
; (setup-lsp :steep)
(setup-lsp :vuels {:on_attach (on-attach-do attach-navic disable-fmt)}))
(setup-lsp :tsserver {:on_attach (on-attach-do attach-navic disable-fmt)})
(setup-lsp :vuels {:on_attach (on-attach-do attach-navic disable-fmt)})
;; TODO
;; https://github.com/Shopify/ruby-lsp/issues/188#issuecomment-1268932965
; (local request-diagnostics
; (fn [client buffer]
; (let [{: util : diagnostic} lsp
; params (util.make_text_document_params buffer)
; publish-diagnostics #(diagnostic.on_publish_diagnostics nil
; (vim.tbl_extend :keep
; params
; {:diagnostics $1.items})
; {:client_id client.id})
; update-diagnostics #(when (not $1)
; (publish-diagnostics $2))
; callback #(client.request :textDocument/diagnostic
; {:textDocument params}
; update-diagnostics)]
; (vim.api.nvim_create_autocmd [:BufEnter :BufWritePre :CursorHold]
; {: buffer : callback}))))
; (fn setup-ruby-ls []
; (let []
; (setup-lsp :ruby_ls {:on_attach (on-attach-do request-diagnostics)})))
{: setup-lsp}

Loading…
Cancel
Save