2022-04-05 19:57:44 +00:00
|
|
|
(let [mod {}
|
|
|
|
cmd vim.cmd
|
|
|
|
api vim.api
|
2022-04-06 14:26:01 +00:00
|
|
|
keymap (require :nifoc.keymap)
|
|
|
|
lsp-format (require :lsp-format)]
|
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
|
2022-04-14 18:25:28 +00:00
|
|
|
: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-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)
|
|
|
|
(vim.api.nvim_create_autocmd [:CursorHold :CursorHoldI]
|
|
|
|
{:callback #(vim.diagnostic.open_float nil
|
|
|
|
{:focus false})
|
|
|
|
:buffer bufnr})))
|
2022-04-05 19:57:44 +00:00
|
|
|
|
|
|
|
(fn mod.maybe-enable-fixer [client bufnr]
|
2022-04-17 20:26:10 +00:00
|
|
|
(when client.server_capabilities.documentFormattingProvider
|
2022-04-05 19:57:44 +00:00
|
|
|
(api.nvim_buf_set_var bufnr :nifoc_fixer_enabled 1)
|
2022-04-06 14:26:01 +00:00
|
|
|
(lsp-format.on_attach client bufnr)))
|
2022-04-05 19:57:44 +00:00
|
|
|
|
|
|
|
mod)
|