1
0
Fork 0
dotfiles/config/nvim/nifoc/diagnostic.fnl

45 lines
1.9 KiB
Text
Raw Normal View History

2022-04-05 19:57:44 +00:00
(let [mod {}
cmd vim.cmd
api vim.api
keymap (require :nifoc.keymap)
augroup (vim.api.nvim_create_augroup :NifocDiagnostic {:clear true})
aucmd vim.api.nvim_create_autocmd]
2022-04-23 22:15:43 +00:00
(fn maybe-refresh-codelens [client]
(when client.server_capabilities.codeLensProvider
(vim.lsp.codelens.refresh)))
2022-04-05 19:57:44 +00:00
(fn mod.setup []
(vim.diagnostic.config {:underline true
2022-04-10 21:47:39 +00:00
:virtual_text false
:signs true
:float {:border :rounded :source true}
2022-04-10 21:47:39 +00:00
:update_in_insert false
:severity_sort true})
(cmd "sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=DiagnosticSignError")
(cmd "sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=DiagnosticSignWarn")
(cmd "sign define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl=DiagnosticSignInfo")
(cmd "sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl=DiagnosticSignHint"))
2022-04-05 19:57:44 +00:00
(fn mod.maybe-enable-diagnostics [bufnr]
(when (= vim.b.nifoc_diagnostics_enabled nil)
(api.nvim_buf_set_var bufnr :nifoc_diagnostics_enabled 1)
(aucmd [:CursorHold :CursorHoldI]
{:callback #(vim.diagnostic.open_float {:focus false})
:buffer bufnr
:group augroup
:desc "Open Diagnostic Window"})))
2022-04-05 19:57:44 +00:00
(fn mod.maybe-enable-lsp [client bufnr]
(when (= vim.b.nifoc_lsp_enabled nil)
(api.nvim_buf_set_var bufnr :nifoc_lsp_enabled 1)
2022-04-10 18:51:43 +00:00
(keymap.lsp-attach client bufnr)
(mod.maybe-enable-diagnostics bufnr)
(aucmd [:CursorHold :CursorHoldI :InsertLeave]
{:callback #(maybe-refresh-codelens client)
:buffer bufnr
:group augroup
:desc "Refresh Codelens"})))
2022-04-05 19:57:44 +00:00
mod)
2022-04-22 12:19:36 +00:00