Created
July 14, 2015 12:18
-
-
Save mbarkhau/d073f16f8acb984eb1fb to your computer and use it in GitHub Desktop.
todo completion plugin for sublime
This file contains 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 datetime as dt | |
import sublime_plugin | |
DEV_NAME = "mb" | |
class TODOCommand(sublime_plugin.EventListener): | |
def _todo_str(self): | |
daystr = dt.date.today().strftime("%Y-%m-%d") | |
return "TODO ({} {}): ".format(DEV_NAME, daystr) | |
def on_query_completions(self, view, prefix, locations): | |
syntax = view.settings().get('syntax', "").lower() | |
filetype = syntax.split("/")[-1].split(".")[0] | |
if filetype in ('javascript', 'json', 'php', 'c', 'c++', 'd', 'go', 'java'): | |
fmt_str = "// {}" | |
elif filetype in ('css',): | |
fmt_str = "/* {}$1 */" | |
elif filetype in ('python', 'cython', 'ruby', 'shell-unix-generic', 'perl'): | |
fmt_str = "# {}" | |
else: | |
fmt_str = "??? " + filetype + "{} ???" | |
return [["todo", fmt_str.format(self._todo_str())]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment