Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sublime user plugins and snippets, etc
'''
add note information for notes written in Markdown
Example:
```noteinfo
{
"date": {
"y": 5,
"m": 2,
"d": 2017
},
"tag": ["papers", "research"]
}
```
'''
import datetime, getpass
import sublime, sublime_plugin
class AddInfoCommand(sublime_plugin.TextCommand):
def run(self, edit):
today = datetime.date.today()
self.view.run_command("insert_snippet", {"contents": "```noteinfo\n{\n\t\"date\": {\n\t\t\"y\": %s,\n\t\t\"m\": %s,\n\t\t\"d\": %s\n\t},\n\t\"tag\": [\"$1\"]\n}\n```" % (int(today.strftime("%d")),int(today.strftime("%m")),int(today.strftime("%Y"))) } )
# import datetime, getpass
# import sublime, sublime_plugin
# class AddInfoCommand(sublime_plugin.TextCommand):
# def run(self, edit):
# print("called")
# self.view.run_command("insert_snippet", { "contents": "%s" % datetime.date.today().strftime("%d %B %Y (%A)") } )
# class AddTimeCommand(sublime_plugin.TextCommand):
# def run(self, edit):
# self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%H:%M") } )
{
"cmd": ["dot", "-Tsvg", "-O", "$file"],
// "cmd": ["dot", "-Tpng", "-O", "$file"],
// "cmd": ["dot", "-Tpdf", "-O", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
{
// "scope": "source.md",
"completions":
[
// auto-completion from LaTeXTools
{ "trigger": "a", "contents": "\\alpha", "description": "TeXMath" },
{ "trigger": "b", "contents": "\\beta" },
{ "trigger": "g", "contents": "\\gamma" },
{ "trigger": "d", "contents": "\\delta" },
{ "trigger": "\\delta", "contents": "\\partial" },
//{ "trigger": "partial", "contents": "delta" }, # can't have trigger as it conflicts with p -> \pi
{ "trigger": "e", "contents": "\\epsilon" },
{ "trigger": "\\epsilon", "contents": "\\varepsilon" },
/* toggle the two! */
{ "trigger": "\\varepsilon", "contents": "\\epsilon" },
{ "trigger": "z", "contents": "\\zeta"},
{ "trigger": "h", "contents": "\\eta" },
{ "trigger": "q", "contents": "\\theta" },
{ "trigger": "\\theta", "contents": "\\vartheta" },
{ "trigger": "\\vartheta", "contents": "\\theta" },
{ "trigger": "i", "contents": "\\iota" },
{ "trigger": "k", "contents": "\\kappa" },
{ "trigger": "l", "contents": "\\lambda" },
{ "trigger": "m", "contents": "\\mu" },
{ "trigger": "n", "contents": "\\nu" },
{ "trigger": "x", "contents": "\\xi" },
{ "trigger": "p", "contents": "\\pi" },
{ "trigger": "r", "contents": "\\rho" },
{ "trigger": "s", "contents": "\\sigma" },
{ "trigger": "t", "contents": "\\tau" },
{ "trigger": "u", "contents": "\\upsilon" },
{ "trigger": "f", "contents": "\\phi" },
{ "trigger": "\\phi", "contents": "\\varphi" },
{ "trigger": "\\varphi", "contents": "\\phi" },
{ "trigger": "c", "contents": "\\chi" },
{ "trigger": "y", "contents": "\\psi" },
{ "trigger": "w", "contents": "\\omega" },
{ "trigger": "v", "contents": "\\digamma"},
{ "trigger": "G", "contents": "\\Gamma" },
{ "trigger": "D", "contents": "\\Delta" },
{ "trigger": "Q", "contents": "\\Theta" },
{ "trigger": "L", "contents": "\\Lambda" },
{ "trigger": "X", "contents": "\\Xi" },
{ "trigger": "P", "contents": "\\Pi" },
{ "trigger": "S", "contents": "\\Sigma" },
{ "trigger": "F", "contents": "\\Phi" },
{ "trigger": "Y", "contents": "\\Psi" },
{ "trigger": "W", "contents": "\\Omega" },
{ "trigger": "0", "contents": "\\emptyset" },
{ "trigger": "V", "contents": "\\forall" },
{ "trigger": "E", "contents": "\\exists" },
{ "trigger": "sm", "contents": "\\setminus" },
{ "trigger": "ld", "contents": "\\ldots" },
{ "trigger": "cd", "contents": "\\cdot" },
{ "trigger": "cdot", "contents": "cdots" },
{ "trigger": "cdots", "contents": "cdot"},
{ "trigger": "la", "contents": "\\langle"},
{ "trigger": "ra", "contents": "\\rangle"},
{ "trigger": "cu", "contents": "\\cup"},
{ "trigger": "ca", "contents": "\\cap"},
{ "trigger": "bcu", "contents": "\\bigcup"},
{ "trigger": "bca", "contents": "\\bigcap"},
{ "trigger": "in", "contents": "\\int"},
{ "trigger": "int", "contents": "infty"},
{ "trigger": "infty", "contents": "int"},
{ "trigger": "su", "contents": "\\sum"},
{ "trigger": "sum", "contents": "sup"},
{ "trigger": "sup", "contents": "succ"},
{ "trigger": "succ", "contents": "succeq"},
{ "trigger": "succeq", "contents": "succcurlyeq"},
{ "trigger": "succcurlyeq", "contents": "sum"},
{ "trigger": "qd", "contents": "\\quad"},
{ "trigger": "qqd", "contents": "\\qquad"},
{ "trigger": "pr", "contents": "\\prod"},
{ "trigger": "prod", "contents": "prec"},
{ "trigger": "prec", "contents": "preceq"},
{ "trigger": "preceq", "contents": "preccurlyeq"},
{ "trigger": "preccurlyeq", "contents": "prod"},
{ "trigger": "lar", "contents": "\\leftarrow"},
{ "trigger": "leftarrow", "contents": "leftarrow"},
{ "trigger": "longleftarrow", "contents": "longleftarrow"},
{ "trigger": "Lar", "contents": "\\Leftarrow"},
{ "trigger": "Leftarrow", "contents": "Leftarrow"},
{ "trigger": "Longleftarrow", "contents": "Longleftarrow"},
{ "trigger": "rar", "contents": "\\rightarrow"},
{ "trigger": "rightarrow", "contents": "rightarrow"},
{ "trigger": "longrightarrow", "contents": "longrightarrow"},
{ "trigger": "Rar", "contents": "\\Rightarrow"},
{ "trigger": "Rightarrow", "contents": "Rightarrow"},
{ "trigger": "Longrightarrow", "contents": "Longrightarrow"},
{ "trigger": "lr", "contents": "\\leftrightarrow"},
{ "trigger": "Lr", "contents": "\\Leftrightarrow"},
{ "trigger": "iff", "contents": "\\Leftrightarrow"},
{ "trigger": "leftrightarrow", "contents": "leftrightarrow"},
{ "trigger": "Leftrightarrow", "contents": "Leftrightarrow"},
{ "trigger": "longleftrightarrow", "contents": "longleftrightarrow"},
{ "trigger": "Longleftrightarrow", "contents": "Longleftrightarrow"},
{ "trigger": "up", "contents": "\\uparrow"},
{ "trigger": "do", "contents": "\\downarrow"},
{ "trigger": "it", "contents": "\\mathit{$1}$0"},
{ "trigger": "bf", "contents": "\\mathbf{$1}$0"},
{ "trigger": "bb", "contents": "\\mathbb{$1}$0"},
{ "trigger": "rm", "contents": "\\mathrm{$1}$0"},
{ "trigger": "sf", "contents": "\\mathsf{$1}$0"},
{ "trigger": "cal", "contents": "\\mathcal"},
{ "trigger": "mathcal", "contents": "mathcal{$1}$0"},
{ "trigger": "lp", "contents": "\\left( $1 \\right) $0"},
{ "trigger": "lb", "contents": "\\left[ $1 \\right] $0"},
{ "trigger": "lbr", "contents": "\\left\\\\{ $0 \\right\\\\}"},
{ "trigger": "fr", "contents": "\\frac"},
{ "trigger": "fra", "contents": "\\frac{$1}{$2}$0"},
{ "trigger": "stack", "contents": "\\stackrel{$1}{$2}$0"},
{ "trigger": "sp", "contents": "\\begin{split}\n$0\n\\end{split}\n"},
// Added by Wentao
///////////////
// General math
// derivative
{ "trigger": "dd", "contents": "\\frac{d $1}{d $2}$0"},
// partial derivative
{ "trigger": "pp", "contents": "\\frac{\\partial $1}{\\partial $2}$0"},
{ "trigger": "eijk", "contents": "\\epsilon${1:_}{ijk}$0"},
// begin environment
{ "trigger": "begin", "contents": "\\begin{$1}\n\t$0\n\\end{$1}" },
// begin eqn array
{ "trigger": "beqna", "contents": "\\begin{eqnarray}\n\t$0\n\\end{eqnarray}"},
// integration with lower and upper limit -+infinity
{ "trigger": "intinf", "contents": "\\int^{+\\infty}_{-\\infty}$0"},
// \left and \right
{ "trigger": "leri", "contents": "\\left $0${1: \\right }"},
///////////////
// General relativity and quantum field theory related
// Unitary operator of a Lorentz transform
{ "trigger": "UL", "contents": "U$1 (\\Lambda)$0"},
// operator of an element in Poincare group
{ "trigger": "ULa", "contents": "U$1 (\\Lambda,a)$0"},
// sexy g_{\mu\nu} for all possible sub/superscript
{ "trigger": "gmn", "contents": "g${1:_}{\\mu${2:\\}${3:_}\\{}\\nu}$0"},
{ "trigger": "gmr", "contents": "g${1:_}{\\mu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "gms", "contents": "g${1:_}{\\mu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "gnr", "contents": "g${1:_}{\\nu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "gns", "contents": "g${1:_}{\\nu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "grs", "contents": "g${1:_}{\\rho${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "Lmn", "contents": "\\Lambda${1:_}{\\mu${2:\\}${3:_}\\{}\\nu}$0"},
{ "trigger": "Lmr", "contents": "\\Lambda${1:_}{\\mu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "Lms", "contents": "\\Lambda${1:_}{\\mu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "Lnr", "contents": "\\Lambda${1:_}{\\nu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "Lns", "contents": "\\Lambda${1:_}{\\nu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "Lrs", "contents": "\\Lambda${1:_}{\\rho${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "Mmn", "contents": "M${1:_}{\\mu${2:\\}${3:_}\\{}\\nu}$0"},
{ "trigger": "Mmr", "contents": "M${1:_}{\\mu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "Mms", "contents": "M${1:_}{\\mu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "Mnr", "contents": "M${1:_}{\\nu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "Mns", "contents": "M${1:_}{\\nu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "Mrs", "contents": "M${1:_}{\\rho${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "wmn", "contents": "\\omega${1:_}{\\mu${2:\\}${3:_}\\{}\\nu}$0"},
{ "trigger": "wmr", "contents": "\\omega${1:_}{\\mu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "wms", "contents": "\\omega${1:_}{\\mu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "wnr", "contents": "\\omega${1:_}{\\nu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "wns", "contents": "\\omega${1:_}{\\nu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "wrs", "contents": "\\omega${1:_}{\\rho${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "dmn", "contents": "\\delta${1:_}{\\mu${2:\\}${3:_}\\{}\\nu}$0"},
{ "trigger": "dmr", "contents": "\\delta${1:_}{\\mu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "dms", "contents": "\\delta${1:_}{\\mu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "dnr", "contents": "\\delta${1:_}{\\nu${2:\\}${3:_}\\{}\\rho}$0"},
{ "trigger": "dns", "contents": "\\delta${1:_}{\\nu${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "drs", "contents": "\\delta${1:_}{\\rho${2:\\}${3:_}\\{}\\sigma}$0"},
{ "trigger": "dij", "contents": "\\delta${1:_}{i${2:\\}${3:_}\\{}j}$0"}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment