/comment-mode

Neovim plugin for comment mode

Primary LanguageLuaMIT LicenseMIT

comment-mode

Neovim plugin for comment mode.

Background

I'm not a fan of default setting from Neovim that automatically insert the current comment leader after hitting <Enter>, 'o' or 'O'.

Screen.Recording.2023-07-19.at.15.50.28.mov

I want to control this behaviour.

How to use

Install the plugin with your preferred package manager:

lazy.nvim

{ "didadadida93/comment-mode" }

packer

--- Lua
{ "didadadida93/comment-mode" }

Once installed, call init function to setup autocmd and user command. It also recommended to call init function at the end of your init.lua file.

-- init.lua
-- ...other configuration
require('comment-mode').init()

By default it will turn off the comment mode.

Screen.Recording.2023-07-19.at.18.55.39.mov
you can toggle comment mode
:ToggleCommentMode
or set a keymap to toggle comment mode
vim.keymap.set('n', '<your keymap>', require('comment-mode').toggle_comment_mode, {})
comment-mode is also come with lualine component
sections = {
  lualine_x = {
    require('comment-mode').comment_mode_component,
  },
}
Screen.Recording.2023-07-19.at.19.29.38.mov

vim.g.commentmode = true -- set comment mode `on` when starting nvim

Contribution

All contribution are welcome! Open issue, pull request, etc.