Skip to content

dhananjaylatkar/docgen.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docgen.nvim

Generate function docs using treesitter

docgen.nvim.webm

Installation

Using lazy.nvim

{
  "dhananjaylatkar/docgen.nvim",
  dependencies = {
    {
    -- make sure parser for your language is installed
      "nvim-treesitter/nvim-treesitter",
      config = function()
        require("nvim-treesitter.configs").setup({
          ensure_installed = { "c" },
        })
      end,
      run = ":TSUpdate",
    }
  },
  opts = {
    -- USE EMPTY FOR DEFAULT OPTIONS
    -- DEFAULTS ARE LISTED BELOW
  },
}

Configuration

You must run require("docgen").setup() to initialize the plugin.

docgen.nvim comes with following defaults:

-- default doc format for each supported language
{
  c = "doxygen", -- "doxygen" or "kernel_doc"
}

Commands

Command Action
:DocGen Insert doc for function in scope using configured format
:DocGen <format> Insert doc for function in scope using given format

Contributing

You can add support for your language or format easily.

Adding new language support

  1. Create lua/parsers/<lang>.lua
  2. Expose get_doc() which shall return a table as follows -
{
  start_pos = "<start pos of doc>",
  ins_pos = "<pos of cursor after inserting>",
  comment = "<list of doc comments>"
}

Adding new doc format

In lua/parsers/<lang>.lua add else condition in get_doc() for doc_format.