diff options
| -rw-r--r-- | .vim/lua/plugins.lua | 11 | ||||
| -rw-r--r-- | .vim/lua/snips.lua | 109 |
2 files changed, 119 insertions, 1 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index da9f458..9560d98 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -186,7 +186,8 @@ return require('packer').startup({function() nvim_lsp = true, nvim_lua = true, orgmode = true, - ultisnips = true, + ultisnips = false, + snippets_nvim = true, } } @@ -286,12 +287,20 @@ return require('packer').startup({function() -- snippets use {'SirVer/ultisnips', -- {{{ + disable = true, requires = {'honza/vim-snippets'}, config = function() vim.g.UltiSnipsJumpForwardTrigger = "<tab>" vim.g.UltiSnipsJumpBackwardTrigger = "<s-tab>" end} -- }}} + use {'norcalli/snippets.nvim', + config = function() + require('snippets').use_suggested_mappings() + -- NOTE(robert): write your own inserter using the plenary helpers + require('snips') + end} + -- use {'L3MON4D3/LuaSnip', -- config = "require('plugins._ultisnips')", -- } diff --git a/.vim/lua/snips.lua b/.vim/lua/snips.lua new file mode 100644 index 0000000..aa7b0bf --- /dev/null +++ b/.vim/lua/snips.lua @@ -0,0 +1,109 @@ +-- vim: foldenable + +local system = function(cmd) + return function() + local args = vim.split(cmd, ' ') + local command = args[1] + table.remove(args, 1) + return table.concat(require('plenary.job'):new({ + command = command, + args = args, + enable_recording = true, + }):sync(), '\n') + end +end + +local U = require'snippets.utils' +require('snippets').snippets = { + _global = { + nowutc = [[${=os.date("!%Y-%m-%dT%H:%M:%SZ")}]], + nowloc = [[${=os.date("%Y-%m-%dT%H:%M:%S%z")}]], + + ok = "✔", + bad = "✘", + + todo = U.force_comment [[NOTE(${=io.popen("id -un"):read"*l"}): ]], + note = U.force_comment [[TODO(${=io.popen("id -un"):read"*l"}): ]], + }, + + sh = { -- {{{ + skel = U.match_indentation [[ +#!/bin/sh +set -e +[ -n "\$DEBUG" ] && set -x +]], + + deps = U.match_indentation [[ +# check requirements +for tool in ${1}; do + if ! command -v "\$tool" >/dev/null; then + printf "%s: %s not installed but required\n" "\$(basename "\$0")" "\$tool" >&2 + exit 1 + fi +done +]], + + getopt = U.match_indentation [[ +${2}= +while getopts ${1}h opt; do + case "\$opt" in + ${1}) ${2}=1 ;; + h|?) + printf "usage: %s [-h]\n" "\$(basename "\$0")" + printf "\n" + printf " -${1} \t ${2}\n" + printf "\n" + exit 2 ;; + esac +done +shift \$((OPTIND - 1)) +]], + }, -- }}} + + tex = { -- {{{ + brief = U.match_indentation [[ +\documentclass{dinbrief} +\usepackage{graphicx} +\usepackage[a4paper,margin=30truemm]{geometry} +% language +\usepackage{polyglossia} +\setdefaultlanguage[spelling=new]{german} +% font +\usepackage{fontspec} +\setmainfont{IBM Plex Sans} +\setmonofont{IBM Plex Mono} +% dinbrief options +\nowindowtics +\nowindowrules + +% unterschrift +\newcommand{\setsign}{\includegraphics[height=30truemm]{/home/robert/Pictures/sign.png}} +\signature{Robert Günzler} +\address{ +% absender + Robert Günzler \\\\ + ${4:STREET} \\\\ + ${5:PLZ} Berlin} + +\date{\today} +\place{Berlin} + +% betreff +% \subject{{\bf anliegen}} + +\begin{document} +\begin{letter}{ +% empfänger + ${1} + +\opening{${2:Sehr geehrte Damen und Herren,}} + +${0} + +\vspace{10truemm} +\closing[\protect\setsign]{${3:Mit freundlichen Grüßen}} +\end{letter} +\end{document} +]], + }, -- }}} +} |