Skip to content

Instantly share code, notes, and snippets.

@mbarkhau
Created July 14, 2015 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbarkhau/d073f16f8acb984eb1fb to your computer and use it in GitHub Desktop.
Save mbarkhau/d073f16f8acb984eb1fb to your computer and use it in GitHub Desktop.
todo completion plugin for sublime
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