GitHub 您所在的位置:网站首页 commentat GitHub

GitHub

2024-07-12 07:00| 来源: 网络整理| 查看: 265

// Comment.nvim

⚡ Smart and Powerful commenting plugin for neovim ⚡

Comment.nvim

✨ Features Supports treesitter. Read more Supports commentstring. Read :h comment.commentstring Supports line (//) and block (/* */) comments Dot (.) repeat support for gcc, gbc and friends Count support for [count]gcc and [count]gbc Left-right (gcw gc$) and Up-Down (gc2j gc4k) motions Use with text-objects (gci{ gbat) Supports pre and post hooks Ignore certain lines, powered by Lua regex 🚀 Installation With lazy.nvim -- add this to your lua/plugins.lua, lua/plugins/init.lua, or the file you keep your other plugins: { 'numToStr/Comment.nvim', opts = { -- add any options here } } With packer.nvim use { 'numToStr/Comment.nvim', config = function() require('Comment').setup() end } With vim-plug '">-- ignores empty lines ignore = '^$' -- ignores line that starts with `local` (excluding any leading whitespace) ignore = '^(%s*)local' -- ignores any lines similar to arrow function ignore = '^const(.*)=(%s?)%((.*)%)(%s?)=>' With function { ignore = function() -- Only ignore empty lines for lua files if vim.bo.filetype == 'lua' then return '^$' end end, }

🗨️ Filetypes + Languages

Most languages/filetypes have native support for comments via commentstring but there might be a filetype that is not supported. There are two ways to enable commenting for unsupported filetypes:

You can set commentstring for that particular filetype like the following. Read :h commentstring for more info. vim.bo.commentstring = '//%s' -- or vim.api.nvim_command('set commentstring=//%s')

You can also use this plugin interface to store both line and block commentstring for the filetype. You can treat this as a more powerful version of the commentstring. Read :h comment.ft for more info. local ft = require('Comment.ft') -- 1. Using set function ft -- Set only line comment .set('yaml', '#%s') -- Or set both line and block commentstring .set('javascript', {'//%s', '/*%s*/'}) -- 2. Metatable magic ft.javascript = {'//%s', '/*%s*/'} ft.yaml = '#%s' -- Multiple filetypes ft({'go', 'rust'}, ft.get('c')) ft({'toml', 'graphql'}, '#%s')

PR(s) are welcome to add more commentstring inside the plugin

🤝 Contributing

There are multiple ways to contribute reporting/fixing bugs, feature requests. You can also submit commentstring to this plugin by updating ft.lua and sending PR.

📺 Videos TakeTuesday E02: Comment.nvim by TJ DeVries 💐 Credits tcomment - To be with me forever and motivated me to write this. nvim-comment - Little and less powerful cousin. Also I took some code from it. kommentary - Nicely done plugin but lacks some features. But it helped me to design this plugin. 🚗 Roadmap Doc comment i.e /**%s*/ (js), ///%s (rust) Header comment ---------------------- -- This is a header -- ----------------------


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有