aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-28 21:50:37 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-28 21:50:37 +1300
commit2347ea43e5078932663fe46e6ff9e35de54765a2 (patch)
tree1157d25d227a053635ab8081a9bf4cd8875cd002
parenta2eccef1861e2c0be988bc182d7b14be94ebc9ed (diff)
parent60e0ac1c36ad41cde3eb7096d57aa4befbd5ca86 (diff)
downloadvim-quickfix-auto-open-2347ea43e5078932663fe46e6ff9e35de54765a2.tar.gz
vim-quickfix-auto-open-2347ea43e5078932663fe46e6ff9e35de54765a2.zip
Merge branch 'release/v0.2.0'v0.2.0
* release/v0.2.0: Add VERSION New version handles :lhelpgrep
-rw-r--r--README.md15
-rw-r--r--VERSION1
-rw-r--r--doc/quickfix_auto_open.txt13
-rw-r--r--plugin/quickfix_auto_open.vim47
4 files changed, 59 insertions, 17 deletions
diff --git a/README.md b/README.md
index 12847ba..6e6a96d 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,21 @@
quickfix\_auto\_open.vim
========================
-This is a tiny plugin packaging of hooks to automatically open the quickfix and
-location lists when a command that changes their contents is run.
+This is a tiny plugin packaging of hooks to automatically open relevant
+quickfix and location lists when a command that changes their contents is run.
Credits
-------
-This is just a plugin repackaging of a fragment from romainl's "minivimrc"
-project on GitHub: <https://github.com/romainl/minivimrc>
+The original commands that do essentially all of this come from Romain
+Lafourcade (romainl)'s "minivimrc" project on GitHub:
+<https://github.com/romainl/minivimrc>
+
+Tom Ryder (tejr) extended them just a bit to handle the slightly different
+behavior of `:lhelpgrep`, and packaged and documented them for this
+distribution.
License
-------
Distributed under the same terms as Vim itself, probably. See `:help license`.
-
-[1]: https://sanctum.geek.nz/
diff --git a/VERSION b/VERSION
index e69de29..0ea3a94 100644
--- a/VERSION
+++ b/VERSION
@@ -0,0 +1 @@
+0.2.0
diff --git a/doc/quickfix_auto_open.txt b/doc/quickfix_auto_open.txt
index c9fc24b..745d882 100644
--- a/doc/quickfix_auto_open.txt
+++ b/doc/quickfix_auto_open.txt
@@ -1,9 +1,9 @@
-*quickfix_auto_open.txt* For Vim version 7.0 Last change: 2018 Jul 24
+*quickfix_auto_open.txt* For Vim version 7.0 Last change: 2018 Dec 28
DESCRIPTION *quickfix_auto_open*
-This is a tiny plugin packaging of hooks to automatically open the quickfix
-and location lists when a command that changes their contents is run.
+This is a tiny plugin packaging of hooks to automatically open relevant
+quickfix and location lists when a command that changes their contents is run.
REQUIREMENTS *quickfix_auto_open-requirements*
@@ -12,10 +12,13 @@ This plugin is only available if 'compatible' is not set. It also requires the
AUTHOR *quickfix_auto_open-author*
-Original commands were found in romainl's "minivimrc" project on GitHub:
+The original commands that do essentially all of this come from Romain
+Lafourcade (romainl)'s "minivimrc" project on GitHub:
<https://github.com/romainl/minivimrc>
-Plugin packaging and documentation by by Tom Ryder <tom@sanctum.geek.nz>.
+Tom Ryder (tejr) extended them just a bit to handle the slightly different
+behavior of |:lhelpgrep|, and packaged and documented them for this
+distribution.
LICENSE *quickfix_auto_open-license*
diff --git a/plugin/quickfix_auto_open.vim b/plugin/quickfix_auto_open.vim
index e2f111f..5ac821b 100644
--- a/plugin/quickfix_auto_open.vim
+++ b/plugin/quickfix_auto_open.vim
@@ -1,6 +1,6 @@
"
" quickfix_auto_open.vim: Always pop open the quickfix list or location list
-" when they're changed. Dispassionately stolen from romainl's minivimrc.
+" when they're changed.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
@@ -8,15 +8,50 @@
if exists('g:loaded_quickfix_auto_open') || &compatible
finish
endif
-if !exists('##QuickfixCmdPost') || !exists('##VimEnter')
+if !has('autocmd') || v:version < 700
finish
endif
let g:loaded_quickfix_auto_open = 1
-" Always pop open quickfix and location lists when changed
+" 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'
+
+ " If the command is 'lhelpgrep', we'll need to switch to the help window
+ " to open its location list rather than the current window's
+ if a:command ==# 'lhelpgrep'
+ help
+ endif
+
+ " Open location list if there's anything in it
+ lwindow
+
+ " 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!
- autocmd QuickfixCmdPost [^l]* cwindow
- autocmd QuickfixCmdPost l* lwindow
- autocmd VimEnter * cwindow
+
+ " 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
+
augroup END