dotwryn/vim/rc.d/34.utility-quick-repl.vim
yage ad66d50b11 BIG REFACTOR; PLEASE BE ADVISED
finally going to commit that zshrc refactor

- smolvsdefault on altaria
- i3-utils refactor
- no need for custom scwrypt executable anymore
- time to say goodbye to the old dotwryn.env in favor of the new and improved rc.ds
- vim/rc.d refactor + QuickREPL and QuickCommand replacements for \r and \t
- going to stop tracking Archives explicitly until new hard drive
- tty-colorscheme is now referenced directly
- colorscheme/spring-sunset needed to swap primary/secondary colors for focus in i3 since it was confusing
- setup config no longer needs to create ~/.config/wryn/env.vim; added some dependencies to arch-linux
- switch from dmenu to rofi by default; allow .i3 overrides in colorschemes; tty-colorscheme is now referenced directly
2024-05-07 21:52:43 -06:00

60 lines
1.5 KiB
VimL

"
" quickly open a REPL with <Leader>r
"
" tries to guess based on configuration + filetype what repl to use,
" otherwise asks the user to provide the required REPL command
" for the current buffer
"
" always uses the last used REPL type unless specified otherwise
" in the :call arguments
"
let g:quickrepl_commands_by_filetype = {
\ 'python': 'bpython',
\ 'zsh': 'zsh',
\ 'bash': 'bash',
\ 'typescript': 'node',
\ 'javascript': 'node',
\}
let g:quickrepl_output_format_default = 'split-pane-horizontal'
let g:quickrepl_output_format_overrides_by_repl_command = {
\ 'bpython': 'split-pane-vertical',
\ 'node': 'split-pane-vertical',
\ 'zsh': 'split-pane-vertical',
\}
let g:quickrepl_repl_command_args_by_repl_command= {
\ 'zsh': '-l',
\}
function QuickREPL(repl = '')
let l:repl = a:repl
if ( l:repl == '' )
let l:repl = get(b:, 'quick_repl', '')
endif
if ( l:repl == '' )
let l:repl = get(g:quickrepl_commands_by_filetype, &filetype, '')
endif
if ( l:repl == '' )
let l:repl = input('input a repl command : ') | redraw
endif
if ( l:repl == '' )
echohl DiffDelete | echo "no command supplied; canceled REPL execution" | echohl None
return
endif
let b:quick_repl = l:repl
let l:output = get(g:quickrepl_output_format_overrides_by_repl_command, l:repl, g:quickrepl_output_format_default)
let l:repl_args = get(g:quickrepl_repl_command_args, l:repl, '')
call ExecuteCommand(l:repl . ' ' . l:repl_args, l:output)
endfunction
nnoremap <Leader>r :call QuickREPL()<CR>