Skip to content

Commit 010d34a

Browse files
docs: code lens command for Neovim
This adds a lead on how to render code lenses inline, for gopls, in Neovim. A full example for Neovim v0.11.0: ```lua local config = { cmd = { "gopls" }, filetypes = { "go", "gomod", "gowork", "gosum" }, root_markers = { "go.work", "go.mod", ".git" }, on_attach = function(client, bufnr) if client.supports_method("textDocument/codeLens") then vim.lsp.codelens.refresh() vim.api.nvim_create_autocmd( { "BufEnter", "CursorHold", "InsertLeave" }, { buffer = bufnr, callback = vim.lsp.codelens.refresh }, ) end end, settings = { gopls = { -- https://github.com/golang/tools/blob/master/gopls buildFlags = { "-tags=wireinject,integration" }, gofumpt = false, }, }, } vim.lsp.config["gopls"] = config vim.lsp.enable("gopls", true) ```
1 parent e426616 commit 010d34a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

gopls/doc/codelenses.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Client support:
1818
- **VS Code**: Code Lenses appear as small text links above a line of source code.
1919
- **Emacs + eglot**: Not supported, but prototype exists at https://github.com/joaotavora/eglot/pull/71.
2020
- **Vim + coc.nvim**: ??
21+
- **Neovim**: Run `vim.lsp.codelens.refresh({ bufnr = 0 })` to refresh code lenses for current buffer. Run `vim.lsp.codelens.run()` to pick a lens. See `:h vim.lsp.codelens` for more details.
2122
- **CLI**: `gopls codelens`. For example, `gopls codelens -exec file.go:123 "run test"` runs the test at the specified line.
2223

2324

0 commit comments

Comments
 (0)