Embedded anonymous triggers
I'm trying to launch anonymous triggers according to some keywords. Specifically, i'm trying to insert license headers with the appropriate comment symbol. This is the code:
global !p
gplv3 = \
r"""Copyright (c) ${3:`date +%Y`} ${2:COMPANY}
This file is part of ${1:SOMElib}.
$1 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
$1 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with $1. If not, see <http://
Created: `date +'%d %b %Y'`
Author: Júlio Hoffimann
"""
endglobal
snippet "lic (\w+)" "Licence header (generic)" br
`!p
license = {
'gpl' : gplv3
}[match.group(1)]
trigger_output = vim.eval(
# TODO: filter trigger_output to insert the comment symbol
snip.rv = trigger_output
endsnippet
When i type `lic gpl` and press <TAB> the trigger is correctly launched, but the tabstops are missed. Do you have a better approach for what i'm trying to achieve? Is it possible to explicitly launch a trigger from within another? Any way to accomplish primitive piping?
Thanks, this plugin is amazing.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- UltiSnips Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Júlio Hoffimann Mendes
- Solved:
- Last query:
- Last reply: