I have tried to extend the regex expression to also find Todos in LaTeX source code. Unfortunately, I am not a regex expert and wanted to ask if this would be a satisfactory solution.
"todo-tree.regex": "((//|#|<!--|;|/\\*|^|\\\\|%)\\s*($TAGS)|^\\s*- \\[ \\])"
I'm trying to detect these cases.
\TODO{Test1} % Function to display TODOs in the PDF as well
% TODO Test2
Wouldn't it be better in the long run to create a regex expression for each individual file type? In my opinion, this would significantly improve modularity.
Underneath, the search performed using ripgrep to make it as fast as possible, so the search needs to use a single regex to search all files. Otherwise the extension would need to search for each file type, and how would it know which types to search for?
The alternative would be to generate a list of all the files first and then search them separately, but that would be much more complex and slower.
However, your expression looks good - I normally use a website like https://regex101.com/ to test them out.
You don't need to keep all the other stuff if you only want to find TODOs in LaTeX files though, so you could simplify it to just (\\\\|%)\\s*($TAGS).
I was hoping to categorize that by file extension.
Like overwrite rules for files found by find $directory -type f -name "*.tex"
You can specify exclude/include globs, so if you only want to search .tex files, you can add something like todo-tree.includeGlobs: [ "**/*.tex" ]
But I can't have another regex for every includeGlob I create.
So in a mixed project this is not a proper solution.
I'll try some experiments to see if adding multiple regexes per file extension (with the default matching all files) and see what the performance is like...
I also need both % TODO: [text] and \TODO{my todo in the pdf}.
I have added "todo-tree.regex": "((//|#|<!--|;|/\\*|^|\\\\|%)\\s*($TAGS)|^\\s*- \\[ \\])" to VSCode settings but still no highlighting in Latex files. Am I missing something?
EDIT: got it working with "todo-tree.regex": "((%|#|//|<!--|^\\s*\\*)\\s*($TAGS)|^\\s*- \\[ \\])" to support Latex and other file types I need. In original regex, \\\\ seems to be the offending part.
It would be nice to change the default regex to include the symbol %, for latex comments. I could swear that it was working before, but since last week, somehow the tags were not being detected. I checked if something was wrong with the configs, or an update had broken something. Finally realized that the regex has no way to detect the comment in latex, so by simply adding the % in the regex as a new option:
"todo-tree.regex": "((//|#|%|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])",
@JavierReyes945 - there will probably be issues with \\\\ as the extension has to do some escaping to generate the command for ripgrep. Escaping backslashes makes the problem harder. There is another issue (#158) where somebody wants to use ??? as a tag, which I am looking into because it has a similar problem.
Did you get it working OK with % comments? I'm loathe to add anything else to the default regex because it tends to cause problems for existing users. At some point soon I'm going to create a wiki page with some example regexs on - so I'll include a section for latex.
@Gruntfuggly: Sorry for the missleading comment. My adjustment was not in \\\\, but simply adding the % symbol.
Default regex in my version (0.0.132):
"todo-tree.regex": "((//|#|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])",
My modified regex:
"todo-tree.regex": "((//|#|%|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])",
To be honest, I am not aware of the exact regex syntax used here (I am mostly used to the Python regex engine, and a little bit PCRE). I just saw that adding a new option to start comments with the % symbol (for latex documents), I could fix the not working detection in a latex file (which again, was working before).
I will try at home later tonight, perhaps I can see what was happening with this issue of latex not working, and/or collaborate here (I found this ext really helpful).
A list of supported comment styles could be created, so that the regex can be tested and validated for specifically those only.
there will probably be issues with \\ as the extension has to do some escaping to generate the command for ripgrep.
I also wanted the extension to find \todo{ and got it working by adding \\\\\\todo\\{.
That's 6 backslashes at the start, so yeah something's not 100% as expected with escaping.
Thanks for the extension by the way, it's a major help ;)
@Jjagg thanks for the \\\\\\ hint. Got it working for % todo, %TODO and \todo{, \TODO{
with : "todo-tree.regex": "((//|#|<!--|;|/\\*|^|%|\\\\\\)\\s*($TAGS)\\{*|^\\s*- \\[ \\])".
I am with @padok. It would be great to declare wich files to search by file extension.
Maybe you can get some inspiration from this project: https://github.com/wayou/vscode-todo-highlight
Something like the "todohighlight.include" option would be really nice and easy to use.
@AndrePsys There are already options to declare which files to search:
todo-tree.includeGlobs
todo-tree.excludeGlobs
I think what @padok is after is different searches for different file extensions which is much more complex.
Hi, I tried every method in this thread but nothing works, my todo tree is still empty. I don't know want to do now.
Can you post an example of what you want it to match?
@JavierReyes945 solution:
My modified regex:
"todo-tree.regex": "((//|#|%|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])",
The new configuration option adds another .regex. Try:
"todo-tree.regex.regex": "((//|#|%|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])",
Thanks @joe4dev
I have been looking for this!, hope the LaTex get included as default! or at least get mentioned how to do it from the wiki
Thanks :)
As I was encountering the same issue earlier today: has anybody opened a pull-request yet?
I was thinking of something like @JavierReyes945 solution. If not, I would be happy to file one.
"((//|#|%|
Most helpful comment
@JavierReyes945 solution:
The new configuration option adds another
.regex. Try: