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

Add to your init.lua with packer.nvim.
-- in your init.lua, to install the pluginuse'jrihon/mutineer.lua'-- set up mutineerrequire('mutineer').setup()require('mutineer').setup({
lineCommentSymbols= {
lua='--',
}
})The command :Mutineer handles both single line and multiline commenting/uncommenting.
-- I did the following in my init.lua (`m` stands for mute) : localkeymap=vim.api.nvim_set_keymaplocalopts= {noremap=true, silent=true }
keymap('n', '<leader>m', ':Mutineer<CR>', opts)
keymap('v', '<leader>m', ':Mutineer<CR>', opts)- It suffices to have the cursor on a line and to then actuate the command.
- Multiline comments are actuated by using
Visual Modeand higlighting the desired lines. - Uncommenting a line is handles by the same command
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[[autocmdBufNewFile,BufRead*.foosetfiletype='foobar']]lineCommentSymbols= { asm=';', -- Assemblyc='//', -- Ccpp='//', -- C++cs='//', -- C#csh='#', -- C-shelld='//', -- Ddart='//', -- Dartgo='//', -- Golanghs='--', -- Haskelljava='//', -- Javajavascript='//', -- JavaScriptkotlin='//', -- Kotlinlua='--', -- Luamatlab='%', -- Matlabperl='#', -- Perlphp='//', -- PHPpython='#', -- Pythonruby='#', -- Rubyrust='//', -- Rustsh='#', -- Shellsql='--', -- SQLswift='//', -- Swifttex='%', -- LaTeXtypescript='//', -- TypeScriptvim='"', -- Vimyml='#', -- YAMLzsh='#', -- Z-shell
}
My roommate for being excited whenever I sent him shows of progress while coding Mutineer.vim and now Mutineer.lua . Thanks S <3