{"id":13895930,"url":"https://github.com/Badhi/nvim-treesitter-cpp-tools","last_synced_at":"2025-07-17T11:32:42.391Z","repository":{"id":39921102,"uuid":"436270699","full_name":"Badhi/nvim-treesitter-cpp-tools","owner":"Badhi","description":"C++ Helper Snippets Using Treesitter","archived":false,"fork":false,"pushed_at":"2024-07-01T01:33:39.000Z","size":901,"stargazers_count":122,"open_issues_count":3,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-07T18:37:05.070Z","etag":null,"topics":["cpp","lua","neovim","nvim","nvim-treesitter","treesitter"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Badhi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-08T14:09:35.000Z","updated_at":"2024-08-04T00:50:18.000Z","dependencies_parsed_at":"2023-02-04T16:31:33.672Z","dependency_job_id":"bc67e1f3-5693-417e-aaf3-1c3a3e454c27","html_url":"https://github.com/Badhi/nvim-treesitter-cpp-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"nvim-treesitter/module-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badhi%2Fnvim-treesitter-cpp-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badhi%2Fnvim-treesitter-cpp-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badhi%2Fnvim-treesitter-cpp-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badhi%2Fnvim-treesitter-cpp-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Badhi","download_url":"https://codeload.github.com/Badhi/nvim-treesitter-cpp-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226260601,"owners_count":17596494,"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":["cpp","lua","neovim","nvim","nvim-treesitter","treesitter"],"created_at":"2024-08-06T18:02:34.398Z","updated_at":"2024-11-25T01:30:49.035Z","avatar_url":"https://github.com/Badhi.png","language":"Lua","readme":"# nt-cpp-tools\n![Unit Tests](https://github.com/badhi/nvim-treesitter-cpp-tools/actions/workflows/unit_tests.yml/badge.svg)\n\nExperimental treesitter based neovim plugin to create intelligent implementations for C++\n\n## Features\n\n1. Out-of class member function implementation\n2. Concrete class implement from Abstract class or Interface\n3. Add missing functions to obey Rule of 3\n4. Add missing functions to obey Rule of 5\n\n## Install\n\nUsing [paq](https://github.com/savq/paq-nvim)\n\n```lua\nrequire \"paq\" {\n    \"nvim-treesitter/nvim-treesitter\",\n    \"Badhi/nvim-treesitter-cpp-tools\",\n}\n```\n\nUsing [packer.nvim](https://github.com/wbthomason/packer.nvim)\n\n```lua\nuse {\n    requires = { \"nvim-treesitter/nvim-treesitter\" },\n    \"Badhi/nvim-treesitter-cpp-tools\",\n}\n```\n\nUsing [lazy.nvim](https://github.com/folke/lazy.nvim)\n```lua\n{\n    \"Badhi/nvim-treesitter-cpp-tools\",\n    dependencies = { \"nvim-treesitter/nvim-treesitter\" },\n    -- Optional: Configuration\n    opts = function()\n        local options = {\n            preview = {\n                quit = \"q\", -- optional keymapping for quit preview\n                accept = \"\u003ctab\u003e\", -- optional keymapping for accept preview\n            },\n            header_extension = \"h\", -- optional\n            source_extension = \"cpp\", -- optional\n            custom_define_class_function_commands = { -- optional\n                TSCppImplWrite = {\n                    output_handle = require(\"nt-cpp-tools.output_handlers\").get_add_to_cpp(),\n                },\n                --[[\n                \u003cyour impl function custom command name\u003e = {\n                    output_handle = function (str, context) \n                        -- string contains the class implementation\n                        -- do whatever you want to do with it\n                    end\n                }\n                ]]\n            },\n        }\n        return options\n    end,\n    -- End configuration\n    config = true,\n}\n```\n\n## Setup\n\n**For [lazy.nvim](https://github.com/folke/lazy.nvim), see [Install](#install)**\n\nAdd the following config to your init script\n\n\u003e **Note:** The config for this plugin, included in the `treesitter.config` is now moved to an independent config. Please make required changes\n\n```lua\nrequire 'nt-cpp-tools'.setup({\n    preview = {\n        quit = 'q', -- optional keymapping for quit preview\n        accept = '\u003ctab\u003e' -- optional keymapping for accept preview\n    },\n    header_extension = 'h', -- optional\n    source_extension = 'cxx', -- optional\n    custom_define_class_function_commands = { -- optional\n        TSCppImplWrite = {\n            output_handle = require'nt-cpp-tools.output_handlers'.get_add_to_cpp()\n        }\n        --[[\n        \u003cyour impl function custom command name\u003e = {\n            output_handle = function (str, context) \n                -- string contains the class implementation\n                -- do whatever you want to do with it\n            end\n        }\n        ]]\n    }\n})\n```\n\n## Usage\n\n* Select the range of the class using visual mode\n* Use below commands\n\n| Command      | Feature |\n| ----------- | ----------- |\n| `TSCppDefineClassFunc`      | Implement out of class member functions\u003cbr\u003e\u003cbr\u003e *subset of functions can be implemented by selecting required function declarations using visual mode or simply keeping the cursor on the function declaration before calling the command*\u003cbr\u003e\u003cbr\u003eSupported special features\u003cbr\u003e1. Templates (with default args)\u003cbr\u003e2. Function arguments with default values\u003cbr\u003e3. Nested classes\u003cbr\u003e(check [test_cases](https://github.com/Badhi/nvim-treesitter-cpp-tools/blob/master/test/implement_functions.txt) for tested  examples)|\n| `TSCppMakeConcreteClass`   | Create a concrete class implementing all the pure virtual functions        |\n| `TSCppRuleOf3`   | Adds the missing function declarations to the class to obey the Rule of 3 (if eligible)        |\n| `TSCppRuleOf5`   | Adds the missing function declarations to the class to obey the Rule of 5 (if eligible)        |\n\n\n## Example\n\n1. `TSCppDefineClassFunc`\n\n![TSImplementFunc](https://user-images.githubusercontent.com/10277051/152277748-d7c0204a-b54e-4ae1-90ac-b1e4cbd51ba5.gif)\n\n2. `TSCppMakeConcreteClass`\n\n![TSConcreteClass](https://user-images.githubusercontent.com/10277051/152278222-d20e34f0-542d-451e-ae16-646f68e9f72f.gif)\n\n3. `TSCppRuleOf3`\n\n![TSRuleOf3](https://user-images.githubusercontent.com/10277051/152277800-a2573916-5e8a-4f3a-804f-88f6f6994281.gif)\n\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBadhi%2Fnvim-treesitter-cpp-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBadhi%2Fnvim-treesitter-cpp-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBadhi%2Fnvim-treesitter-cpp-tools/lists"}