8000 GitHub - fredrikaverpil/godoc.nvim at v1.3.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fuzzy search Go packages/symbols and view docs from within Neovim

License

Notifications You must be signed in to change notification settings

fredrikaverpil/godoc.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godoc

godoc.nvim

Fuzzy search Go std lib packages and project packages.

Screenshots

Snacks picker Screenshot is showing the Snacks picker.

Telescope picker

Telescope picker

Native picker

Native picker

Features

  • Browse and search Go standard library packages and project packages.
  • Native syntax highlighting for Go documentation.
  • Optionally leverage stdsym for symbols searching.
  • Supports pickers:
    • Native Neovim picker (no preview)
    • Telescope picker with preview
    • Snacks picker with preview
    • mini.pick picker with preview

Requirements

  • Neovim >= 0.8.0
  • Go installation with go doc and go list commands available
  • Tree-sitter (for syntax highlighting)

Installation

Using lazy.nvim:

{
    "fredrikaverpil/godoc.nvim",
    version = "*",
    dependencies = {
        { "nvim-telescope/telescope.nvim" }, -- optional
        { "folke/snacks.nvim" }, -- optional
        { "echasnovski/mini.pick" }, -- optional
        {
            "nvim-treesitter/nvim-treesitter",
            opts = {
              ensure_installed = { "go" },
            },
        },
    },
    build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional
    cmd = { "GoDoc" },
    opts = {},
}

Usage

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 disable this by passing remap_commands = { GoDoc = false } to x-ray/go.nvim or you can customize the godoc.nvim command.

Examples

: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")
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_mini_picker()  -- search packages using the mini.pick picker
godoc.get_documentation("strings.Builder")  -- get the godoc (returns table<string>)
godoc.show_documentation("strings.Builder")  -- view docs for strings.Builder in split

Configuration

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, snacks or mini
        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 },
                },
            },
        },
    },
}

Health Check

The plugin includes a health check to verify your Go installation and documentation system:

:checkhealth godoc

Contributing

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 the output becomes quite "busy" and incoherent now, when applying the syntax highlighting of Go syntax.

0