serve-d icon indicating copy to clipboard operation
serve-d copied to clipboard

How to use with kate editor ?

Open devosalain opened this issue 3 years ago • 14 comments

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.

devosalain avatar May 18 '22 00:05 devosalain

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)

WebFreak001 avatar May 18 '22 11:05 WebFreak001

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/

devosalain avatar May 18 '22 23:05 devosalain

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

WebFreak001 avatar May 18 '22 23:05 WebFreak001

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 ?

devosalain avatar May 18 '22 23:05 devosalain

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.

WebFreak001 avatar May 19 '22 09:05 WebFreak001

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 avatar May 19 '22 12:05 devosalain

.

devosalain avatar May 31 '22 14:05 devosalain

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.

WebFreak001 avatar May 31 '22 15:05 WebFreak001

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

devosalain avatar Jun 01 '22 19:06 devosalain

can you send LSP logs from your editor?

WebFreak001 avatar Jun 08 '22 10:06 WebFreak001

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

  • Showing calltips & documentation using DCD
  • Navigating through the code using features like Go to definition using DCD
  • Dynamically showing compilation errors by invoking dub without any binary output: doesn't appear to be working.
  • Auto-Fix for issues like missing imports

[maybe] working

  • Finding global symbols using DCD: maybe working?
  • Outlining the document and jumping to various functions using Dscanner: maybe working?
  • Statically linting the code using Dscanner
  • Formatting the document using Dfmt

already included in kate by default, so who knows

  • Syntax highlighting
  • Autocompletion

couldn't find the option lol

  • Building, running & debugging the project from within ~~VSCode~~ Kate
  • Full DUB integration
  • Snippets
  • GUI Editor for dub.json files
  • Showing GC calls from the profilegc.log file

Moth-Tolias avatar Jan 10 '23 19:01 Moth-Tolias

@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.

WebFreak001 avatar Jan 10 '23 21:01 WebFreak001

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.

Moth-Tolias avatar Jan 14 '23 07:01 Moth-Tolias

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

WebFreak001 avatar Jan 14 '23 17:01 WebFreak001