Skip to content

javiorfo/nvim-hemingway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-hemingway

nvim-hemingway is a minimal Neovim plugin written in Lua for commenting code.

Caveats

  • This plugin has been developed on and for Linux following open source philosophy.

Overview

Feature nvim-hemingway NOTE
Single comment ✔️ Set by HemingwayComment
Multiline comment ✔️ Set by HemingwayMultiComment
Comment on Normal Mode ✔️ Using HemingwayComment
Comment on Visual Mode ✔️ Using HemingwayMultiComment
Comment on Insert Mode
Undo comment ✔️ Executing the same command over a commented line
Supported filetypes ✔️ Check this file
Add comment to filetype not included ✔️ By the setup function

Installation

Packer

use {
    'javiorfo/nvim-hemingway',
    requires = 'javiorfo/nvim-popcorn'
}

Lazy

{
    'javiorfo/nvim-hemingway',
    lazy = true,
    dependencies = { 'javiorfo/nvim-popcorn' },
    cmd = { "HemingwayInfo" },
    keys = {
        { "<leader>co", "<Plug>HemingwayComment" },
        { "<leader>co", "<Plug>HemingwayMultiComment", mode = "v" },
    }
}

Usage

  • Set mappings in init.lua (Packer)
local opts = { noremap = true, silent = true }

-- Normal mode 
vim.api.nvim_set_keymap('n', '<leader>co', '<Plug>HemingwayComment', opts)
-- Visual mode
vim.api.nvim_set_keymap('v', '<leader>co', '<Plug>HemingwayMultiComment<CR>', opts)
  • Executing the map corresponding to HemingwayComment with the cursor in a specific line, it will comment the aforementioned line with the corresponding comment string of the file.
  • In VISUAL MODE. Executing the map corresponding to HemingwayMultiComment with the cursor in a specific line or multiple lines will comment the aforementioned line (or lines) with the comment string of the file.
  • Executing any of these commands in a commented line will uncomment that line (or lines)
  • The main strings used for comments are the ones taken from this file. If there is no value for the file you are using, you can set it in your personal Neovim init.lua:
-- Depending on the filetype comment style
require'hemingway'.add_comments{
    myfiletype1 = { single = "** " },
    myfiletype2 = { left = "*|* ", right = " *|*" },
    myfiletype3 = { single = "** ", left = "*|* ", right = " *|*"  },
}
  • To see commentary info about the current file, execute command line :HemingwayInfo

Screenshots

Comments in Java and XML files:

lua comments

NOTE: The colorscheme umbra from nvim-nyctophilia is used in these images.


Donate

  • Bitcoin (QR) 1GqdJ63RDPE4eJKujHi166FAyigvHu5R7v
  • Paypal