New snippets, no ale

This commit is contained in:
2023-08-04 15:24:33 +02:00
parent d30ab401f8
commit 8c8970548b
8 changed files with 140 additions and 17 deletions

View File

@@ -40,3 +40,8 @@ $1
\`\`\`
$0
endsnippet
snippet ,m "Math equation" A
\$\$ $1 \$\$ $0
endsnippet

View File

@@ -35,3 +35,35 @@ for ${1:i} in ${2:$3..$4} {
}$0
endsnippet
snippet while "while loop"
while $1 {
$2
} $0
endsnippet
global !p
import re
def create_parameter_placeholders(snip):
placeholders_amount = int(snip.buffer[snip.line].strip())
snip.buffer[snip.line] = ''
anon_snippet_body = 'println!("' + '{}'.join(['$' + str(i+1) for i in range(placeholders_amount)]) + f"${placeholders_amount}" + '"'
if placeholders_amount > 0:
anon_snippet_body = anon_snippet_body + ', '
anon_snippet_body = anon_snippet_body + ', '.join(['$' + str(i+1) for i in range(placeholders_amount, 2*placeholders_amount)]) + ");"
snip.expand_anon(anon_snippet_body)
endglobal
post_jump "create_parameter_placeholders(snip)"
snippet "print\d+" "println" rA
`!p snip.rv = match.group(1)`
endsnippet
snippet println "println" A
println!("$1");$0
endsnippet

View File

@@ -31,7 +31,7 @@ snippet vec "Vector"
\\vec{$1}$0
endsnippet
snippet env "Environment" bA
snippet #env "Environment" bA
\\begin{$1}
$2
\\end{$1}$0
@@ -164,7 +164,7 @@ snippet () "( ... )"
\\left( $1 \\right) $0
endsnippet
snippet menc "Mathmode-text" iA
snippet ,text "Mathmode-text" iA
\\text{ $1 }$0
endsnippet
@@ -180,14 +180,6 @@ snippet geq "greater equal"
\\geq
endsnippet
snippet let "lesser than"
<
endsnippet
snippet grt "greater than"
>
endsnippet
snippet case "if else mathstyle"
\\begin{cases}
$1 & \\quad \\text{$2}\\\\ $3 & \\quad \\text{$4}\\\\ \\end{cases}$0
@@ -202,11 +194,11 @@ snippet ival "Intervall"
endsnippet
snippet xx "multiplication" i
\\cdot
\\cdot $0
endsnippet
snippet root "nth root"
\\sqrt[$1]{$2}$0
snippet root "nth root" i
\\sqrt[$1]{$2} $0
endsnippet
snippet sdef "Definition"
@@ -265,18 +257,22 @@ endsnippet
snippet bit "itemize"
\\begin{itemize}
\\item $1`!p t[1] = t[1].replace("+\n", "\n\t\\item")`
\\item $1`!p t[1] = t[1].replace(" \n", "\n\t\\item")`
\\end{itemize}
$0
endsnippet
snippet ben "enumerate"
\\begin{enumerate}
\\item $1`!p t[1] = t[1].replace("+\n", "\n\t\\item")`
\\item $1`!p t[1] = t[1].replace(" \n", "\n\t\\item")`
\\end{enumerate}
$0
endsnippet
snippet - "new item" b
\\item $0
endsnippet
snippet sch "chapter"
\\chapter{$1}$0
endsnippet
@@ -532,3 +528,8 @@ snippet frame "Add a new Frame" b
$2
\\end{frame}$0
endsnippet
snippet != "not equal" iA
\\neq $0
endsnippet

View File

@@ -0,0 +1,25 @@
snippet "reg []" "Register of size." A
reg [${1:7}:${2:0}] ${3:register};$0
endsnippet
global !p
def complete(t, opts):
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
return "(" + "|".join(opts) + ")"
endglobal
snippet always "Do something always @" b
always @($1`!p snip.rv=complete(t[1], ['*', 'posedge clk', 'negedge clk', 'posedge rst_n', 'negedge rst_n'])`) begin
$2
end $0
endsnippet
snippet al "Do something always @" b
always @($1) begin
$2
end $0
endsnippet