1
0
Fork 0

nvim: Set formatexpr for LSP

This commit is contained in:
Daniel Kempkens 2022-04-18 23:08:19 +02:00
parent f79f609e5d
commit 857592bb7c
2 changed files with 8 additions and 5 deletions

View file

@ -19,12 +19,14 @@
(when (= vim.b.nifoc_lsp_enabled nil)
(api.nvim_buf_set_var bufnr :nifoc_lsp_enabled 1)
(keymap.lsp-attach client bufnr)
(vim.api.nvim_create_autocmd [:CursorHold :CursorHoldI]
{:callback #(vim.diagnostic.open_float nil
{:focus false})
:buffer bufnr})))
(api.nvim_create_autocmd [:CursorHold :CursorHoldI]
{:callback #(vim.diagnostic.open_float nil
{:focus false})
:buffer bufnr})))
(fn mod.maybe-enable-fixer [client bufnr]
(when client.server_capabilities.documentRangeFormattingProvider
(api.nvim_buf_set_option bufnr :formatexpr "v:lua.vim.lsp.formatexpr()"))
(when client.server_capabilities.documentFormattingProvider
(api.nvim_buf_set_var bufnr :nifoc_fixer_enabled 1)
(lsp-format.on_attach client bufnr)))

View file

@ -6,7 +6,7 @@
diagnostic (require :nifoc.diagnostic)]
(fn custom-attach [client bufnr]
(when client.server_capabilities.documentSymbolProvider
(lsp_status.on_attach client bufnr))
(lsp-status.on_attach client bufnr))
(when client.server_capabilities.documentHighlightProvider
(illuminate.on_attach client bufnr))
(when client.server_capabilities.codeLensProvider
@ -16,6 +16,7 @@
(fn custom-attach-no-format [client bufnr]
(set client.server_capabilities.documentFormattingProvider false)
(set client.server_capabilities.documentRangeFormattingProvider false)
(custom-attach client bufnr))
;; Setup