Skip to content

Create vala-language-client to debug the language server #227

@albfan

Description

@albfan

I'm trying to setup a complete workflow for vala.

Adding mesonbuild/meson#9582 to meson, one can do:

mkdir -p home/alberto/tutorial/vala-lsp
cd home/alberto/tutorial/vala-lsp
git init
meson init --language vala
vim
:e sample.vala

With a correct setup, vim-lsp or similar work (if setup as mentioned in this project README.md)

so far so good, but after that, debug is little complex

I enable vim-lsp debug and extract basic operations:

So after run this server: (it is listening on stdin)

$ vala-language-server 

Initialize:

Content-Length: 1995

{"id":1,"jsonrpc":"2.0","method":"initialize","params":{"rootUri":"file:///home/alberto/tutorial/vala-lsp","capabilities":{"workspace":{"configuration":true,"applyEdit":true},"window":{"workDoneProgress":false},"textDocument":{"semanticHighlightingCapabilities":{"semanticHighlighting":false},"codeAction":{"isPreferredSupport":true,"disabledSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":false},"completion":{"completionItem":{"snippetSupport":false,"resolveSupport":{"properties":["additionalTextEdits"]},"documentationFormat":["markdown","plaintext"]},"dynamicRegistration":false,"completionItemKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,1,2,3,4,5,6,7,8,9]}},"formatting":{"dynamicRegistration":false},"codeLens":{"dynamicRegistration":false},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"rangeFormatting":{"dynamicRegistration":false},"declaration":{"dynamicRegistration":false,"linkSupport":true},"references":{"dynamicRegistration":false},"typeHierarchy":false,"foldingRange":{"rangeLimit":5000,"dynamicRegistration":false,"lineFoldingOnly":true},"documentSymbol":{"symbolKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,1,2,3,4,5,6,7,8,9]},"dynamicRegistration":false,"labelSupport":false,"hierarchicalDocumentSymbolSupport":false},"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":false,"willSaveWaitUntil":false,"willSave":false,"didSave":true},"documentHighlight":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false,"linkSupport":true},"typeDefinition":{"dynamicRegistration":false,"linkSupport":true},"definition":{"dynamicRegistration":false,"linkSupport":true}}},"rootPath":"/home/alberto/tutorial/vala-lsp","clientInfo":{"name":"vim-lsp"},"processId":42803,"trace":"off"}}

Response:

Content-Length: 534

{"result":{"capabilities":{"textDocumentSync":2,"definitionProvider":true,"documentSymbolProvider":true,"completionProvider":{"triggerCharacters":[".",">"]},"signatureHelpProvider":{"triggerCharacters":["(","[",","]},"hoverProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"implementationProvider":true,"workspaceSymbolProvider":true,"renameProvider":{"prepareProvider":true},"codeLensProvider":{"resolveProvider":false}},"serverInfo":{"name":"Vala Language Server","version":"0.48.3"}},"jsonrpc":"2.0","id":1}
Content-Length: 153

{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///home/alberto/tutorial/vala-lsp/src/vala_lsp.vala","diagnostics":[]}}Content-Length: 143

{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///usr/share/vala-0.54/vapi/glib-2.0.vapi","diagnostics":[]}}Content-Length: 146

{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///usr/share/vala-0.54/vapi/gobject-2.0.vapi","diagnostics":[]}}Content-Length: 135

{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///home/alberto/tutorial/vala-lsp","diagnostics":[]}}

Ask for hover for stdout.printf

Content-Length: 185

{"id":5,"jsonrpc":"2.0","method":"textDocument/hover","params":{"textDocument":{"uri":"file:///home/alberto/tutorial/vala-lsp/src/vala_lsp.vala"},"position":{"character":12,"line":1}}}

Response: void GLib.FileStream.printf (string format, ...)

Content-Length: 203

{"result":{"contents":[{"language":"vala","value":"void GLib.FileStream.printf (string format, ...)"}],"range":{"start":{"line":1,"character":11},"end":{"line":1,"character":17}}},"jsonrpc":"2.0","id":5}

Hope this helps others to start with lsp and extend, improve features.

Good to have: Miss a vala-language-client (connected by socket? or localhost) to launch queries. Even a GUI would be awesome (as a side project)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementA new featuremetaMeta-level issues pertaining to this project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions