local util = require 'lspconfig.util' local configs = require 'lspconfig.configs' configs.omnisharp = { default_config = { cmd = { "dotnet", "C:\\Users\\andre.schaf\\.vscode\\extensions\\ms-dotnettools.csharp-2.13.10-win32-x64\\.roslyn\\Microsoft.CodeAnalysis.LanguageServer.dll" -- "C:\\dev\\tools\\omni\\OmniSharp.Roslyn.dll" -- "/path/to/omnisharp/OmniSharp.dll" }, }, filetypes = { 'cs' }, root_dir = util.root_pattern('*.sln', '*.csproj', 'omnisharp.json', 'function.json'), 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 = false, -- Specifies whether 'using' directives should be grouped and sorted during -- document formatting. organize_imports_on_format = false, -- 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 = false, -- 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, on_new_config = function(new_config, _) -- Get the initially configured value of `cmd` new_config.cmd = { unpack(new_config.cmd or {}) } -- Append hard-coded command arguments table.insert(new_config.cmd, '-z') -- https://github.com/OmniSharp/omnisharp-vscode/pull/4300 vim.list_extend(new_config.cmd, { '--hostPID', tostring(vim.fn.getpid()) }) table.insert(new_config.cmd, 'DotNet:enablePackageRestore=false') vim.list_extend(new_config.cmd, { '--encoding', 'utf-8' }) table.insert(new_config.cmd, '--languageserver') -- Append configuration-dependent command arguments if new_config.enable_editorconfig_support then table.insert(new_config.cmd, 'FormattingOptions:EnableEditorConfigSupport=true') end if new_config.organize_imports_on_format then table.insert(new_config.cmd, 'FormattingOptions:OrganizeImports=true') end if new_config.enable_ms_build_load_projects_on_demand then table.insert(new_config.cmd, 'MsBuild:LoadProjectsOnDemand=true') end if new_config.enable_roslyn_analyzers then table.insert(new_config.cmd, 'RoslynExtensionsOptions:EnableAnalyzersSupport=true') end if new_config.enable_import_completion then table.insert(new_config.cmd, 'RoslynExtensionsOptions:EnableImportCompletion=true') end if new_config.sdk_include_prereleases then table.insert(new_config.cmd, 'Sdk:IncludePrereleases=true') end if new_config.analyze_open_documents_only then table.insert(new_config.cmd, 'RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly=true') end -- Disable the handling of multiple workspaces in a single instance new_config.capabilities = vim.deepcopy(new_config.capabilities) new_config.capabilities.workspace.workspaceFolders = false -- https://github.com/OmniSharp/omnisharp-roslyn/issues/909 end, init_options = {}, } }