Last active
March 22, 2017 18:23
-
-
Save diego898/ab8f2a36542c074e74e6b5d0691e38c5 to your computer and use it in GitHub Desktop.
A simple ST plugin to highlight text like `\todo`, `@todo`, `@author_name` - originally from - https://github.com/SublimeText/LaTeXTools/issues/1052#issuecomment-287898776
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
class HighlightTodoListener(sublime_plugin.EventListener): | |
def highlight_todo(self, view): | |
# only highlight tex files | |
if not view.score_selector(0, "text.tex"): | |
return | |
# adapt this regex as you wish | |
commands = ["todo"] | |
annotations = ["todo", "TODO", "note", "diego"] | |
regions = view.find_all( | |
r"\\(?:{com})\b|" | |
r"@(?:{anon})\b" | |
.format(com="|".join(commands), anon="|".join(annotations)) | |
) | |
view.erase_regions("td_highlighter") | |
view.add_regions("td_highlighter", regions, "keyword", "bookmark" | |
# , flags=sublime.DRAW_OUTLINED | |
) | |
on_load = highlight_todo | |
on_post_save = highlight_todo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment