itemis / xtext-languageserver-example

An Example for an Xtext Language Server
Eclipse Public License 1.0
54 stars 26 forks source link

[General Question] Completely stuck trying to make VS Code suggest tokens #77

Closed nsoubelet closed 2 years ago

nsoubelet commented 2 years ago

Hello, this is not a project's issue. Sorry about that, I hope you are fine with it, otherwise I can copy in a different place if you point me out.

Issue I created my DSL. It works on Eclipse and in Web mode. In order to be able to create a VS Code extension I followed this project's general structure. Everything works as expected but the suggestions. By suggestions I refer to the functionality one can find in the XText Web project/Eclipse in which all the possible tokens in the current context are listed by pressing ctrl+space.

Right now when pressing ctrl+space VS Code shows the list of keywords listed in the syntax, without any particular sensitivity to the context, that is, what effectively applies after certain token.

Capabilities I put some extra logs and realized that when Code initializes Language server it offers the following capabilities:

Result: {
  "capabilities": {
    "textDocumentSync": 2,
    "hoverProvider": true,
    "completionProvider": {
      "resolveProvider": false,
      "triggerCharacters": [
        "."
      ]
    },
    "signatureHelpProvider": {
      "triggerCharacters": [
        "(",
        ","
      ]
    },
    "definitionProvider": true,
    "referencesProvider": true,
    "documentHighlightProvider": true,
    "documentSymbolProvider": true,
    "workspaceSymbolProvider": true,
    "codeActionProvider": false,
    "documentFormattingProvider": true,
    "documentRangeFormattingProvider": true,
    "renameProvider": {
      "prepareProvider": true
    },
    "executeCommandProvider": {
      "commands": []
    },
    "workspace": {
      "workspaceFolders": {
        "supported": true,
        "changeNotifications": true
      }
    },
    "semanticHighlighting": {
      "scopes": []
    }
  }
}

At this point I am not sure whether I misunderstood VS Code<>Xtext (LSP4J) integration possibilities or I am missing something or doing something wrong. It seems you're the only one around that worked on this and shared your work, so maybe you can help me here.

Thanks

cdietrich commented 2 years ago

hi, for me this still works ootb (using my 226 wip branch) Bildschirmfoto 2021-10-07 um 11 33 28 maybe your combination of vscode, lsp4j, xtext is wrong?

nsoubelet commented 2 years ago

Thanks! vscode, vscode-language and LSP4J I am using same versions I think. I am going to check xtext version then (currently using latest). One important thing, I am using the embedded alternative (self-contained). However as far as I understand only difference is the transport between vscode/server but not the protocol itself, so should not be differences, right?

cdietrich commented 2 years ago

you need to use xtext 2.26.0.m2/snapshots for latest lsp4j &lsp protocol version

cdietrich commented 2 years ago

@nsoubelet did that help?

nsoubelet commented 2 years ago

Hello @cdietrich yes it helped me! Sorry for not closing it before. In fact, I was thinking of adapting this one https://github.com/itemis/xtext-generator-vscode to generate the structure you have in this very project since seems to be, at least in my experience, the only one available in github that works with a recent xtext version.