dgagn / diagflow.nvim Goto Github PK
View Code? Open in Web Editor NEWLSP diagnostics in virtual text at the top right of your screen
LSP diagnostics in virtual text at the top right of your screen
It would be great to have the ability to disable this for certain filetypes. I'd be happy to push through a PR too.
My use case is for when I'm scrolling in Lazy's popup I see the LSP notifications in the top right:
Being able to do something like:
enable = function() return vim.bo.filetype ~= "lazy" end
Thanks for your plugin, i had to add this to my lua config to hide the "original" inline messages
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = false
}
)
otherwise, it would display both
The FAQ provides a snippet for hiding diagflow messages while in insert mode. If the LSP loads after or during your first insert, diagflow messages will appear while in insert mode and hide while outside of insert mode -- the opposite of what's desired. I've hacked together a very simple workaround that fits my use-case here. I split toggle_event
into enable_event
and disable_event
. I'm curious about a more permanent solution. :)
If I understand the docs correctly, setting toggle_event = { "InsertEnter" },
is supposed to disable the output while in Insert Mode?
While that does work some of the time, new diagnostics still pop up in Insert mode. As far as I can tell, that is due to update_event = { 'DiagnosticChanged' }
which gets triggered a lot during typing in insert mode.
Tbf, I am not even sure I understand correctly what the three *_event
settings exactly do. toggle_event
hides the diagnostics, update_event
updates & shows them? In any case, my goal is to simply hide diagnostics completely while in insert mode, and show them while outside insert mode, and I am not sure how to achieve that behavior. Considering that is a configuration many people would like, I'd say it could make sense to offer that directly as a setting?
Error detected while processing DiagnosticChanged Autocommands for "*":
Error executing lua callback: ...ocal/share/nvim/lazy/diagflow.nvim/lua/diagflow/lazy.lua:95: attempt to call field 'is_disabled' (a nil value)
stack traceback:
...ocal/share/nvim/lazy/diagflow.nvim/lua/diagflow/lazy.lua:95: in function <...ocal/share/nvim/lazy/diagflow.nvim/lua/diagflow/lazy.lua:90>
[C]: in function 'nvim_exec_autocmds'
/usr/share/nvim/runtime/lua/vim/diagnostic.lua:727: in function 'set'
/usr/share/nvim/runtime/lua/vim/lsp/diagnostic.lua:206: in function 'handler'
/usr/share/nvim/runtime/lua/vim/lsp.lua:1049: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
There are standart highlight groups for lsp.
Not 100% sure but I think it's LspDiagnostic*
(this also changed sometime in the past so I'm never completely sure)
I'm not at my computer with neovim rn so I can't check
I think it would make sense to just use this highlight groups instead of your own ones
Can you provide an API to enable and disable Dialogflow
? I like to disable diagnostics in InsertMode
and reenable them in NormalMode
.
Diagnostics don't seem to be correctly refreshed even after they've been addressed. After saving the document, can you trigger a check to clear the diagnostics properly? Relying on CursorMoved
and DiagnosticChanged
doesn't seem to be enough.
diagflow.nvim/lua/diagflow/lazy.lua
Lines 218 to 219 in 880aed2
If you set up toggle_event
, config.enable
will be assignd as a boolean type.
vim.diagnostic.disable()
and vim.diagnostic.enable()
are useful to temporarily toggle diagnostics on and off. However, it appears diagflow is not respecting these commands and persists even after using vim.diagnostic.disable()
The diagnostic disappear when I use the vim.lsp.buf.hover.
I still need to execute :DiagflowToggle
two times to show the diagnostic again.
Here is my diagflow config:
require("diagflow").setup({
enable = true,
max_width = 30, -- The maximum width of the diagnostic messages
severity_colors = { -- The highlight groups to use for each diagnostic severity level
error = "DiagnosticFloatingError",
warning = "DiagnosticFloatingWarning",
info = "DiagnosticFloatingInfo",
hint = "DiagnosticFloatingHint",
},
gap_size = 1,
scope = "line", -- 'cursor', 'line'
padding_top = 5,
placement = "top",
update_event = { "DiagnosticChanged", "BufEnter" },
toggle_event = { "InsertEnter" }
})
Here is my lspconfig config related to vim.lsp.buf.hover:
local lspconfig = require('lspconfig')
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
end,
})
I think the messages would be more readable when the text is broken on whitespace.
Thanks for this nice plugin!
So the default diagnostic messages can be configured. Among other things, there is the option vim.diagnostic.config.format
(nvim docs), which accepts a function for formatting the diagnostic text. Most importantly, one such option is to add the diagnostic source to the text, which is relevant when you have more than one diagnostics provider in a given buffer (e.g. lsp + linter via null-ls)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.