nvim: Improve marksman zk link handling

Instead of completely detaching marksman as soon as we are in a
zettelkasten directory, this disables displaying the 'non-existent link'
diagnostic instead. Only disables signs and virtual_text for now (still
displayed as diagnostic in e.g. Trouble windows) but should provide a
good first step into more fine-grained control.
Oh if only marksman just provided a flag to toggle this feature..
This commit is contained in:
Marty Oehme 2024-12-01 15:25:24 +01:00
parent 0bbfeb2c68
commit 0d7edd4e19
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -239,9 +239,40 @@ return {
on_attach = function(client, bufnr)
-- TODO: for some reason this stays true even after rootdir switch?
if client.config.in_zk_notebook then
vim.defer_fn(function()
vim.lsp.buf_detach_client(bufnr, client.id)
end, 1000)
local default_handler = vim.diagnostic.handlers.virtual_text
vim.diagnostic.handlers.virtual_text = {
show = function(namespace, bufnrr, diagnostics, opts)
for i, diagnostic in ipairs(diagnostics) do
if
diagnostic.source
== "Marksman" -- You need to check what the correct value should be here
then
table.remove(diagnostics, i)
end
end
default_handler.show(namespace, bufnrr, diagnostics, opts)
end,
hide = function(...)
default_handler.hide(...)
end,
}
local default_handler = vim.diagnostic.handlers.signs
vim.diagnostic.handlers.signs = {
show = function(namespace, bufnrr, diagnostics, opts)
for i, diagnostic in ipairs(diagnostics) do
if
diagnostic.source
== "Marksman" -- You need to check what the correct value should be here
then
table.remove(diagnostics, i)
end
end
default_handler.show(namespace, bufnrr, diagnostics, opts)
end,
hide = function(...)
default_handler.hide(...)
end,
}
end
on_attach(client, bufnr)
end,