I'm writting a function to integrates NERDTree with Ack. The goal is to create a "Find in Directory".
I create this:
function! Fif_NERDTreeGetPath()
let nodePath = g:NERDTreeFileNode.GetSelected().path.str()
return nodePath
endfunction
:command! -nargs=+ Fif :Ack "<args>" Fif_NERDTreeGetPath()
The function Fif_NERDTreeGetPath()
returns the correct path for the directory that cursor is on.
But, when I execute Fif word
it return:
:ack -s -H --nopager --nocolor --nogroup --column "word" Fif_NERDTreeGetPath()
It's almost right. The problem is the path is not being returned. I'm expecting something like:
:ack -s -H --nopager --nocolor --nogroup --column "word" /path/to/directory/
This is my first vim function. I don't know how to solve. Tks!
execute
solves. The final command for Find In Files with NERDTree and Ack.vim is::command! -nargs=+ Fif let node_path = g:NERDTreeFileNode.GetSelected().path.str() | :execute "normal! \<c-w>\<c-w>" | :execute ':Ack "<args>" ' . node_path
. When I position the cursor on the NerdTree directory node, I run:Fif keyword
and everything works fine.