First of all, thank you for the quick response! My new approach is to keep track of all BufRead autocmds that happen between QuickFixCmdPre and QuickFixCmdPost, and explicitly call bufexists() on each one of them afterwards to get all buffers that was actually added. The reason being that I do actually want to handle those. Do that sound like a good plan? It seems to work well so far.
Also, is it intended behaviour that vim do reuse buffer numbers, or do you want me to write an issue about it? If it is intended, are there other cases where it could happen? The current design in govim assumes that buffer numbers are unique and never reused. Regards, Pontus torsdag 4 februari 2021 kl. 23:38:57 UTC+1 skrev [email protected]: > Hi, > > On Thu, Feb 4, 2021 at 2:02 PM [email protected] <[email protected]> > wrote: > >> Hi all, >> >> We recently received an issue about using :vimgrep in the Go plugin govim >> <https://github.com/govim/govim>. >> >> In govim we handle `BufRead` autocommands for .go files, and send >> notifications to the Language Server that a new file has been opened. >> >> As :vimgrep search through files, we do get autocommands for each and >> every file, but sending notifications for all .go files searched will put a >> lot of load on the language server as it thinks that the user actually >> opened (and closed) all files searched within just a second. >> >> *Is there a way to differentiate BufRead autocommands triggered by >> :vimgrep from others?* It would be great if we could identify those and >> filter them, or even better if they didn't trigger autocommands in the >> first place. >> >> > The MRU (https://github.com/yegappan/mru) plugin uses the QuickFixCmdPre > and > QuickFixCmdPost autocmds to stop adding the buffers to the MRU list when a > vimgrep command is executed. You can see whether that will help. > > https://github.com/yegappan/mru/blob/master/plugin/mru.vim#L954 > > Regards, > Yegappan > > >> I also noticed that vim will keep the same buffer numbers as :vimgrep >> search through files without a match. If it do find a match the file & >> buffer is kept and the buffer number is increased. For those we obviously >> do want the autocommand as they are indeed opened. >> >> I can't find any information about if this is expected, except for the >> "Vim Buffer FAQ" over at https://vim.fandom.com/wiki/Vim_buffer_FAQ. >> According to that FAQ a buffer number should never be reused. >> >> *Are there cases where we should expect that a buffer number is reused >> within the same vim session?* >> >> Regards, Pontus >> >> 40googlegroups.com >> <https://groups.google.com/d/msgid/vim_dev/d8cef0cb-fe57-413a-9294-c3685c50cb82n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/afb4bfe0-191d-43e4-aded-19d7a29183e6n%40googlegroups.com.
