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") (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] ; (let [{: nvim_create_autocmd : nvim_command} vim.api]
; (nvim_create_autocmd :BufWritePre ; (nvim_create_autocmd :BufWritePre
; {:callback #(nvim_command "normal migggqG`i")})) ; {:callback #(nvim_command "normal migggqG`i")}))

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

@ -30,8 +30,7 @@
:filetypes [:fennel] :filetypes [:fennel]
:root_dir #(lspconfig.util.find_git_ancestor $1) :root_dir #(lspconfig.util.find_git_ancestor $1)
:settings {}}}) :settings {}}})
(tset configs :steep (tset configs :steep {:default_config {:cmd ["steep langserver"]
{:default_config {:cmd ["steep langserver"]
:filetypes [:ruby] :filetypes [:ruby]
:root_dir #(lspconfig.util.find_git_ancestor $1) :root_dir #(lspconfig.util.find_git_ancestor $1)
:settings {}}})) :settings {}}}))
@ -87,21 +86,26 @@
(let [{: setup} (. lspconfig lsp)] (let [{: setup} (. lspconfig lsp)]
(setup (or config {:on_attach on-attach})))) (setup (or config {:on_attach on-attach}))))
(let [fmt #{:formatCommand $1 :formatStdin true} (local fmt #{:formatCommand $1 :formatStdin true})
lint #{:lintCommand $1 :lintFormats $2 :lintStdin true} (local lint #{:lintCommand $1 :lintFormats $2 :lintStdin true})
fennel-lint "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1" (local fennel-lint
fennel [(fmt "fnlfmt /dev/stdin") (lint fennel-lint ["%f:%l: %m"])] "fennel --globals vim,hs,spoon --raw-errors $(realpath --relative-to . ${INPUT}) 2>&1")
eslint {:lintCommand "eslint -f visualstudio --stdin --stdin-filename ${INPUT}"
(local fennel [(fmt "fnlfmt /dev/stdin") (lint fennel-lint ["%f:%l: %m"])])
(local eslint
{:lintCommand "eslint -f visualstudio --stdin --stdin-filename ${INPUT}"
:lintIgnoreExitCode true :lintIgnoreExitCode true
:lintStdin true :lintStdin true
:lintFormats ["%f(%l,%c): %tarning %m" "%f(%l,%c): %rror %m"]} :lintFormats ["%f(%l,%c): %tarning %m" "%f(%l,%c): %rror %m"]})
prettier (fmt "prettier --stdin-filepath ${INPUT}")
javascript [eslint prettier] (local prettier (fmt "prettier --stdin-filepath ${INPUT}"))
black (fmt "black --quiet -") (local javascript [eslint prettier])
; flake8 (lint "flake8 --stdin-display-name ${INPUT} -" ["%f:%l:%c: %m"]) (local black (fmt "black --quiet -"))
isort (fmt "isort --quiet --profile black -") (local flake8 (lint "flake8 --stdin-display-name ${INPUT} -" ["%f:%l:%c: %m"]))
python [black isort]] (local isort (fmt "isort --quiet --profile black -"))
(setup-lsp :efm {:on_attach on-attach (local python [black isort])
(setup-lsp :efm {:on_attach on-attach
:init_options {:documentFormatting true :init_options {:documentFormatting true
:hover true :hover true
:documentSymbol true :documentSymbol true
@ -119,20 +123,44 @@
:python :python
:typescriptreact :typescriptreact
:vue]}) :vue]})
(setup-lsp :elmls)
(setup-lsp :fennel-ls) (setup-lsp :elmls)
(setup-lsp :pylsp {:on_attach (on-attach-do attach-navic disable-fmt)}) (setup-lsp :fennel-ls)
(setup-lsp :pyright (setup-lsp :pylsp {:on_attach (on-attach-do attach-navic disable-fmt)})
(setup-lsp :pyright
{:on_attach on-attach {:on_attach on-attach
:settings {:python {:analysis {:autoImportCompletions true}}}}) :settings {:python {:analysis {:autoImportCompletions true}}}})
(setup-lsp :rust_analyzer
(setup-lsp :rust_analyzer
{:on_attach on-attach {:on_attach on-attach
:cmd [:rustup :run :stable :rust-analyzer] :cmd [:rustup :run :stable :rust-analyzer]
:settings {:rust-analyzer {:checkOnSave {:command :clippy}}}}) :settings {:rust-analyzer {:checkOnSave {:command :clippy}}}})
(setup-lsp :tsserver {:on_attach (on-attach-do attach-navic disable-fmt)})
; (setup-lsp :ruby_ls) (setup-lsp :tsserver {:on_attach (on-attach-do attach-navic disable-fmt)})
; (setup-lsp :typeprof) (setup-lsp :vuels {:on_attach (on-attach-do attach-navic disable-fmt)})
; (setup-lsp :steep)
(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} {: setup-lsp}

Loading…
Cancel
Save