# NOTE: Each snippet has been duplicated to be used with or without a leading
# period. If changes are made to one, ensure they're reflected in the other.
# Atom snippets don't yet support multiple prefixes. See atom/snippets#107.

".text.roff":
	
	# Macro definition
	".de":
		prefix: ".de"
		body: ".de ${1:NAME}\n.\t$3\n.."
		description: "Define a new macro"
		leftLabel: ".de"

	de:
		prefix: "de"
		body: ".de ${1:NAME}\n.\t$3\n.."
		description: "Define a new macro"
		leftLabel: ".de"
	

	# "If" block
	".if":
		prefix: ".if"
		body: ".if ${1:COND} \\\\{\\\\\n.\t$2\n.\\\\}"
		description: "Multiline `if` statement"
		leftLabel: ".if"

	if:
		prefix: "if"
		body: ".if ${1:COND} \\\\{\\\\\n.\t$2\n.\\\\}"
		description: "Multiline `if` statement"
		leftLabel: ".if"

	
	# "If/else" block
	".ie":
		prefix: ".ie"
		body: ".ie ${1:COND} \\\\{\\\\\n.\t$2\n.\\\\}\n.el \\\\{\\\\\n.\t$3\n.\\\\}"
		description: "Multiline `if/else` block"
		leftLabel: ".ie"

	ie:
		prefix: "ie"
		body: ".ie ${1:COND} \\\\{\\\\\n.\t$2\n.\\\\}\n.el \\\\{\\\\\n.\t$3\n.\\\\}"
		description: "Multiline `if/else` block"
		leftLabel: ".ie"
	
	
	# Manual pages
	manpage:
		prefix: "manpage"
		body: """
			.TH ${1:PROGNAME} 1
			.SH NAME
			${1:progname} \\- ${2:short description}
			.SH SYNOPSIS
			.B ${1:progname}
			${3:[command-line options]
			.\\\\" TIP: Use the `opt` snippet to insert options here}
			.SH DESCRIPTION
			${4:-- Extended description --}
			.SH OPTIONS
			${5:-- Options --}
			.SH EXAMPLES
			${6:-- Examples --}
			$7
		"""
		leftLabel: "man"
		description: "Template for a basic manual-page"
		descriptionMoreURL: "http://liw.fi/manpages/"
	
	opt:
		prefix: "opt"
		body: "[\\\\fB\\\\-${1:o}\\\\fR \\\\fI${2:value}\\\\fR]\n$3"
		leftLabel: "man"
		description: "Short option: [-o value]"
	
	optl:
		prefix: "optl"
		body: "[\\\\fB\\\\-\\\\-${1:option}\\\\fR \\\\fI${2:value}\\\\fR]\n$3"
		leftLabel: "man"
		description: "Long option: [--option value]"
	
	optinfo:
		prefix: "optinfo"
		body: '.TP\n.BI \\\\-${1:o} " ${2:value}" \\\\fR, "\\\\fB \\\\-\\\\-${3:option}" \\\\fR=\\\\fI${2:value}\\\\fR\n${4:Description}\n$5'
		leftLabel: "man"
		description: "Extended information about an option"
		descriptionMoreURL: "http://liw.fi/manpages/"
	
	sh:
		prefix: "sh"
		body: """.
			.\\\\" ${2:--------------------------------------------------------------------}
			.SH "${1:SECTION HEADING}"
			.\\\\" ${2:--------------------------------------------------------------------}
			.$3"""
		leftLabel: "man"
		description: "Bordered section heading"
	
	
	# Code snippets for manpages
	".code":
		prefix: ".code"
		body: ".PP\n.nf\n.RS\n.ft C\n${1:Enter code block here}\n.ft\n.RE\n.fi\n.PP"
		leftLabel: "man"
		description: "Block of example code"
		descriptionMoreURL: "http://liw.fi/manpages/"
	
	code:
		prefix: "code"
		body: ".PP\n.nf\n.RS\n.ft C\n${1:Enter code block here}\n.ft\n.RE\n.fi\n.PP"
		leftLabel: "man"
		description: "Block of example code"
		descriptionMoreURL: "http://liw.fi/manpages/"
		


	# Mandoc template
	mandoc:
		prefix: "mandoc"
		body: """
			.Dd $Mdocdate$
			.Dt ${1:PROGNAME} 1
			.Os 
			.Sh NAME
			.Nm ${1:progname}
			.Nd ${2:Short description}
			.Sh SYNOPSIS
			.Nm ${1:progname}
			.Op Fl ${3:options}
			.Ar ${4:arguments}
			.Sh DESCRIPTION
			${5:-- Text --}
			.Sh ENVIRONMENT
			${6:-- Text --}
			.Sh FILES
			${7:-- Text --}
			.Sh EXIT STATUS
			${8:-- Text --}
			.Sh EXAMPLES
			${9:-- Text --}
			.Sh DIAGNOSTICS
			${10:-- Text --}
			.Sh ERRORS
			${11:-- Text --}
			.Sh SEE ALSO
			.Xr ${12:manpage} 1
			$13
		"""
		leftLabel: "mdoc"
		description: "Skeleton for a mandoc manual page"
		descriptionMoreURL: "http://mdocml.bsd.lv/man/mdoc.7.html"
	
	
	# Table template
	tbl:
		prefix: "tbl"
		body: ".TS\nallbox;\nl c c .\n${1:Header1}\t${2:Header2}\t${3:Header3}\n${4:Body1\tBody2\tBody3}\n.TE\n"
		leftLabel: "tbl"
		description: "Template for a 3-column bordered table"
		descriptionMoreURL: "http://linux.die.net/man/1/tbl"


	# Debugging message
	log:
		prefix: "log"
		body: ".tm ${1:Text}"
		leftLabel: ".tm"
		description: "Trace message to STDERR"


".source.pic":

	# DFORMAT block
	".dformat":
		prefix: ".df"
		body: ".begin dformat\nstyle $1\n.end"
	
	dformat:
		prefix: "df"
		body: ".begin dformat\nstyle $1\n.end"


	# CHEM: Dextroamphetamine molecule
	dextroamphetamine:
		prefix: "dex"
		body: """
			.cstart
				.ps 26
				size 28
			R1:
				ring double 1,2 3,4 5,6
				bond 60 from R1.V2
				bond 120
			A1:
				front bond down ; CH3
				bond 60 from A1 ; NH2
				.ps
			.cend
			"""
