From 2e6c54477e29b52cbb01de14a1c393f54d7b2d04 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Mon, 23 Mar 2015 15:29:59 +0100 Subject: Remove cruft stuff from vim and use git submodules for plugins --- .config/vim/plugin/templates.vim | 105 --------------------------------------- 1 file changed, 105 deletions(-) delete mode 100755 .config/vim/plugin/templates.vim (limited to '.config/vim/plugin/templates.vim') diff --git a/.config/vim/plugin/templates.vim b/.config/vim/plugin/templates.vim deleted file mode 100755 index b24dfb5..0000000 --- a/.config/vim/plugin/templates.vim +++ /dev/null @@ -1,105 +0,0 @@ -" vim:fileencoding=iso-8859-1 -if has("python") -py < jabber.ccc.de) reported some problems in his - VIM environment, which inserts a CR after the first character - in templates. He came up with a workaround. Replace the - imap command in the end with - command('imap ^D ^[:py template_complete()a') - to make it work. - -""" -import sys -#sys.path.remove("") -from vim import * -from cStringIO import StringIO -import re, os -template_buffer = {} - -def template_complete(): - global template_buffer - - # Check for a template - currentPos = current.window.cursor[1] - template = "" - while currentPos >= 0 and len(current.line) > 0 and not current.line[currentPos].isspace(): - template = current.line[currentPos] + template - currentPos = currentPos - 1 - currentPos = currentPos + 1 - - if template is "": - return - - # Search for that template - fileType = eval("&ft") - if fileType not in template_buffer or template not in template_buffer[fileType]: - if fileType not in template_buffer: - template_buffer[fileType] = {} - searchPath = eval("g:templatePath") - - searchPaths = [ - "%s/%s/%s" % (searchPath, fileType, template), - "%s/%s" % (searchPath, template), - "%s/%s/%s.py" % (searchPath, fileType, template), - "%s/%s.py" % (searchPath, template) - ] - for templateFile in searchPaths: - if not os.access(templateFile, os.F_OK): - continue - try: - if templateFile[-3:] == ".py": - template_buffer[fileType][template] = open(templateFile, "r").read() - else: - template_buffer[fileType][template] = open(templateFile, "r").readlines() - break - except: - continue - else: - template_buffer[fileType][template] = False - if template_buffer[fileType][template] is not False: - # Insert template - indention = re.search("^\s+", current.line) - if indention is None: - indention = "" - else: - indention = indention.group(0) - endOfLine = current.line[current.window.cursor[1] + 1:] - current.line = current.line[:currentPos] - range = current.buffer.range(current.window.cursor[0], current.window.cursor[0]) - - if type(template_buffer[fileType][template]) == str: - # Execute as python code - backup = sys.stdout - sys.stdout = StringIO() - code = template_buffer[fileType][template] - exec code in {}, {"_vim": current, "_command": command} - insert = sys.stdout.getvalue().split("\n") - sys.stdout = backup - else: - insert = template_buffer[fileType][template] - - firstLine = True - sentVar = False - for line in insert: - if line.find("<++>") is not -1: - sentVar = True - if firstLine: - range.append(line) - else: - range.append(indention + line) - firstLine = False - if sentVar: - range.append(endOfLine) - else: - range.append("<++>%s" % endOfLine) - command('normal J') - -command('imap  :py template_complete()a') -EOF -endif -- cgit