Last active
August 29, 2015 14:24
-
-
Save pepoluan/613fb93a7bced2dac9b7 to your computer and use it in GitHub Desktop.
SaltStack State to install vim and update the syntax files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!pyobjects | |
# This init.sls state file should be put into /srv/salt/vim | |
# And /srv/salt/vim/syntax should contain the VimL scriptfiles you list in syntax_updates below | |
### TUNABLES ### | |
# Separate entries with a comma | |
# Make sure every entry exists in the syntax/ directory | |
syntax_updates = [ 'sh.vim' ] | |
# The SaltStack State Location, APPEND A SLASH please | |
salt_stub = 'salt://vim/' | |
### DO NOT EDIT BELOW THIS LINE ### | |
import os | |
import re | |
ETC_dir = '/etc/vim/' | |
VIM_dir = '/usr/share/vim/' | |
re_vimsub = re.compile('vim[0-9]+') | |
def Fmanage(fname, fdir=ETC_dir, sourcename=None, sourcedir=salt_stub, **kwargs): | |
sname = sourcename or fname | |
return File.managed(os.path.join(fdir, fname), source=sourcedir + sname, | |
template='jinja', show_diff=False, | |
user='root', group='root', mode=644, | |
**kwargs) | |
with Pkg.installed('vim'): | |
# Install and activate Pathogen via vimrc.local | |
with Fmanage('pathogen.vim'): | |
Fmanage('vimrc.local') | |
File.directory(os.path.join(ETC_dir, 'bundle'), user='root', group='root', mode=644) | |
# Perform update on syntax files | |
# First we need to find the vim## directory location | |
m = None | |
for dirname in os.listdir(VIM_dir): | |
m = re_vimsub.match(dirname) | |
if m is not None: break | |
if m: | |
vim_sub = m.group() | |
vim_syntax_path = os.path.join(VIM_dir, vim_sub, 'syntax') | |
for scriptname in syntax_updates: | |
Fmanage(scriptname, fdir=vim_syntax_path, sourcedir=salt_stub + 'syntax/') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment