gopls introduces interactive refactoring via new LSP standard
The Go language server, gopls, now supports multi-step interactive dialogs for complex code transformations through a new Language Server Protocol proposal.
Summary
The Go team has introduced interactive refactoring capabilities to gopls, allowing the language server to request user input during code transformations. This is powered by a new open standard for the Language Server Protocol (LSP) designed to work across different editors. Supported features include customizable struct tag modification, interface implementation, and moving declarations across files.
New LSP capabilities in gopls
- Implements a new LSP capability (proposed in microsoft/language-server-protocol#1164) to allow servers to collect user input before computing edits.
- Enables multi-step dialogs for transformations that previously relied on hardcoded defaults.
- Struct tags: Users can now select specific tag keys (e.g., json, yaml, db) and naming conventions (camelCase, snake_case, PascalCase).
- Interface implementation: Provides dynamic symbol search to select interface types and handle type parameters.
- Move declaration: A preview feature that allows moving declarations and their dependencies between files while updating references and imports.
- Available in gopls v0.24.0 and the official VS Code Go extension v0.56.0.
Why it matters
By proposing this as an open LSP standard rather than an editor-specific hack, the Go team ensures that these advanced refactoring tools can eventually benefit users of Neovim, Emacs, and other LSP-compliant editors.
Original reference: go.dev →