Skip to content

Conversation

@riton
Copy link

@riton riton commented Feb 18, 2023

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.

⚠️ I'm a real beginner in lua so the code may be far from optimal 🧑‍🎓

* Add support for multiple completion directories.
  Motivation: complete from both the 'buffer cwd' and
  'the cwd where neovim was opened'
@zhou13
Copy link

zhou13 commented Mar 3, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants