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

attempt to index local 'opts' (a nil value) #50

Open
outp1 opened this issue Jan 5, 2025 · 1 comment
Open

attempt to index local 'opts' (a nil value) #50

outp1 opened this issue Jan 5, 2025 · 1 comment

Comments

@outp1
Copy link

outp1 commented Jan 5, 2025

I'm getting following error when trying to call handler:

Error executing vim.schedule lua callback: ...lazy/omnisharp-extended-lsp.nvim/lua/omnisharp_utils.lua:152: attempt to index local 'opts' (a nil value)
stack traceback:
        ...lazy/omnisharp-extended-lsp.nvim/lua/omnisharp_utils.lua:152: in function 'cmd_params'
        ...lazy/omnisharp-extended-lsp.nvim/lua/generic_command.lua:39: in function 'omnisharp_cmd'
        ...lazy/omnisharp-extended-lsp.nvim/lua/generic_command.lua:50: in function 'handler'
        ...nvim/lazy/omnisharp-extended-lsp.nvim/lua/definition.lua:140: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

My configuration looks like this. There is a small chance that it's an AstroNvim issue.

return {
  "AstroNvim/astrolsp",
  -- we need to use the function notation to get access to the `lspconfig` module
  ---@param opts AstroLSPOpts
  opts = function(plugin, opts)
    opts.servers = opts.servers or {}
    table.insert(opts.servers, "omnisharp")

    opts.config = require("astrocore").extend_tbl(opts.config or {}, {
      -- this must be a function to get access to the `lspconfig` module
      omnisharp = {
        handlers = {
          ["textDocument/definition"] = require("omnisharp_extended").definition_handler,
          ["textDocument/typeDefinition"] = require("omnisharp_extended").type_definition_handler,
          ["textDocument/references"] = require("omnisharp_extended").references_handler,
          ["textDocument/implementation"] = require("omnisharp_extended").implementation_handler,
        },

        -- the command for starting the server
        cmd = { "omnisharp", "--languageserver", "--hostPID", tostring(vim.fn.getpid()) },
        -- the filetypes to attach the server to
        filetypes = { "cs" },
        settings = {
          omnisharp = {
            enableDecompilationSupport = true,
          },
        },
        -- root directory detection for detecting the project root
        -- root_dir = require("lspconfig.util").root_pattern "pack.pl",
      },
    })
  end,
}

After i change line of plugin code from this:
excludeDefinition = opts.excludeDefinition or false,
to this:
excludeDefinition = false,
all works just fine

@Hoffs
Copy link
Owner

Hoffs commented Jan 6, 2025

As I understand #49 should have resolved this

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

No branches or pull requests

2 participants