NvChad / ui

Lightweight & high performance UI plugin for nvchad
GNU General Public License v3.0
286 stars 130 forks source link

Type error for plugin `keys` field #226

Closed KorigamiK closed 8 months ago

KorigamiK commented 9 months ago

Passing a function to NvPluginSpec.keys for example:

  {
    "folke/which-key.nvim",
    keys = function()
      return { "<leader>" }
    end,
  }

Raises the diagnostic error:

Diagnostics:
Cannot assign `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` to `(string|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?`.
- `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match `(string|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?`
- `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match any subtypes in `(string|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?`
- Type `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match `nil`
- Type `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match `fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]`
- Type `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match `LazyKeymaps[]`
- Type `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match `string[]`
- Type `(string|function|LazyKeymaps[]|fun(_: LazyPlugin, keys: string[]):string|LazyKeymaps[]|string[])?` cannot match `string` [assign-type-mismatch]

Not really sure what's wrong here

siduck commented 8 months ago

looks like type issue in nvchad_types, as @lucario387 's left using base46, i cant ask him to contribute.

ig time to learn how to make lua types myself

lucario387 commented 8 months ago

... But you can :)

siduck commented 8 months ago

@KorigamiK this is related to the type we use from lazy.nvim so not our issue kinda. https://github.com/folke/lazy.nvim/issues/1268

lucario387 commented 8 months ago

Figured out why :) Lua-ls cannot figure out the types of the resulting table image

lucario387 commented 8 months ago

Found the fix

lucario387 commented 8 months ago

@KorigamiK can you test again?

KorigamiK commented 8 months ago

@KorigamiK can you test again?

You got it. it is fixed :smile:

lucario387 commented 8 months ago

:)