razzmatazz / csharp-language-server

Roslyn-based LSP language server for C#
MIT License
605 stars 41 forks source link

Lsp keep reload the project #165

Closed Wordluc closed 4 months ago

Wordluc commented 5 months ago

with this opt local cap = vim.tbl_deep_extend("force", vim.lsp.protocol.make_client_capabilities(), require('cmp_nvim_lsp').default_capabilities() ) cap.workspace.didChangeWatchedFiles.dynamicRegistration = true

Lsp reload all the project(saying that is changed .sln) even thought i had not changed anything.

image

ps:i use didChangeWatchedFiles to notify the server when i delete a file

Wordluc commented 5 months ago

it seems that lsp dosnet support file operations, for this i use "didChangeWatchedFiles"

razzmatazz commented 5 months ago

Hey @Wordluc which OS is this?

Wordluc commented 5 months ago

Windows 10

Wordluc commented 5 months ago

for now i found this solutions:


cap.workspace.didChangeWatchedFiles.dynamicRegistration = true
local oldMath = require("vim.lsp._watchfiles")._match

require("vim.lsp._watchfiles")._match = function(a, b)
    if string.find(b, '.csproj') or string.find(b, '.sln') then
        return false
    end

    return oldMath(a, b)
end
tcx4c70 commented 5 months ago

Hi @Wordluc , change to .csproj detected, will reload solution means the client tells the server that some csproj files are changed. Could you please share the trace log of which files are in the workspace/didChangeWatchedFiles? I guess there are some csproj files are in it.

From the workaround you shared, I think the client you are using sends unchanged files in workspace/didChangeWatchedFiles.

And from lsp spec, it's better to watch file changes in client side and client should send the changed files to server.

Wordluc commented 5 months ago

@tcx4c70 without the workaround are present diffent .csproj, the thing is that i don't change them, so like you said it's a problem of the client so nvim lsp? or is there something that "change" or "save" some csproj?

Wordluc commented 4 months ago

the problem is that i use visual studio to build and debug the solution since visual studio open .sln to load the solution