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:
parent
0bbfeb2c68
commit
0d7edd4e19
1 changed files with 34 additions and 3 deletions
|
@ -239,9 +239,40 @@ return {
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
-- TODO: for some reason this stays true even after rootdir switch?
|
-- TODO: for some reason this stays true even after rootdir switch?
|
||||||
if client.config.in_zk_notebook then
|
if client.config.in_zk_notebook then
|
||||||
vim.defer_fn(function()
|
local default_handler = vim.diagnostic.handlers.virtual_text
|
||||||
vim.lsp.buf_detach_client(bufnr, client.id)
|
vim.diagnostic.handlers.virtual_text = {
|
||||||
end, 1000)
|
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
|
end
|
||||||
on_attach(client, bufnr)
|
on_attach(client, bufnr)
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in a new issue