Skip to content

Commit

Permalink
fix(omnisharp): update on_new_config (#2692)
Browse files Browse the repository at this point in the history
* fix(omnisharp): update on_new_config

Save the initial value of cmd to be used in subsequent calls to on_new_config.

* feat: replace excessive code with a call to unpack

* fix(omnisharp): disable capabilities.workspace.workspaceFolders

* fix(omnisharp): added empty lines
  • Loading branch information
JustALawnGnome7 authored Jun 30, 2023
1 parent 5da5745 commit 0011c43
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/lspconfig/server_configurations/omnisharp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ return {
root_dir = function(fname)
return util.root_pattern '*.sln'(fname) or util.root_pattern '*.csproj'(fname)
end,
on_new_config = function(new_config, new_root_dir)
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, { '-s', new_root_dir })
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
Expand Down Expand Up @@ -76,6 +80,10 @@ return {
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 = {},
},
Expand Down

0 comments on commit 0011c43

Please sign in to comment.