Skip to content

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

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 pluginuse'jrihon/mutineer.lua'
-- set up mutineerrequire('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) : localkeymap=vim.api.nvim_set_keymaplocalopts= {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[[autocmdBufNewFile,BufRead*.foosetfiletype='foobar']]

Natively supported languages

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
}

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

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages