2022-04-05 19:57:44 +00:00
|
|
|
(let [mod {}
|
2022-07-27 09:04:23 +00:00
|
|
|
sign vim.cmd.sign
|
2022-04-05 19:57:44 +00:00
|
|
|
api vim.api
|
2022-04-27 20:17:59 +00:00
|
|
|
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]
|
2022-05-22 21:05:38 +00:00
|
|
|
(when (client.supports_method :textDocument/codeLens)
|
2022-11-11 14:06:11 +00:00
|
|
|
(vim.schedule vim.lsp.codelens.refresh)))
|
2022-04-23 22:15:43 +00:00
|
|
|
|
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
|
2023-01-11 22:48:51 +00:00
|
|
|
:float {:border :rounded
|
|
|
|
:source true
|
|
|
|
:focusable false}
|
2022-04-10 21:47:39 +00:00
|
|
|
:update_in_insert false
|
|
|
|
:severity_sort true})
|
2023-01-11 21:45:22 +00:00
|
|
|
(sign "define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=")
|
|
|
|
(sign "define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=")
|
|
|
|
(sign "define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl=")
|
|
|
|
(sign "define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl="))
|
2022-04-05 19:57:44 +00:00
|
|
|
|
2022-04-27 20:17:59 +00:00
|
|
|
(fn mod.maybe-enable-diagnostics [bufnr]
|
|
|
|
(when (= vim.b.nifoc_diagnostics_enabled nil)
|
2022-11-11 14:06:11 +00:00
|
|
|
(api.nvim_buf_set_var bufnr :nifoc_diagnostics_enabled 1)))
|
2022-04-27 20:17:59 +00:00
|
|
|
|
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)
|
2022-04-27 20:17:59 +00:00
|
|
|
(mod.maybe-enable-diagnostics bufnr)
|
2022-11-11 14:06:11 +00:00
|
|
|
(aucmd [:InsertLeave :BufEnter :BufWritePost]
|
2022-04-27 20:17:59 +00:00
|
|
|
{: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
|
|
|
|