golang.org/x/tools/gopls@v0.15.3/doc/helix.md (about) 1 # Helix 2 3 Configuring `gopls` to work with Helix is rather straightforward. Install `gopls`, and then add it to the `PATH` variable. If it is in the `PATH` variable, Helix will be able to detect it automatically. 4 5 The documentation explaining how to install the default language servers for Helix can be found [here](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers) 6 7 ## Installing `gopls` 8 9 The first step is to install `gopls` on your machine. 10 You can follow installation instructions [here](https://github.com/golang/tools/tree/master/gopls#installation). 11 12 ## Setting your path to include `gopls` 13 14 Set your `PATH` environment variable to point to `gopls`. 15 If you used `go install` to download `gopls`, it should be in `$GOPATH/bin`. 16 If you don't have `GOPATH` set, you can use `go env GOPATH` to find it. 17 18 ## Additional information 19 20 You can find more information about how to set up the LSP formatter [here](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers#autoformatting). 21 22 It is possible to use `hx --health go` to see that the language server is properly set up. 23 24 ### Configuration 25 26 The settings for `gopls` can be configured in the `languages.toml` file. 27 The official Helix documentation for this can be found [here](https://docs.helix-editor.com/languages.html) 28 29 Configuration pertaining to `gopls` should be in the table `language-server.gopls`. 30 31 #### How to set flags 32 33 To set flags, add them to the `args` array in the `language-server.gopls` section of the `languages.toml` file. 34 35 #### How to set LSP configuration 36 37 Configuration options can be set in the `language-server.gopls.config` section of the `languages.toml` file, or in the `config` key of the `language-server.gopls` section of the `languages.toml` file. 38 39 #### A minimal config example 40 41 In the `~/.config/helix/languages.toml` file, the following snippet would set up `gopls` with a logfile located at `/tmp/gopls.log` and enable staticcheck. 42 43 ```toml 44 [language-server.gopls] 45 command = "gopls" 46 args = ["-logfile=/tmp/gopls.log", "serve"] 47 [language-server.gopls.config] 48 "ui.diagnostic.staticcheck" = true 49 ``` 50 51