Pure-D / serve-d

D LSP server (dlang language server protocol server)
MIT License
197 stars 48 forks source link

How to use with kate editor ? #223

Open devosalain opened 2 years ago

devosalain commented 2 years ago

I went to lsp directory , did a "dub build" and it created a "liblsp.a" file. Kate editor should support .d but it did not find an lsp server. Would it be possible to guide me ? Thanks.

WebFreak001 commented 2 years ago

the lsp folder is a library for users wishing to write LSP clients or servers (just the protocol)

You want to run dub build just in the serve-d folder, which will result in a serve-d binary which you can use with your editor. (serve-d is the LSP server for D)

devosalain commented 2 years ago

after git clone, dub build returns, /home/x/served/serve-d >dub build Dependency from serve-d:serverbase to root package references wrong path: /usr/home/x/served/serve-d/ vs. /usr/home/x/served/serve-d/lsp/

WebFreak001 commented 2 years ago

what's your dub --version? try updating dub

devosalain commented 2 years ago

dub --version DUB version 1.14.0, built on May 14 2022 But it seems I have a problem with my clang/llvm compiler. So i must tell dub to use gcc11 instead... And should i add something after "dub build" or will "dub build" build everything ?

WebFreak001 commented 2 years ago

dub build will build everything, but I think you might need a newer version as subpackage dependency resolution by path changed a little bit between the versions and is incompatible with each other.

devosalain commented 2 years ago

It seems i had to adjust the paths of the dependencies in dub.sdl subdirectories from ".." to "../xxx"

Then i had to add to dub.json: "dflags-ldc": ["-gcc=gcc11"], or dub.sdl: dflags "-gcc=gcc11" platform="ldc"

devosalain commented 2 years ago

.

WebFreak001 commented 2 years ago

changing the subdirectories from ".." to "../xxx" results in a DUB warning:

Warning: Sub package serve-d:protocol, referenced by serve-d:lsp 0.7.4+commit.40.g38bc7b7 must be referenced using the path to its base package

you might want to consider upgrading your DUB installation as it seems that the ".." path is what should be used.

Note: don't download DUB from the website and uninstall manually installed versions. It should come with the compiler or in case of packages in linux distros it should be a lot more up-to-date (latest dub version is 1.29.0 - on ArchLinux the currently bundled version is 1.27.0 from January)

For specifying -gcc=gcc11 that seems unrelated to what has been posted here so far. You might need that for all of your compilation executions, so it might be better if you put that in your /etc/ldc2.conf file as default switches or just keep your changes local as it seems very specific to your system.

devosalain commented 2 years ago

the kate editor finds serve-d language server but is not showing anything usefull, nor helpfull. It does nothing ...

WebFreak001 commented 2 years ago

can you send LSP logs from your editor?

Moth-Tolias commented 1 year ago

here's what i get, after placing serve-d.exe in C:/D/dmd2/windows/bin and opening a default hello world project:

[18:38:36  LSP Client Log] Started server d@C:/Users/Su/Documents/src/servedtest: C:/D/dmd2/windows/bin/serve-d.exe
[18:38:36  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
serve-d v0.7.4 with workspace-d v3.7.0 
Included features: "d", "workspaces" 
Built: Fri Jan 7 16:41:29 2022 
with compiler LDC v2.98 on win64 littleEndian 
dub, dfmt and dscanner are bundled within (compiled in)
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00001.043] [configLoad]: file:///C:/Users/Su/Documents/src/servedtest
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00001.046] [globalStartup]: Initializing serve-d...
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
2023-01-10T18:38:37.447 [error] source\served\extension.d:1156:__lambda1 Failed to attach DCD component to : Failed running program ['dcd-server' '--version'] and no alternative existed in 'C:\D\dmd2\windows\bin\dcd-server'.
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
2023-01-10T18:38:37.448 [info] source\served\extension.d:638:rootsForProject Root Suggestions: [RootSuggestion("C:\\Users\\Su\\Documents\\src\\servedtest", true)]
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00001.094] [workspaceStartup] 0 / 1: file:///C%3A/Users/Su/Documents/src/servedtest
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00001.094] [completionStartup] 0 / 1: file:///C%3A/Users/Su/Documents/src/servedtest
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00001.094] [configFinish]
[18:38:37  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
2023-01-10T18:38:37.491 [info] source\served\extension.d:670:doStartup registering instance for root RootSuggestion("C:\\Users\\Su\\Documents\\src\\servedtest", true)
[18:41:12  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
2023-01-10T18:41:12.376 [info] source\served\extension.d:758:delayedProjectActivation Initializing instance for root RootSuggestion("C:\\Users\\Su\\Documents\\src\\servedtest", true)
[18:41:12  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00155.979] [dubReload] 0 / 1: file:///C:/Users/Su/Documents/src/servedtest
[18:41:12  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
[progress] [00156.441] [dubReload] 1 / 1: file:///C:/Users/Su/Documents/src/servedtest
[18:41:12  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
2023-01-10T18:41:12.839 [info] source\served\extension.d:829:delayedProjectActivation Root RootSuggestion("C:\\Users\\Su\\Documents\\src\\servedtest", true) initialized in 461 ms, 883 μs, and 5 hnsecs
[18:41:12  LSP Server Log] d@C:/Users/Su/Documents/src/servedtest
2023-01-10T18:41:12.842 [error] source\served\extension.d:1156:__lambda1 Failed to attach DCD component to C:\Users\Su\Documents\src\servedtest: Failed running program ['dcd-server' '--version'] and no alternative existed in 'C:\D\dmd2\windows\bin\dcd-server'. 
{"code":-32603,"data":"object.Exception@C:\\Users\\runneradmin\\AppData\\Local\\dub\\packages\\workspace-d-3.7.0\\workspace-d\\source\\workspaced\\backend.d(181): Attempted to get unknown instance component DCDComponent in instance cwd:C:\\Users\\Su\\Documents\\src\\servedtest\n----------------\n0x00007FF70B63E20D\n0x00007FF70B63DF86\n0x00007FF70B63AF40\n0x00007FF70B614B6A\n0x00007FF70B1B9470\n0x00007FF70B171D4D\n0x00007FF70B17D9C1\n0x00007FF70B177E52\n0x00007FF70B16331E\n0x00007FF70B164722\n0x00007FF70B621E78\n0x00007FF70B622459","message":"Attempted to get unknown instance component DCDComponent in instance cwd:C:\\Users\\Su\\Documents\\src\\servedtest"}

after that it seems to just be more of the same. here's the state of things i found in my limited amount of testing:

not working

[maybe] working

already included in kate by default, so who knows

couldn't find the option lol

WebFreak001 commented 1 year ago

@Moth-Tolias in your log I can see it fails to start DCD. Usually serve-d should auto-download it, but it seems there is some problem with that. If you manually install dcd-server it should start to work.

Moth-Tolias commented 1 year ago

putting dcd-client.exe and dcd-server.exe in C:/D/dmd2/windows/bin alongside serve-d.exe fixed "Go to definition" and calltips, thank you. it takes rather a while to boot up, but i assume that's just my potato of a laptop at fault - there aren't any obvious errors in the log output.

auto-fixing missing imports and showing compilation errors still don't seem to be working though, and the things i couldn't find an option for remain unchanged.

WebFreak001 commented 1 year ago

the last things you mentioned will be fixed in the next release, they are in #285 right now