Recently I've been playing with my statusline and I'm coming to a point where I want to set a different highlighting group for the statusline of my quickfix window, location list window, and the other windows.
To do so I need to programmatically determine what type of buffer I am in. To differentiate between the "regular" buffers and the quickfix/location buffers I can easily test if &buftype
returns quickfix
.
The problem is to differentiate quickfix and location list since &buftype
returns quickfix
for both buffers.
I've seen this SO question which provides three solutions that don't satisfy me:
- The
w:quickfix_title
variable tells you what command was used to generate the list displayed in the window. This is not what I'm looking for since I can open my location list with different commands other thanlopen
(SyntasticCheck
would be an example) - Parsing the output of
ls
, matching the buffer number and checking if the name of the buffer matchesLocation List
orQuickfix List
. That could be a solution but I use different versions of Vim in different languages, so matching against all the possible names (e.g.Location List
andListe des emplacements
) is not ideal. - The third answer is about closing and reopening the windows to test if you were in one of them, this is really not convenient for a statusline setting.
So here are my two questions:
- Is there another way to easily differentiate the quickfix buffer from the location list one?
- If not what would be the best way to set a statusline background depending on the type of quickfix window you're in?