main
Alpha Chen 1 week ago
parent 7f2ba97d3c
commit d7f5d96ed8
No known key found for this signature in database

@ -124,12 +124,6 @@
(tset palette f :middle [[:NONE :NONE :NONE :NONE]])) (tset palette f :middle [[:NONE :NONE :NONE :NONE]]))
(tset vim.g palette-key palette)) (tset vim.g palette-key palette))
;;; navic
;; TODO Enable this when 0.8 is released
;; TODO Use fennel for this?
; (set vim.o.winbar "%{%v:lua.require'nvim-navic'.get_location()%}")
;;; netrw ;;; netrw
;; https://github.com/tpope/vim-vinegar/issues/13 ;; https://github.com/tpope/vim-vinegar/issues/13

@ -6,118 +6,151 @@
;; $ rake init:local-nvim[DIR] ;; $ rake init:local-nvim[DIR]
(local lspconfig (require :lspconfig)) (local lspconfig (require :lspconfig))
(local {: lsp} vim) (local {: iter : lsp} vim)
; (lsp.set_log_level :debug) ; (lsp.set_log_level :debug)
;; Use rounded borders for :LspInfo ;; rounded borders
(let [{: default_options} (require :lspconfig.ui.windows)]
(tset default_options :border :rounded))
(let [configs (require :lspconfig.configs)]
(tset configs :steep {:default_config {:cmd ["steep langserver"]
:filetypes [:ruby]
:root_dir #(lspconfig.util.find_git_ancestor $1)
:settings {}}}))
;; default hover windows to have borders
(let [{: hover} lsp.handlers] (let [{: hover} lsp.handlers]
(tset lsp.handlers :textDocument/hover (lsp.with hover {:border :rounded})) (tset lsp.handlers :textDocument/hover (lsp.with hover {:border :rounded}))
(tset lsp.handlers :textDocument/signatureHelp (tset lsp.handlers :textDocument/signatureHelp
(lsp.with hover {:border :rounded}))) (lsp.with hover {:border :rounded})))
(let [opts {:noremap true :silent true}] ;; set up key mappings
(let [{: nvim_create_autocmd} vim.api
opts {:noremap true :silent true}
callback (fn []
(vim.keymap.set :n :<leader>e vim.diagnostic.open_float opts) (vim.keymap.set :n :<leader>e vim.diagnostic.open_float opts)
(vim.keymap.set :n :<leader>q vim.diagnostic.setloclist opts)) (vim.keymap.set :n :<leader>q vim.diagnostic.setloclist opts)
;; for back-compat - remove once muscle memory has been remapped gd to CTRL+]
(fn on-attach [client bufnr] (vim.keymap.set :n :gd lsp.buf.definition opts)
(vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc") ;; switch out formatting a single line for formatting the whole file instead
(let [bufopts {:noremap true :silent true :buffer bufnr}] (vim.keymap.set :n :gqq #(lsp.buf.format {:async true}) opts))]
(vim.keymap.set :n :gD lsp.buf.declaration bufopts) (nvim_create_autocmd :LspAttach {: callback}))
(vim.keymap.set :n :gd lsp.buf.definition bufopts)
(vim.keymap.set :n :gi lsp.buf.implementation bufopts) (lspconfig.pyright.setup {})
(vim.keymap.set :n :<leader>D lsp.buf.type_definition bufopts) (lspconfig.terraformls.setup {})
(vim.keymap.set :n :<leader>lf #(lsp.buf.format {:async true}) bufopts))) (lspconfig.yamlls.setup {:settings {:yaml {:schemas {"https://json.schemastore.org/github-workflow.json" :/.github/workflows/*}}}})
(fn on-attach-do [...] ;;; efm-langserver
(let [fns [...]] ; https://benaiah.me/posts/everything-you-didnt-want-to-know-about-lua-multivals/
(fn [client bufnr] (let [fmt #{:formatCommand $1 :formatStdin true}
(on-attach client bufnr) lint #{:lintCommand $1 :lintFormats $2 :lintStdin true}
(each [_ f (ipairs fns)] fennel [(fmt "fnlfmt /dev/stdin")
(f client bufnr))))) (lint (-> (iter [:fennel
:--globals
(fn attach-navic [client bufnr] "vim,hs,spoon"
((. (require :nvim-navic) :attach) client bufnr)) :--raw-errors
"$(realpath --relative-to . ${INPUT})"
(fn disable-fmt [client] :2>&1])
(set client.resolved_capabilities.document_formatting false)) (: :join " ")) ["%f:%l: %m"])]
yaml [(fmt "yamlfmt -in")]]
(fn setup-lsp [lsp config] (lspconfig.efm.setup {:init_options {:documentFormatting true
(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 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"]})
(local prettier (fmt "prettier --stdin-filepath ${INPUT}"))
(local javascript [eslint prettier])
(local yamlfmt (fmt "yamlfmt -in"))
(local shellcheck {:lintCommand "shellcheck -f gcc -x"
:lintSource :shellcheck
:lintFormats ["%f:%l:%c: %trror: %m"
"%f:%l:%c: %tarning: %m"
"%f:%l:%c: %tote: %m"]})
(setup-lsp :efm {:on_attach on-attach
:init_options {:documentFormatting true
:hover true :hover true
:documentSymbol true :documentSymbol true
:codeAction true :codeAction true
:completion true} :completion true}
:settings {:languages {: fennel :settings {:languages {: fennel : yaml}}
: javascript :filetypes [:fennel :yaml]}))
:sh [shellcheck]
:typescript javascript ; :settings {:languages {: fennel
:typescriptreact javascript ; : js
:vue [prettier] ; :typescript js
:yaml [yamlfmt]}} ; :typescriptreact js
:filetypes [:fennel ; :vue [(fmt "prettier --stdin-filepath ${INPUT}")]
:javascript ; :yaml [(fmt "yamlfmt -in")]}
:sh ; :lintDebounce 1000000000}
:typescript ; :filetypes [:fennel
:typescriptreact ; :javascript
:vue ; :typescript
:yaml]}) ; :typescriptreact
; :vue
(setup-lsp :ansiblels) ; :yaml]}))
(setup-lsp :elmls)
(setup-lsp :fennel_ls {:settings {:fennel-ls {:extra-globals "hs spoon vim"}}}) ; (fn on-attach [_client bufnr])
(setup-lsp :pyright
{:on_attach on-attach ; (let [bufopts {:noremap true :silent true :buffer bufnr}]
:settings {:python {:analysis {:autoImportCompletions true}}}}) ; (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)))
(setup-lsp :ruff)
(setup-lsp :ruby_lsp) ; (fn on-attach-do [...]
(setup-lsp :rust_analyzer ; (let [fns [...]] ; https://benaiah.me/posts/everything-you-didnt-want-to-know-about-lua-multivals/
{:on_attach on-attach ; (fn [client bufnr]
:cmd [:rustup :run :stable :rust-analyzer] ; (on-attach client bufnr)
:settings {:rust-analyzer {:checkOnSave {:command :clippy}}}}) ; (each [_ f (ipairs fns)]
; (f client bufnr)))))
(setup-lsp :terraformls) ;
; (fn attach-navic [client bufnr]
; (setup-lsp :tsserver {:on_attach (on-attach-do attach-navic disable-fmt)}) ; ((. (require :nvim-navic) :attach) client bufnr))
(setup-lsp :vuels {:on_attach (on-attach-do attach-navic disable-fmt)}) ;
; (fn enable-fmt [client bufnr]
; (let [bufopts {:noremap true :silent true :buffer bufnr}]
; (vim.keymap.set :n :<leader>lf #(lsp.buf.format {:async true}) bufopts)))
;
; (fn disable-rename [client]
; (set client.server_capabilities.rename false))
;
; (fn setup-lsp [lsp config]
; (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
; :lintStdin true
; :lintFormats ["%f(%l,%c): %tarning %m" "%f(%l,%c): %rror %m"]})
;
; (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
; :cmd [:rustup :run :stable :rust-analyzer]
; :settings {:rust-analyzer {:checkOnSave {:command :clippy}}}})
;
; (setup-lsp :ts_ls {:on_attach (on-attach-do attach-navic)})
; (setup-lsp :vuels {:on_attach (on-attach-do attach-navic)})
;; TODO ;; TODO
;; https://github.com/Shopify/ruby-lsp/issues/188#issuecomment-1268932965 ;; https://github.com/Shopify/ruby-lsp/issues/188#issuecomment-1268932965
@ -143,4 +176,3 @@
; (setup-lsp :ruby_ls {:on_attach (on-attach-do request-diagnostics)}))) ; (setup-lsp :ruby_ls {:on_attach (on-attach-do request-diagnostics)})))
{: setup-lsp} {: setup-lsp}

5
.gitmodules vendored

@ -80,11 +80,6 @@
url = https://github.com/nvim-treesitter/nvim-treesitter-textobjects.git url = https://github.com/nvim-treesitter/nvim-treesitter-textobjects.git
branch = master branch = master
shallow = true shallow = true
[submodule "navic"]
path = .local/share/nvim/site/pack/alpha/start/navic
url = https://github.com/SmiteshP/nvim-navic.git
branch = master
shallow = true
[submodule "vue"] [submodule "vue"]
path = .local/share/nvim/site/pack/alpha/start/vue path = .local/share/nvim/site/pack/alpha/start/vue
url = https://github.com/posva/vim-vue.git url = https://github.com/posva/vim-vue.git

@ -1 +0,0 @@
Subproject commit 8649f694d3e76ee10c19255dece6411c29206a54
Loading…
Cancel
Save