All Projects → danymat → neogen

danymat / neogen

Licence: GPL-3.0 License
A better annotation generator. Supports multiple languages and annotation conventions.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to neogen

Comment.nvim
🧠 💪 // Smart and powerful comment plugin for neovim. Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
Stars: ✭ 796 (+134.81%)
Mutual labels:  neovim, nvim, comment, neovim-plugin, neovim-lua
Nvim Bqf
Better quickfix window in Neovim, polish old quickfix window.
Stars: ✭ 120 (-64.6%)
Mutual labels:  neovim, nvim, neovim-plugin
nvim-ghost.nvim
👻 GhostText plugin for Neovim with zero dependencies 🎉 Supports neovim running inside WSL too! 🥳 Windows/Linux/macOS supported out-of-the-box! 😄 (Other OSes need python3.6+ installed)
Stars: ✭ 32 (-90.56%)
Mutual labels:  neovim, nvim, neovim-plugin
agitator.nvim
No description or website provided.
Stars: ✭ 16 (-95.28%)
Mutual labels:  neovim, nvim, neovim-plugin
Chadtree
File manager for Neovim. Better than NERDTree.
Stars: ✭ 653 (+92.63%)
Mutual labels:  neovim, nvim, neovim-plugin
Semshi
🌈 Semantic Highlighting for Python in Neovim
Stars: ✭ 758 (+123.6%)
Mutual labels:  neovim, nvim, neovim-plugin
Lualine.nvim
A blazing fast and easy to configure neovim statusline written in pure lua.
Stars: ✭ 198 (-41.59%)
Mutual labels:  neovim, nvim, neovim-plugin
Acid.nvim
Asynchronous Clojure Interactive Development
Stars: ✭ 147 (-56.64%)
Mutual labels:  neovim, nvim, neovim-plugin
modes.nvim
Prismatic line decorations for the adventurous vim user
Stars: ✭ 299 (-11.8%)
Mutual labels:  nvim, neovim-plugin, neovim-lua
awesome-neovim
Awesome Configurations for C/C++,Zig,Web and Lua development in NeoVim
Stars: ✭ 54 (-84.07%)
Mutual labels:  nvim, neovim-plugin, neovim-lua
comment-box.nvim
✨ Clarify and beautify your comments using boxes and lines.
Stars: ✭ 91 (-73.16%)
Mutual labels:  nvim, comment, neovim-plugin
Nvim Compe
Auto completion plugin for nvim that written in Lua.
Stars: ✭ 433 (+27.73%)
Mutual labels:  neovim, nvim, neovim-plugin
Packer.nvim
A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
Stars: ✭ 418 (+23.3%)
Mutual labels:  neovim, nvim, neovim-plugin
Nvim Hlslens
Hlsearch Lens for Neovim
Stars: ✭ 55 (-83.78%)
Mutual labels:  neovim, nvim, neovim-plugin
Iron.nvim
Interactive Repl Over Neovim
Stars: ✭ 265 (-21.83%)
Mutual labels:  neovim, nvim, neovim-plugin
Lsp Status.nvim
Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
Stars: ✭ 201 (-40.71%)
Mutual labels:  neovim, nvim, neovim-plugin
lir.nvim
Neovim file explorer
Stars: ✭ 194 (-42.77%)
Mutual labels:  neovim, nvim, neovim-plugin
close-buffers.nvim
📑 Delete multiple vim buffers based on different conditions
Stars: ✭ 54 (-84.07%)
Mutual labels:  neovim, nvim, neovim-plugin
lesvim
Nvim config focus on Javascript, Typescript, Rust and Lua - 🚀 💪 ( Fast and Powerfull ) - Deno and other typescript LSP working well together
Stars: ✭ 69 (-79.65%)
Mutual labels:  neovim, nvim
dotfiles
dotfiles of my linux setup
Stars: ✭ 25 (-92.63%)
Mutual labels:  neovim, nvim

Neogen - Your Annotation Toolkit

Neovim Lua

Table Of Contents

Features

  • Create annotations with one keybind, and jump your cursor in the inserted annotation
  • Defaults for multiple languages and annotation conventions
  • Extremely customizable and extensible
  • Written in lua (and uses Tree-sitter)

screen2

Requirements

Installation

Use your favorite package manager to install Neogen, e.g:

use {
    "danymat/neogen",
    config = function()
        require('neogen').setup {}
    end,
    requires = "nvim-treesitter/nvim-treesitter",
    -- Uncomment next line if you want to follow only stable versions
    -- tag = "*" 
}

Usage

  • If you want to keep it simple, you can use the :Neogen command:
" will generate annotation for the function you're inside
:Neogen
" or you can force a certain type of annotation.
" It'll find the next upper node that matches the type
" E.g if you're on a method of a class and do `:Neogen class`, it'll find the class declaration and generate the annotation.
:Neogen func|class|type|...
  • If you like to use the lua API, I exposed a function to generate the annotations.
require('neogen').generate()

You can bind it to your keybind of choice, like so:

local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap("n", "<Leader>nf", ":lua require('neogen').generate()<CR>", opts)

Calling the generate function without any parameters will try to generate annotations for the current function.

You can provide some options for the generate, like so:

require('neogen').generate({
    type = "func" -- the annotation type to generate. Currently supported: func, class, type, file
})

For example, I can add an other keybind to generate class annotations:

local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap("n", "<Leader>nc", ":lua require('neogen').generate({ type = 'class' })<CR>", opts)

Cycle between annotations

I added support passing cursor positionings in templates. That means you can now cycle your cursor between different parts of the annotation.

If you want to map some keys to the cycling feature, you can do like so:

local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap("i", "<C-l>", ":lua require('neogen').jump_next<CR>", opts)
vim.api.nvim_set_keymap("i", "<C-h>", ":lua require('neogen').jump_prev<CR>", opts)

Or, if you want to use a key that's already used for completion purposes, take a look at the code snippet here:

nvim-cmp
local cmp = require('cmp')
local neogen = require('neogen')

cmp.setup {
    ...

    -- You must set mapping if you want.
    mapping = {
        ["<tab>"] = cmp.mapping(function(fallback)
            if require('neogen').jumpable() then
                require('neogen').jump_next()
            else
                fallback()
            end
        end, {
            "i",
            "s",
        }),
        ["<S-tab>"] = cmp.mapping(function(fallback)
            if require('neogen').jumpable(true) then
                require('neogen').jump_prev()
            else
                fallback()
            end
        end, {
            "i",
            "s",
        }),
    },
    ...
}

Configuration

require('neogen').setup {
        enabled = true,             --if you want to disable Neogen
        input_after_comment = true, -- (default: true) automatic jump (with insert mode) on inserted annotation
        -- jump_map = "<C-e>"       -- (DROPPED SUPPORT, see [here](#cycle-between-annotations) !) The keymap in order to jump in the annotation fields (in insert mode)
    }
}

If you're not satisfied with the default configuration for a language, you can change the defaults like this:

require('neogen').setup {
    enabled = true,
    languages = {
        lua = {
            template = {
                annotation_convention = "emmylua" -- for a full list of annotation_conventions, see supported-languages below,
                ... -- for more template configurations, see the language's configuration file in configurations/{lang}.lua
                }
        },
        ...
    }
}

Supported Languages

There is a list of supported languages and fields, with their annotation style

Languages Annotation Conventions Supported annotation types
sh Google Style Guide ("google_bash") func, file
c Doxygen ("doxygen") func, file
csharp Xmldoc ("xmldoc")
Doxygen ("doxygen")
func, file, class
cpp Doxygen ("doxygen") func, file, class
go GoDoc ("godoc") func, type
java Javadoc ("javadoc) func, class
javascript JSDoc ("jsdoc") func, class, type, file
jsx JSDoc ("jsdoc") func, class, type, file
lua Emmylua ("emmylua")
Ldoc ("ldoc")
func, class, type, file
php Php-doc ("phpdoc") func, type, class
python Google docstrings ("google_docstrings")
Numpydoc ("numpydoc")
reST ("reST")
func, class, type, file
ruby YARD ("yard")
Rdoc ("rdoc")
func, type, class
rust RustDoc ("rustdoc")
Alternative ("alternative")
func, file, class
typescript JSDoc ("jsdoc") func, class, type, file
tsx JSDoc ("jsdoc") func, class, type, file
vue JSDoc ("jsdoc") func, class, type, file

Adding Languages

  1. Using the defaults to generate a new language support: Adding Languages
  2. (advanced) Only if the defaults aren't enough, please see here: Advanced Integration

GIFS

screen1

screen3

screen4

Credits

  • Binx, for making that gorgeous logo for free!

Support

You like my plugin and want to express your gratitude 👼 ? You can suppport me by donating the equivalent of my morning coffee (no minimum required). I would really appreciate your support as it can motivate me to continue this journey 💝

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].