Fuzzy search Go std lib packages and project packages.
Screenshot is showing the Snacks picker.
- Browse and search Go standard library packages and project packages.
- Native syntax highlighting for Go documentation.
- Optionally leverage
stdsym
for symbols searching. - Supports pickers:
- Neovim >= 0.8.0
- Go installation with
go doc
andgo list
commands available - Tree-sitter (for syntax highlighting)
Using lazy.nvim:
{
"fredrikaverpil/godoc.nvim",
version = "*",
dependencies = {
{ "nvim-telescope/telescope.nvim" }, -- optional
{ "folke/snacks.nvim" }, -- optional
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "go" },
},
},
},
build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional
cmd = { "GoDoc" }
opts = {},
}
The plugin provides the following command:
:GoDoc
- Open picker and search packages.:GoDoc <package>
- Directly open documentation for the specified package or symbol.
Warning
The :GoDoc
command is also used by
x-ray/go.nvim. You can configure this
plugin's command to something else if you wish.
:GoDoc " browse all standard library packages
:GoDoc strings " view documentation for the strings package
:GoDoc strings.Builder " view documentation for strings.Builder
local godoc = require("godoc.nvim")
godoc.show_native_picker() -- search packages using the native Neovim picker
godoc.show_telescope_picker() -- search packages using the telescope picker
godoc.show_snacks_picker() -- search packages using the Snacks.nvim picker
godoc.show_documentation("strings.Builder") -- view docs for strings.Builder
These are the defaults:
opts = {
command = "GoDoc", -- the desired Vim command to use
window = {
type = "split", -- split or vsplit
},
highlighting = {
language = "go", -- the tree-sitter parser used for syntax highlighting
},
picker = {
type = "native", -- native, telescope or snacks
snacks_options = {
layout = {
layout = {
height = 0.8,
width = 0.9, -- Take up 90% of the total width (adjust as needed)
box = "horizontal", -- Horizontal layout (input and list on the left, preview on the right)
{ -- Left side (input and list)
box = "vertical",
width = 0.3, -- List and input take up 30% of the width
border = "rounded",
{ win = "input", height = 1, border = "bottom" },
{ win = "list", border = "none" },
},
{ win = "preview", border = "rounded", width = 0.7 }, -- Preview window takes up 70% of the width
},
},
win = {
preview = {
wo = { wrap = true },
},
},
},
},
}
The plugin includes a health check to verify your Go installation and documentation system:
:checkhealth godoc
Contributions are welcome! Please feel free to submit a pull request.
I would be extra interested in discussions and contributions around improving
the syntax highlighting of go doc
output, as it is currently quite messy to
just apply the syntax highlighting of Go syntax.