1

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.

I found cwindow and 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?

1
  • Welcome to the site. I can sympathize, I also switched to ALE recently. Syntastic remains one of my favorite pieces of software ever.
    – Friedrich
    Apr 21 at 7:14

1 Answer 1

3

I would try the following two options:

let g:ale_open_list = 1
let g:ale_keep_list_window_open = 0
3
  • 1
    I don't know how I missed that. How embarrassing. Thank you. Sadly this doesn't close the list when the buffer it belongs to is being closed.
    – FalcoGer
    Apr 20 at 20:49
  • Thanks for the feedback! Welcome to Vim :-) Apr 21 at 4:02
  • @FalcoGer about the closing issue: it's not really what you ask but maybe something like nnoremap <C-L> :cclose<CR><C-L> may help you. I usually add some more commands and hijack redraw to make all visual clutter go away (the idea to do so is of course stolen from tpope's vim-sensible).
    – Friedrich
    Apr 21 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.