Search code examples
linuxgoautocompletesublimetext3language-server-protocol

Sublime Text: [Errno 2] No such file or directory: 'gopls'


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


Solution

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