qf.nvim icon indicating copy to clipboard operation
qf.nvim copied to clipboard

no config opt for { silent = true } => autocommands result in repeating error msg in console

Open joehannes opened this issue 3 years ago • 5 comments

hey! awesome work!!!

just found your plugin and am playing around with it ... haven't had much of a chance to use it yet, but ...

if I kick of my vim and got

  • no diagnostic errors in my file
  • autocommand like WinEnter ... will trigger
  • a console (cmd-region) error printed incusive of an interactive, focus stealing prompt like

Error Screenie Example of Autocommand with WinEnter

I traced the error down to the qf.open function in qf.lua ... there's a seemingly hastily inserted if-block that checks for ~= true ... plus I can see that function is called various times with the parameter left out, so definitely ~= true by default

Error in Code to be found here

you could possibly handle that via adding a debug/silent param with a sensible default setting (false) ... a quickfix might be to invert the truthy check to read: == false ... instead

Since I do wanna use/try out your plugin properly I might clone your Repo now and do a PR shortly, so hang on tight :-)

best, joehannes, keep the good stuff

joehannes avatar May 31 '22 00:05 joehannes

Thanks for the issue.

I am guessing it is the l.focus_open autocmd.

I haven't used that one particularly myself as I am primary using the vim.lsp.setloclist for filling the locationlist, which means the only times I get the error is if I try to open the list manually, which won't steel focus since it is just one line (similar to how vim copen behaves, which is what I based it on).

I've thought about the error and when it should appear, so perhaps a global option will be a good solution.

A PR would be much appreciated :)

That line was written before vim.notify and I think replacing err_writeln with a vim.notify(_, vim.log.levels.ERROR) would be more idiomatic and will integrate into notification plugins to not clutter the echo area.

ten3roberts avatar May 31 '22 08:05 ten3roberts

heyhey, thx for the quick response :-)

Yep, I guess you're right with the l.focus_open autocmd.

I wonder how using the vim.lsp.setloclist thingy helps you not seeing this issue anyway ... Maybe you never run into a situation where there's no linting-errors so you never got empty l-lists? I guess that's unlikely, so basically I just don't understand :-)

However, I just installed the diaglist-plugin to auto-populate my qf/l-lists, but anyway, if the open files don't have no diagnostics I get a phallanx of notifications on nvim-startup. Also, I didn't like getting a notification every time I (re-)focus one of my buffers.

=> I additionally silenced the "big mouth"-autocmd, hehe :-) (just added the silent = true to the aucmd only)

I created a PR with those changes, please do have a look when you got some time :-)

all the best to Stockholm, J

joehannes avatar May 31 '22 16:05 joehannes

ahh, btw, I recommend you add a stylua.toml configuration-file to the project. I had to throw my local commits away and redo the thing in the github online/basic text editor without (auto-)formatting, because my local nvim would change all kinds of styles without that stylua.toml in place, making the PR impossible ...

joehannes avatar May 31 '22 16:05 joehannes

Yeah, those 1000+- diffs with whitespace changed.

I've been using the lsp format from sumneko_lua. Which plugin are you using for stylua?

I've just been using my own rolled script for overriding the onPublishDiagnostics where I count up the diags for each kind, show in the statusline, and put them in a quickfix list if there are any, otherwise it closes it.

ten3roberts avatar May 31 '22 16:05 ten3roberts

Exactly :-) I'm using lsp format from sumneko_lua as well I think, hehe :-) Not sure though, and it did give those 1000+- diffs with tabs/spaces etc ... I found that if you commit to a standard by putting a central stylua.toml like eg. found at the bottom of the stylua github repo page ...

column_width = 120
line_endings = "Unix"
indent_type = "Tabs"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "Always"

then in theory all the lua-formatters of whoever is working on a PR should pick that up automatically.

So, in short, I guess I recommend putting such a file there and reformat all lua-files yourself just once, so the bigger 1000+- diffs are (to you) obviously just formatting and you can just commit them ... this way in the future nobody runs into this kinda issue :-)

Anyway, as of the onPublishDiagnostics thingy ... I'm afraid I'm not that fond of lua and manually tinkering with nvim-cfg yet, though I'm getting there, haha, but I haven't tried myself on my own scripts/plugins just yet (just some cfg-fns only). But I also got my diagnostics displayed in:

  • statusline
  • tabline
  • tab itself
  • inline ghost text
  • gitgutter and now .... in the LocList window, haha :-) (if you want to check out my somewhat buggy - I believe a fresh install needs 2 or three runs of PackerInstall and PackerCompile until it runs smoothly - init.lua => here's the repo)

okidoe, Cheers, blessings, Joehannes

joehannes avatar May 31 '22 17:05 joehannes