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

MasonLspconfigSettings setup annotation #500

Open
polirritmico opened this issue Dec 17, 2024 · 2 comments
Open

MasonLspconfigSettings setup annotation #500

polirritmico opened this issue Dec 17, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@polirritmico
Copy link

polirritmico commented Dec 17, 2024

Is your feature request related to a problem? Please describe.

Hi,

Since the setup annotation defines the use of MasonLspconfigSettings for the config options, the lsp diagnostics complains when passing a table without some fields like the options table from the README example:

imagen

Since internally, mason-lspconfig is using vim.tbl_deep_extend between the user options and the defaults inside the settings.set call, the resulting setting.current is indeed a MasonLspconfigSettings type, so there's no need to "force it".

Describe the solution you'd like

It would be a nice touch if the annotations offers some flexibility to avoid those warnings or the usage of ---@diagnostic disable [missing-fields].

Describe potential alternatives you've considered

This could be fixed in a lot of ways. For example this two approaches:

  1. Add a user config type like MasonLspconfigUserSettings:
---@class MasonLspconfigUserSettings
---@field ensure_installed? string[]
---@field automatic_installation? boolean
---@field handlers? type table<string, fun(server_name: string)>
---@param config MasonLspconfigUserSettings | MasonLspconfigSettings | nil
function M.setup(config)
    if config then
        settings.set(config)
    end
    -- etc.
end
  1. Make the MasonLspconfigSettings fields optional:
---@class MasonLspconfigSettings
local DEFAULT_SETTINGS = {
    ---@type string[]?
    ensure_installed = {},
    ---@type boolean?
    automatic_installation = false,
    ---@type table<string, fun(server_name: string)>?
    handlers = nil,
}

Additional context

If it helps I can work on the PR; I just need to know the selected approach.

Regards


Edit: update the first approach annotations

@polirritmico polirritmico added the enhancement New feature or request label Dec 17, 2024
@sebazelonka
Copy link

Same issue here, I started to setup neovim today and I found the same message. Is this an issue or only a warning?

@polirritmico
Copy link
Author

polirritmico commented Dec 21, 2024

Same issue here, I started to setup neovim today and I found the same message. Is this an issue or only a warning?

Just a warning. Use ---@diagnostic disable [missing-fields] or pass all the MasonLspconfigSettings fields to the setup call until this is addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants