Git Product home page Git Product logo

omnisharp-extended-lsp.nvim's Introduction

omnisharp-extended-lsp.nvim

Extended LSP handlers and additional commands that support and are aware of OmniSharp $metadata documents (e.g. decompilation) and source generated documents.

Currently supported commands:

  • textDocument/definition
  • textDocument/typeDefinition
  • textDocument/references
  • textDocument/implementation

Related issue on $metadata documents: OmniSharp/omnisharp-roslyn#2238

How to use

There are 2 ways to use the plugin, using custom command or overriding lsp handler.

(tested with Neovim 0.9.5 on Windows and 0.10.0 nightly on MacOS)

Custom command (Optimal)

Using provided custom command for each supported action:

-- replaces vim.lsp.buf.definition()
nnoremap gd <cmd>lua require('omnisharp_extended').lsp_definition()<cr>

-- replaces vim.lsp.buf.type_definition()
nnoremap <leader>D <cmd>lua require('omnisharp_extended').lsp_type_definition()<cr>

-- replaces vim.lsp.buf.references()
nnoremap gr <cmd>lua require('omnisharp_extended').lsp_references()<cr>

-- replaces vim.lsp.buf.implementation()
nnoremap gi <cmd>lua require('omnisharp_extended').lsp_implementation()<cr>

These commands will call appropriate OmniSharp provided LSP command directly (e.g. o#/v2/gotodefinition instead of textDocument/definition). OmniSharp commands provide information about metadata files (decompiled assemblies and such) and source generated files. If results contain any of these files, the handler will then try to create read-only buffers before bringing up quickfix list or navigating to single result.

Custom command for Telescope

There are also commands provided specifically for nvim-telescope users:

nnoremap gr <cmd>lua require('omnisharp_extended').telescope_lsp_references()<cr>
-- options are supported as well
nnoremap gd <cmd>lua require('omnisharp_extended').telescope_lsp_definition({ jump_type = "vsplit" })<cr>
nnoremap <leader>D <cmd>lua require('omnisharp_extended').telescope_lsp_type_definition()<cr>
nnoremap gi <cmd>lua require('omnisharp_extended').telescope_lsp_implementation()<cr>

Custom handler (Suboptimal)

Using provided custom LSP handler for each supported action:

local config = {
  ...
  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,
  },
  ...
}

require'lspconfig'.omnisharp.setup(config)

Custom handler is invoked for results of respective LSP native command (e.g. vim.lsp.buf.definition()). The handler then checks the results and if it determines that the result may contain non-local files (metadata, source generated) or that the request was made from within metadata file, it will retry the request using Custom command method, mentioned above. This means, that in some cases, LSP will be called twice, compared to always once, when using a command approach (not counting when there is a need to retrieve metadata/source generated file contents).

OmniSharp settings

For decompilation to work, OmniSharp extension for decompilation support might need to be enabled. See omnisharp wiki for information where omnisharp.json needs to be placed (~/.omnisharp/omnisharp.json).

{
  "RoslynExtensionsOptions": {
    "enableDecompilationSupport": true
  }
}

Important notes

  • Plugin searches for LSP server configured with the name omnisharp or omnisharp_mono, so if your server is configured using a different name, this will not work out of the box.
  • Navigation from within source generated files does not seem to be supported by omnisharp itself. Source generated files are technically identified by 2 UUID's, but gotodefinition expects a file name, so technically these 2 can't map to each other. Maybe in the future omnisharp devs will think of a way to make this work.
  • Telescope preview does not work for "special" files as they are not actually accessible files. It should be possible to modify buffer_previewer_maker to handle this, but currently has not been implemented.

omnisharp-extended-lsp.nvim's People

Contributors

chewcw avatar hoffs avatar miksuh-dev avatar tcrundall avatar torgst avatar zoriya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

omnisharp-extended-lsp.nvim's Issues

GotoDefinition from external Libraries

This is not a real issue since it it not the problem of your plugin, but I wanted to know if it is only me who has that problem, that I am not able to go to external libraries.
I always get the error:

Error executing vim.schedule lua callback: ...t_nvimWvgMgH/usr/share/nvim/runtime/lua/vim/lsp/util.lua:997: Cursor
position outside buffer
stack traceback:
[C]: in function 'nvim_win_set_cursor'
...t_nvimWvgMgH/usr/share/nvim/runtime/lua/vim/lsp/util.lua:997: in function 'jump_to_location'
...imWvgMgH/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:343: in function 'handler'
....mount_nvimWvgMgH/usr/share/nvim/runtime/lua/vim/lsp.lua:1025: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

I guess somehow it doesn't find the correct way since it opens afterward a buffer with the correct name.

If this problem is not only mine, would it be maybe possible to extend this plugin such that this is also possible?

Add windows support

Go to definitions currently doesn't support windows. I think because the matcher and defolderize only catch / but not \\.

lsp.log

[DEBUG][2022-01-21 14:11:54] .../lua/vim/lsp.lua:1023	"LSP[omnisharp]"	"client.request"	1	"textDocument/definition"	{  position = {    character = 18,    line = 4  },  textDocument = {    uri = "file:///C:/Users/IlhamAgustiawan/dev/personal/TodoApi/Program.cs"  }}	<function 1>	3
[DEBUG][2022-01-21 14:11:54] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 3,  jsonrpc = "2.0",  method = "textDocument/definition",  params = {    position = {      character = 18,      line = 4    },    textDocument = {      uri = "file:///C:/Users/IlhamAgustiawan/dev/personal/TodoApi/Program.cs"    }  }}
[DEBUG][2022-01-21 14:11:54] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 3,  jsonrpc = "2.0",  result = {    range = {      end = {        character = 48,        line = 42      },      start = {        character = 34,        line = 42      }    },    uri = "file:///%24metadata%24%5CProject%5CTodoApi%5CAssembly%5CMicrosoft%5CAspNetCore%5CMvc%5CSymbol%5CMicrosoft%5CExtensions%5CDependencyInjection%5CMvcServiceCollectionExtensions.cs"  }}

Options for how to manage buffers

Hi, it's me again.

It might be that this lies without the scope of this extension, but here goes.

I'd like to handle buffers a bit differently:

  1. Close "definition buffers" once they lose focus.
  2. Keep subsequent definitions in the same buffer.

And possibly related to this, I've noticed that if I go to a definition I can close that buffer without issue.
However, the second time I go to the same definiton, the buffer is marked as edited - so that it asks me if I want to save before closing it.

All of this could also be me who is still confused about buffers in vim, and the fact that I am using some plugins I've yet to understand (thanks to nvchad/nvchad).

vim.lsp.buf.definition fails

💔 Problem

Any ideas how I can make vim.lsp.buf.definition() work?

Calling :lua vim.lsp.buf.definition() errors with this

Error executing vim.schedule lua callback: ...9.0/nvim-linux64/share/nvim/runtime/lua/vim/lsp/util.lua:1157: Cursor posi
tion outside buffer
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        ...9.0/nvim-linux64/share/nvim/runtime/lua/vim/lsp/util.lua:1157: in function 'jump_to_location'
        ...nvim-linux64/share/nvim/runtime/lua/vim/lsp/handlers.lua:412: in function 'handler'
        ...b/v0.9.0/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:1394: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
Press ENTER or type command to continue

But calling :lua require('omnisharp_extended').lsp_definitions() works (decompiles and opens a buffer with the method). I am sure there is something obvious I missed but I've not been able to find it.

🗃️ Setup

I am using Neovim v0.9.0 and here is the change I made to my dotfiles:

use 'Hoffs/omnisharp-extended-lsp.nvim'

...

lsp_config.omnisharp.setup({
  ...
  handers = {
    ["textDocument/definition"] = require('omnisharp_extended').handler
  }
})

(commit)

Omnisharp not working with LazyVim and bloating the lsp.log file (13GB+ and counting)

My ~/.local/state/nvim/lsp.log is rapidly filling up with garbage. I think, for every keystroke, the following is being added to that file

click here to expand
[START][2024-05-14 08:35:52] LSP logging initiated
[ERROR][2024-05-14 08:35:52] ...lsp/handlers.lua:535	"OmniSharp.Script.ScriptContextProvider: Failed to resolve compilation dependencies - System.NullReferenceException: Object reference not set to an instance of an object.\n   at Dotnet.Script.DependencyModel.Context.DotnetRestorer.<Restore>g__CreateConfigFileArgument|4_1(<>c__DisplayClass4_0&)\n   at Dotnet.Script.DependencyModel.Context.DotnetRestorer.Restore(ProjectFileInfo projectFileInfo, String[] packageSources)\n   at Dotnet.Script.DependencyModel.Context.ProfiledRestorer.Restore(ProjectFileInfo projectFileInfo, String[] packageSources)\n   at Dotnet.Script.DependencyModel.Compilation.CompilationDependencyResolver.GetDependencies(String targetDirectory, IEnumerable`1 scriptFiles, Boolean enableScriptNugetReferences, String defaultTargetFramework)\n   at OmniSharp.Script.ScriptContextProvider.CreateScriptContext(ScriptOptions scriptOptions, String[] allCsxFiles, Boolean editorConfigEnabled) in /Users/runner/work/1/s/src/OmniSharp.Script/ScriptContextProvider.cs:line 89 | "
[WARN][2024-05-14 08:35:52] ...lsp/handlers.lua:537	"OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = o#/backgrounddiagnosticstatus, Params = {\n  \"Status\": 0,\n  \"NumberProjects\": 1,\n  \"NumberFilesTotal\": 1,\n  \"NumberFilesRemaining\": 0\n}, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = o#/backgrounddiagnosticstatus, Params = {\n  \"Status\": 0,\n  \"NumberProjects\": 1,\n  \"NumberFilesTotal\": 1,\n  \"NumberFilesRemaining\": 0\n}, TraceParent = , TraceState =  }'"
[WARN][2024-05-14 08:35:52] ...lsp/handlers.lua:537	"OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = o#/backgrounddiagnosticstatus, Params = {\n  \"Status\": 0,\n  \"NumberProjects\": 1,\n  \"NumberFilesTotal\": 1,\n  \"NumberFilesRemaining\": 0\n}, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = o#/backgrounddiagnosticstatus, Params = {\n  \"Status\": 0,\n  \"NumberProjects\": 1,\n  \"NumberFilesTotal\": 1,\n  \"NumberFilesRemaining\": 0\n}, TraceParent = , TraceState =  }'"

I have removed most of the output because I was hitting the character limit for the create issue form, but have uploaded it in full here

As you can imagine, this adds up quickly, and before long my log file was 13GB in size. One question that occurred to me is - does Hoffs/omnisharp-extended-lsp.nvim install OmniSharp/omnisharp-roslyn or am I supposed to be doing that manually?

In any case, I haven't been able to get Omnisharp working in neovim.

Reproduction:

  1. Start a fresh LazyVim config
  2. Open neovim and run :LazyExtras
  3. Enable lang-omnisharp
  4. Close neovim
  5. Open a .cs file in neovim
  6. Observe that LSP functionality does not work
  7. Observe garbage in log file

Thanks in advance for any assistance you're able to provide.

Cannot find the function in same $metafile$?

Repo:

  • Made dotnet api template (WeatherForecastController)
  • gd on line 38 FromDateTime() takes me too the correct $metafile$
  • gd on AddDays(index) fails with error.
Notworking Working

It strange to me which functions its able to find and which it cannot. ILogger it cannot find but ApiController can be found.

Is this because I'm using dotnet 7?

Config:

config

Not being able to go to definition

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

Error if telescope plugin is not installed

If telescope is not installed omnisharp-extented-lsp causes the following error on initialization:

omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:2: module 'telescope.make_entry' not found

Can Telescope be checked first as an optional dependency?

nvim_win_set_cursor error

I got this error:

Error executing vim.schedule lua callback: ...dspeed/Apps/nvim/share/nvim/runtime/lua/vim/lsp/util.lua:1157: Cursor position outside buffer                                                    
stack traceback:                                                                                                                                                                               
        [C]: in function 'nvim_win_set_cursor'                                                                                                                                                 
        ...dspeed/Apps/nvim/share/nvim/runtime/lua/vim/lsp/util.lua:1157: in function 'jump_to_location'                                                                                       
        ...nvim/lazy/telescope.nvim/lua/telescope/builtin/__lsp.lua:176: in function 'handler'                                                                                                 
        .../sajadspeed/Apps/nvim/share/nvim/runtime/lua/vim/lsp.lua:1393: in function ''                                                                                                       
        vim/_editor.lua: in function <vim/_editor.lua:0>  

It's my config:

		lspconfig["omnisharp"].setup({
			capabilities = capabilities,
			cmd = { "dotnet", "/home/sajadspeed/.local/share/nvim/mason/packages/omnisharp/libexec/OmniSharp.dll" },
			handlers = {
				["textDocument/definition"] = require("omnisharp_extended").handler,
			},
			-- Enables support for reading code style, naming convention and analyzer
			-- settings from .editorconfig.
			enable_editorconfig_support = true,

			-- If true, MSBuild project system will only load projects for files that
			-- were opened in the editor. This setting is useful for big C# codebases
			-- and allows for faster initialization of code navigation features only
			-- for projects that are relevant to code that is being edited. With this
			-- setting enabled OmniSharp may load fewer projects and may thus display
			-- incomplete reference lists for symbols.
			enable_ms_build_load_projects_on_demand = false,

			-- Enables support for roslyn analyzers, code fixes and rulesets.
			enable_roslyn_analyzers = true,

			-- Specifies whether 'using' directives should be grouped and sorted during
			-- document formatting.
			organize_imports_on_format = true,

			-- Enables support for showing unimported types and unimported extension
			-- methods in completion lists. When committed, the appropriate using
			-- directive will be added at the top of the current file. This option can
			-- have a negative impact on initial completion responsiveness,
			-- particularly for the first few completion sessions after opening a
			-- solution.
			enable_import_completion = true,

			-- Specifies whether to include preview versions of the .NET SDK when
			-- determining which version to use for project loading.
			sdk_include_prereleases = true,

			-- Only run analyzers against open files when 'enableRoslynAnalyzers' is
			-- true
			analyze_open_documents_only = false,
		})

These issues not helping:
#14
#13

handler function can't handle `require("telescope.builtin").lsp_definitions()`

Hi,

I'm using AstroNvim.
They provide a lot of default configurations and I found the config set both vim.lsp.buf.definition() and require("telescope.builtin").lsp_definitions() on the same key bind. The latter mapping is preffered and causing the no cursor error.

I disabled the require("telescope.builtin").lsp_definitions() by override the mapping as a workaround. Is it able to handle the function in the handlers section?
https://github.com/AstroNvim/AstroNvim/blob/377db3f7d6273779533c988dadc07a08e0e43f2e/lua/astronvim/utils/lsp.lua#L355

I'm not familier with customizing neovim configurations and lua itself.

Indicate decompilation may require omnisharp.json->EnableDecompilationSupport

Platform: Windows 10
Terminal: Wezterm 20220403-144923-54d503de
Neovim: v0.7.0-dev+1241-g08d9d74fd

I tried to use this plugin several times but never managed to view decompiled source, only metadata. I recently discovered the boolean EnableDecompilationSupport property in ~/.omnisharp/omnisharp.json under RoslynExtensionsOptions. Upon setting it to true, decompilation worked.

My suggestion is that it be indicated in the README.md that users may need to set this value in order for decompilation to work. Maybe this is obvious, but it wasn't for me. .__.

Demonstration:

nvim_omnisharp_decompilation.mp4

Thoughts on not attaching the lsp client to the assembly/decompiled buffer?

First off, thanks for creating this! I just came across your plugin and it solves a definite pain point I've had when using neovim on .net code bases.

After some quick testing of this plugin I noticed that the lsp client seems to be executing on the assembly files and puts a bunch of diagnostic errors into them if I navigate to and away from them in quick succession. Removing this line vim.lsp.buf_attach_client(bufnr, client_id) inside the buf_from_metadata method seems to stop it from happening.

For the majority of use cases that I would have, I would not want the lsp client to try and execute on the assembly/decompiled buffer. I'm assuming your use cases may differ, but I bring this up because I noticed some question marks above the line attaching the lsp client. What are your thoughts on this?

Go to definition fails after doing :LspRestart

I have found that I can go to a third party dll class/method definition just fine, but if I run :LspRestart and then attempt to do that same thing again, I get this error:

image

BUT - this issue goes away completely if I uncomment this line and then comment out the line after that. I assume there's a reason we don't want to uncomment this though

OmniSharp LSP not working in Neovim for .NET Projects

Issue Summary:

I'm experiencing issues getting OmniSharp LSP to work with Neovim for .NET projects. When opening a .NET project and executing the :LspLog command, I see multiple errors and warnings in the log.

Environment:

OS: macOS 14.1 (same error happens in linux ubuntu 22)
Neovim Version: v0.9.4
OmniSharp Version: v1.39.11 (omnisharp-osx.zip)
Installed dotnet SDKs: 6.0.418, 8.0.101
Mono Version: 6.12.0.199

Neovim init.lua configuration:

local pid = vim.fn.getpid()
local omnisharp_bin = "/Users/rampaged/Downloads/omnisharp-osx/run"

local config = {
  handlers = {
    ["textDocument/definition"] = require("omnisharp_extended").handler,
  },
  cmd = { omnisharp_bin, "--languageserver", "--hostPID", tostring(pid) },

  enable_editorconfig_support = true,
  enable_ms_build_load_projects_on_demand = false,
  enable_roslyn_analyzers = false,
  organize_imports_on_format = false,
  enable_import_completion = false,
  sdk_include_prereleases = true,
  analyze_open_documents_only = false,
}

require("lspconfig").omnisharp.setup(config)

Steps to Reproduce:

  1. Install omnisharp-roslyn server version v1.39.11 (omnisharp-osx.zip)
  2. follow this documentation to configure custom handler from this plugin.
  3. Open a .NET project in Neovim.
  4. Execute :LspLog command.
  5. Observe the error and warning messages in the log.

:LspLog Errors in Neovim after opening a dotnet project

[START][2024-01-31 23:55:05] LSP logging initiated
[ERROR][2024-01-31 23:55:05] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/ramfattah/Downloads/omnisharp-osx/run"	"stderr"	""
[WARN][2024-01-31 23:55:07] ...lsp/handlers.lua:537	"OmniSharp.CompositionHostBuilder: It looks like you have Mono installed which contains a MSBuild lower than 17.0.0 which is the minimum supported by the configured .NET Core Sdk.\n Try updating Mono to the latest stable or preview version to enable better .NET Core Sdk support. | "
[ERROR][2024-01-31 23:55:11] ...lsp/handlers.lua:535	'OmniSharp.MSBuild.ProjectLoader: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. | '
[WARN][2024-01-31 23:55:12] ...lsp/handlers.lua:537	"OmniSharp.MSBuild.ProjectManager: Failed to load project file '/Users/ramfattah/Documents/bots/BotBuilder-Samples/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj'. | "
[WARN][2024-01-31 23:55:12] ...lsp/handlers.lua:537	"OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = o#/msbuildprojectdiagnostics, Params = {\n  \"FileName\": \"/Users/ramfattah/Documents/bots/BotBuilder-Samples/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj\",\n  \"Warnings\": [],\n  \"Errors\": [\n    {\n      \"LogLevel\": \"Error\",\n      \"FileName\": \"/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets\",\n      \"Text\": \"The reference assemblies for \\\".NETFramework,Version=v6.0\\\" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.\",\n      \"StartLine\": 1232,\n      \"StartColumn\": 5,\n      \"EndLine\": 0,\n      \"EndColumn\": 0\n    }\n  ]\n}, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = o#/msbuildprojectdiagnostics, Params = {\n  \"FileName\": \"/Users/ramfattah/Documents/bots/BotBuilder-Samples/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj\",\n  \"Warnings\": [],\n  \"Errors\": [\n    {\n      \"LogLevel\": \"Error\",\n      \"FileName\": \"/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets\",\n      \"Text\": \"The reference assemblies for \\\".NETFramework,Version=v6.0\\\" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.\",\n      \"StartLine\": 1232,\n      \"StartColumn\": 5,\n      \"EndLine\": 0,\n      \"EndColumn\": 0\n    }\n  ]\n}, TraceParent = , TraceState =  }'"
[ERROR][2024-01-31 23:55:12] ...lsp/handlers.lua:535	"OmniSharp.MSBuild.ProjectManager: Attempted to update project that is not loaded: /Users/ramfattah/Documents/bots/BotBuilder-Samples/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj | "

Note, i'm new to neovim, not sure if i'm doing this correctly.

happy to provide additional information if needed.
Thanks.

Error when invoking

Hi, trying out this cool plugin as this is a feature I've been missing from VSCode.

However, using nothing more exotic than your example config from the readme, I am still seeing the following error:

Error executing vim.schedule lua callback: ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:231: attempt to index field 'params' (a nil value)

And this is no matter where I am invoking - internal or external types.

Error executing vim.schedule lua callback: ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:56: Vim(append):Error executing lua callback: ...r-textobjects/lua/ nvim-treesitter/textobjects/select.lua:59: attempt to concatenate local 'query' (a table value) stack traceback:

ominsharp configuration

~ $ bat .omnisharp/omnisharp.json
  {
    "RoslynExtensionsOptions": {
      "enableDecompilationSupport": true
    }
  }

lsp configuration

....
    local pid = vim.fn.getpid()
    local omnisharp_bin = "/usr/bin/omnisharp"
  
   require 'lspconfig'.omnisharp.setup({
     handlers = {
           ["textDocument/definition"] = require('omnisharp_extended').handler,
     },
     cmd = { omnisharp_bin, '--languageserver', '--hostPID', tostring(pid) },
    capabilities = capabilities
       -- rest of your settings
    })
....

I am using Arch Linux with Neovim 0.8-dev

full Erro message

Error executing vim.schedule lua callback: ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:56: Vim(append):Error executing lua callback: ...r-textobjects/lua/
nvim-treesitter/textobjects/select.lua:77: E31: No such mapping
stack traceback:
        [C]: in function 'nvim_buf_del_keymap'
        ...r-textobjects/lua/nvim-treesitter/textobjects/select.lua:77: in function 'detach'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:478: in function 'detach_module'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:487: in function 'reattach_module'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:106: in function <...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:105>
        [C]: in function 'nvim_buf_set_option'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:56: in function 'buf_from_metadata'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:97: in function 'get_metadata'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:152: in function 'handle_locations'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:207: in function 'handler'
        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1043: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
stack traceback:
        [C]: in function 'nvim_buf_set_option'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:56: in function 'buf_from_metadata'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:97: in function 'get_metadata'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:152: in function 'handle_locations'
        ...t/omnisharp-extended-lsp.nvim/lua/omnisharp_extended.lua:207: in function 'handler'
        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1043: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>


Handler for `textDocument/reference` when source generators are involved?

I use Godot engine with C#, which involves the use of source-generators. I noticed that textDocument/reference fails when I try it on any identifier that is referenced in something that's generated, and I'm wondering if it can be solved in a similar way that this plugin is currently solving textDocument/definition?

One of the generators I use is GodotOnReady, such that if I try vim.lsp.buf.references() on a member like this:

[OnReadyGet("something")] private Node _something;

I get the following error:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1735: index out of range
stack traceback:
        [C]: in function '_str_byteindex_enc'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1735: in function 'locations_to_items'
        /usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:193: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1383: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Alas, I don't even know exactly how source generation works (I will be reading up) -- how much more complicated is this problem compared to the problem that this plugin already solves?

Multiple projects can have inconsistent project name

Request using from:

{
  position = {
    character = 6,
    line = 8
  },
  textDocument = {
    uri = "file:///Users/..../ReadApi/Controllers/Controller.cs"
  }
}

Returns metadata for

{  id = 5,  jsonrpc = "2.0",  result = {    Source = "...",    SourceName = "$metadata$/Project/..../Database/Assembly/Microsoft/AspNetCore/Mvc/Core/Symbol/Microsoft/AspNetCore/Mvc/ProducesResponseTypeAttribute.cs"  }}

Where instead of ReadApi result is for Database project.

It might be related to https://github.com/OmniSharp/omnisharp-roslyn/blob/ff21ac475cdf8afb15579f2b5fb346945db2a7e9/src/OmniSharp.Roslyn.CSharp/Services/Navigation/MetadataService.cs#L29 where it returns response for first result out of all projects. In that case this should resolve locations better and update uri's accordingly respecting the metadata sourcename uri's

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.