This is the first commit that brings the privet dotfiles to a public reop previously this was all one puppet module. Now this has been split out so I can put all of the private files in a private puppet module
35 lines
870 B
Text
35 lines
870 B
Text
global !p
|
|
import vim
|
|
|
|
# Tests for the existence of a variable declared by Vim's filetype detection
|
|
# suggesting the type of shell script of the current file
|
|
def testShell(scope, shell):
|
|
return vim.eval("exists('" + scope + ":is_" + shell + "')")
|
|
|
|
# Loops over the possible variables, checking for global variables
|
|
# first since they indicate an override by the user.
|
|
def getShell():
|
|
for scope in ["g", "b"]:
|
|
for shell in ["bash", "posix", "sh", "kornshell"]:
|
|
if testShell(scope, shell) == "1":
|
|
if shell == "kornshell":
|
|
return "ksh"
|
|
if shell == "posix":
|
|
return "sh"
|
|
return shell
|
|
return "sh"
|
|
endglobal
|
|
|
|
snippet #!
|
|
`!p snip.rv = '#!/bin/' + getShell() + "\n\n" `
|
|
endsnippet
|
|
|
|
snippet !env "#!/usr/bin/env (!env)"
|
|
`!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" `
|
|
endsnippet
|
|
|
|
snippet if "If Condition" b
|
|
if [ $1 ]; then
|
|
$0
|
|
fi
|
|
endsnippet
|