Skip to content

Latest commit

 

History

History
51 lines (30 loc) · 2.69 KB

gopls.md

File metadata and controls

51 lines (30 loc) · 2.69 KB

Go Language Server

You can use the Go language server to benefit from Go support:

Go demo

by following these steps:

  1. Install Go Language Server, by following these instructions:
  • Download and install Go

  • 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.

  1. 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.

  2. 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.

    Gopls template

  3. Optional: You may also customize the mappings section:

    Go LS template mappings

    or configuration section according to your preferences.

    Go LS template configuration

  4. 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:

    Go LS in LSP Console

Syntax coloration

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.

Go TextMate Bundles

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).