David-Kunz / gen.nvim

Neovim plugin to generate text using LLMs with customizable prompts
The Unlicense
977 stars 62 forks source link

[enhancement] hide diagnostic in the new buffer gen.nvim on split view #85

Open gipo355 opened 3 months ago

gipo355 commented 3 months ago

The new buffer created becomes a christmas tree with lsps and other diagnostics one may have active.

I've tried to set up an autocmd on BufEnter with pattern gen.nvim to trigger vim.diagnostic.hide() but wasn't succesful. ( works when exiting and reentering tho). The other event emitters I tried don't work too.

Is it possible to disable them on the new buffer?

the code in question is here

https://github.com/David-Kunz/gen.nvim/blob/46ab810130097494bbcf12b1426a7166f4c2995e/lua/gen/init.lua#L121-L129

this is the result

image

life00 commented 3 months ago

This is more of an LSP question rather than gen.nvim. So I recommend you search in nvim-lspconfig or similar.

I actually previously had certain issues with my LSP server and tried solving it by disabling it in certain filetypes temporarily without uninstalling it, or at least disable diagnostics. It was a huge pain, and at the end I actually could not get it to disable, instead I fixed the issues with the LSP server itself lol.

I remember trying to do similar autocmd disable diagnostics stuff, as I said I also couldn't get it to work. I think you are on the right track though.

Btw what are the LSP's you are using here? It appears to be some markdown format LSP and grammar+spelling LSP?

gipo355 commented 3 months ago

thanks for your suggestion @life00!

I decided to post it here because I thought it could be a sane default to disable possible linting lsps people have on by default together with diagnostics.

This is because the filetype is set to markdown.

If you take a look at things like glow.nvim, dev-docs.nvim, I don't incur in this problem over there when opening their windows.

That said, for now my autocmd works only when leaving the buffer and re-entering it. (and is enough for me)

It appears it can't open with them disabled for some reason. (it reactivates them)

this is a list of the lsps: [marksman, prosemd_lsp, markdownlint, proselint, codespell, write_good]

life00 commented 3 months ago

@gipo355 its great you found the solution that at least somewhat fixes your problem.

That's a lot of LSPs :D

I just wanted to comment on that. I personally only use ltex-ls with ltex_extra and find it to be sufficient (I also have languagetool server installed separately), and I believe that languagetool provides the best results among open source spell, grammar, and style checkers. Regarding the syntax LSPs, I did not particularly enjoy having them complain about some formatting errors. It was just annoying, distracting, and unnecessary. I just use the prettier formatter, it appears to do the best job. I also disabled several rules in languagetool like capitalization and spelling errors, because those are provided by neovim already. In addition to that, I also use lsp_lines that allow showing diagnostics only when I focus on the line. This might be the reason why I never had the issue you are facing with this plugin. Just wanted to suggest.