Skip to content

jrihon/mutineer.lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mutineer.lua

Simplifies commenting and uncommenting lines of code for all and custom filetypes Simplifies commenting and uncommenting lines of code

Installation

Add to your init.lua with packer.nvim.

  -- in your init.lua, to install the plugin
  use 'jrihon/mutineer.lua'
  -- set up mutineer
  require('mutineer').setup()

Configuration

Extend with custom commenting symbols

require('mutineer').setup({
                            lineCommentSymbols = {
                                                    lua = '--',
                                                }
                        })

Mappings

The command :Mutineer handles both single line and multiline commenting/uncommenting.

-- I did the following in my init.lua (`m` stands for mute) : 
local keymap = vim.api.nvim_set_keymap
local opts = {noremap = true, silent = true }
keymap('n', '<leader>m', ':Mutineer<CR>', opts)
keymap('v', '<leader>m', ':Mutineer<CR>', opts)

Usage

  • It suffices to have the cursor on a line and to then actuate the command.
  • Multiline comments are actuated by using Visual Mode and higlighting the desired lines.
  • Uncommenting a line is handles by the same command

Custom filetypes

You can check if vim recognises your filetype by :echo &filetype or :lua print(vim.bo.filetype).
If this command returns or nil, the filetype is not recognised.

path/to/mutineer.lua/docs/AllKnownVimFileTypes.txt contains a list of all the natively recognised filetypes.

To have a certain filetype recognised :

vim.cmd[[autocmd BufNewFile,BufRead *.foo set filetype='foobar']]

Natively supported languages

  lineCommentSymbols = {    asm = ';',              -- Assembly
                            c = '//',               -- C
                            cpp = '//',             -- C++
                            cs = '//',              -- C#
                            csh = '#',              -- C-shell
                            d = '//',               -- D
                            dart = '//',            -- Dart
                            go = '//',              -- Golang
                            hs = '--',              -- Haskell
                            java = '//',            -- Java
                            javascript = '//',      -- JavaScript
                            kotlin = '//',          -- Kotlin
                            lua = '--',             -- Lua
                            matlab = '%',           -- Matlab
                            perl = '#',             -- Perl
                            php = '//',             -- PHP
                            python = '#',           -- Python
                            ruby = '#',             -- Ruby
                            rust = '//',            -- Rust
                            sh = '#',               -- Shell
                            sql = '--',             -- SQL
                            swift = '//',           -- Swift
                            tex = '%',              -- LaTeX
                            typescript = '//',      -- TypeScript
                            vim = '"',              -- Vim
                            yml = '#',              -- YAML
                            zsh = '#',              -- Z-shell
                        }

Acknowledgements

My roommate for being excited whenever I sent him shows of progress while coding Mutineer.vim and now Mutineer.lua . Thanks S <3

About

Commenting in nvim - Lua Edition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages