I'm switching from the syntastic plugin to the ALE plugin. In syntastic there was an option
g:syntastic_auto_loc_list that would automatically open the location list after it had been populated. If all errors were fixed that location list would close automatically again.
I have looked over the ALE documentation but have found no such option, so I tried to do it myself.
Specifically what I want is this:
- Open the quickfix and location lists automatically when there are any entries or when they have been altered.
- When opening a list, the list should appear as a horizontal split in the tab that the relevant file is in. Some of my attempts would spam all lists in the first tab, I don't want that.
- Do not open the qf/loc lists if the buffer is hidden.
- Close the corresponding list(s) when a buffer becomes hidden or is closed.
- If the last file is closed and there is a corresponding list open, then vim should quit.
- If the last file in a tab is closed and there is a list open, that list should close and the tab should be deleted as well.
- Close the list(s) if they are/become empty
- Don't open lists for readonly files, nothing I can do about it anyway, so there is no point wasting screen space.
- When lists are opened, they should never get focus, unless I manually switch to them, so that I don't get interrupted while typing.
lwindow would show/hide the quickfix/location lists automatically but they need to be invoked. So I tried autocmd. The problem is I can't figure this out at all. Here is what I tried:
augroup AutoCAndLWindow autocmd! autocmd QuickFixCmdPost [^l]* nested cwindow | setlocal nowrap | redraw! autocmd QuickFixCmdPost l* nested lwindow | setlocal nowrap | redraw! augroup END
This doesn't do anything at all. When ALE gets around to populate the list, the window doesn't open.
augroup AutoCAndLWindow autocmd! autocmd InsertEnter,InsertLeave,BufWritePost * cwindow | lwindow augroup END
This throws an error at me:
Error detected while processing InsertLeave Autocommands for "*": E776: No location list
I think this is because it tries to open a location list for the quickfix list.
I also want the location/quickfix windows to close when the corresponding buffer is closed or hidden. I like it to work with tabs and splits. I have found a few examples on the internet such as this one, but that throws errors at me when I close a tab with a quickfix open for a file I'm editing.
How do I achieve what I want?