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

fix: Mark fields in user_option and user_surround as optional #308

Merged

Conversation

thalesmello
Copy link
Contributor

Type linter complains that missing options should be valid in configuration, when in fact they're optional. This marks the fields as optional.

@kylechui
Copy link
Owner

Just out of curiosity, what linter are you using? I can't seem to be able to replicate this using LuaLS and selene. I'm not opposed to merging this in, but I'm also curious about how the placement of ? matters, i.e. ---@field var? type vs. ---@field var type?. I suspect the former means field not required and the latter means field required, but may be nil, but I would like clarification on that.

@thalesmello
Copy link
Contributor Author

Hi.

I'm using LuaLS + neodev, and I had warnings in my nvim-surround config that motivated me to try to find a way to make the fields optional.

I'm not a Lua expert, so I'm not sure I'm doing the right thing here. I tried adding the field? question mark, and it got rid of the warnings in the way I was expecting, and it still provides completion, so it at least it works.

I tried to look for official documentation, but I couldn't find any info about optional fields, only optional params, and optional type?. I'm wondering whether field? could be undocumented behavior, of it might even be the same thing as type? considering table.field = nil is how you delete a field in Lua.

Also, would you mind also testing this branch to make sure it also works in another setup?

@kylechui
Copy link
Owner

Hmm strange, I've also been using neodev. I believe this should be a LuaLS issue, but I've been unable to reproduce it for myself, despite best efforts. I tried adding the ? to keymaps, and see this in my autocomplete:
image

However, I don't get any warnings/errors about missing fields etc. Have you updated nvim-surround/LuaLS to their latest respective versions?

@gregorias
Copy link

The question mark behavior is documented for @param, and it’s also present in the syntax for @field.

Type linter complains that missing options should be valid in
configuration, when in fact they're optional. This markes the
fields as optional.
@kylechui kylechui force-pushed the bugfix/mark-user-option-fields-optional branch from 55764e2 to d82fde4 Compare April 10, 2024 15:12
@kylechui kylechui merged commit f7bb9fc into kylechui:main Apr 11, 2024
4 checks passed
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.

3 participants