1
0
Fork 0

nvim: LSP configuration updates

This commit is contained in:
Daniel Kempkens 2022-05-22 23:05:38 +02:00
parent 6b3a0c92ee
commit 41fa76eb00
4 changed files with 10 additions and 8 deletions

View file

@ -5,7 +5,7 @@
augroup (vim.api.nvim_create_augroup :NifocDiagnostic {:clear true}) augroup (vim.api.nvim_create_augroup :NifocDiagnostic {:clear true})
aucmd vim.api.nvim_create_autocmd] aucmd vim.api.nvim_create_autocmd]
(fn maybe-refresh-codelens [client] (fn maybe-refresh-codelens [client]
(when client.server_capabilities.codeLensProvider (when (client.supports_method :textDocument/codeLens)
(vim.lsp.codelens.refresh))) (vim.lsp.codelens.refresh)))
(fn mod.setup [] (fn mod.setup []

View file

@ -22,9 +22,9 @@
(set-bufvar 0 :nifoc_formatter_disabled 1)) (set-bufvar 0 :nifoc_formatter_disabled 1))
(fn mod.maybe-enable-lsp [client bufnr] (fn mod.maybe-enable-lsp [client bufnr]
(when client.server_capabilities.documentRangeFormattingProvider (when (client.supports_method :textDocument/rangeFormatting)
(api.nvim_buf_set_option bufnr :formatexpr "v:lua.vim.lsp.formatexpr()")) (api.nvim_buf_set_option bufnr :formatexpr "v:lua.vim.lsp.formatexpr()"))
(when client.server_capabilities.documentFormattingProvider (when (client.supports_method :textDocument/formatting)
(set-bufvar bufnr :nifoc_lsp_formatter_enabled 1))) (set-bufvar bufnr :nifoc_lsp_formatter_enabled 1)))
(fn mod.maybe-format-buffer [] (fn mod.maybe-format-buffer []

View file

@ -77,9 +77,11 @@
(let [current-context (.. (. current-function-symbols sym.kind) (let [current-context (.. (. current-function-symbols sym.kind)
sym.text)] sym.text)]
(table.insert context-levels current-context)))))) (table.insert context-levels current-context))))))
(set-bufvar ctx.bufnr :nifoc_lsp_current_context (let [current-context vim.b.nifoc_lsp_current_context
(table.concat context-levels "  ")) new-context (table.concat context-levels "  ")]
(vim.api.nvim_command :redrawstatus)) (when (not= current-context new-context)
(set-bufvar ctx.bufnr :nifoc_lsp_current_context new-context)
(vim.api.nvim_cmd {:cmd :redrawstatus} []))))
(fn update-current-context [bufnr] (fn update-current-context [bufnr]
(let [params {:textDocument (vim.lsp.util.make_text_document_params bufnr)}] (let [params {:textDocument (vim.lsp.util.make_text_document_params bufnr)}]
@ -161,7 +163,7 @@
handle-symbols-under-cursor))) handle-symbols-under-cursor)))
(fn mod.on-attach [client bufnr] (fn mod.on-attach [client bufnr]
(when client.server_capabilities.documentSymbolProvider (when (client.supports_method :textDocument/documentSymbol)
(aucmd [:CursorHold] (aucmd [:CursorHold]
{:callback #(update-current-context bufnr) {:callback #(update-current-context bufnr)
:buffer bufnr :buffer bufnr

View file

@ -5,7 +5,7 @@
diagnostic (require :nifoc.diagnostic) diagnostic (require :nifoc.diagnostic)
formatting (require :nifoc.formatting)] formatting (require :nifoc.formatting)]
(fn custom-attach [client bufnr] (fn custom-attach [client bufnr]
(when client.server_capabilities.documentHighlightProvider (when (client.supports_method :textDocument/documentHighlight)
(illuminate.on_attach client bufnr)) (illuminate.on_attach client bufnr))
(nifoc-lsp.on-attach client bufnr) (nifoc-lsp.on-attach client bufnr)
(diagnostic.maybe-enable-lsp client bufnr) (diagnostic.maybe-enable-lsp client bufnr)