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

Error: No locations found #39

Closed mrphil2105 closed 4 months ago

mrphil2105 commented 4 months ago

When using any of the functions provided I get the error "No locations found". OmniSharp is installed via Mason and is working fine if not called through omnisharp_extended. Any idea what might be causing this?

Hoffs commented 4 months ago

Hello, Have you provided correct path to OmniSharp when configuring LSP? It'd be great if you could provide:

  1. Output of :LspInfo
  2. Enable LSP debug logging via vim.lsp.set_log_level("DEBUG") and provide the output of :LspLog after you tried using one of the commands
mrphil2105 commented 4 months ago

1.

 Language client log: /home/mrphil2105/.local/state/nvim/lsp.log
 Detected filetype:   cs

 1 client(s) attached to this buffer: 

 Client: omnisharp (id: 1, bufnr: [4])
    filetypes:       cs, vb
    autostart:       true
    root directory:  /home/mrphil2105/CSharp Projects/BachelorProject
    cmd:             omnisharp -z --hostPID 15106 DotNet:enablePackageRestore=false --encoding utf-8 --languageserver FormattingOptions:EnableEditorConfigSupport=true Sdk:IncludePrereleases=true

2.

[DEBUG][2024-06-29 18:46:04] ...m/lsp/client.lua:676    "LSP[omnisharp]"    "client.request"    1   "o#/v2/gotodefinition"  {  column = 21,  fileName = "/home/mrphil2105/CSharp%20Projects/BachelorProject/WebApi/Controllers/SubmissionController.cs",  line = 14}    <function 1>    4
[DEBUG][2024-06-29 18:46:04] .../vim/lsp/rpc.lua:286    "rpc.send"  {  id = 17,  jsonrpc = "2.0",  method = "o#/v2/gotodefinition",  params = {    column = 21,    fileName = "/home/mrphil2105/CSharp%20Projects/BachelorProject/WebApi/Controllers/SubmissionController.cs",    line = 14  }}
[DEBUG][2024-06-29 18:46:04] .../vim/lsp/rpc.lua:408    "rpc.receive"   {  id = 17,  jsonrpc = "2.0",  result = {}}
[DEBUG][2024-06-29 18:46:05] ...m/lsp/client.lua:676    "LSP[omnisharp]"    "client.request"    1   "textDocument/signatureHelp"    {  position = {    character = 21,    line = 14  },  textDocument = {    uri = "file:///home/mrphil2105/CSharp%20Projects/BachelorProject/WebApi/Controllers/SubmissionController.cs"  }}   <function 1>    4
[DEBUG][2024-06-29 18:46:05] .../vim/lsp/rpc.lua:286    "rpc.send"  {  id = 18,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 21,      line = 14    },    textDocument = {      uri = "file:///home/mrphil2105/CSharp%20Projects/BachelorProject/WebApi/Controllers/SubmissionController.cs"    }  }}
[DEBUG][2024-06-29 18:46:05] .../vim/lsp/rpc.lua:408    "rpc.receive"   {  id = 18,  jsonrpc = "2.0"}

OmniSharp is only installed through Mason and I do not set it up in any specific way in my LSP config other than doing the following:

require("mason-lspconfig").setup_handlers {
    function(server_name)
        require("lspconfig")[server_name].setup {
            capabilities = capabilities,
            on_attach = on_attach,
            settings = servers[server_name],
            filetypes = (servers[server_name] or {}).filetypes,
        }
    end,
}
Hoffs commented 4 months ago

Hmm, looks fine more or less. On what symbol are you trying to invoke go to definition?

Hoffs commented 4 months ago

Okay, managed to replicate it, the fact that your directory "CSharp Projects" contains spaces causes the issue. Seems like omnisharp does not like that it gets url encoded (space -> %20), will see what's the deal here.

Hoffs commented 4 months ago

Merged an update that should resolve this issue, in my testing it works well on both Windows and Unix when directories have spaces (it should also handle other URI encoding thingies).

If you still have issues, feel free to reopen this issue.