nnoremap ec :execute b:executeDefault nnoremap ei :execute b:executeInteractive nnoremap eb :execute b:executeBuild nnoremap ef :execute b:executeFormat nnoremap et :execute b:executeTest " --- (e)xe(c)ute ----------------------------------------------------- " (i)nteractive " (b)uild " auto-(f)ormat " (t)ests " {{{ augroup file_specific_commands autocmd! autocmd FileType * let b:executeDefault = "call ExecuteCommand('%:p', 'split-pane-horizontal')" autocmd FileType * let b:executeInteractive = "call ExecuteCommand('%:p ' . input(expand('%').' -- '), 'split-pane-horizontal')" autocmd FileType * let b:executeBuild = "echohl ErrorMsg | echom 'ERROR: no build steps defined' | echohl None" autocmd FileType * let b:executeFormat = "%s/\\s\\+$//" autocmd FileType * let b:executeTest = "echohl ErrorMsg | echom 'ERROR: no test steps defined' | echohl None" autocmd FileType go let b:executeDefault = "!clearq:?GoRun" autocmd FileType go let b:executeFormat = "(go-imports)" autocmd FileType go nnoremap gd (go-def-tab) autocmd FileType markdown let b:executeDefault = '!google-chrome-stable %:p' autocmd FileType python let b:executeDefault = "call ExecuteCommand('python %:p', 'split-pane-vertical')" autocmd FileType python let b:executeInteractive = "call ExecuteCommand('bpython -qi %:p ' . input(expand('%').' -- '), 'split-pane-vertical')" autocmd FileType tex let b:executeDefault = 'call ExecuteScwrypt("latex/open-pdf", "%:p")' autocmd FileType tex let b:executeBuild = 'call ExecuteScwrypt("latex/build-pdf", "%:p")' autocmd FileType tex let b:executeFormat = 'call ExecuteScwrypt("latex/cleanup", "%:p")' autocmd FileType yaml let b:scwryptDefault = "--group scwrypts --type zsh --name helm/get-template " autocmd FileType yaml let b:scwryptBuild = "--group scwrypts --type zsh --name helm/update-dependencies " autocmd FileType yaml let b:scwryptArgs = "--template-filename %:p " autocmd FileType yaml let b:executeDefault = 'call ExecuteScwrypt(b:scwryptDefault, b:scwryptArgs . "--raw ", "split-pane-vertical", "yaml")' autocmd FileType yaml let b:executeInteractive = 'call ExecuteScwryptInteractive(b:scwryptDefault, b:scwryptArgs, "split-pane-vertical", "yaml")' autocmd FileType yaml let b:executeBuild = 'call ExecuteScwrypt(b:scwryptBuild, b:scwryptArgs, "split-pane-vertical", "yaml")' autocmd FileType yaml let b:executeTest = 'call ExecuteScwrypt(b:scwryptDefault, b:scwryptArgs, "split-pane-vertical", "yaml")' autocmd FileType rust let b:executeDefault = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo run --quiet\"', 'split-pane-horizontal')" autocmd BufRead,BufNewFile */Cargo.toml let b:executeDefault = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo run --quiet\"', 'split-pane-horizontal')" autocmd FileType rust let b:executeInteractive = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo run --quiet -- ' . input('cargo run -- ') . '\"', 'split-pane-horizontal')" autocmd BufRead,BufNewFile */Cargo.toml let b:executeInteractive = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo run --quiet -- ' . input('cargo run -- ') . '\"', 'split-pane-horizontal')" autocmd FileType rust let b:executeBuild = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo build\"', 'split-pane-horizontal')" autocmd BufRead,BufNewFile */Cargo.toml let b:executeBuild = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo build\"', 'split-pane-horizontal')" autocmd FileType rust let b:executeTest = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo test\"', 'split-pane-horizontal')" autocmd BufRead,BufNewFile */Cargo.toml let b:executeTest = "call ExecuteCommand('zsh -c \"cd %:p:h; cargo test\"', 'split-pane-horizontal')" " --- OVERRIDES ---------------------------- " autocmd FileType *.scwrypts let b:scwryptsType = "" autocmd FileType zsh.scwrypts let b:scwryptsType = "zsh" autocmd FileType python.scwrypts let b:scwryptsType = "py" autocmd FileType javascript.scwrypts let b:scwryptsType = "zx" autocmd FileType typescript.scwrypts let b:scwryptsType = "zx" autocmd FileType *.scwrypts let b:scwryptsSubPath = substitute(substitute(expand("%:p"), ".*\.scwrypts/", "", ""), "^".b:scwryptsType."/", "", "") autocmd FileType *.scwrypts let b:scwryptsAutoName = b:scwryptsType . " " . substitute(substitute(b:scwryptsSubPath, ".[a-z]\\+$", "", ""), "/", " ", "g") . " " autocmd FileType *.scwrypts let b:scwryptsPrevArgs = ' ' autocmd FileType *.scwrypts let b:scwryptsEnvs = split(system('scwrypts --list-envs'), '\n') autocmd FileType *.scwrypts let b:scwryptsEnvChoices = split(system('echo SCWRYPTS_ENV=; scwrypts --list-envs | awk "{print \"\"NR\". \"\$0}"'), '\n') autocmd FileType *.scwrypts let b:executeDefault = "call ExecuteScwrypt(b:scwryptsAutoName, ' ', 'split-pane-horizontal', 'bash', '4')" autocmd FileType *.scwrypts let b:executeInteractive = "call ExecuteScwryptInteractive(b:scwryptsAutoName, ' ', 'split-pane-horizontal')" autocmd FileType *.scwrypts let b:executeBuild = "let $SCWRYPTS_ENV=b:scwryptsEnvs[inputlist(b:scwryptsEnvChoices) - 1]" autocmd FileType *.scwrypts let b:executeTest = "call ExecuteScwrypt(b:scwryptsAutoName, b:scwryptsPrevArgs, 'split-pane-horizontal', 'bash', '4')" augroup end " }}}