{"id":15144330,"url":"https://github.com/david-kunz/treesitter-unit","last_synced_at":"2025-10-23T20:32:21.082Z","repository":{"id":45724226,"uuid":"398533404","full_name":"David-Kunz/treesitter-unit","owner":"David-Kunz","description":"A Neovim plugin to deal with treesitter units","archived":false,"fork":false,"pushed_at":"2021-09-12T07:46:54.000Z","size":43,"stargazers_count":155,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-30T21:04:34.029Z","etag":null,"topics":["lua","neovim","plugin","tree-sitter","treesitter"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/David-Kunz.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-08-21T10:51:30.000Z","updated_at":"2025-01-14T10:45:29.000Z","dependencies_parsed_at":"2022-09-24T12:51:02.037Z","dependency_job_id":null,"html_url":"https://github.com/David-Kunz/treesitter-unit","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/David-Kunz%2Ftreesitter-unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Kunz%2Ftreesitter-unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Kunz%2Ftreesitter-unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Kunz%2Ftreesitter-unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/David-Kunz","download_url":"https://codeload.github.com/David-Kunz/treesitter-unit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237886844,"owners_count":19381910,"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":["lua","neovim","plugin","tree-sitter","treesitter"],"created_at":"2024-09-26T10:40:35.984Z","updated_at":"2025-10-23T20:32:15.790Z","avatar_url":"https://github.com/David-Kunz.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# treesitter-unit\n\nA tiny [Neovim](https://neovim.io/) plugin to deal with [treesitter](https://github.com/tree-sitter/tree-sitter) units.\nA unit is defined as a treesitter node including all its children.\nIt allows you to quickly select, yank, delete or replace language-specific ranges.\n\nFor inner selections, the main node under the cursor is selected.\nFor outer selections, the next node is selected.\n\n![demo-with-highlight](https://user-images.githubusercontent.com/1009936/130355705-5da61f06-52a9-43f4-a98c-7e2df3ae175b.gif)\n\n## Installation\n\nRequirements: [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) including a parser for your language\n\nFor [vim-plug](https://github.com/junegunn/vim-plug):\n```\nPlug 'David-Kunz/treesitter-unit'\n```\nFor [packer](https://github.com/wbthomason/packer.nvim):\n```\nuse 'David-Kunz/treesitter-unit'\n```\n\n## Usage\n\n### Select treesitter unit\nYou can select the current treesitter unit\n```\n:lua require\"treesitter-unit\".select(outer?)\n```\nThis function takes an optional Boolean flag to specify if the outer scope should be selected as well, default `false`.\nFor operations like delete, change, ... please see section \"Useful mappings\".\n\n### Automatic Highlighting\nYou can toggle automatic highlighting for the current treesitter unit.\n```\n:lua require\"treesitter-unit\".toggle_highlighting(higroup?)\n```\nAs an optional parameter you can specify the highlight group, default: `\"CursorLine\"`.\n\nAlternative: `enable_highlighting(higroup?)` and `disable_highlighting()`.\n\n### Useful mappings\n\nFor init.vim:\n```\nxnoremap iu :lua require\"treesitter-unit\".select()\u003cCR\u003e\nxnoremap au :lua require\"treesitter-unit\".select(true)\u003cCR\u003e\nonoremap iu :\u003cc-u\u003elua require\"treesitter-unit\".select()\u003cCR\u003e\nonoremap au :\u003cc-u\u003elua require\"treesitter-unit\".select(true)\u003cCR\u003e\n```\nFor init.lua:\n```\nvim.api.nvim_set_keymap('x', 'iu', ':lua require\"treesitter-unit\".select()\u003cCR\u003e', {noremap=true})\nvim.api.nvim_set_keymap('x', 'au', ':lua require\"treesitter-unit\".select(true)\u003cCR\u003e', {noremap=true})\nvim.api.nvim_set_keymap('o', 'iu', ':\u003cc-u\u003elua require\"treesitter-unit\".select()\u003cCR\u003e', {noremap=true})\nvim.api.nvim_set_keymap('o', 'au', ':\u003cc-u\u003elua require\"treesitter-unit\".select(true)\u003cCR\u003e', {noremap=true})\n```\n\nExamples:\n- `viu` to select the inner unit\n- `cau` to change the outer unit\n\n\n## Similar plugins\n\n- [nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects) for more fine-granular control\n- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter#incremental-selection) for incremental selection\n- [nvim-ts-hint-textobject](https://github.com/mfussenegger/nvim-ts-hint-textobject)\n\n## Making-of video\n[![](https://i.ytimg.com/vi/dPQfsASHNkg/hqdefault.jpg?sqp=-oaymwEcCPYBEIoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==\u0026rs=AOn4CLC_iCGCXjipwKLOxHi2OFBR5XAQfw)](https://youtu.be/dPQfsASHNkg \"Let's create a Neovim plugin using Treesitter and Lua\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid-kunz%2Ftreesitter-unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavid-kunz%2Ftreesitter-unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid-kunz%2Ftreesitter-unit/lists"}