aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lsp/omnisharp.lua
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-10-20 20:55:26 +0300
committerawy <awy@awy.one>2025-10-20 20:55:26 +0300
commit662dafc52b2c8a9426bb2197ab9246a8cda318e4 (patch)
treef9d1f20e3864360bf941fd6bc02848ed77b037a8 /.config/nvim/lsp/omnisharp.lua
parent8131d9f2898b991a2d2c7a2ac601ce9e07cc9c9f (diff)
downloadhyprdots-662dafc52b2c8a9426bb2197ab9246a8cda318e4.tar.gz
nvqw
Diffstat (limited to '.config/nvim/lsp/omnisharp.lua')
-rw-r--r--.config/nvim/lsp/omnisharp.lua92
1 files changed, 92 insertions, 0 deletions
diff --git a/.config/nvim/lsp/omnisharp.lua b/.config/nvim/lsp/omnisharp.lua
new file mode 100644
index 0000000..cfc9ba1
--- /dev/null
+++ b/.config/nvim/lsp/omnisharp.lua
@@ -0,0 +1,92 @@
+---@brief
+---
+--- https://github.com/omnisharp/omnisharp-roslyn
+--- OmniSharp server based on Roslyn workspaces
+---
+--- `omnisharp-roslyn` can be installed by downloading and extracting a release from [here](https://github.com/OmniSharp/omnisharp-roslyn/releases).
+--- OmniSharp can also be built from source by following the instructions [here](https://github.com/omnisharp/omnisharp-roslyn#downloading-omnisharp).
+---
+--- OmniSharp requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
+---
+--- **By default, omnisharp-roslyn doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of the unzipped run script or binary.
+---
+--- For `go_to_definition` to work fully, extended `textDocument/definition` handler is needed, for example see [omnisharp-extended-lsp.nvim](https://github.com/Hoffs/omnisharp-extended-lsp.nvim)
+---
+---
+
+local util = require 'lspconfig.util'
+
+---@type vim.lsp.Config
+return {
+ cmd = {
+ vim.fn.executable('OmniSharp') == 1 and 'OmniSharp' or 'omnisharp',
+ '-z', -- https://github.com/OmniSharp/omnisharp-vscode/pull/4300
+ '--hostPID',
+ tostring(vim.fn.getpid()),
+ 'DotNet:enablePackageRestore=false',
+ '--encoding',
+ 'utf-8',
+ '--languageserver',
+ },
+ filetypes = { 'cs', 'vb' },
+ root_dir = function(bufnr, on_dir)
+ local fname = vim.api.nvim_buf_get_name(bufnr)
+ on_dir(
+ util.root_pattern '*.sln'(fname)
+ or util.root_pattern '*.csproj'(fname)
+ or util.root_pattern 'omnisharp.json'(fname)
+ or util.root_pattern 'function.json'(fname)
+ )
+ end,
+ init_options = {},
+ capabilities = {
+ workspace = {
+ workspaceFolders = false, -- https://github.com/OmniSharp/omnisharp-roslyn/issues/909
+ },
+ },
+ settings = {
+ FormattingOptions = {
+ -- Enables support for reading code style, naming convention and analyzer
+ -- settings from .editorconfig.
+ EnableEditorConfigSupport = true,
+ -- Specifies whether 'using' directives should be grouped and sorted during
+ -- document formatting.
+ OrganizeImports = nil,
+ },
+ MsBuild = {
+ -- 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.
+ LoadProjectsOnDemand = nil,
+ },
+ RoslynExtensionsOptions = {
+ -- Enables support for roslyn analyzers, code fixes and rulesets.
+ EnableAnalyzersSupport = nil,
+ -- 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.
+ EnableImportCompletion = nil,
+ -- Only run analyzers against open files when 'enableRoslynAnalyzers' is
+ -- true
+ AnalyzeOpenDocumentsOnly = nil,
+ -- Enables the possibility to see the code in external nuget dependencies
+ EnableDecompilationSupport = nil,
+ },
+ RenameOptions = {
+ RenameInComments = nil,
+ RenameOverloads = nil,
+ RenameInStrings = nil,
+ },
+ Sdk = {
+ -- Specifies whether to include preview versions of the .NET SDK when
+ -- determining which version to use for project loading.
+ IncludePrereleases = true,
+ },
+ },
+}