Created attachment 151776 [details] LSP Output Log SUMMARY The Omnisharp language server is started by Kate in what seems to be the home directory rather than where the project folder is; this causes Omnisharp not to be able to find the desired C# solution (.sln) and not provide LSP support as it should. (Omnisharp version 1.39.1) STEPS TO REPRODUCE 1. Install Omnisharp-roslyn (There's several AUR pages for it; I provided one in the URL section of this report) 2. Clone a C# project from a source repository 3. Open the project folder with Kate (Kate will prompt the user to enable the language server) OBSERVED RESULT The language server is started but doesn't provide any of the intended functions, possibly due to being out of scope of the project location EXPECTED RESULT The language server should be directed to the C# project appropriately to provide LSP data SOFTWARE/OS VERSIONS Linux: Arch Linux KDE Plasma Version: 5.25.4 KDE Frameworks Version: 5.97.0 Qt Version: 5.15.5 ADDITIONAL INFORMATION
Hi, if you program in C# can you try a different config or perhaps some variable is missing from the current config?
I mean, I can try a different config (Kate already includes one by default) but I'm not too sure how I'm going to figure it out; my experience with Omnisharp is mostly limited to VSCode, where it typically does this on its own, so...
You can check what other editors do. Point is, its highly unlikely any of the kate devs will pick this as I think no one is a c# programmer.
I would assume one needs some logic to find the first directory with an .csproj file like e.g. the vim plugin does do it. https://github.com/nickspoons/vim-sharpenup/blob/master/autoload/sharpenup/legacycsproj.vim Would that help? Does your project have such a file? Unfortunately ATM we only allow a fixed list of names for such a root directory search via "rootIndicationFileNames": ["pubspec.yaml"],
I've looked a bit into this and the rootpath of the language server is set correctly for me. It uses the rootpath from the project base directory. I've also started work on a patch that implements Christoph's suggestion. Though it should not be of any help here really, as the rootpath is already set and we generally don't want to override it. Can you provide us additional info? - Did you open the project using the Open Folder... action? - In the Kate Output View are there any warnings, erros by the OmniSharp server? For me the server seems to have trouble finding dotnet libraries. Probably, because some env var is not set correctly.
I missed that output log :)
For more context, I did use the "open folder" action but I opened a folder that had a .csproj file and the .sln file was in a subdirectory
From the logs it looks like the server started up, but maybe something went wrong because of the permission denied: /home/neko-san/.local/share/Steam/steamapps/compatdata/0/pfx/dosdevices/z:/var/cache/ldconfig' is denied. ---> System.IO.IOException: Permission denied Can you fix your permissions and retry? Also, from the one C-Sharp project I just opened *.sln is located one level above *.csproj. Not sure if I understood you correctly, but I would try opening on the topmost level of the project.
The funny thing about this is: that's not where I had the editor open at all I had the editor open in /mnt/extraSgorage/<rest of the path> (nowhere near my home directory or any "Z:" drive What you're seeing is omnisharp looking in a Steam Proton prefix for no clear reason; which has nothing to do with what the language server should even be looking at
For me, the peoject was arranged with .csproj in the top level and the .sln in a sub-level (the opposite of what you described)
Tested now with and without my patch, and the server just works for me... even without finding dotnet libraries. Some LSP actions seem to be not supported by the server (Go To Declaration, Go To type definition, Highlight, Expand and Shrink Selection) but the rest should work fine. I would really recommend trying to fix that permissions issue. I tested with this project - https://github.com/ttu/csharp-tutorial as project opened at toplevel - https://aur.archlinux.org/packages/omnisharp-roslyn > What you're seeing is omnisharp looking in a Steam Proton prefix for no clear reason; which has nothing to do with what the language server should even be looking at Yeah, don't know why it is doing that, maybe it is searching for dotnet libraries. In any case, that cannot be influenced by Kate, so you would need to report that at the omnisharp repo.
This might also be relevant for you: https://bugs.kde.org/show_bug.cgi?id=459579 Essentially, ensure before opening any document (that's when the LSP server is started) that you have activated (selected) the project which belongs to this document. If you want to be 100% sure that you are doing this correctly, open only one project in Kate.
After we fixed the mismatch in project path. This should now work all the time, right? If so, can we mark it as resolved?
I still have this problem (though it was a cloned Visual Studio project from someone else's machine) but whatever... I'm resigned to not having a solution at this point.
> I had the editor open in /mnt/extraSgorage/<rest of the path> (nowhere near my home directory or any "Z:" drive Can you try with a project that exists in your home directory somewhere? Maybe the lsp server just isn't able to access that `/mnt/...` path and falls back to your home dir.
> Can you try with a project that exists in your home directory somewhere? Maybe the lsp server just isn't able to access that `/mnt/...` path and falls back to your home dir. Doing this in the home folder made no difference, apparently; it still falls back to the home directory. ``` git clone (project url) cd (project url) kate . (click on files in the project folde view on the right until something triggers kate to run the language server) (same result as before) ```
Can you use the following config. Put it in "User Server Settings" in the settings dialog: ``` { "servers": { "c-sharp": { "command": ["omnisharp", "-lsp"], "commandDebug": ["omnisharp", "--debug", "--verbose"], "url": "https://github.com/OmniSharp/omnisharp-roslyn", "rootIndicationFileNames": ["*.csproj"], "highlightingModeRegex": "^C#$" } } } ``` make sure the json is valid. Then - open your project - open a csharp file => should start the server In the above config I added an explicit ` "rootIndicationFileNames": ["*.csproj"],` I am not yet sure whether *.csproj will work, but we already have stuff like this so maybe it works.
> I am not yet sure whether *.csproj will work, but we already have stuff like this so maybe it works. Unfortunately I think that doesn't work, we lookup only precise filenames, no idea why that was added to some other places. If we want that, we need to extend that.
Also, rootIndicationFileNames will be ignored as the rootpath is already set previously to the project base directory. I've verified this.
We merged a change to support wildcards https://invent.kde.org/utilities/kate/-/merge_requests/907
Should we now add the *.csproj stuff?
https://invent.kde.org/utilities/kate/-/merge_requests/1142