From 4f32a207195440c39d66394da451862f2e92ce92 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 28 Dec 2018 21:47:01 +1300 Subject: New version handles :lhelpgrep --- README.md | 15 ++++++++------ doc/quickfix_auto_open.txt | 13 +++++++----- plugin/quickfix_auto_open.vim | 47 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 58 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: +The original commands that do essentially all of this come from Romain +Lafourcade (romainl)'s "minivimrc" project on GitHub: + + +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/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: -Plugin packaging and documentation by by Tom Ryder . +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 " 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('')) + 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 -- cgit v1.2.3 From 60e0ac1c36ad41cde3eb7096d57aa4befbd5ca86 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 28 Dec 2018 21:47:33 +1300 Subject: Add VERSION --- VERSION | 1 + 1 file changed, 1 insertion(+) diff --git a/VERSION b/VERSION index e69de29..0ea3a94 100644 --- a/VERSION +++ b/VERSION @@ -0,0 +1 @@ +0.2.0 -- cgit v1.2.3