Skip to content

docs(plugin): add docs for installing comment.nvim with lazy.nvim #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@

### 🚀 Installation

- With [lazy.nvim](https://github.com/folke/lazy.nvim)

```lua
return {
'numToStr/Comment.nvim',
keys = { -- example keymaps for lazy loading this plugin.
{ "gcc", mode = "n", desc = "Toggles the current line using linewise comment" },
{ "gbc", mode = "n", desc = "Toggles the current line using blockwise comment" },
{ "gc", mode = "v", desc = "Toggles the region using linewise comment" },
{ "gb", mode = "v", desc = "Toggles the region using blockwise comment" },
Comment on lines +26 to +29
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is way too much noise for an install instruction.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the recommended way to install via lazy.nvim?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of keys here is to register the key mapping, but not load the plugin until the keys are actually use (ie 'lazy' load it).

If you don't include keys, then the next best thing would be using an event to use.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That file specifically, or comment.nvim in general?

I am looking at that file, and I'm kinda surprised to not see a setup method 🤔 Actually, it looks like https://github.com/numToStr/Comment.nvim/blob/master/lua/Comment/init.lua is what would actually be loaded via require('Comment').setup.

Lazy.nvim has a convention of, if you have opts = true or opts = { ... }, it essentially ends up doing:

require('Comment').setup(opts)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@technicalpickles setup() method in init.lua create keymaps. And Comment.lua file is for Plug mappings and is the base for most of the keymaps in init.lua. Also, in general <Plug> mappings should never require any setup() call in any plugin.

Assuming if a user doesn't want any keymaps, they don't need to call setup() they can directly use <Plug> mappings to create their own keymaps.

},
opts = {} -- lazy equivalent to setup({}) function
}
```

- With [packer.nvim](https://github.com/wbthomason/packer.nvim)

```lua
Expand Down