地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

Server languageserver.golang failed to start: Command "gopls" of languageserver.golang is not executable: Error: not found: gopls

goplsがcocから呼び出せないところにいるときのエラー

   14     "golang": {
   15       "command": "gopls",
   16       "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
   17       "filetypes": ["go"],
   18       "initializationOptions": {
   19         "usePlaceholders": true
   20       }
   21     },

:CocConfigで上記のような設定の場合は実行ユーザのパスが通っているところにgoplsが必要。

例えばユーザ切り替え時に同一のvimrcなんかを読んじゃってgoplsを叩いてもパスが通ってないケースが多そう

goplsが叩けるユーザでgoplsのパスを追加する必要がある。

パスに存在するよって場合はneovimから実行可能かを確認する必要がある

:echo executable('gopls')

そもそもインストールされてない場合はこっち

$ go get golang.org/x/tools/gopls@latest