golang.org/x/tools/gopls@v0.15.3/doc/subl.md (about)

     1  # Sublime Text
     2  
     3  Use the [LSP] package. After installing it using Package Control, do the following:
     4  
     5  * Open the **Command Palette**
     6  * Find and run the command **LSP: Enable Language Server Globally**
     7  * Select the **gopls** item. Be careful not to select the similarly named *golsp* by mistake.
     8  
     9  Finally, you should familiarise yourself with the LSP package's *Settings* and *Key Bindings*. Find them under the menu item **Preferences > Package Settings > LSP**.
    10  
    11  ## Examples
    12  Minimal global LSP settings, that assume **gopls** and **go** appear on the PATH seen by Sublime Text:<br>
    13  ```
    14  {
    15      "clients": {
    16          "gopls": {
    17               "enabled": true,
    18           }
    19      }
    20  }
    21  ```
    22  
    23  Global LSP settings that supply a specific PATH for finding **gopls** and **go**, as well as some settings for Sublime LSP itself:
    24  ```
    25  {
    26      "clients": {
    27          "gopls": {
    28              "enabled": true,
    29              "env": {
    30                  "PATH": "/path/to/your/go/bin",
    31              }
    32          }
    33      },
    34      // Recommended by https://agniva.me/gopls/2021/01/02/setting-up-gopls-sublime.html
    35      // except log_stderr mentioned there is no longer recognized.
    36      "show_references_in_quick_panel": true,
    37      "log_debug": true,
    38      // These two are recommended by LSP-json as replacement for deprecated only_show_lsp_completions
    39      "inhibit_snippet_completions": true,
    40      "inhibit_word_completions": true,
    41   }
    42   ```
    43  
    44  LSP and gopls settings can also be adjusted on a per-project basis to override global settings.
    45  ```
    46  {
    47      "folders": [
    48          {
    49              "path": "/path/to/a/folder/one"
    50          },
    51          {
    52              // If you happen to be working on Go itself, this can be helpful; go-dev/bin should be on PATH.
    53              "path": "/path/to/your/go-dev/src/cmd"
    54          }
    55       ],
    56      "settings": {
    57          "LSP": {
    58              "gopls": {
    59                  // To use a specific version of gopls with Sublime Text LSP (e.g., to try new features in development)
    60                  "command": [
    61                      "/path/to/your/go/bin/gopls"
    62                  ],
    63                  "env": {
    64                      "PATH": "/path/to/your/go-dev/bin:/path/to/your/go/bin",
    65                      "GOPATH": "",
    66                  },
    67                  "settings": {
    68                      "experimentalWorkspaceModule": true
    69                  }
    70              }
    71          },
    72          // This will apply for all languages in this project that have
    73          // LSP servers, not just Go, however cannot enable just for Go.
    74          "lsp_format_on_save": true,
    75      }
    76  }
    77  ```
    78  
    79  Usually changes to these settings are recognized after saving the project file, but it may sometimes be necessary to either restart the server(s) (**Tools > LSP > Restart Servers**) or quit and restart Sublime Text itself.
    80  
    81  [LSP]: https://packagecontrol.io/packages/LSP