9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

Cant get vue language server to work #66

Closed Superpat closed 5 months ago

Superpat commented 9 months ago

Cant get @vue/language-server to work.

I installed it with yarn global add @vue/language-server then wrote this script:

#!/bin/bash

vue-language-server --stdio

My server entry looks like this:

    [Servers.vueServer]
    Command = ["bash", "-c", "/home/patrick/bin/vueLSP.sh"]
    StderrFile = "vueServer.stderr.log"
    LogFile = "vueServer.log"

I always get the following error: 2023/11/20 11:06:48 failed to create file manager: failed to connect to language server ["bash" "-c" "/home/patrick/bin/vueLSP.sh"]: initialize failed: jsonrpc2: code -32603 message: Request initialize failed with message: Cannot read properties of undefined (reading 'cancellationPipeName')

The log files are empty.

As I reminder of my last issue, I was able to get the standard typescript compiler to work just fine.

Superpat commented 9 months ago

If I execute bash -c /home/patrick/bin/vueLSP.sh from my terminal the command will stay in execution, if I execute it from acme it will end with bash: exit 1, so I think there might be something interfering or missing when ran this way ?

Superpat commented 9 months ago

Managed to get a different error message: 2023/11/20 14:33:38 jsonrpc2: code -32603 message: Hover: unknown language server for URI

Superpat commented 9 months ago

So I figured out that the ts server path was required.

After adding

        [Servers.vueServer.Options.typescript]
            serverPath = "path/to/node_modules/typescript/lib/tsserverlibrary.js"

And clicking L hov after putting my cursor on a symbol gives me:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x568c5b]

goroutine 1 [running]:
github.com/fhs/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc00012fef0, {0x60ec60, 0xc00001a0c0}L: exit 2
)
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/internal/lsp/acmelsp/remote.go:161 +0xbb
main.run(0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/cmd/L/main.go:216 +0xc25
main.main()
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/cmd/L/main.go:114 +0x6a

That's progress ! At least now theres some communication between the two.

Superpat commented 9 months ago

        [Servers.vueServer.Options.takeOverMode]
            enabled = true

is also an option, I think it means we dont have to define the typescript serverpath. Unfortunately it also causes the same crash.

Superpat commented 9 months ago

Ok, I noticed some errors in the LogFile and after some tweaks I got it to disappear and get it to print some stuff in StderrFile.

My options are currently:

        [Servers.vueServer.Options.typescript]
            tsdk = "/home/patrick/.config/yarn/global/node_modules/typescript/lib"

I get the following error from L assist:

panic: L: exit 2
runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x568c5b]

goroutine 1 [running]:
github.com/fhs/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc00028bbe8, {0x60ec60, 0xc00001a0c0})
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/internal/lsp/acmelsp/remote.go:161 +0xbb
github.com/fhs/acme-lsp/internal/lsp/acmelsp.(*outputWin).Update(0xc0000ab5f0, 0xc000017080?, {0x610f08?, 0xc000012840?}, {0x5d2903?, 0x585a01?})
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/internal/lsp/acmelsp/assist.go:234 +0x2a6
github.com/fhs/acme-lsp/internal/lsp/acmelsp.Assist({0x60de08, 0xc0000ea240}, {0x5d2903, 0x4})
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/internal/lsp/acmelsp/assist.go:270 +0x385
main.run(0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/cmd/L/main.go:184 +0x885
main.main()
    /home/patrick/go/pkg/mod/github.com/fhs/acme-lsp@v0.11.0/cmd/L/main.go:114 +0x6a

And the following message in my StderrFile:

/home/patrick/.config/yarn/global/node_modules/@vue/language-server/node_modules/@volar/language-server/out/common/documents.js:107
                            start: this.document.offsetAt(change.contentChange.range.start),
                                                                                     ^

TypeError: Cannot read properties of null (reading 'start')
    at IncrementalScriptSnapshot.applyVersionChanges (/home/patrick/.config/yarn/global/node_modules/@vue/language-server/node_modules/@volar/language-server/out/common/documents.js:107:86)
    at IncrementalScriptSnapshot.getSnapshot (/home/patrick/.config/yarn/global/node_modules/@vue/language-server/node_modules/@volar/language-server/out/common/documents.js:43:18)
    at Object.getScriptSnapshot (/home/patrick/.config/yarn/global/node_modules/@vue/language-server/node_modules/@volar/language-server/out/common/project.js:48:28)
    at Proxy.getScriptSnapshot (/home/patrick/.config/yarn/global/node_modules/@vue/language-core/out/languageModule.js:82:33)
    at syncVirtualFiles (/home/patrick/.config/yarn/global/node_modules/@volar/language-core/out/languageContext.js:46:49)
    at Object.get (/home/patrick/.config/yarn/global/node_modules/@volar/language-core/out/languageContext.js:33:17)
    at Object.getMapsByVirtualFileName (/home/patrick/.config/yarn/global/node_modules/@volar/language-service/out/documents.js:188:42)
    at getMapsByVirtualFileName.next (<anonymous>)
    at Object.getTextDocument (/home/patrick/.config/yarn/global/node_modules/@volar/language-service/out/baseLanguageService.js:171:27)
    at Object.doValidation (/home/patrick/.config/yarn/global/node_modules/@volar/language-service/out/languageFeatures/validation.js:92:37)
Superpat commented 6 months ago

I was playing with this recently and apparently it does work a bit, I can get the L commands to work in 75% of cases and the Diagnostic info is correct. But it all breaks down whenever I Put a file, most of the commands will keep working, but don't acknowledge the new state of the file, so stuff like diagnostics will keep giving the pre-Put diagnostics and if I do an L command over a section that has changed too much there will be an exception.

Seeing as I have exactly the same problem with the haskell language server, I think somekind of progress / reload / onSave action is not working correctly.

Superpat commented 5 months ago

Since I'm seeing some new activity on this depot and since the vue language tools had a pretty major upgrade I wanted to rexplore this. I'll be closing this specific issue and try to open ones that are more precise.

Superpat commented 2 months ago

I was testing the vue language services in acme-lsp today and I finally got it working. Here's the config:

    [Servers.tsServer]
    Command = ["/path/to/bin/typescript-language-server", "--stdio"]
    StderrFile = "tsServer.stderr.log"
    LogFile = "tsServer.log"

        [[Servers.tsServer.Options.plugins]]
            name = "@vue/typescript-plugin"
            location = "/path/to/node_modules/@vue/language-server"
            languages = ["vue"]

[[FilenameHandlers]]
  Pattern = "\\.jsx$"
  LanguageID = "javascriptreact"
  ServerKey = "tsServer"

[[FilenameHandlers]]
  Pattern = "\\.js$"
  LanguageID = "javascript"
  ServerKey = "tsServer"

[[FilenameHandlers]]
  Pattern = "\\.ts$"
  LanguageID = "typescript"
  ServerKey = "tsServer"

[[FilenameHandlers]]
  Pattern = "\\.vue$"
  LanguageID = "vue"
  ServerKey = "tsServer"

[[FilenameHandlers]]
  Pattern = "\\.vue$"
  LanguageID = "vue"
  ServerKey = "tsServer"

[[FilenameHandlers]]
  Pattern = "\\.tsx$"
  LanguageID = "typescriptreact"
  ServerKey = "tsServer"

[[FilenameHandlers]]
  Pattern = "\\.json$"
  LanguageID = "json"
  ServerKey = "tsServer"