Comments (2)
You can get the current language at a position (line
, col
) via
local parsers = require'nvim-treesitter.parsers'
local root_lang_tree = parsers.get_parser()
local lang_tree = root_lang_tree:language_for_range({ line, col, line, col })
local lang = lang_tree.lang
there should be no need to use queries to find out where which language is injected
from nvim-ts-context-commentstring.
Thanks, @theHamsta! That code snippet was enough to help me figure it out. Now, we are only operating on the injected language sub-tree.
I still had to use queries for some languages though. Mainly because JSX is not an injected language with language tree, but it is a part of the tree created by the JS/TSX parsers.
But I did manage to use language tree for most of the logic.
from nvim-ts-context-commentstring.
Related Issues (20)
- Svelte only returns html-comment for all locations HOT 2
- Need help in debugging strange situation HOT 1
- Work-around to make this work with native comments in Neovim 0.10 HOT 4
- Incorrect commentstring for erb tags on eruby files
- Incorrect commentstring inside <?php ?> tags HOT 1
- Does not seems to work on html files like shown in the doc
- Add support for Neovim's built-in comments HOT 2
- Required fields in ts_context_commentstring.Config HOT 1
- vue style comment wrong HOT 3
- Vue comment not working properly HOT 2
- This plugin doesn't set the `comments` var. HOT 2
- BREAKING CHANGES HOT 6
- Incorrent commentstring for inline markdown code blocks HOT 4
- `set ft?` return `filetype=on` and causing losing syntax highlighting HOT 5
- Commenting is slow in large Markdown files HOT 3
- context_commentstring nvim-treesitter module is deprecated HOT 2
- tsx is not properly commenting even when ts-context-commentstring works HOT 1
- Please do not create unnecessary global variables
- Vue comment js/ts using html comment tags HOT 2
- Doesn't work ootb with mini.comment / Comment.nvim (React) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-ts-context-commentstring.