Hoffs / omnisharp-extended-lsp.nvim

Extended 'textDocument/definition' handler for OmniSharp Neovim LSP (now also `textDocument/references`, `textDocument/implementation` and source generated files)
147 stars 18 forks source link

Not being able to go to definition #14

Closed AdamBremholm closed 2 years ago

AdamBremholm commented 2 years ago

I am getting the below error when trying to go to definition on an external library going to definition with: lua require('omnisharp_extended').telescope_lsp_definitions()

Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:1077: Cursor position outside buffer stack traceback: [C]: in function 'nvim_win_set_cursor' /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:1077: in function 'jump_to_location' ...ker/start/telescope.nvim/lua/telescope/builtin/__lsp.lua:175: in function 'handler' /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1241: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>

latest part from the lsp.log

./vim/lsp/rpc.lua:473 "rpc.receive" { id = 12, jsonrpc = "2.0", result = { activeParameter = 0, activeSignature = 1, signatures = { { documentation = '\n

\n Adds authorization policy services to the specified .\n \n The to add services to.\n The so that additional calls can be chained.\n ', label = "IServiceCollection IServiceCollection.AddAuthorization()", parameters = {} }, { documentation = '\n \n Adds authorization policy services to the specified .\n \n The to add services to.\n An action delegate to configure the provided .\n The so that additional calls can be chained.\n ', label = "IServiceCollection IServiceCollection.AddAuthorization(Action configure)", parameters = { { documentation = "An action delegate to configure the provided Microsoft.AspNetCore.Authorization.AuthorizationOptions .", label = "Action configure" } } } } }} [DEBUG][2022-09-02 20:12:46] .../lua/vim/lsp.lua:1239 "LSP[omnisharp]" "client.request" 1 "textDocument/definition" { position = { character = 37, line = 20 }, textDocument = { uri = "file:///home/adam/personal/car-api/CarConsole/Program.cs" }} <function 1> 4 [DEBUG][2022-09-02 20:12:46] .../vim/lsp/rpc.lua:364 "rpc.send" { id = 13, jsonrpc = "2.0", method = "textDocument/definition", params = { position = { character = 37, line = 20 }, textDocument = { uri = "file:///home/adam/personal/car-api/CarConsole/Program.cs" } }} [DEBUG][2022-09-02 20:12:46] .../vim/lsp/rpc.lua:473 "rpc.receive" { id = 13, jsonrpc = "2.0", result = { range = { end = { character = 41, line = 61 }, start = { character = 15, line = 61 } }, uri = "file:///%24metadata%24/Project/CarConsole/Assembly/Microsoft/AspNetCore/Authorization/Symbol/Microsoft/AspNetCore/Authorization/AuthorizationPolicyBuilder.cs" }}

~/.omnisharp » cat omnisharp.json { "RoslynExtensionsOptions": { "enableDecompilationSupport": true }

omnisharp works fine normally,. and is installed with: williamboman/nvim-lsp-installer }

go to definition works with vscode for same property.

nvim --version NVIM v0.8.0-dev

AdamBremholm commented 2 years ago

had another keymapping pointing to the normal lsp go to definition. Your plugin works fine thank you!

pluma9 commented 2 years ago

I got the same error. lua require('omnisharp_extended').lsp_definitions() also works for me.

Hi @AdamBremholm, could you please re-open this issue? The reason is that the README claims that this command is not necessary for neovim nightly, which implies that lua vim.lsp.buf.definition() should work.

Hoffs commented 2 years ago

The reason is that the README claims that this command is not necessary for neovim nightly, which implies that lua vim.lsp.buf.definition() should work

Hi @pluma9 , have you set the handler part of the config?

pluma9 commented 2 years ago

@Hoffs Yes, I have (I guess this is the reason why I can do lua require('omnisharp_extended').lsp_definitions()). My config:

local pid = vim.fn.getpid()
local omnisharp_bin = "D:\\programs\\omnisharp\\OmniSharp.exe"
local omnisharp_cmd = { omnisharp_bin, "--languageserver", "--hostPID", tostring(pid)}

require'lspconfig'.omnisharp.setup{
    cmd = omnisharp_cmd,
    on_new_config = function(new_config,new_root_dir)
        new_config.cmd = omnisharp_cmd
    end,
    on_attach = on_attach,
    root_dir = function(file, _)
        if file:sub(-#".csx") == ".csx" then
            return util.path.dirname(file)
        end
        return util.root_pattern("*.sln")(file) or util.root_pattern("*.csproj")(file)
    end,
    handler = {
        ["textDocument/definition"] = require('omnisharp_extended').handler,
    },
}
Hoffs commented 2 years ago

@pluma9 based on your config snippet, you have handler =, but it should be handlers = (see https://neovim.io/doc/user/lsp.html#lsp-handler-configuration , part following if using 'nvim-lspconfig'...). Being able to call lua require('omnisharp_extended').lsp_definitions() just means that plugin itself is installed/available.

pluma9 commented 2 years ago

@Hoffs It works like a charm now. Thanks for pointing that out.