cmp-path
cmp-path copied to clipboard
feat: Allow get_cwd() function to return an array
This P.R allows get_cwd()
function to return an array.
My motivation is to use a custom get_cwd()
function such as
get_cwd = function(params)
return {
vim.fn.expand(('#%d:p:h'):format(params.context.bufnr)), -- default value
vim.fn.getcwd(),
}
end
that allows to have completion for both the buffer cwd (current behavior) and for the cwd where neovim was opened for relative paths.
I've tried to handle the get_cwd()
returns a string case not to break user configurations with custom get_cwd()
.
So, no backward incompatibility is expected.
:warning: I'm a real beginner in lua
so the code may be far from optimal :student:
I have the same problem. The default relative path does not work sometimes. It is better if your example cwd
is the default behavior. Thank you for the PR!