OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.78k stars 419 forks source link

Q: How to speed up start? #2640

Open loeffel-io opened 1 month ago

loeffel-io commented 1 month ago

This is my neovim setup for my unity project:

            ["omnisharp"] = function()
                lspconfig["omnisharp"].setup({
                    on_attach = on_attach,
                    capabilities = capabilities,
                    cmd = { "omnisharp", "--languageserver", "--hostPID", tostring(pid) },
                    root_dir = lspconfig.util.root_pattern("*.csproj", "*.sln"),
                    handlers = {
                        ["textDocument/definition"] = omnisharp_extended.handler,
                        ["textDocument/references"] = omnisharp_extended.handler,
                        ["textDocument/implementation"] = omnisharp_extended.handler,
                        ["textDocument/typeDefinition"] = omnisharp_extended.handler,
                    },
                    settings = {
                        FormattingOptions = {
                            EnableEditorConfigSupport = true,
                        },
                        RoslynExtensionsOptions = {
                            EnableAnalyzersSupport = false,    -- Disable analyzers for better performance
                            EnableImportCompletion = false,    -- Disable import completion to improve completion time
                            EnableDecompilationSupport = true, -- Enable decompilation support (optional)
                        },
                    },
                })
            end,

it takes around 5 minutes until everything is loaded - this is unacceptable - gopls loads my insane big project instantly.

do i need to exclude some directories or something or is this startup speed normal? If yes, how?

file tree depth 1

├── Assets
├── Library
├── LocalPackages
├── Logs
├── Packages
├── ProjectSettings
├── Temp
├── UserSettings
└── obj
JoeRobich commented 4 weeks ago

Hi @loeffel-io, Loading projects requires performing design-time builds of all the projects in order to determine necessary references. I would expect this to take around the same time as performing a cold build. OmniSharp does have a LoadProjectsOnDemand option which might improve your scenario by only loading projects that have open files. You can see the list of configuration options at https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options#msbuild

loeffel-io commented 3 weeks ago

Hey @JoeRobich, thank you for your reply.

Does this make sense for a unity project?

Setting MsBuild -> LoadProjectsOnDemand stops the Lsp from starting on my side