You can use the Go language server to benefit from Go
support:
by following these steps:
- Install Go Language Server, by following these instructions:
-
Read the "Installation" section to install the Go language server gopls, basically, open a terminal and execute the following command:
go install golang.org/x/tools/gopls@latest
As the command will add go in your OS PATH, you will have to close and reopen your IDE to update this PATH.
-
Open the New Language Server Dialog. This can usually be found under the IDE settings related to Language Server Protocol (LSP). For more information, refer to the New Language Server Dialog documentation.
-
Select Go Language Server as the template from the available options. This will populate the command field with a default command:
gopls -mode=stdio
for Windows OS.sh -c gopls -mode=stdio
for other OS.
-
Optional: You may also customize the mappings section:
or configuration section according to your preferences.
-
Click OK to apply the changes. You should now have Go language support enabled in your IDE, with the Go language server integrated, and you should see the language server in the LSP console:
Today LSP4IJ doesn't support textDocument/semanticTokens
(please vote at issue 238), the demo
uses the Go TextMate grammar
that you can configure in IntelliJ via the Editor / TextMate Bundles
settings.
You need to clone https://github.com/golang/vscode-go/tree/master/extension and reference this folder (which contains the package.json) to benefit from syntax coloration and language configuration (matching brackets, etc).