Skip to content

update guidance about plugin config typing#30

Merged
mrcjkb merged 1 commit intolumen-oss:mainfrom
mrjones2014:mrj/push-zqrnwoxmxqpp
Mar 19, 2026
Merged

update guidance about plugin config typing#30
mrcjkb merged 1 commit intolumen-oss:mainfrom
mrjones2014:mrj/push-zqrnwoxmxqpp

Conversation

@mrjones2014
Copy link
Contributor

Nowadays, lua_ls supports (partial) classes, basically you can inherit from another class but make all its fields nullable.

For example:

---@class SomeClass
---@field test boolean

---@class (partial) PartialClass: SomeClass

---@type SomeClass
local thing = {} -- warning about missing `test` field

---@type PartialClass
local thing2 = {} -- no warning because `test` field is nullable/optional

I've used this successfully in a few plugins, it works really nicely.

@mrcjkb
Copy link
Member

mrcjkb commented Mar 10, 2026

Thanks for your suggestion 🙏

This approach has some potential caveats:

  1. Can you generate useful vimdoc from (partial) classes (using panvimdoc or vimcats, etc.)?
    It isn't used anywhere in Neovim core, so I'm guessing there isn't good support for it yet.
    I will have to look into adding support for this to vimcats when I have some time.
  2. You have expose the internal class as part of the public API, which may not be worth the reduced boilerplate in some cases.

On the other hand, it potentially means less effort in keeping the classes synchronised.
For now, I'd recommend not to remove the existing section, but state that (partial) classes are an option (while mentioning the caveats).

@mrjones2014
Copy link
Contributor Author

Good point! I'll fix up the PR some time this week.

@mrjones2014 mrjones2014 force-pushed the mrj/push-zqrnwoxmxqpp branch from dc1f359 to c11e542 Compare March 18, 2026 20:48
@mrjones2014 mrjones2014 force-pushed the mrj/push-zqrnwoxmxqpp branch from c11e542 to e625bf5 Compare March 18, 2026 20:49
@mrjones2014
Copy link
Contributor Author

Updated

@mrcjkb mrcjkb merged commit 4b82929 into lumen-oss:main Mar 19, 2026
1 check passed
@mrjones2014 mrjones2014 deleted the mrj/push-zqrnwoxmxqpp branch March 19, 2026 14:23
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