Visual Studio Code: gopls and YAML
- One minute read - 168 wordsThe Go team is developing a Language Server Protocol [LSP] implementation) called gopls
. Visual Studio Code (and others) support LSP. Other languages (e.g. Python have LSP implementations too). I’ve been using gopls
for some time. It works (mostly) very well and replaces multiple, indepedent tools with two (gopls
and delve
).
My Visual Studio Code settings that include gopls
is:
"go.autocompleteUnimportedPackages": true,
"go.useLanguageServer": true,
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"usePlaceholders": true,
"wantCompletionDocumentation": true,
},
"go.toolsEnvVars": {
},
"go.languageServerFlags": [
"-rpc.trace",
"serve",
"--debug=localhost:6060",
],
"go.enableCodeLens": {
"references": true,
"runtest": true
},
One of the Google engineers working on gopls
gave a comprehensive and interesting overview of the tool at GopherCon 2019.
I learned recently that RedHat’s YAML extension for Visual Studio Code integrates with JSON Schema Store. This includes a schema for Google Cloud Build. Adding the following setting to Visual Studio Code settings permits the extension to verify files using any of the supported schemas and provide hints:
"yaml.schemaStore.enable": true,