That's because of how the globbing works: single star *
symbol does not match hidden files by design. In the shell default globbing style could be changed to do so (shopt -s dotglob
in Bash), but it seems that it's not easily reachable in Vim.
You have several possibilities to solve your problem anyway. First and most obvious is to glob hidden and not hidden files separately and then concatenate results, like this:
let backup_path = '~/.vimbackup'
let s:backup_files = glob(backup_path . '/*') . "\n" . glob(backup_path . '/.[^.]*')
(Be careful not to fetch .
and ..
along with hidden files.)
Another and probably more convenient way (but less portable, though) is to use backticks expansion in glob
:
let backup_path = '~/.vimbackup'
let s:backup_files = glob('`find ' . backup_path . ' -maxdepth 1 -type f`')
This forces Vim to execute the command inside backticks to get the list of globbing files, and find
lists all files (-type f
tells to list files, not directories) including hidden ones, in the specified directory (-maxdepth 1
forbids recursion).