{"id":15144329,"url":"https://github.com/joosepalviste/nvim-ts-context-commentstring","last_synced_at":"2025-05-14T17:02:33.622Z","repository":{"id":38617269,"uuid":"342013314","full_name":"JoosepAlviste/nvim-ts-context-commentstring","owner":"JoosepAlviste","description":"Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.","archived":false,"fork":false,"pushed_at":"2024-12-07T12:22:36.000Z","size":2519,"stargazers_count":1230,"open_issues_count":20,"forks_count":34,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-13T01:57:30.483Z","etag":null,"topics":["lua","neovim","neovim-plugin","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoosepAlviste.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-02-24T19:33:53.000Z","updated_at":"2025-04-07T03:25:16.000Z","dependencies_parsed_at":"2024-10-26T08:36:40.773Z","dependency_job_id":"afb931ec-f68f-432a-a9bf-70280f74fc38","html_url":"https://github.com/JoosepAlviste/nvim-ts-context-commentstring","commit_stats":{"total_commits":107,"total_committers":34,"mean_commits":"3.1470588235294117","dds":0.514018691588785,"last_synced_commit":"1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoosepAlviste%2Fnvim-ts-context-commentstring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoosepAlviste%2Fnvim-ts-context-commentstring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoosepAlviste%2Fnvim-ts-context-commentstring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoosepAlviste%2Fnvim-ts-context-commentstring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoosepAlviste","download_url":"https://codeload.github.com/JoosepAlviste/nvim-ts-context-commentstring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654048,"owners_count":21140235,"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","neovim-plugin","plugin","tree-sitter","treesitter"],"created_at":"2024-09-26T10:40:35.315Z","updated_at":"2025-04-13T01:57:59.351Z","avatar_url":"https://github.com/JoosepAlviste.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `nvim-ts-context-commentstring`\n\nA Neovim plugin for setting the `commentstring` option based on the cursor\nlocation in the file. The location is checked via treesitter queries.\n\nThis is useful when there are embedded languages in certain types of files. For\nexample, Vue files can have many different sections, each of which can have a\ndifferent style for comments.\n\nNote that this plugin *only* changes the `commentstring` setting. It does not \nadd any mappings for commenting. It is recommended to use a commenting plugin \nlike [`Comment.nvim`](https://github.com/numToStr/Comment.nvim) alongside this \nplugin.\n\n![Demo gif](https://user-images.githubusercontent.com/9450943/185669080-a5f05064-c247-47f5-9b63-d34a9871186e.gif)\n\n\n\n## Getting started\n\n**Requirements:**\n\n- [Neovim version 0.9.4](https://github.com/neovim/neovim/releases/tag/v0.9.4)\n- Tree-sitter parsers (e.g. installed with [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter))\n\n**Installation:**\n\nUse your favorite plugin manager. For example, here's how it would look like\nwith [lazy.nvim](https://github.com/folke/lazy.nvim):\n\n```lua\nrequire('lazy').setup {\n  'JoosepAlviste/nvim-ts-context-commentstring',\n}\n```\n\n**Setup:**\n\nFor most commenting plugins, this is all you need and the defaults should work \nout of the box. However, some commenting plugins require a bit more set up. See \nthe [Configuration section](#configuration) for more details about the different \nplugins.\n\nIf you want to change the configuration, call the `setup` function of this \nplugin, e.g.:\n\n```lua\nrequire('ts_context_commentstring').setup {\n  enable_autocmd = false,\n}\n```\n\n\u003e **Note**\n\u003e\n\u003e There is a minimal configuration file available at \n\u003e [`utils/minimal_init.lua`](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/blob/main/utils/minimal_init.lua) for reference.\n\n\u003e **Note**\n\u003e\n\u003e Don't forget to use `:h lua-heredoc` if you're using `init.vim`.\n\n\n## Configuration\n\nIt is recommended to use a commenting plugin that has an integration available \nwith this plugin. Then, the `commentstring` calculation can be triggered only \nwhen commenting. The available integrations are listed in the \n[wiki](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations). \nThe following plugins have an integration available:\n\n- [Native Neovim commenting](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#native-commenting-in-neovim-010)\n- [`b3nj5m1n/kommentary`](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#kommentary)\n- [`terrortylor/nvim-comment`](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#nvim-comment)\n- [`numToStr/Comment.nvim`](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#commentnvim)\n- [`echasnovski/mini.nvim/mini-comment`](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#minicomment)\n- [`tpope/vim-commentary`](https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#vim-commentary)\n\nHowever, if an integration is not set up, then the default behavior is to \ncalculate the `commentstring` on the `CursorHold` autocmd, meaning that the \n`:h updatetime` should be set to a smaller value than the default of 4s:\n\n```lua\nvim.opt.updatetime = 100\n```\n\n\u003e **Note**\n\u003e\n\u003e For more advanced configuration options, see `:h ts-context-commentstring`.\n\n\n## More demos\n\n**React:**\n\n![React demo gif](https://user-images.githubusercontent.com/9450943/185669182-d523c328-251e-41b0-a76e-d867c401a040.gif)\n\n**Svelte:**\n\n![Svelte demo gif](https://user-images.githubusercontent.com/9450943/185669229-ad10848e-ba13-45e0-8447-a3a1f03eb85e.gif)\n\n**HTML:**\n\n![html](https://user-images.githubusercontent.com/9450943/185669275-cdfa7fa4-092e-439b-822e-330559a7d4d7.gif)\n\n**Nesting:**\n\nI injected HTML into JavaScript strings and created multiple levels of nesting \nwith language tree. This sort of nesting of languages works without any extra \nconfiguration in the plugin.\n\n![nested](https://user-images.githubusercontent.com/9450943/185669303-e6958706-f5b7-439c-98f7-2393e6325107.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoosepalviste%2Fnvim-ts-context-commentstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoosepalviste%2Fnvim-ts-context-commentstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoosepalviste%2Fnvim-ts-context-commentstring/lists"}