5

Installed LSP server on Sublime Text 3, then enabled gopls from the LSP: Enable Language Server Globally > selected gopls.

Also executed below command on terminal.

GO111MODULE=on go get golang.org/x/tools/gopls@latest

Error shown:

Could not start gopls

LSP.sublime-settings

{
    "clients":
    {
        "gopls":
        {
            "enabled": true
        }
    }
}

gopls command

❯  which gopls
/home/user/go/bin/gopls

I am using MX Linux. Please help !

Source

Community
  • 1
  • 1
Rahul Bali
  • 692
  • 10
  • 28

2 Answers2

10

This solved the problem.

## LSP.sublime-settings -- User
{
    "clients":
    {
        "gopls":
        {
            "command": [
                "/home/rahulbali/go/bin/gopls",
                "-v",
                "-rpc.trace",
                "-logfile=/home/rahulbali/gopls.log"
            ],
            "enabled": true,
            "env": {
                "PATH": "home/rahulbali/go/bin:/usr/local/go/bin"
            },
            "scopes":["source.go"],
            "syntaxes": [
                "Packages/Go/Go.sublime-syntax",
                "Packages/GoSublime/syntax/GoSublime-Go-Recommended.sublime-syntax",
            ],
            "settings": {
                "gopls.usePlaceholders": true,
                "gopls.completeUnimported": true,
            },
            "languageId": "go"

        }
    }
}

Source: https://github.com/golang/go/issues/43746#issuecomment-761760279

Edit: Make 'gopls' is in your shell path.

Rahul Bali
  • 692
  • 10
  • 28
  • If you are doing a Fresh Install of GoLang and Sublime Text, this link should solve with ease. https://github.com/golang/tools/blob/master/gopls/doc/subl.md#sublime-text – Rahul Bali Sep 19 '21 at 17:44
1

What sublime text quotes is:

{
    "clients": {
        "gopls": {
            "enabled": true,
            "command": ["gopls"],
            "selector": "source.go",
            "initializationOptions": {
                "experimentalWorkspaceModule": false
            }
        }
    }
}

Giving the absolute path (which gopls) to gopls binary should solve the 'not found' problem.

{
    "clients": {
        "gopls": {
            "enabled": true,
            "command": ["/Users/xxx/go/bin/gopls"],
            "selector": "source.go",
            "initializationOptions": {
                "experimentalWorkspaceModule": false
            }
        }
    }
}
dpaks
  • 375
  • 1
  • 13