{"id":13412958,"url":"https://github.com/s1n7ax/nvim-comment-frame","last_synced_at":"2025-09-28T20:32:34.838Z","repository":{"id":48410338,"uuid":"387168219","full_name":"s1n7ax/nvim-comment-frame","owner":"s1n7ax","description":"Detects the language using treesitter and adds a comment block","archived":false,"fork":false,"pushed_at":"2025-02-24T06:05:49.000Z","size":75,"stargazers_count":97,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T12:42:04.662Z","etag":null,"topics":["comments","lua","neovim","neovim-plugin","nvim","plugin","treesitter"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s1n7ax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-18T12:16:17.000Z","updated_at":"2025-03-09T15:32:15.000Z","dependencies_parsed_at":"2023-01-19T21:46:32.182Z","dependency_job_id":null,"html_url":"https://github.com/s1n7ax/nvim-comment-frame","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1n7ax%2Fnvim-comment-frame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1n7ax%2Fnvim-comment-frame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1n7ax%2Fnvim-comment-frame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1n7ax%2Fnvim-comment-frame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s1n7ax","download_url":"https://codeload.github.com/s1n7ax/nvim-comment-frame/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635198,"owners_count":20322896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comments","lua","neovim","neovim-plugin","nvim","plugin","treesitter"],"created_at":"2024-07-30T20:01:31.604Z","updated_at":"2025-09-28T20:32:29.788Z","avatar_url":"https://github.com/s1n7ax.png","language":"Lua","funding_links":[],"categories":["Editing Support","Lua"],"sub_categories":["Comment"],"readme":"# nvim-comment-frame\n\nBasically when you give it some text it creates a comment frame like below.\n\n```\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n~~                   nvim-comment-frame                   ~~\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n```\n\n## Features\n\n- Language detection\n- Wrap lines\n- Auto indent\n\n### Language detection\n\n- Detects the current language using `treesitter` and changes\nthe comment string based on the language.\n\n**JavaScript**\n\n```javascript\n//--------------------------------------------------------//\n//       JavaScript, often abbreviated as JS, is a        //\n//       programming language that conforms to the        //\n//                ECMAScript specification                //\n//--------------------------------------------------------//\nvar fs = require('fs');\nvar path = require('path');\n\nvar BUFFER = bufferFile('../public/data.png');\n\nfunction bufferFile(relPath) {\n    return fs.readFileSync(path.join(__dirname, relPath));\n}\n```\n\n**Bash**\n\n```bash\n#----------------------------------------------------------#\n#    Bash is a Unix shell and command language written     #\n#                       by Brian Fox                       #\n#----------------------------------------------------------#\nfor i in $(seq 1 10);\ndo\n    echo $i\ndone\n```\n\n**Lua**\n\n```lua\n--********************************************************--\n--    Lua is a lightweight, high-level, multi-paradigm    --\n--      programming language designed primarily for       --\n--              embedded use in applications              --\n--********************************************************--\nfunction String.trim(str)\n    return str:gsub('^%s+', ''):gsub('%s+$', '')\nend\n```\n\n### Wrap lines\n\n**CSS**\n\n```css\n/*------------------------------------------------------------------*/\n/*         Cascading Style Sheets is a style sheet language         */\n/*        used for describing the presentation of a document        */\n/*        written in a markup language such as HTML. CSS is         */\n/*         a cornerstone technology of the World Wide Web,          */\n/*                  alongside HTML and JavaScript.                  */\n/*------------------------------------------------------------------*/\nbody, h1 {\n    font-family: arial,sans-serif;\n    font-size: 14px;\n}\n```\n\n### Auto indent\n\n- `auto_indent` is set to `true` by default. When this option is on, plugin will\nuse `treesitter` to get the indentation of the current line and indent the comment\n- Based on the `expandtab` option, plugin will use `tab` or `space` for\n  indentation\n- You can turn off this globally or just for a language by `auto_indent = false`\n\n```c\ndetachstack(Client *c)\n{\n    Client **tc, *t;\n\n    for (tc = \u0026c-\u003emon-\u003estack; *tc \u0026\u0026 *tc != c; tc = \u0026(*tc)-\u003esnext);\n    *tc = c-\u003esnext;\n    //--------------------------------------------------------//\n    //      C is a general-purpose, procedural computer       //\n    //       programming language supporting structured       //\n    //        programming, lexical variable scope, and        //\n    //          recursion, with a static type system          //\n    //--------------------------------------------------------//\n\n    if (c == c-\u003emon-\u003esel) {\n        for (t = c-\u003emon-\u003estack; t \u0026\u0026 !ISVISIBLE(t); t = t-\u003esnext);\n        c-\u003emon-\u003esel = t;\n    }\n}\n```\n\n## Install\n\n**Packer**\n\n- Add the plugin to the configuration\n\n```lua\nuse { \n    's1n7ax/nvim-comment-frame',\n    requires = {\n        { 'nvim-treesitter' }\n    },\n    config = function()\n        require('nvim-comment-frame').setup()\n    end\n}\n```\n\n- Install the plugin\n\n```vim\n:PackerInstall\n```\n\n- Compile the packages\n\n```\n:PackerCompile\n```\n\n## Keymaps\n\n### Following are the default keymaps.\n\n- `\u003cleader\u003ecf` - Single line comment\n- `\u003cleader\u003ecm` - Multiline comment\n\n### Adding custom keymaps\n\n```lua\nrequire('nvim-comment-frame').setup({\n    keymap = '\u003cleader\u003ecc',\n    --       ^^^^^^^^^^^ change this to what ever you want\n\n    multiline_keymap = '\u003cleader\u003eC',\n    --                 ^^^^^^^^^^^ change this to what ever you want\n})\n```\n\n### Adding keymaps manually\n\n#### Lua\n\n```lua\nvim.api.nvim_set_keymap('n', '\u003cleader\u003ecc', \":lua require('nvim-comment-frame').add_comment()\u003cCR\u003e\", {})\n--                           ^^^^^^^^^^^ change this to what ever you want\n\nvim.api.nvim_set_keymap('n', '\u003cleader\u003eC', \":lua require('nvim-comment-frame').add_multiline_comment()\u003cCR\u003e\", {})\n--                           ^^^^^^^^^^^ change this to what ever you want\n```\n\n#### Vimscript\n\n```vim\nnmap \u003cleader\u003ecc :lua require('nvim-comment-frame').add_comment()\u003cCR\u003e\n\"   ^^^^^^^^^^^ change this to what ever you want\n\nnmap \u003cleader\u003eC :lua require('nvim-comment-frame').add_multiline_comment()\u003cCR\u003e\n\"   ^^^^^^^^^^^ change this to what ever you want\n```\n\n\n## Configurations\n\n### Common configurations\n\nExcept `disable_default_keymap` and `keymap`, all the other properties can be\noverridden for individual language.\n\nFollowing are the general configurations with default values.\n\n```lua\nrequire('nvim-comment-frame').setup({\n\n    -- if true, \u003cleader\u003ecf keymap will be disabled\n    disable_default_keymap = false,\n\n    -- adds custom keymap\n    keymap = '\u003cleader\u003ecc',\n    multiline_keymap = '\u003cleader\u003eC',\n\n    -- start the comment with this string\n    start_str = '//',\n\n    -- end the comment line with this string\n    end_str = '//',\n\n    -- fill the comment frame border with this character\n    fill_char = '-',\n\n    -- width of the comment frame\n    frame_width = 70,\n\n    -- wrap the line after 'n' characters\n    line_wrap_len = 50,\n\n    -- automatically indent the comment frame based on the line\n    auto_indent = true,\n\n    -- add comment above the current line\n    add_comment_above = true,\n\n    -- configurations for individual language goes here\n    languages = {\n    }\n})\n```\n\n### Language specific configurations\n\n```lua\nrequire('nvim-comment-frame').setup({\n    languages = {\n        -- configuration for Lua programming language\n        -- @NOTE global configuration will be overridden by language level\n        -- configuration if provided\n        lua = {\n            -- start the comment with this string\n            start_str = '--[[',\n\n            -- end the comment line with this string\n            end_str = ']]--',\n\n            -- fill the comment frame border with this character\n            fill_char = '*',\n\n            -- width of the comment frame\n            frame_width = 100,\n\n            -- wrap the line after 'n' characters\n            line_wrap_len = 70,\n\n            -- automatically indent the comment frame based on the line\n            auto_indent = false,\n\n            -- add comment above the current line\n            add_comment_above = false,\n        },\n    }\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1n7ax%2Fnvim-comment-frame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs1n7ax%2Fnvim-comment-frame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1n7ax%2Fnvim-comment-frame/lists"}