vim execute overhaul

This commit is contained in:
Wryn (yage) Wagner 2023-11-13 16:35:35 -07:00
parent 6cbe57637b
commit 039c03b6b5
5 changed files with 77 additions and 65 deletions

View File

@ -4,7 +4,13 @@ let escapeTmuxPaneID = g:escapeTmuxSession . ":0.0"
let escapeCommandOutputs = ['tmux', 'split-pane-vertical', 'split-pane-horizontal'] let escapeCommandOutputs = ['tmux', 'split-pane-vertical', 'split-pane-horizontal']
function ExecuteScwrypt(scwrypt = '', args = '', output = '', syntax = 'bash') function ExecuteScwrypt(scwrypt = '', args = '', output = '', syntax = 'bash')
call ExecuteCommand('scwrypts ' . a:scwrypt . ' -- ' . a:args, a:output, 'shell', a:syntax) let b:scwryptsPrevArgs = a:args
call ExecuteCommand('scwrypts -n ' . a:scwrypt . ' -- ' . a:args, a:output, 'shell', a:syntax)
echom 'scwrypts -n ' . a:scwrypt . '--' . a:args
endfunction
function ExecuteScwryptInteractive(scwrypt = '', args = '', output = '', syntax = 'bash')
call ExecuteScwrypt(a:scwrypt, a:args . input('scwrypts ' . a:scwrypt . '--' . a:args), a:output, a:syntax)
endfunction endfunction
function ExecuteCommand(args = '', output = '', flavor = 'shell', syntax = 'bash') function ExecuteCommand(args = '', output = '', flavor = 'shell', syntax = 'bash')

62
vim/file-execute.vim Normal file
View File

@ -0,0 +1,62 @@
nnoremap <Leader>ec :execute b:executeDefault<CR>
nnoremap <Leader>ei :execute b:executeInteractive<CR>
nnoremap <Leader>eb :execute b:executeBuild<CR>
nnoremap <Leader>ef :execute b:executeFormat<CR>
nnoremap <Leader>et :execute b:executeTest<CR>
" --- (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 = "!clear<CR><CR>q:?GoRun<CR><CR>"
autocmd FileType go let b:executeFormat = "<Plug>(go-imports)"
autocmd FileType go nnoremap <silent> gd <Plug>(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")'
" --- 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-vertical')"
autocmd FileType *.scwrypts let b:executeInteractive = "call ExecuteScwryptInteractive(b:scwryptsAutoName, ' ', 'split-pane-vertical')"
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-vertical')"
augroup end
" }}}

View File

@ -23,6 +23,8 @@ augroup forced_filetype_recognition
autocmd BufRead,BufNewFile *.template.yaml set filetype=yaml.cloudformation autocmd BufRead,BufNewFile *.template.yaml set filetype=yaml.cloudformation
autocmd BufRead,BufNewFile git.conf setfiletype gitconfig autocmd BufRead,BufNewFile git.conf setfiletype gitconfig
autocmd BufRead,BufNewFile */scwrypts/* execute "set filetype=".&filetype.".scwrypts"
let g:tex_flavor = "latex" let g:tex_flavor = "latex"
augroup end augroup end
@ -58,68 +60,4 @@ augroup end
let g:markdown_fenced_languages = ['javascript', 'json', 'python', 'bash', 'yaml', 'shell=zsh', 'sql'] let g:markdown_fenced_languages = ['javascript', 'json', 'python', 'bash', 'yaml', 'shell=zsh', 'sql']
" }}} " }}}
" --- (e)xe(c)ute -----------------------------------------------------
" (i)nteractive
" (b)uild
" auto-(f)ormat
" (t)ests
" {{{
augroup file_specific_command_overrides
autocmd!
nnoremap <Leader>ec :call ExecuteCommand('%:p', 'split-pane-horizontal')<CR>
nnoremap <Leader>ei :echohl ErrorMsg <bar> echom 'ERROR: no interactive execute defined' <bar> echohl None<CR>
nnoremap <Leader>eb :echohl ErrorMsg <bar> echom 'ERROR: no build steps defined' <bar> echohl None<CR>
nnoremap <Leader>ef :echohl ErrorMsg <bar> echom 'ERROR: no auto-format steps defined' <bar> echohl None<CR>
nnoremap <Leader>et :echohl ErrorMsg <bar> echom 'ERROR: no test steps defined' <bar> echohl None<CR>
autocmd FileType tex nnoremap <Leader>ec :! scwrypts -n latex/open-pdf -- %:p<CR>
autocmd FileType tex nnoremap <Leader>eb :! scwrypts -n latex/build-pdf -- %:p<CR>
autocmd FileType tex nnoremap <Leader>ef :! scwrypts -n latex/cleanup -- %:p<CR>
autocmd FileType markdown nnoremap <Leader>ec :!xdg-open %:p<CR>
autocmd FileType go nnoremap <Leader>ec :!clear<CR><CR>q:?GoRun<CR><CR>
autocmd FileType go nnoremap <silent> <Leader>ef <Plug>(go-imports)
autocmd FileType go nnoremap <silent> gd <Plug>(go-def-tab)
autocmd FileType python nnoremap <Leader>ec :call ExecuteCommand('python %:p', 'split-pane-vertical')<CR>
autocmd FileType python nnoremap <Leader>ei :call ExecuteCommand('bpython -qi %:p', 'split-pane-vertical')<CR>
autocmd FileType yaml nnoremap <Leader>ec :call ExecuteScwrypt(
\ '-n --name helm/get-template --group scwrypts --type zsh'
\ , '--template-filename %:p', 'split-pane-vertical'
\ , 'yaml'
\)<CR>
autocmd FileType yaml nnoremap <Leader>ei :call ExecuteScwrypt(
\ '-n --name helm/get-template --group scwrypts --type zsh'
\ , '--raw --template-filename %:p', 'split-pane-vertical'
\ , 'yaml'
\)<CR>
autocmd FileType yaml nnoremap <Leader>eb :call ExecuteScwrypt(
\ '-n --name helm/update-dependencies --group scwrypts --type zsh'
\ , '--template-filename %:p', 'split-pane-vertical'
\ , 'yaml'
\)<CR>
augroup end
" }}}
" --- notes for meeeeee ----
" {{{
" need to adapt this for helm execution;
" should check for values.test.yaml or tests/default.yaml
" echom 'quicktest' | execute 'vertical terminal helm template directus . --debug --values values.yaml --values values.test.yaml --show-only %' | set syntax=yaml
" }}}
" --- organization overrides ------------------------------------------
" {{{
source $WRYNVIMPATH/override/rentdynamics.vim
source $WRYNVIMPATH/override/directus.vim
" }}}
"
"
syntax on syntax on

View File

@ -3,4 +3,6 @@ augroup directus
autocmd BufRead,BufEnter,BufNewFile */Projects/directus/*.js setlocal noexpandtab autocmd BufRead,BufEnter,BufNewFile */Projects/directus/*.js setlocal noexpandtab
autocmd BufRead,BufEnter,BufNewFile */Projects/directus/*.mjs setlocal noexpandtab autocmd BufRead,BufEnter,BufNewFile */Projects/directus/*.mjs setlocal noexpandtab
autocmd BufRead,BufEnter,BufNewFile */Projects/directus/*.ts setlocal noexpandtab autocmd BufRead,BufEnter,BufNewFile */Projects/directus/*.ts setlocal noexpandtab
autocmd BufRead,BufNewFile */Projects/directus/cloud/code/scwrypts/* let b:scwryptsAutoName = "directus " . b:scwryptsAutoName
augroup end augroup end

View File

@ -7,10 +7,14 @@ endif
source $WRYNVIMPATH/options.vim source $WRYNVIMPATH/options.vim
source $WRYNVIMPATH/execute.vim source $WRYNVIMPATH/execute.vim
source $WRYNVIMPATH/formatting.vim source $WRYNVIMPATH/formatting.vim
source $WRYNVIMPATH/file-execute.vim
source $WRYNVIMPATH/navigation.vim source $WRYNVIMPATH/navigation.vim
source $WRYNVIMPATH/color.vim source $WRYNVIMPATH/color.vim
source $WRYNVIMPATH/utility.vim source $WRYNVIMPATH/utility.vim
source $WRYNVIMPATH/override/rentdynamics.vim
source $WRYNVIMPATH/override/directus.vim
" --------------------------------------------------------------------- " ---------------------------------------------------------------------
" {{{ " {{{