aboutsummaryrefslogtreecommitdiff
path: root/plugin/quickfix_auto_open.vim
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/quickfix_auto_open.vim')
-rw-r--r--plugin/quickfix_auto_open.vim46
1 files changed, 7 insertions, 39 deletions
diff --git a/plugin/quickfix_auto_open.vim b/plugin/quickfix_auto_open.vim
index 63195da..73b3f4b 100644
--- a/plugin/quickfix_auto_open.vim
+++ b/plugin/quickfix_auto_open.vim
@@ -5,50 +5,18 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('loaded_quickfix_auto_open') || &compatible
- finish
-endif
-if !has('autocmd') || v:version < 700
+if exists('loaded_quickfix_auto_open') || &compatible || v:version < 700
finish
endif
let loaded_quickfix_auto_open = 1
-" Open an appropriate quickfix or location list, depending on the command
-function! s:Open(command) abort
-
- " The command starts with 'l', so we'll be opening a location list
- if strpart(a:command, 0, 1) ==# 'l'
-
- " I can't figure out anything sensible to do for the :lhelpgrep command,
- " but for all the other location window commands, :lwindow is sensible
- if a:command !=# 'lhelpgrep'
- lwindow
- endif
-
- " The command did not start with 'l', so we can just open the quickfix
- " window, and we're done
- else
- cwindow
-
- endif
-
-endfunction
-
" Set up hooks in self-clearing group
augroup quickfix_auto_open
autocmd!
-
- " Run whenever a command changes a quickfix or location list
- if exists('##QuickFixCmdPost')
- autocmd QuickFixCmdPost *
- \ call s:Open(expand('<amatch>'))
- endif
-
- " Run on Vim startup completion to open any quickfix list already present,
- " with a blank command name
- if exists('##VimEnter')
- autocmd VimEnter *
- \ call s:Open('')
- endif
-
+ autocmd VimEnter *
+ \ cwindow
+ autocmd QuickFixCmdPost [^l]*
+ \ cwindow
+ autocmd QuickFixCmdPost l*
+ \ lwindow
augroup END