From 723a58f7a55796198d3f1974c148ad9de44d579a Mon Sep 17 00:00:00 2001 From: robin92pl Date: Fri, 23 Apr 2021 11:49:27 +0200 Subject: [PATCH] Try to set ackprg on every invocation Before this change, plugin would stop initialization unless g:ackprg has been found. This would prohibit from loading :Ack, :AckFromSearch and other autoload commands from being accessible. With this patch, plugin continues initialization when g:ackprg is missing and retries setting it when one of the autoload commands is called. --- autoload/ack.vim | 1 + plugin/ack.vim | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/autoload/ack.vim b/autoload/ack.vim index b6afdba4..4e35bebf 100644 --- a/autoload/ack.vim +++ b/autoload/ack.vim @@ -16,6 +16,7 @@ endif "----------------------------------------------------------------------------- function! ack#Ack(cmd, args) "{{{ + call ack#UpdateAckPrg() call s:Init(a:cmd) redraw diff --git a/plugin/ack.vim b/plugin/ack.vim index 202ae2ea..05c72c13 100644 --- a/plugin/ack.vim +++ b/plugin/ack.vim @@ -6,17 +6,21 @@ if !exists("g:ack_default_options") let g:ack_default_options = " -s -H --nopager --nocolor --nogroup --column" endif -" Location of the ack utility -if !exists("g:ackprg") - if executable('ack-grep') - let g:ackprg = "ack-grep" - elseif executable('ack') - let g:ackprg = "ack" - else - finish +function! ack#UpdateAckPrg() "{{{ + " Location of the ack utility + if !exists("g:ackprg") + if executable('ack-grep') + let g:ackprg = "ack-grep" + elseif executable('ack') + let g:ackprg = "ack" + else + return + endif + let g:ackprg .= g:ack_default_options endif - let g:ackprg .= g:ack_default_options -endif +endfunction "}}} + +call ack#UpdateAckPrg() if !exists("g:ack_apply_qmappings") let g:ack_apply_qmappings = !exists("g:ack_qhandler")