coc-snippets stopped accepting the multiline python code in the todo (and other) snippets, this fixes an `UnexpectedIndentation` exception.
		
			
				
	
	
		
			105 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
priority -1
 | 
						|
 | 
						|
snippet me "Identify me"
 | 
						|
Kenneth Benzie (Benie) <k.benzie83@gmail.com>
 | 
						|
endsnippet
 | 
						|
 | 
						|
global !p
 | 
						|
class Comment(object):
 | 
						|
	def __init__(self):
 | 
						|
		# Get the commentstring.
 | 
						|
		commentstring = snip.opt('&commentstring').strip()
 | 
						|
		# Slipt it into before and after parts.
 | 
						|
		commentparts = [part.strip() for part in commentstring.split('%s')]
 | 
						|
		self.commentbefore = commentparts[0] + ' '
 | 
						|
		self.commentafter = ' ' + commentparts[1] if commentparts[1] else ''
 | 
						|
		# Determine if we are in an existing comment.
 | 
						|
		line = vim.current.buffer[vim.current.window.cursor[0] - 1].strip()
 | 
						|
		# If interpolation has not occcured and the current line starts with the
 | 
						|
		# comment leader, we are in a comment.
 | 
						|
		self.incomment = not snip.c and line.startswith(commentparts[0])
 | 
						|
 | 
						|
	def before(self):
 | 
						|
		return '' if self.incomment else self.commentbefore
 | 
						|
 | 
						|
	def after(self):
 | 
						|
		return '' if self.incomment else self.commentafter
 | 
						|
endglobal
 | 
						|
 | 
						|
snippet todo "TODO commment"
 | 
						|
`!p comment=Comment();snip.rv=comment.before()`TODO${1/.+/(/}$1${1/.+/)/}: $0`!p snip.rv=comment.after()`
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet fixme "FIXME comment"
 | 
						|
`!p comment=Comment();snip.rv=comment.before()`FIXME${1/.+/(/}$1${1/.+/)/}: $0`!p snip.rv=comment.after()`
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet note "NOTE comment"
 | 
						|
`!p comment=Comment();snip.rv=comment.before()`NOTE: $0`!p snip.rv=comment.after()`
 | 
						|
endsnippet
 | 
						|
 | 
						|
global !p
 | 
						|
from datetime import datetime, timedelta, tzinfo
 | 
						|
from time import daylight, gmtime, localtime, timezone, tzname
 | 
						|
 | 
						|
class LocalTZ(tzinfo):
 | 
						|
	"""Query OS for local timezone offset."""
 | 
						|
 | 
						|
	def __init__(self):
 | 
						|
		"""Initialize LocalTZ."""
 | 
						|
		tzinfo.__init__(self)
 | 
						|
		self.unixEpochOrdinal = datetime.utcfromtimestamp(
 | 
						|
			0).toordinal()
 | 
						|
 | 
						|
	def dst(self, _):
 | 
						|
		return timedelta(0)
 | 
						|
 | 
						|
	def utcoffset(self, dt):
 | 
						|
		t = ((dt.toordinal() - self.unixEpochOrdinal) * 86400 + dt.hour * 3600
 | 
						|
			 + dt.second + timezone)
 | 
						|
		utc = datetime(*gmtime(t)[:6])
 | 
						|
		local = datetime(*localtime(t)[:6])
 | 
						|
		return local - utc
 | 
						|
 | 
						|
	def tzname(self, dt):
 | 
						|
		if daylight and localtime().tm_isdst:
 | 
						|
			return tzname[daylight]
 | 
						|
		return tzname[0]
 | 
						|
endglobal
 | 
						|
 | 
						|
snippet date "date now"
 | 
						|
`!p snip.rv=datetime.now().strftime('%a %d %b %Y')`
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet time "time now"
 | 
						|
`!p snip.rv=datetime.now().strftime('%H:%M:%S')`
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet datetime "date and time now"
 | 
						|
`!p snip.rv=datetime.now(LocalTZ()).strftime('%a %d %b %Y %H:%M:%S %Z')`
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet utc "UTC date time now" i
 | 
						|
`!p snip.rv=datetime.now(LocalTZ()).strftime('%Y-%m-%dT%H:%M:%S%z')`
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet *x "GitHub style checkbox"
 | 
						|
* [${1:x}] $0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet "* [" "GitHub style checkbox"
 | 
						|
* [${1: }] $0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet *[ "GitHub style checkbox"
 | 
						|
* [${1: }] $0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet shrug "¯\\_(ツ)_/¯" i
 | 
						|
¯\_(ツ)_/¯
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet tableflip "(╯°▪°)╯︵┻━┻" i
 | 
						|
(╯°▪°)╯︵┻━┻
 | 
						|
endsnippet
 |