cmp-path icon indicating copy to clipboard operation
cmp-path copied to clipboard

feat: Allow get_cwd() function to return an array

Open riton opened this issue 2 years ago • 1 comments

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:

riton avatar Feb 18 '23 14:02 riton

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!

zhou13 avatar Mar 03 '23 00:03 zhou13