NvChad / ui

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

Types not recognised #331

Closed KorigamiK closed 4 weeks ago

KorigamiK commented 4 weeks ago

Describe the bug NvChad types are not recognized anymore.

Expected behavior No diagnostic errors

Screenshots

   └╴-  lua/  8 
     ├╴-  chadrc.lua  3 
     │ ├╴- Undefined type or alias `ChadrcConfig`. Lua Diagnostics. (undefined-doc-name) [1, 10]
     │ ├╴- Fields cannot be injected into the reference of `ChadrcConfig` for `ui`. To do so, use `---@class` for `M`. Lua Diagnostics. (inject-field) [6, 3]
     │ └╴- Fields cannot be injected into the reference of `ChadrcConfig` for `base46`. To do so, use `---@class` for `M`. Lua Diagnostics. (inject-field) [38, 3]
     ├╴-  highlights.lua  2 
     │ ├╴- Undefined type or alias `Base46HLGroupsList`. Lua Diagnostics. (undefined-doc-name) [7, 10]
     │ └╴- Undefined type or alias `HLTable`. Lua Diagnostics. (undefined-doc-name) [27, 10]
     └╴-  plugins/  3 
       └╴-  init.lua  3 
         ├╴- Undefined type or alias `NvPluginSpec`. Lua Diagnostics. (undefined-doc-name) [1, 10]
         ├╴- The same file is required with different names. Lua Diagnostics. (different-requires) [42, 20]
         └╴- Undefined type or alias `LazyKeymaps`. Lua Diagnostics. (undefined-doc-name) [277, 24]

Desktop (please complete the following information):

siduck commented 4 weeks ago

show your lspconfig

KorigamiK commented 4 weeks ago

Here it is:

local configs = require "nvchad.configs.lspconfig"

configs.defaults()
local handlers = {
  ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }),
  ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }),
}

local on_attach = configs.on_attach
local on_init = configs.on_init
local capabilities = configs.capabilities

local lspconfig = require "lspconfig"

lspconfig.lua_ls.setup {
  handlers = handlers,
}
siduck commented 4 weeks ago

image

you removed the types there... copy the ones from our default lua_ls setup

KorigamiK commented 4 weeks ago

Why isn't the lua_ls table not extended? The handlers are not set in the default configuration either:

  require("lspconfig").lua_ls.setup {
    on_attach = M.on_attach,
    capabilities = M.capabilities,
    on_init = M.on_init,

    settings = {
      Lua = {
        diagnostics = {
          globals = { "vim" },
        },
        workspace = {
          library = {
            vim.fn.expand "$VIMRUNTIME/lua",
            vim.fn.expand "$VIMRUNTIME/lua/vim/lsp",
            vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types",
            vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy",
            "${3rd}/luv/library",
          },
          maxPreload = 100000,
          preloadFileSize = 10000,
        },
      },
    },
  }
siduck commented 4 weeks ago

not extended

that isnt nvchad thing, its how lspconfig does things..

siduck commented 4 weeks ago

why do you have to set handlers in lsp's setup? its a global thing right

KorigamiK commented 4 weeks ago

why do you have to set handlers in lsp's setup? its a global thing right

It's because lsp hover doesn't have borders on by default in NvChad. Maybe it's worth adding the handlers in the default nchad configuration as well?

https://github.com/LazyVim/LazyVim/issues/556#issuecomment-1501207493

KorigamiK commented 4 weeks ago

why do you have to set handlers in lsp's setup? its a global thing right

But I am modifying literally the same table after the default configuration is added right? Why doesn't it add on to the existing lua_ls table?

siduck commented 4 weeks ago

.setup doesnt modify the old values, it initializes with whatever key/vals it has