A Go language server.

Overview

A Go Language Server based on the Go Extension for Visual Studio Code

Wraps the VSCode Go extension from Microsoft into a language server, such that its functionality can be reused with other LSP-aware clients.

In the first iteration we will mock VSCode APIs or simulate their behavior backed by an LSP. We will maintain this as a fork of the original repository such that we can easily pick up incoming improvements of that by just rebasing. Once we got more confidence, we'd probably refactor the VSCode specific parts away.

Original README.md.

Mismatches and Challenges

  • There is no such thing as the activeTextEditor in LSP. For services that have a TextDocumentItem, we set it before calling the service impl, but for other services, e.g. executeCommand we cannot make sure that they are performed on the correct document.
  • We have to use/mock/adapt a lot of global variables

Prerequisites

Make sure the go command is available from your path and that the GOPATH environment variable points to where your go packages are installed. Some go packages are necessary:

go get -u -v github.com/nsf/gocode
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/josharian/impl
go get -u -v github.com/tylerb/gotype-live
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/zmb3/gogetdoc
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/cweill/gotests/...
go get -u -v github.com/alecthomas/gometalinter
go get -u -v honnef.co/go/tools/...
go get -u -v github.com/sourcegraph/go-langserver
go get -u -v github.com/derekparker/delve/cmd/dlv
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruc

Note: this list comes from here.

Build and usage

  1. Run npm install to install the package dependencies.
  2. Run npm run compile to compile the Typescript to Javascript.
  3. Run the server with node ./out/src-vscode-mock/cli.js --stdio.
Issues
  • Can't open some .go files

    Can't open some .go files

    Something like this was reported by our internal users, but it's the first time I witness it myself. See attached video.

    I was using the theiaide/theia-go image (https://hub.docker.com/r/theiaide/theia-go/), pulled fresh today. In it, I cloned the golang repo (https://github.com/golang/go.git) and noticed I could not open file src/bufio/bufio_test.go . However I am able to open other .go files in the same directory. The file itself looks fine; I can "cat" it successfully.

    This may not consistently reproducable (it works for me using a different, internal docker image, that also has golang LS).

    Here's the exception:

    Uncaught (in promise) A resource provider for 'file:///home/theia/go/src/bufio/bufio_test.go' is not registered.
    rejected @ opener-service.ts:6
    Promise.then (async)
    step @ opener-service.ts:6
    fulfilled @ opener-service.ts:6
    Promise.then (async)
    step @ opener-service.ts:6
    (anonymous) @ opener-service.ts:6
    __awaiter @ opener-service.ts:6
    open @ opener-service.ts:71
    FileNavigatorModel.doOpenNode @ navigator-model.ts:32
    TreeModel.openNode @ tree-model.ts:238
    TreeWidget.handleDblClickEvent @ tree-widget.ts:280
    ondblclick @ tree-widget.ts:131
    

    peek 2018-02-01 08-01

    bug 
    opened by marcdumais-work 4
  • Send LSP-compliant responses to codelens requests

    Send LSP-compliant responses to codelens requests

    In the responses to textDocument/codeLens and codeLens/resolve, go-language-server currently returns objects with unnecessary fields that are not specified in the Language Server Protocol. This is not a big problem per-se, because the extra JSON fields can be ignored by the consumers. However, they represent a significant amount of data.

    In particular, each item in the CodeLens array that is returned as the response to textDocument/codeLens contains the text of the whole document. As an example, I opened the file ./src/net/http/h2_bundle.go from the Go source code [1]. Its size is 310K and contains about 440 functions, meaning we'll return about 440 code lenses. Just the duplicated in each entry that contains the document text will contribute for 136M of the response (the total response is bigger).

    This is because the code returns blindly the internal vscode data structures. Because the CodeLens vscode data structure contains a reference to the text document, it is included every time the structure is serialized. Instead, we should generate structures that only contain the fields specified in the LSP.

    [1] https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go

    opened by simark 3
  • Bump vscode-languageclient to 3.5.0

    Bump vscode-languageclient to 3.5.0

    Use the latest released version of vscode-languageclient. The protocol bits have been moved to a new package, vscode-languageserver-protocol, so add a dependency on it and adjust the code.

    Signed-off-by: Simon Marchi [email protected]

    opened by simark 3
  • Catch error when calling updateGoPathGoRootFromConfig

    Catch error when calling updateGoPathGoRootFromConfig

    If the go binary is not available from the PATH, the server outputs this error message.

    server --> client: b'{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"[lspserver] (node:17641) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: \"file\" argument must be a non-empty string"}}' server --> client: b'{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"[lspserver] (node:17641) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code."}}'

    The TypeError comes from node's child_process.execFile when the vscode-go code tries to run the go binary, because goRuntimePath's value is undefined.

    This patch makes updateGoPathGoRootFromConfig return a rejected promise with a meaningful error message when the go binary is not found, and then makes the server send an error message to the client including the error and backtrace. The result looks like this:

    server --> client: b'{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":1,"message":"Error: Cannot find \"go\" binary. Update PATH or GOROOT appropriately\n at Object.updateGoPathGoRootFromConfig (/home/emaisin/src/go-language-server/out/src/goInstallTools.js:280:31)\n at Object. (/home/emaisin/src/go-language-server/out/src-vscode-mock/activate.js:105:33)\n at Generator.next ()\n at /home/emaisin/src/go-language-server/out/src-vscode-mock/activate.js:13:71\n at new Promise ()\n at __awaiter (/home/emaisin/src/go-language-server/out/src-vscode-mock/activate.js:9:12)\n at Object.activate (/home/emaisin/src/go-language-server/out/src-vscode-mock/activate.js:34:12)\n at LspServer. (/home/emaisin/src/go-language-server/out/src-vscode-mock/lsp-server.js:93:31)\n at Generator.next ()\n at /home/emaisin/src/go-language-server/out/src-vscode-mock/lsp-server.js:13:71"}}'

    It's not very readable as-is, but I suppose that when the client prints it in a log, the \n will be presented as real line breaks. But the important thing is that the info is there, so that one has a lead to start debugging.

    There was another instance (in runTool) where the result of getGoRuntimePath was not checked, so it generated a similar unclear error.

    Fixes #16

    Signed-off-by: Simon Marchi [email protected]

    opened by simark 3
  • Try to find a solution for selection sensitive commands

    Try to find a solution for selection sensitive commands

    On the LS, we don't have selection. Would be great if the client sent the selection as an argument with the commands that need it. A wrapper command on the client could be helpful.

    opened by JanKoehnlein 3
  • Make outputChannel work

    Make outputChannel work

    A lot of valuable output goes into the output channel of the VSCode extension. We should implement something similar for Theia and then route the outputChannel there. Maybe related to https://github.com/theia-ide/theia/issues/786

    enhancement 
    opened by JanKoehnlein 2
  • add go get for fillstruct (as listed on...

    add go get for fillstruct (as listed on...

    add go get for fillstruct (as listed on https://github.com/theia-ide/go-language-server/blob/master/src/goInstallTools.ts#L42 )

    Change-Id: I61b01918501cc034858e6046d51b17ad9bbdf9ea Signed-off-by: nickboldt [email protected]

    opened by nickboldt 1
  • Send LSP-compliant structures for commands in codeLens/resolve responses

    Send LSP-compliant structures for commands in codeLens/resolve responses

    When a Command LSP record is output in a codeLens/resolve response, it contains these fields, which are not specified by the LSP:

    "uriRangeOrPosition": { "start": { "character": 10, "line": 32 }, "end": { "character": 18, "line": 32 } }, "rangeOrUri": { "scheme": "file", "fsPath": "/home/emaisin/src/ls-interact/go-test/test.go", "external": "file:///home/emaisin/src/ls-interact/go-test/test.go", "path": "/home/emaisin/src/ls-interact/go-test/test.go", "$mid": 1 }

    This patch makes the server output only the fields that are specified by the LSP. I made a standalone function to convert from a vscode Command to an LSP Command, because we might have to re-use it in other responses that contain commands.

    Signed-off-by: Simon Marchi [email protected]

    opened by simark 1
  • Unclear error when go binary is not found

    Unclear error when go binary is not found

    When trying to use the server, I got this error:

    server --> client: b'{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"[lspserver] (node:17641) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: \\"file\\" argument must be a non-empty string"}}'
    server --> client: b'{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"[lspserver] (node:17641) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code."}}'
    

    and the server wouldn't reply anything. After some debugging, I found that it was because it didn't find the go binary. The rejected promise should be handled to avoid that warning, and a better error message should be given to the user to indicate what to fix.

    opened by simark 1
  • Make code lens work

    Make code lens work

    Code lens works fine apart from opening the references:

    The server composes a set of arguments of type URI, Position and Location[] for the editor.action.showReferences command (in goReferencesCodelens#resolveCodeLens). These are sent to the client, as such converted to plain JSON objects. The client, when trying to execute the command, validates the args to be instance of URI, IPosition and Array, which fails as they are plain JSON objects.

    One solution could be to register a separate command in the theia-go-extension that is called instead and does the conversion.

    opened by JanKoehnlein 1
  • Allow users to specify clientProcessId

    Allow users to specify clientProcessId

    Currently if a clientProcessId is provided, the program prints and error to stdio (which will disrupt connections made via stdio).

    Signed-off-by: Casey Flynn [email protected]

    opened by caseyflynn-google 0
  • textDefinition on some comments returns an error

    textDefinition on some comments returns an error

    This situation can happen if you hold ctrl down and hover some words in comments with your cursor.

    client --> server: {"id": 124, "jsonrpc": "2.0", "method": "textDocument/definition", "params": {"textDocument": {"uri": "file:///home/emaisin/src/ls-interact/go-test/test.go"}, "position": {"character": 46, "line": 12}}}
    server --> client: {"jsonrpc":"2.0","id":124,"error":{"code":-32600,"message":"Command failed: /home/emaisin/gopath/bin/godef -t -i -f /home/emaisin/src/ls-interact/go-test/test.go -o 334\ngodef: no identifier found\n","data":"Command failed: /home/emaisin/gopath/bin/godef -t -i -f /home/emaisin/src/ls-interact/go-test/test.go -o 334\ngodef: no identifier found\n"}}
    

    In Theia, this results in an annoying error popup. If you move all over the comments with your cursor while holding ctrl, you'll get many error popups.

    It can be reproduced when using this code there (test.go): https://github.com/simark/ls-interact/tree/master/go-test, and hovering the word "that" on line 13.

    opened by simark 0
  • Find out whether we can leverage command descriptions

    Find out whether we can leverage command descriptions

    Currently, we only use the command title to present commands to the user. The command descriptions are sometimes much more meaningful. Do we have a way to map them to LSP or at least Theia?

    enhancement 
    opened by JanKoehnlein 0
  • Revise all usages of commands.executeCommand

    Revise all usages of commands.executeCommand

    The VSCode extension executes VSCode commands in a couple of places. We should introduce new LSP requests/notifications for these or get rid of the command calls.

    enhancement 
    opened by JanKoehnlein 2
Owner
theia-ide
Theia is a cloud & desktop IDE implemented in TypeScript
theia-ide
Web-based IDE for the Go language

Welcome to godev! The aim of this project is to develop a premier Go language IDE hosted in a web interface. This was inspired by the way that the god

Chris McGee 347 Mar 5, 2022
Emacs mode for the Go programming language

This is go-mode, the Emacs mode for editing Go code. It is a complete rewrite of the go-mode that shipped with Go 1.0.3 and before, and was part of Go

Dominik Honnef 1.2k Jun 28, 2022
An autocompletion daemon for the Go programming language

An autocompletion daemon for the Go programming language VERY IMPORTANT: this project is not maintained anymore, look for alternatives or forks if you

null 5k Jun 30, 2022
Delve is a debugger for the Go programming language.

The GitHub issue tracker is for bugs only. Please use the developer mailing list for any feature proposals and discussions. About Delve Installation L

Derek Parker 503 Jun 21, 2022
A Language Server Protocol (LSP) server for Jsonnet

Jsonnet Language Server A Language Server Protocol (LSP) server for Jsonnet. Features Jump to definition self-support.mp4 dollar-support.mp4 Error/War

Grafana Labs 56 Jun 24, 2022
Generate code for any language, with any language.

gocog - generate code for any language, with any language gocog v1.0 build 20130206 Binaries for popular OSes are available on the Downloads page of t

Nate Finch 65 Feb 11, 2021
Floppa programming language inspired by the brainf*ck programming language. Created just for fun and you can convert your brainf*ck code to floppa code.

Floppa Programming Language Created just for fun. But if you want to contribute, why not? Floppa p.l. inspired by the brainf*ck programming language.

null 18 Apr 26, 2022
Please is a cross-language high-performance extensible build system for reproducible multi-language builds.

Please is a cross-language build system with an emphasis on high performance, extensibility and reproducibility. It supports a number of popular languages and can automate nearly any aspect of your build process.

Thought Machine 2k Jun 28, 2022
Q Language : A script language for Go

Q Language - A script language for Go 语言特色 与 Go 语言有最好的互操作性。可不进行任何包装即可直接使用 Go 语言的函数、类及其成员变量和方法。 有赖于 Go 语言的互操作性,这门语言直接拥有了一套非常完整且您十分熟悉的标准库,无额外学习成本。 与 Go

null 8 May 24, 2022
T# Programming Language. Something like Porth, Forth but written in Go. Stack-oriented programming language.

The T# Programming Language WARNING! THIS LANGUAGE IS A WORK IN PROGRESS! ANYTHING CAN CHANGE AT ANY MOMENT WITHOUT ANY NOTICE! Something like Forth a

T# 92 Jun 29, 2022
A repository for showcasing my knowledge of the Google Go (2009) programming language, and continuing to learn the language.

Learning Google Golang (programming language) Not to be confused with the Go! programming language by Francis McCabe I don't know very much about the

Sean P. Myrick V19.1.7.2 1 Nov 26, 2021
A repository for showcasing my knowledge of the Go! (2003) programming language, and continuing to learn the language.

Learning Go! (programming language) Not to be confused with Google Golang (2009) I don't know too much about the Go! programming language, but I know

Sean P. Myrick V19.1.7.2 1 Nov 26, 2021
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

null 1 Dec 27, 2021
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

Yayx Programming Language 7 May 20, 2022
Becca - A simple dynamic language for exploring language design

Becca A simple dynamic language for exploring language design What is Becca Becc

Nicholas Bailey 0 Mar 29, 2022
Tdtl - TKeel Digital Twins Language (TDTL) is language of Digital Twins in tKeel

TQL TKeel Digital Twins Language (TDTL) is language of Digital Twins in tKeel, w

null 1 Feb 18, 2022
Microsoft SQL server driver written in go language

A pure Go MSSQL driver for Go's database/sql package Install Requires Go 1.8 or above. Install with go get github.com/denisenkom/go-mssqldb . Connecti

null 1.6k Jun 23, 2022
CoAP Client/Server implementing RFC 7252 for the Go Language

Canopus Canopus is a client/server implementation of the Constrained Application Protocol (CoAP) Updates 25.11.2016 I've added basic dTLS Support base

Zubair Hamed 148 Jan 23, 2022
Scalable real-time messaging server in language-agnostic way

Centrifugo is a scalable real-time messaging server in language-agnostic way. Centrifugo works in conjunction with application backend written in any

Centrifugal 6.1k Jun 28, 2022
A Go language server.

A Go Language Server based on the Go Extension for Visual Studio Code Wraps the VSCode Go extension from Microsoft into a language server, such that i

theia-ide 31 Nov 21, 2021
Unified text diffing in Go (copy of the internal diffing packages the officlal Go language server uses)

gotextdiff - unified text diffing in Go This is a copy of the Go text diffing packages that the official Go language server gopls uses internally to g

Hexops 82 Jun 24, 2022
Language Server Indexing Format (LSIF) generator for Go

Go LSIF indexer Visit https://lsif.dev/ to learn about LSIF. Installation Binary downloads are available on the releases tab. Installation: Linux curl

Sourcegraph 91 Apr 13, 2022
Scalable real-time messaging server in language-agnostic way

Centrifugo is a scalable real-time messaging server in language-agnostic way. Centrifugo works in conjunction with application backend written in any

Centrifugal 6.1k Jun 24, 2022
RTSP 1.0 client and server library for the Go programming language

RTSP 1.0 client and server library for the Go programming language

Alessandro Ros 271 Jun 30, 2022
language server protocol sdk implement for go

LSP(language server protocol) defines for golang lsp types is from vscode-languageserver-node. Project is working in progress. Example func main() {

Tobias Yin 31 Jun 7, 2022
LuaHelper is a High-performance lua plugin, Language Server Protocol for lua.

LuaHelper is a High-performance lua plugin, Language Server Protocol for lua.

Tencent 262 Jun 29, 2022
A simple Go server/microservice example for Docker's Go Language Guide.

docker-gs-ping A simple Go server/microservice example for Docker's Go Language Guide. Notable features: Includes a multi-stage Dockerfile, which actu

shuntagami 0 Nov 28, 2021
Create HTTP server with go language.

go-http-server Create HTTP server with go language. 一、HTTP Server的简单实现 1.简单的Server接口定义 该接口包含了路由、服务启动、服务关闭功能 2.路由中包含了访问路径以及处理函数 3.服务启动 初始化服务时,可以起对应服务名称

jun.hai 1 Jan 7, 2022