From 630b74872b275cc1f0cefc2472f66691755a75f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Walle?= Date: Sat, 3 Nov 2012 17:07:01 +0100 Subject: [PATCH] Add test to determine shell The 'sh' filetype in Vim covers sh, bash and ksh. This function looks for declared variables that results from Vim's own test. The global variables are checked first since they are typically specifed by the user in .vimrc --- UltiSnips/sh.snippets | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/UltiSnips/sh.snippets b/UltiSnips/sh.snippets index 1085d86..3771cab 100644 --- a/UltiSnips/sh.snippets +++ b/UltiSnips/sh.snippets @@ -1,3 +1,17 @@ +global !p +import vim +def testShell(scope, shell): + return vim.eval("exists('" + scope + ":is_" + shell + "')") + +def getShell(): + for scope in ["g", "b"]: + for shell in ["bash", "sh", "kornshell"]: + if testShell(scope, shell) == "1": + if shell == "kornshell": + return "ksh" + return shell + return "sh" +endglobal ########################################################################### # TextMate Snippets #