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

Change nvim_create_autocmd callback to a lambda #1295

Merged

Conversation

chiting
Copy link
Contributor

@chiting chiting commented May 30, 2023

Related to #1140

callback in vim.api.nvim_create_autocmd() seems to require a lambda.

I didn't test it for VimScript or Neovim v0.5.0+ so I didn't change it for these.

@chiting chiting requested a review from a team as a code owner May 30, 2023 22:11
@hashicorp-cla
Copy link

hashicorp-cla commented May 30, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback in vim.api.nvim_create_autocmd() seems to require a lambda.

Can you be a bit more specific - are you suggesting that auto-formatting is not triggered without the lambda, or that you get an error?

I'm not that familiar with Lua or Vim, but the two snippets of code seem equivalent to me so I'm somewhat surprised if this makes a difference.

@radeksimko radeksimko added documentation Improvements or additions to documentation waiting-response labels Jun 13, 2023
@chiting
Copy link
Contributor Author

chiting commented Jul 6, 2023

callback in vim.api.nvim_create_autocmd() seems to require a lambda.

Can you be a bit more specific - are you suggesting that auto-formatting is not triggered without the lambda, or that you get an error?

I'm not that familiar with Lua or Vim, but the two snippets of code seem equivalent to me so I'm somewhat surprised if this makes a difference.

I was getting an error and went to check the lua documentation which uses a lua function as parameter for the callback (or a string if it's a VimScript function name): https://neovim.io/doc/user/api.html#nvim_create_autocmd()

I'm not that familiar with lua either but it seems to me we're assigning the result returned by the function to the callback in the original snippet, instead of the function itself.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me we're assigning the result returned by the function to the callback in the original snippet, instead of the function itself

That looks like a plausible explanation which I'm going to trust 😅 Thanks for this extra context.

@radeksimko radeksimko merged commit 7fce3c3 into hashicorp:main Jul 6, 2023
@chiting chiting deleted the fix-example-usage-neovim-0-8-plus branch July 14, 2023 09:39
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation waiting-response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants