Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow get_cwd() function to return an array #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

None yet

2 participants