fix: nvim escape time

This commit is contained in:
Philipp Hochkamp 2023-01-25 11:24:15 +01:00
parent 7e0ca28180
commit f7ac9c2ace
8 changed files with 13 additions and 827 deletions

24
flake.lock generated
View file

@ -40,11 +40,11 @@
"coc-nvim": {
"flake": false,
"locked": {
"lastModified": 1674586885,
"narHash": "sha256-I+/silVjSmjLNOTDVVSoQKbzkNgoJdiV/mmX14EBLL8=",
"lastModified": 1674723043,
"narHash": "sha256-ZMVyB892SjkP0H1mgHj7fOvDgvP+KcwVh5B3N0B2R9A=",
"owner": "neoclide",
"repo": "coc.nvim",
"rev": "f3b0e2f2c028e03b97f36ae9a1f7152cf0d10be6",
"rev": "663edb65711212a89012990bdd5c013b81a09770",
"type": "github"
},
"original": {
@ -82,11 +82,11 @@
]
},
"locked": {
"lastModified": 1674615852,
"narHash": "sha256-FcZ42T0m+CVbNyqHsmjixlFzuCevZXsbPBG/3JtoBak=",
"lastModified": 1674727661,
"narHash": "sha256-yiT8F+VrFS5xnDwfb6kLYitAztXuxiblhz8+AP6T28g=",
"owner": "nix-community",
"repo": "emacs-overlay",
"rev": "53018b60fc15aaac1722031e50b043883b74fcd0",
"rev": "6b44cc8a441bed3796e6ddc984745fcdeaba8aa4",
"type": "github"
},
"original": {
@ -201,11 +201,11 @@
},
"nixpkgs-master": {
"locked": {
"lastModified": 1674624031,
"narHash": "sha256-jrprd08u7leFnxQA9wAzzYRmn+aK0pqEBjDv3aFpIqw=",
"lastModified": 1674746945,
"narHash": "sha256-xJ5XrXWPHDArSAJtJVBGRQzHu3ESI13zMNjXbnRaAjY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "343b5c8134ac2387088f7662b2c4938361a714f1",
"rev": "e39a949aaa9e4fc652b1619b56e59584e1fc305b",
"type": "github"
},
"original": {
@ -431,11 +431,11 @@
"zsh-completions": {
"flake": false,
"locked": {
"lastModified": 1674037718,
"narHash": "sha256-MuLmPZW46z33voKOh0vyQcOYjbrZaVPJOwpMEAwxKt8=",
"lastModified": 1674729619,
"narHash": "sha256-2Y1e8fbEer5HtOeI7GHSie0cizKLpd0wlDVooRGO5Ng=",
"owner": "zsh-users",
"repo": "zsh-completions",
"rev": "dd686f35d1314f9cfcf20fa13ac7bb33b1d424e1",
"rev": "54156de9cbcc807e9cdb9a7c4e6c09d4bab14536",
"type": "github"
},
"original": {

View file

@ -1,121 +0,0 @@
# This file contains snippets that are always defined. I personally
# have snippets for signatures and often needed texts
# sligthly lower priority than everything else since specialized versions
# should overwrite. The user needs to adjust her priority in her snippets to
# ~-55 so that other filetypes will still overwrite.
priority -60
global !p
def _parse_comments(s):
""" Parses vim's comments option to extract comment format """
i = iter(s.split(","))
rv = []
try:
while True:
# get the flags and text of a comment part
flags, text = next(i).split(':', 1)
if len(flags) == 0:
rv.append(('OTHER', text, text, text, ""))
# parse 3-part comment, but ignore those with O flag
elif 's' in flags and 'O' not in flags:
ctriple = ["TRIPLE"]
indent = ""
if flags[-1] in string.digits:
indent = " " * int(flags[-1])
ctriple.append(text)
flags, text = next(i).split(':', 1)
assert flags[0] == 'm'
ctriple.append(text)
flags, text = next(i).split(':', 1)
assert flags[0] == 'e'
ctriple.append(text)
ctriple.append(indent)
rv.append(ctriple)
elif 'b' in flags:
if len(text) == 1:
rv.insert(0, ("SINGLE_CHAR", text, text, text, ""))
except StopIteration:
return rv
def get_comment_format():
""" Returns a 4-element tuple (first_line, middle_lines, end_line, indent)
representing the comment format for the current file.
It first looks at the 'commentstring', if that ends with %s, it uses that.
Otherwise it parses '&comments' and prefers single character comment
markers if there are any.
"""
commentstring = vim.eval("&commentstring")
if commentstring.endswith("%s"):
c = commentstring[:-2]
return (c, c, c, "")
comments = _parse_comments(vim.eval("&comments"))
for c in comments:
if c[0] == "SINGLE_CHAR":
return c[1:]
return comments[0][1:]
endglobal
##########################
# LOREM IPSUM GENERATORS #
##########################
snippet lorem "Lorem Ipsum - 50 Words" b
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
endsnippet
##########################
# VIM MODELINE GENERATOR #
##########################
# See advice on `:help 'tabstop'` for why these values are set. Uses second
# modeline form ('set') to work in languages with comment terminators
# (/* like C */).
snippet modeline "Vim modeline"
vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'`
endsnippet
#########
# DATES #
#########
snippet date "YYYY-MM-DD" w
`!v strftime("%Y-%m-%d")`
endsnippet
snippet ddate "DD.MM.YYYY" w
`!v strftime("%d.%m.%Y")`
endsnippet
snippet diso "ISO format datetime" w
`!v strftime("%Y-%m-%d %H:%M:%S%z")`
endsnippet
snippet time "hh:mm" w
`!v strftime("%H:%M")`
endsnippet
snippet datetime "YYYY-MM-DD hh:mm" w
`!v strftime("%Y-%m-%d %H:%M")`
endsnippet
snippet todo "TODO comment" bw
`!p snip.rv=get_comment_format()[0]` ${2:TODO}: $1 ${3: <${4:`!v strftime('%d.%m.%y %H:%M')`}${5:, `git config --get user.name`}>} `!p snip.rv=get_comment_format()[2]`
endsnippet
##########
# Misc #
##########
snippet uuid "Random UUID" w
`!p if not snip.c: import uuid; snip.rv = uuid.uuid4()`
endsnippet
# vim:ft=snippets:

View file

@ -1,115 +0,0 @@
# Snippets for Go
priority -50
# when to abbriviate and when not?
# b doesn't work here, because it ignores whitespace
# optional local name?
snippet /^import/ "Import declaration" r
import (
"${1:package}"
)
endsnippet
snippet /^package/ "Package declaration" r
// Package $1 provides ...
package ${1:main}
endsnippet
# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle
snippet /^cons/ "Constants declaration" r
const (
${1:constant}${2/(.+)/ /}${2:type} = ${0:value}
)
endsnippet
snippet /^con/ "Constant declaration" r
const ${1:name}${2/(.+)/ /}${2:type} = ${0:value}
endsnippet
snippet iota "Iota constant generator" b
const (
${1:constant}${2/(.+)/ /}${2:type} = iota
)
endsnippet
snippet struct "Struct declaration" b
type ${1:Struct} struct {
${0:${VISUAL}}
}
endsnippet
snippet interface "Interface declaration" b
type ${1:Interface} interface {
${0:${VISUAL}}
}
endsnippet
snippet if "If statement" b
if ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet switch "Switch statement" b
switch ${1:expression}${1/(.+)/ /}{
case$0
}
endsnippet
# functions
snippet /^main/ "Main function" r
func main() {
${0:${VISUAL}}
}
endsnippet
snippet /^meth/ "Method" r
func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} {
${0:${VISUAL}}
}
endsnippet
snippet func "Function" b
func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
${0:${VISUAL}}
}
endsnippet
snippet funch "HTTP handler" b
func ${1:handler}(${2:w} http.ResponseWriter, ${3:r} *http.Request) {
${0:${VISUAL}}
}
endsnippet
# types and variables
snippet map "Map type" b
map[${1:keytype}]${2:valtype}
endsnippet
snippet : "Variable declaration :=" b
${1:name} := ${0:value}
endsnippet
snippet var "Variable declaration" b
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
endsnippet
snippet vars "Variables declaration" b
var (
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
)
endsnippet
snippet json "JSON field"
\`json:"${1:displayName}"\`
endsnippet
# vim:ft=snippets:
# error handling
snippet err "Basic error handling" b
if err != nil {
log.${1:Fatal}(err)
}
endsnippet

View file

@ -1,399 +0,0 @@
###########################################################################
# TEXTMATE SNIPPETS #
###########################################################################
# Many of the snippets here use a global option called
# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline
# before '{' braces.
global !p
def junit(snip):
if snip.opt("g:ultisnips_java_junit", "") == "3":
snip += ""
else:
snip.rv += "@Test\n\t"
def nl(snip):
if snip.opt("g:ultisnips_java_brace_style", "") == "nl":
snip += ""
else:
snip.rv += " "
def getArgs(group):
import re
word = re.compile('[a-zA-Z><.]+ \w+')
return [i.split(" ") for i in word.findall(group) ]
def camel(word):
return word[0].upper() + word[1:]
endglobal
snippet sleep "try sleep catch" !b
try {
Thread.sleep(${1:1000});
} catch (InterruptedException e){
e.printStackTrace();
}
endsnippet
snippet /i|n/ "new primitive or int" !br
${1:int} ${2:i} = ${3:1};
$0
endsnippet
snippet /o|v/ "new Object or variable" !br
${1:Object} ${2:var} = new $1(${3});
endsnippet
snippet f "field" !b
${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`};
endsnippet
snippet ab "abstract" b
abstract
endsnippet
snippet as "assert" b
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0
endsnippet
snippet at "assert true" !b
assertTrue(${1:actual});
endsnippet
snippet af "assert false" !b
assertFalse(${1:actual});$0
endsnippet
snippet ae "assert equals" !b
assertEquals(${1:expected}, ${2:actual});
endsnippet
snippet br "break"
break;
endsnippet
snippet cs "case" b
case $1:
$2
$0
endsnippet
snippet ca "catch" b
catch (${1:Exception} ${2:e})`!p nl(snip)`{
$0
}
endsnippet
snippet cle "class extends" b
public class ${1:`!p
snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{
$0
}
endsnippet
snippet clc "class with constructor, fields, setter and getters"
public class `!p
snip.rv = snip.basename or "untitled"` {
`!p
import re
args = getArgs(t[1])
if len(args) == 0: snip.rv = ""
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";"
if len(args) == 0:
snip.rv += "\n"`
}$0
`!p
args = getArgs(t[1])
if len(args) == 0: snip.rv = ""
for i in args:
snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\
\tthis." + i[1] + " = " + i[1] + ";\n\t}\n"
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\
\n\t\treturn " + i[1] + ";\n\t}\n"
`
}
endsnippet
snippet cl "class" b
public class ${1:`!p
snip.rv = snip.basename or "untitled"`} {
$0
}
endsnippet
snippet cos "constant string" b
public static final String ${1:var} = "$2";$0
endsnippet
snippet co "constant" b
public static final ${1:String} ${2:var} = $3;$0
endsnippet
snippet de "default" b
default:
$0
endsnippet
snippet elif "else if" b
else if ($1)`!p nl(snip)`{
$0
}
endsnippet
snippet else "else" b
else`!p nl(snip)`{
$0
}
endsnippet
snippet fi "final" b
final
endsnippet
snippet fore "for (each)" b
for ($1 : $2)`!p nl(snip)`{
$0
}
endsnippet
snippet fori "for with int i" b
for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{
$0
}
endsnippet
snippet for "for" b
for ($1; $2; $3)`!p nl(snip)`{
$0
}
endsnippet
snippet if "if" b
if ($1)`!p nl(snip)`{
$0
}
endsnippet
snippet imt "import junit_framework_TestCase;" b
import junit.framework.TestCase;
$0
endsnippet
snippet im "import" b
import ${1:java}.${2:util}.$0
endsnippet
snippet in "interface" b
interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }{
$0
}
endsnippet
snippet cc "constuctor call or setter body"
this.${1:var} = $1;
endsnippet
snippet list "Collections List" b
List<${1:String}> ${2:list} = new ${3:Array}List<$1>();
endsnippet
snippet map "Collections Map" b
Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>();
endsnippet
snippet set "Collections Set" !b
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
endsnippet
snippet /Str?|str/ "String" !br
String
endsnippet
snippet cn "constructor, \w fields + assigments" b
`!p
import re
args = getArgs(t[1])
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
if len(args) == 0:
snip.rv += "\n"`
}
endsnippet
snippet j.b "java_beans_" i
java.beans.
endsnippet
snippet j.i "java_io" i
java.io.
endsnippet
snippet j.m "java_math" i
java.math.
endsnippet
snippet j.n "java_net_" i
java.net.
endsnippet
snippet j.u "java_util_" i
java.util.
endsnippet
snippet main "method (main)" b
public static void main(String[] args)`!p nl(snip)`{
$0
}
endsnippet
snippet try "try/catch" !b
try {
$1
} catch(${2:Exception} ${3:e}){
${4:e.printStackTrace();}
}
endsnippet
snippet mt "method throws" b!
${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{
$0
}
endsnippet
snippet m "method" b
${1:private} ${2:void} ${3:method}(${4}) {
$0
}
endsnippet
snippet md "Method With javadoc" !b
/**
* ${7:Short Description}`!p
for i in getArgs(t[4]):
snip.rv += "\n\t * @param " + i[1] + " usage..."`
* `!p
if "throws" in t[5]:
snip.rv = "\n\t * @throws " + t[6]
else:
snip.rv = ""` `!p
if not "void" in t[2]:
snip.rv = "\n\t * @return object"
else:
snip.rv = ""`
**/
${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{
$0
}
endsnippet
snippet getter "getter"
public ${1:String} get${2:Name}() {
return `!p snip.rv = t[2].lower()`;
}
endsnippet
snippet setter "setter"
public void set${1:Name}(${2:String} $1) {
return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
}
endsnippet
snippet setget "setter and getter"
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
}
public $2 get$1() {
return `!p snip.rv = t[1].lower()`;
}
endsnippet
snippet pa "package" b
package
endsnippet
snippet p "print" b
System.out.print($1);$0
endsnippet
snippet pl "println" b
System.out.println($1);$0
endsnippet
snippet pr "private" b
private
endsnippet
snippet po "protected" b
protected
endsnippet
snippet pu "public" b
public
endsnippet
snippet re "return" b
return
endsnippet
snippet st "static"
static
endsnippet
snippet sw "switch" b
switch ($1)`!p nl(snip)`{
case $2: $0
}
endsnippet
snippet sy "synchronized"
synchronized
endsnippet
snippet tc "test case"
public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCase}`!p nl(snip)`{
$0
}
endsnippet
snippet t "test" b
`!p junit(snip)`public void test${1:Name}() {
$0
}
endsnippet
snippet tt "test throws" b
`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{
$0
}
endsnippet
snippet th "throw" b
throw new $0
endsnippet
snippet wh "while" b
while ($1)`!p nl(snip)`{
$0
}
endsnippet
# vim:ft=snippets:

View file

@ -1,172 +0,0 @@
snippet limxa "lim from x to a" i
\lim_{${2:x} \rightarrow ${1:a}} $0
endsnippet
snippet liminf "lim from x to infinity" i
\lim_{${1:x} \rightarrow \infty} $0
endsnippet
snippet ddx "fr d dx" i
\frac{d}{dx}
endsnippet
snippet pm "Generate pmatrix" i
\begin{pmatrix} $0 \end{pmatrix}
endsnippet
snippet cd "cdot" i
\cdot
endsnippet
snippet lra "leftrightarrow" i
\leftrightarrow
endsnippet
snippet Lra "Leftrightarrow" i
\Leftrightarrow
endsnippet
snippet la "leftarrow" i
\leftarrow
endsnippet
snippet La "Leftarrow" i
\Leftarrow
endsnippet
snippet ra "rightarrow" i
\rightarrow
endsnippet
snippet Ra "Rightarrow" i
\Rightarrow
endsnippet
snippet gm "Generate pmatrix" i
\begin{gmatrix} $0 \end{gmatrix}
endsnippet
snippet bm "Creates a BMatrix" i
\begin{bmatrix} $0 \end{bmatrix}
endsnippet
snippet ta "add a tag"
\tag{${1:Tag Text}}
endsnippet
snippet fr "Fraction" i
\frac{$1}{$2}
endsnippet
snippet p "Programmiersprache" i
\`\`\`{${1:mips}}
$2
\`\`\`
endsnippet
snippet pi "Include Code from other file" i
\`\`\`{.${1:mips}include=${2:source.asm}}
\`\`\`
endsnippet
snippet head "Generates header with everything" b
---
title: '`!p pwd = os.getcwd()
if "mafi1" in pwd:
snip.rv = "Mafi1 Übung " + snip.basename[1:3] +" (Gruppe 10)"
elif "rs" in pwd:
snip.rv = "RS Übung " + snip.basename[1:3] + " (Gruppe 3)"
`'
date: `date +%d.%m.%Y`
author:
- 'Philipp Hochkamp (Mat. Nr. 211011)'
- 'Jonas Röger (Mat. Nr. 210435)'
- 'Nico Jansen (Mat. Nr. 210175)'
titlepage: true
---
endsnippet
snippet new "New Note"
- [${1:Title}](`!p
def getCategory():
w = vim.current.buffer
i = vim.current.window.cursor[0]-1
while i >= 0:
if w[i].split(" ")[0] == "##":
return w[i].split(" ")[1].lower()+"/"
i = i-1
return os.path.basename(w.name).split(".md")[0]+"/"
snip.rv = getCategory() + t[1].replace(" ", "-").lower()`.md)
endsnippet
snippet al "Align Block" i
\begin{align*}
${1:${VISUAL}}
\end{align*}
endsnippet
snippet eq "Equation Block" i
\begin{equation}
${1:${VISUAL}}
\end{equation}
endsnippet
snippet bl "Custom Block" i
\begin{${1:tabluar}}$2
$3
\end{$1}
endsnippet
snippet tab "tabular (or arbitrary) environment" i
\begin{${1:tabular}}{${2:c}}
${0:${VISUAL}}
\end{$1}
endsnippet
snippet mb "Math bold font text" i
\mathbb{${1:R}}
endsnippet
snippet mf "Math Fraktur text" i
\mathfrak{${1:P}}
endsnippet
snippet nt "No Tag and end line" i
\notag \\\\
endsnippet
snippet sum "\sum^{}_{}" i
\sum^{${1:n}}_{${2:i=1}} ${0}
endsnippet
snippet lr( "left( right)" i
\left( ${1:${VISUAL}} \right) ${0}
endsnippet
snippet lr| "left| right|" i
\left| ${1:${VISUAL}} \right| ${0}
endsnippet
snippet lr{ "left\{ right\}" i
\left\{ ${1:${VISUAL}} \right\} ${0}
endsnippet
snippet lr[ "left\[ right\]" i
\left [ ${0:${VISUAL}} \right ]
endsnippet
snippet refl "Reference Link" i
[${1:${VISUAL:Text}}][${2:id}]$0
[$2]:${4:http://${3:www.url.com}} "${5:$4}"
endsnippet
snippet fnt "Footnote" i
[^${1:${VISUAL:Footnote}}]$0
[^$1]:${2:Text}
endsnippet
snippet link "Link to something" i
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
endsnippet
snippet img "Image" i
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
endsnippet
snippet ilc "Inline Code" i
\`$1\`$0
endsnippet
snippet sqrt "square root" i
\sqrt{${1}} $2
endsnippet

View file

@ -1,3 +0,0 @@
snippet sh "Shebang" EndStuff
#!/usr/bin/env python
endsnippet

View file

@ -1,5 +0,0 @@
snippet sn "Snippet"
`echo snippet` ${1:Keys} "${2:Description}" ${3:EndStuff}
$4
`echo endsnippet`
endsnippet

View file

@ -9,6 +9,7 @@
gruvbox
];
extraConfig = ''
set -sg escape-time 0 # makes vim esc usable
new-session -s main
bind-key -n C-e send-prefix
bind '"' split-window -c "#{pane_current_path}"