Comments (30)
You need to install the comment
parser to get highlighting inside comments.
from nvim-treesitter.
I'll try to send a PR tomorrow or next week
from nvim-treesitter.
Hi and thanks for reporting this ! What you are aiming for here is what we call language injection, that is we want to treat certain parts of the program (the comments) differently.
We will build a comment (doc and codetags) later and use it together with language injection later. Unfortunately language injection is a bit tougher than expected.
from nvim-treesitter.
but maybe this something we can add by default? don't know how common is to use just TODO something
instead of TODO: something
from nvim-treesitter.
Language injection is on by default now, only thing missing is creating the codetag parser, and setting things up for each language.
We are (still) missing some other things like a strip directive, that we will try to hack into here.
from nvim-treesitter.
@joellidin you need the @text.note
highlight group.
from nvim-treesitter.
Are there some examples present to achieve this currently with treesitter? @vigoux
from nvim-treesitter.
@caheredia the syntax is
TODO: something
, you can highlight tokens that don't have:
if you want with a custom query like
@stsewd according to python docs, https://www.python.org/dev/peps/pep-0350/#id25 it looks like Codetags should be followed by a colon. Although in the wild, I've seen more "TODO"s without the colon. Either way thanks for the custom query, I'll add that to my conifgs
from nvim-treesitter.
Damn, I didn't understand this π€¦ββοΈ Maybe it'll also help other people someday.
Sorry for the noise and thanks a lot for the help!
from nvim-treesitter.
I am sorry to yet again bring this up. But for python it still does not highlight the todo comments for me.
The healtcheck seems fine:
nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
- WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK: `node` found v14.20.0 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
## Parser/Features H L F I J
- go β β β β β
- bash β β β . β
- cpp β β β β β
- cuda β β β β β
- regex β . . . .
- graphql β . . β β
- markdown β . β . β
- make β . β . β
- python β β β β β
- rust β β β β β
- sql β . . . β
- typescript β β β β β
- json β β β β .
- comment β . . . .
- lua β β β β β
- dockerfile β . . . β
- c β β β β β
- scss β . . β .
- vim β β β . β
- toml β β β β β
- yaml β β β β β
- javascript β β β β β
- bibtex β . β β .
- css β . β β β
- latex β . β . β
- help β . . . .
from nvim-treesitter.
For those who still haven't figured out how to do that, just add the following to your lua config:
vim.api.nvim_set_hl(0, "@text.note", { link = "Search" })
Or you can use any word from :hi
instead of "Search".
from nvim-treesitter.
Glad to hear it's on your roadmap already. This is in no way urgent, and I like that you're looking to do this in a generic fashion (which ultimately is what makes treesitter highlighting superior).
from nvim-treesitter.
Okay, language injection is here now ! Now what we need is a little parser to highlight such code tags, maybe a little code tag parser could be good !
from nvim-treesitter.
Sounds great. I regularly use the following:
FIXME:
,FIXME(username):
(must be addressed)TODO:
,TODO(username):
(should be addressed)NYI:
(not yet implemented)
from nvim-treesitter.
Awesome, it sounds like there was a PEP too specifying that a bit, maybe we can use that as a reference : https://www.python.org/dev/peps/pep-0350/
There is still some things to do to : for each language we'd have to set up injection, and use the strip!
operator.
The problem is that the strip operator is not yet implemented and wouldn't word for now, so we need to find a proper way of doing so.
from nvim-treesitter.
I planned to do that with #590 So you could trim node ranges in the queries to get subranges of them.
from nvim-treesitter.
Likewise the lack of python TODO
is a pain point for me as well. Glad it's on the roadmap.
from nvim-treesitter.
So, together with @steelsojka we've been discussing a bit.
There is some upstream issues that might block language injection a bit, and that we need to fix before going forward.
While this work is being done, I'll be working on the todo
parser, and if anyone wants to contribute, I'll be really grateful.
from nvim-treesitter.
@vigoux I mostly code in python, but happy to help in any way I can
from nvim-treesitter.
@steelsojka did a a set of two PRs (neovim/neovim#13207, and #627) to be able to inject in a better way.
from nvim-treesitter.
An absolute MUST feature. See this PR neovim/neovim#13252
I work with files that are php -> js
and php -> html -> js
I could determine which of these parser chains to use based on filename. Have a spectacular syntax highlighting!
from nvim-treesitter.
Yes plssss
from nvim-treesitter.
I see this issue was recently closed, but TODO still isn't working for me in python
``` health#nvim_treesitter#check ======================================================================== ## Installation-
OK:
tree-sitter
found 0.19.3(parser generator, used for :TSInstallFromGrammar) -
OK:
git
executable found. -
OK:
cc
executable found.
Parser/Features H L F I
- scala . . . .
- python β β β β
- supercollider β β β β
- go β β β β
- haskell . . . .
- toml x x x x
- glimmer β . . .
- ruby β β . β
- bash β β β .
- vue β . β .
- php β x β .
- java β β . β
- svelte β . β β
- yaml β β β β
- kotlin β . . .
- nix β β β .
- devicetree β β β β
- html β β β β
- dart x β . β
- julia β β . .
- turtle β β β β
- rst β β . .
- json β β β β
- fennel x β . .
- css x . β β
- teal β β β β
- erlang . . . .
- ocaml_interfacex β β .
- ql β x . .
- javascript β x β β
- graphql β . . β
- ocaml x β β .
- query β β β β
- elm . . . .
- comment x . . .
- regex β . . .
- c β β x x
- verilog x x x .
- jsdoc x . . .
- ocamllex x . . .
- jsonc x x x x
- swift . . . .
- sparql x x x x
- c_sharp x . . .
- cpp x x x x
- gdscript x x . .
- clojure x x . .
- typescript x x x x
- lua x x x x
- rust x x x x
- tsx x x x x
- ledger x . x x
from nvim-treesitter.
@caheredia the syntax is TODO: something
, you can highlight tokens that don't have :
if you want with a custom query like
("text" @text.warning
(#match? @text.warning "^(TODO|HACK|WARNING)$"))
from nvim-treesitter.
I would highlight it without the : as well.
from nvim-treesitter.
Sorry to reactivate an old issue, but I never got my TODOs and FIXMEs highlighted in my neovim. Currently running 0.6.1, and I'm having the problem in two different languages, ruby and javascript. It's been like this for a while for me, and I was even surprised to find that it was supposed to work.
Healthcheck seems OK:
nvim_treesitter: health#nvim_treesitter#check
========================================================================
## Installation
- OK: `tree-sitter` found 0.20.4 (parser generator, only needed for :TSInstallFromGrammar)
- OK: `node` found v16.13.1 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: Apple clang version 12.0.5 (clang-1205.0.22.11)
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
## Parser/Features H L F I J
- javascript β β β β β
- ruby β β β β β
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
I don't know if color scheme can have an impact (like a non-implemented highlight group?), so I tried to switch and get the same result with nord, onedark, palenight, everforest and basically all decent color schemes I could think of.
Anything I may be missing? At this point I don't know how to investigate any further.
from nvim-treesitter.
You need to install the
comment
parser to get highlighting inside comments.
How I do that?
from nvim-treesitter.
Now I realized, I just added comment
inside the ensure_installed
list in my treesitter configuration.
Anyway, I think there are better solutions for this purpose: https://github.com/folke/todo-comments.nvim
from nvim-treesitter.
@joellidin I see that the :
are highlighted, so this is probably your colorscheme missing highlighting the @text.*
captures, see #2293 (comment)
from nvim-treesitter.
@joellidin I see that the
:
are highlighted, so this is probably your colorscheme missing highlighting the@text.*
captures, see #2293 (comment)
@stsewd Thank you for the response. I looked and it seems that my colorscheme should have it. See picture below when I checked :hi
. Worth noting maybe is that the todo comments get highlighted when I disable TS hightlighting. Is it anything obvious I am missing maybe?
from nvim-treesitter.
Related Issues (20)
- Compute indentexpr for the whole buffer and cache it HOT 1
- Reinstalling language parser fails on Windows when a file handle to the old parser exists HOT 9
- file types with dot notation are highlighted incorrectly HOT 4
- Dockerfile bash injection is too broad HOT 8
- neovim crashes when editing an html file HOT 3
- "Error while calling lua chunk / attempt to index a boolean value" on startup HOT 3
- "Error executing vim.schedule lua callback, invalid node type at position 196 for language bash" when file is Makefile HOT 1
- How I can change highlight in svelte file? js to ts in injected highlight HOT 1
- [Windows] Failed to load parser for language: `uv_dlopen` HOT 1
- Latex creates errors HOT 1
- new fresh install(with lazyvim) on windows hangs at Treesitter compilation step with zig HOT 1
- Impossible Pattern - Error HOT 3
- Fenced Code Blocks on markdown files only highlighting with one color HOT 3
- stack corruption detected HOT 4
- inaccurate folding in svelte files HOT 2
- `free(): invalid pointer` crash on `php_only` parser HOT 13
- neovim-nvim-treesitter package in aur wrong HOT 1
- can't install lua tree sitter HOT 5
- Neovim crashes when highlighting an SQL heredoc inside a PHP file HOT 2
- Add pest language HOT 1
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-treesitter.