Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/javiorfo/nvim-hemingway

Neovim plugin written in Lua for commenting code
https://github.com/javiorfo/nvim-hemingway

commentary comments neovim neovim-plugin

Last synced: about 2 months ago
JSON representation

Neovim plugin written in Lua for commenting code

Awesome Lists containing this project

README

        

# 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 | :heavy_check_mark: | Set by `HemingwayComment` |
| Multiline comment | :heavy_check_mark: | Set by `HemingwayMultiComment` |
| Comment on Normal Mode | :heavy_check_mark: | Using `HemingwayComment` |
| Comment on Visual Mode | :heavy_check_mark: | Using `HemingwayMultiComment` |
| Comment on Insert Mode | :x: | |
| Undo comment | :heavy_check_mark: | Executing the same command over a commented line |
| Supported filetypes | :heavy_check_mark: | [Check this file](https://github.com/javiorfo/nvim-hemingway/blob/master/lua/hemingway.lua) |
| Add comment to filetype not included | :heavy_check_mark: | By the `setup` function |

## Installation
`Packer`
```lua
use {
'javiorfo/nvim-hemingway',
requires = 'javiorfo/nvim-popcorn'
}
```
`Lazy`
```lua
{
'javiorfo/nvim-hemingway',
lazy = true,
dependencies = { 'javiorfo/nvim-popcorn' },
cmd = { "HemingwayInfo" },
keys = {
{ "co", "HemingwayComment" },
{ "co", "HemingwayMultiComment", mode = "v" },
}
}
```

## Usage
- Set mappings in *init.lua* (Packer)
```lua
local opts = { noremap = true, silent = true }

-- Normal mode
vim.api.nvim_set_keymap('n', 'co', 'HemingwayComment', opts)
-- Visual mode
vim.api.nvim_set_keymap('v', 'co', 'HemingwayMultiComment', 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](https://github.com/javiorfo/nvim-hemingway/blob/master/lua/hemingway.lua). If there is no value for the file you are using, you can set it in your personal Neovim init.lua:
```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](https://github.com/javiorfo/nvim-nyctophilia) is used in these images.

---

### Donate
- **Bitcoin** [(QR)](https://raw.githubusercontent.com/javiorfo/img/master/crypto/bitcoin.png) `1GqdJ63RDPE4eJKujHi166FAyigvHu5R7v`
- [Paypal](https://www.paypal.com/donate/?hosted_button_id=FA7SGLSCT2H8G)