Case
A user defined command to open files recursively in a directory.
The command
After weeks trying to get this to work, I got to the following code after trying to understand this answer:
function! DumbnoteOpenNote(...)
let Note = a:1
execute "e " Note
endfunction
function! DumbnotePathsCompletion(...)
return split(globpath(g:dumbnoteDefaultCollection, '**/*'), '\n')
endfunction
command! -bang -complete=customlist,DumbnotePathsCompletion -nargs=* DumbnoteOpenNote call DumbnoteOpenNote(<f-args>)
The problem
Given the following directory structure:
|--ADirectory
|--BDirectory
| |--Afile
| |--Bfile
|
|--Cdirectory
| |--Afile
| |--Bfile
|
|--Afile
|--Bfile
|--Cfile
Typing:
:DumbnoteOpenNote <tab>
will expand to the path specified in the customlist
and the completion works just fine with both tab
and the arrows.
Here is my first question:
Does it really need to expand to the whole path (in this case /home/user/path/
)? When I use the command, I already know that I am looking for completion only in that path, and I don't need to see the whole path.
Is it possible to get completion from that path on?
Despite of that, if I type:
:DumbnoteOpenNote <tab>Bf<tab>
Hoping to get the completion to the Bfile
, the completion will just come back to the first alphabetical item. The same happens if typing:
:DumbnoteOpenNote <tab>CD<tab>
Assuming that the idea is to get completion to the CDirectory
. After that ..CD<tab>
the completion will - again - jump back to the first alphabetical item, in both cases it means BDirectory/
.
Why would the -complete=customlist
be alphabetically ordered? And is it possible to configure that?
This behavior happens both on Vim
Is it possible to get completion from that path on Vim 8 and Neovim 0.2 both installed from the official Archlinux repositories.
Any help on how to improve this question (and the ascii repository structure) is appreciated.
Thanks in advance!
execute "e " Note
so why don't you simply use:e
and:find
with yourpath
set properly (something likeset path+=**
for example)?:help :command-completion-customlist
).:h :command-completion-customlist
. I've been reading that help pages since some weeks ago, but haven't understood that yet... :/