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
This commit is contained in:
2024-05-07 16:38:40 -06:00
parent 466d4ec77d
commit ad66d50b11
64 changed files with 727 additions and 437 deletions

View File

@ -0,0 +1,25 @@
if !isdirectory(expand("$HOME/.vim/bundle/Vundle.vim")) | let g:plugins_ok = 0 | finish | endif
" -------------------------------------------------------------------
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " 00.plugin-vundle.vim
Plugin 'valloric/youcompleteme' " 01.plugin-youcompleteme.vim
Plugin 'w0rp/ale' " 02.plugin-ale.vim
Plugin 'scrooloose/nerdtree' " 03.plugin-nerdtree.vim
Plugin 'tpope/vim-surround' " 04.plugin-vim-surround.vim
Plugin 'tpope/vim-fugitive' " 05.plugin-vim-fugitive.vim
Plugin 'jeffkreeftmeijer/vim-dim' " 07.plugin-vim-dim.vim
Plugin 'chrisbra/unicode.vim' " 08.plugin-unicode.vim
Plugin 'rrethy/vim-hexokinase' " 09.plugin-vim-hexokinase.vim
Plugin 'fatih/vim-go' " 10.plugin-vim-go.vim
Plugin 'rust-lang/rust.vim' " 11.plugin-rust.vim
" ---------------------------------------------------------------------
call vundle#end()
filetype plugin indent on
let g:plugins_ok = 1

View File

@ -0,0 +1,29 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_goto_buffer_command = 'new-tab'
let g:ycm_auto_hover = ''
let g:preferred_rust_root = trim(system("rustup toolchain list -v | grep default | sed 's|[^/]*||'"))
if isdirectory(g:preferred_rust_root)
let g:ycm_rust_toolchain_root = g:preferred_rust_root
endif
function! ToggleYCM()
if g:ycm_auto_trigger
let g:ycm_auto_trigger = 0
echohl DiffDelete | echo "YouCompleteMe autocompletion disabled" | echohl None
else
let g:ycm_auto_trigger = 1
echohl DiffAdd | echo "YouCompleteMe autocompletion enabled" | echohl None
endif
endfunction
nnoremap <S-y> :call ToggleYCM()<CR>
nnoremap gd :YcmCompleter GoToDefinition<CR>
augroup ycm_hover
autocmd FileType rust,typescript,javascript,python nnoremap <silent><buffer> ? <Plug>(YCMHover)
augroup end

View File

@ -0,0 +1,26 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
let g:ale_linters = {
\ 'cs' : ['OmniSharp'],
\ 'python' : ['pylint'],
\ 'go' : ['golint'],
\ 'rust' : ['analyzer'],
\}
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier'],
\ 'rust': ['rustfmt'],
\}
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_sign_column_always = 1
nnoremap <Leader>at <Plug>(ale_toggle_buffer)
nnoremap <Leader>ae <Plug>(ale_next)
nnoremap <Leader>ad :YcmDiags<CR> " requires 01.plugin-youcompleteme.vim
nnoremap <Leader>ar <Plug>(ale_previous)
nnoremap <Leader>f <Plug>(ale_fix)

View File

@ -0,0 +1,5 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
nnoremap <C-o> :NERDTreeToggle %<CR>
let g:NERDTreeNodeDelimiter = "\u00a0" " -- fixes ^G character

View File

@ -0,0 +1,3 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------

View File

@ -0,0 +1,9 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
" I'm not really convinced this is a useful plugin for me; keeping it
" around for a bit longer to see if I find some fantastic way I work
" well with it since it is very popular :)
" \g git fugitive shortcuts
nnoremap <Leader>gb :Git blame<CR>

View File

@ -0,0 +1,3 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------

View File

@ -0,0 +1,4 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
imap <C-U> <Plug>(UnicodeFuzzy)

View File

@ -0,0 +1,4 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
let g:Hexokinase_highlighters = ['foregroundfull']

View File

@ -0,0 +1,8 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------
let g:go_imports_autosave = 0
let g:go_def_mapping_enabled = 0
let g:go_fmt_fail_silently = 1
let g:go_def_reuse_buffer = 1
let g:go_textobj_enabled = 0

View File

@ -0,0 +1,3 @@
if g:plugins_ok != 1 | finish | endif
" -------------------------------------------------------------------

View File

@ -8,4 +8,4 @@ set timeoutlen=200
set showmatch matchtime=0
set backspace=indent,eol,start
set spellfile=$WRYNVIMPATH/en.utf-8.add spelllang=en
set spellfile=$DOTWRYN/vim/en.utf-8.add spelllang=en

7
vim/rc.d/30.utility.vim Normal file
View File

@ -0,0 +1,7 @@
function EnsureTmuxSession()
call system("tmux new -ds " . g:escapeTmuxSession . " -c $HOME >/dev/null 2>&1")
endfunction
function FindGitRoot()
return finddir('.git/..', expand('%:p:h').';')
endfunction

View File

@ -1,18 +1,13 @@
"
" escape-to-shell execution wrapper with great functionality
" and an OK-to-bad API (EXTREMELY helpful)
"
let escapeTmuxSession = "vim-exec"
let escapeTmuxPaneID = g:escapeTmuxSession . ":0.0"
let escapeCommandOutputs = ['tmux', 'split-pane-vertical', 'split-pane-horizontal']
function ExecuteScwrypt(scwrypt = '', args = '', output = '', syntax = 'bash')
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
function ExecuteCommand(args = '', output = '', flavor = 'shell', syntax = 'bash')
let output = a:output
if output == ''
@ -83,11 +78,3 @@ function GetPrefferredCommandOutput()
return 'shell-escape'
endfunction
function EnsureTmuxSession()
call system("tmux new -ds " . g:escapeTmuxSession . " -c $HOME >/dev/null 2>&1")
endfunction
function FindGitRoot()
return finddir('.git/..', expand('%:p:h').';')
endfunction

View File

@ -0,0 +1,13 @@
"
" 31.utility-execute.vim wrapper for scwrypts-specific execution
"
function ExecuteScwrypt(scwrypt = '', args = '', output = '', syntax = 'bash')
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

View File

@ -0,0 +1,59 @@
"
" 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>

View File

@ -0,0 +1,43 @@
"
" quickly run a custom command with <Leader>t
"
" this is a safer version of what used to be my 'quicktest'
" bindings; sometimes I don't have the time to create a proper
" language/technology-specific testing utility, and would
" rather run a quick SHELL command at the touch of a button
"
" this safer, upgrade to the previous bindings (listed below)
" requires buffer-level specificity and does not allow quick
" commands to bleed between vim sessions and buffers; this
" has saved me from some accidental push-to-main-with-admin-power
" situations which arose from the previous bindings
"
" previously:
"
" " \t = run last quicktest
" " t)ype new quicktest
" " e)dit last quicktest
" nnoremap <Leader>t q:?^echom 'quicktest'<CR><CR><CR>
" nnoremap <Leader>tt q:oechom 'quicktest' \| call ExecuteCommand('')<ESC>F'i
" nnoremap <Leader>te q:?^echom 'quicktest'<CR>
"
let g:quick_command_output_format = 'split-pane-horizontal'
function QuickCommand()
let l:quick_command = get(b:, 'quick_command', '')
if ( l:quick_command == '' )
let l:quick_command = input('input quick command : ') | redraw
endif
if ( l:quick_command == '' )
echohl DiffDelete | echo "no command supplied; canceled execution" | echohl None
return
endif
let b:quick_command = l:quick_command
call ExecuteCommand(l:quick_command, g:quick_command_output_format)
endfunction
nnoremap <Leader>t :call QuickCommand()<CR>

View File

@ -1,7 +1,10 @@
function Sudowrite()
execute 'w !sudo tee "%"'
endfunction
nnoremap <Leader><Leader>w :call Sudowrite()<CR>
function MakeFileExecutable(sudo = 0)
if a:sudo
execute '! sudo chmod +x "%"'
@ -9,3 +12,6 @@ function MakeFileExecutable(sudo = 0)
execute '! chmod +x "%"'
endif
endfunction
nnoremap <Leader><Leader>x :call MakeFileExecutable(0)<CR>
nnoremap <Leader><Leader>xx :call MakeFileExecutable(1)<CR>

View File

@ -40,6 +40,15 @@ augroup file_specific_commands
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 = ""

8
vim/rc.d/70.bindings.vim Normal file
View File

@ -0,0 +1,8 @@
" backslash for Leader and backspace for LocalLeader
nmap <BS> <Nop>
let mapleader = "\\"
let maplocalleader = "\<BS>"
" (e)dit / (s)ource (v)imrc
nnoremap <Leader>ev :tabedit $VIMRC<CR>
nnoremap <Leader>sv :source $VIMRC<CR>

View File

@ -1,22 +1,15 @@
source $HOME/.config/wryn/env.vim
if isdirectory(expand("$HOME/.vim/bundle/Vundle.vim"))
source $WRYNVIMPATH/vundle.vim
if empty($DOTWRYN)
let $DOTWRYN=expand("$HOME/.wryn")
endif
source $WRYNVIMPATH/options.vim
source $WRYNVIMPATH/execute.vim
source $WRYNVIMPATH/formatting.vim
source $WRYNVIMPATH/file-execute.vim
source $WRYNVIMPATH/navigation.vim
source $WRYNVIMPATH/color.vim
source $WRYNVIMPATH/utility.vim
let $VIMRC=expand("$DOTWRYN/vim/rc.vim")
for vimrcfile in split(trim(system("find " . expand("$DOTWRYN/vim/rc.d") . " -type f | sort -u")), '\n')
execute 'source ' . vimrcfile
endfor
source $WRYNVIMPATH/override/rentdynamics.vim
source $WRYNVIMPATH/override/directus.vim
" ---------------------------------------------------------------------
" {{{
" -------------------------------------------------------------------
" --- generic bindings (easy reference) -----------------------------
" -------------------------------------------------------------------
" <SPACE> to execute macro on q
nnoremap <Space> @q
@ -27,48 +20,22 @@ nnoremap <Leader>q q:
" \s previous selection command
nnoremap <Leader>s :'<,'>
" \m to set buffer to modifiable
nnoremap <Leader>m :set modifiable<CR>
" (e)dit / (s)ource vimrc
nnoremap <Leader>ev :tabedit $WRYNVIMRC<CR>
nnoremap <Leader>sv :source $MYVIMRC<CR>
" Q to replace current line/selection with bash execution
" Q to replace current line(s) with shell execution
vnoremap Q !$SHELL<CR>
nnoremap Q !!$SHELL<CR>
" \j like J, but append current line to the line below
nnoremap <Leader>j ddpkJ
" move the current line down/up one
nnoremap - :move +1 <CR>
nnoremap _ :move -2 <CR>
" \j like J, but append current line to the line below
nnoremap <Leader>j ddpkJ
" \d insert formatted date below
nnoremap <Leader>d :let @d = system("date '+%A, %B %-d, %Y'")<CR>o<C-r>d<BS> <esc>
" \g git fugitive shortcuts
nnoremap <Leader>gb :Git blame<CR>
" \r = open last REPL (p)ython (n)odejs (c)lisp
nnoremap <Leader>r q:?^echom 'quickrepl'<CR><CR>
nnoremap <Leader>rp q:oechom 'quickrepl' \| call ExecuteCommand('bpython', 'split-pane-vertical')<CR>
nnoremap <Leader>rn q:oechom 'quickrepl' \| call ExecuteCommand('node', 'split-pane-vertical')<CR>
nnoremap <Leader>rc q:oechom 'quickrepl' \| call ExecuteCommand('clisp', 'split-pane-horizontal')<CR>
nnoremap <Leader>rs q:oechom 'quickrepl' \| call ExecuteCommand('zsh -l', 'split-pane-vertical')<CR>
" \t = run last quicktest
" t)ype new quicktest
" e)dit last quicktest
nnoremap <Leader>t q:?^echom 'quicktest'<CR><CR><CR>
nnoremap <Leader>tt q:oechom 'quicktest' \| call ExecuteCommand('')<ESC>F'i
nnoremap <Leader>te q:?^echom 'quicktest'<CR>
" ./utility.vim
nnoremap <Leader><Leader>w :call Sudowrite()<CR>
nnoremap <Leader><Leader>x :call MakeFileExecutable(0)<CR>
nnoremap <Leader><Leader>xx :call MakeFileExecutable(1)<CR>
" \m to set buffer to modifiable
nnoremap <Leader>m :set modifiable<CR>
" (c)opy / (p)aste from xclip
" TODO: learn how to compile vim with x11 compatibility and delete
@ -79,13 +46,12 @@ nnoremap <Leader>sc :'<,'>w !xclip<CR><CR>
" enable/disable true color
nnoremap <f12> :set invtermguicolors<CR>
" --- available / rarely used bindings (personal reference) ---
" -------------------------------------------------------------------
" --- available / rarely used bindings (personal reference) ---------
" -------------------------------------------------------------------
" nnoremap <BS>
" nnoremap <C-t>
" nnoremap <C-b>
" nnoremap z
" nnoremap ^
" }}}
" ---------------------------------------------------------------------

View File

@ -1,86 +0,0 @@
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" --- installed plugins -----------------------------------------------
" {{{
Plugin 'fatih/vim-go'
Plugin 'jeffkreeftmeijer/vim-dim'
Plugin 'rrethy/vim-hexokinase'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'valloric/youcompleteme'
Plugin 'w0rp/ale'
Plugin 'chrisbra/unicode.vim'
" }}}
" ---------------------------------------------------------------------
call vundle#end()
filetype plugin indent on
" --- plugin configuration --------------------------------------------
" {{{
" fatih/vim-go
let g:go_imports_autosave = 0
let g:go_def_mapping_enabled = 0
let g:go_fmt_fail_silently = 1
let g:go_def_reuse_buffer = 1
let g:go_textobj_enabled = 0
" rrethy/vim-hexokinase
let g:Hexokinase_highlighters = ['foregroundfull']
" scrooloose/nerdtree
nnoremap <C-o> :NERDTreeToggle %<CR>
let g:NERDTreeNodeDelimiter = "\u00a0" " -- fixes ^G character
" Valloric/YouCompleteMe
function! ToggleYCM()
if g:ycm_auto_trigger
let g:ycm_auto_trigger = 0
echohl DiffDelete | echo "YouCompleteMe autocompletion disabled" | echohl None
else
let g:ycm_auto_trigger = 1
echohl DiffAdd | echo "YouCompleteMe autocompletion enabled" | echohl None
endif
endfunction
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_goto_buffer_command = 'new-tab'
nnoremap <S-y> :call ToggleYCM()<CR>
nnoremap gd :YcmCompleter GoToDefinition<CR>
" w0ryn/ale
let g:ale_linters = {
\ 'cs' : ['OmniSharp'],
\ 'python' : ['pylint'],
\ 'go' : ['golint']
\}
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier']
\}
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_sign_column_always = 1
nmap <Leader>at <Plug>(ale_toggle_buffer)
nmap <Leader>ae <Plug>(ale_next)
nmap <Leader>ar <Plug>(ale_previous)
nmap <Leader>f <Plug>(ale_fix)
imap <C-U> <Plug>(UnicodeFuzzy)
" }}}
" ---------------------------------------------------------------------