# HG changeset patch # User Steve Losh # Date 1696353318 14400 # Node ID c4bb62cd1c7f1fe3b80c21754054ba20566d1afb # Parent fdb4a84069f30e3b892e69b4d6132b1ed43f9876 Split vimrc diff -r fdb4a84069f3 -r c4bb62cd1c7f .hgsubstate --- a/.hgsubstate Mon Sep 18 08:57:48 2023 -0400 +++ b/.hgsubstate Tue Oct 03 13:15:18 2023 -0400 @@ -3,7 +3,7 @@ b6a8b49e2173ba5a1b34d00e68e0ed8addac3ebd vim/bundle/abolish a16a9b63eb85cc0960a7f25c54647ac1f99f3360 vim/bundle/ack 599e1bb1aee98e563132553cf8b7bc32cb402b75 vim/bundle/badwolf -24f6d94dd03ba0fdc703265fe281f70cf2b45ba6 vim/bundle/boxdraw +b7f789f305b1c5b0b4623585e0f10adb417f2966 vim/bundle/boxdraw b542a7bc4d9bc5da8fb12e110fe7975131fb57a4 vim/bundle/clam 8295187ea1210138c0b171d8e3ec3569936f4c1a vim/bundle/commentary c6d1fc5e58d689bfb104ff336aeb89d9ef1b48e2 vim/bundle/ctrlp diff -r fdb4a84069f3 -r c4bb62cd1c7f bin/bootstrap.sh --- a/bin/bootstrap.sh Mon Sep 18 08:57:48 2023 -0400 +++ b/bin/bootstrap.sh Tue Oct 03 13:15:18 2023 -0400 @@ -58,6 +58,7 @@ ensure_link "src/dotfiles/stumpwm/local-share-stumpwm" ".local/share/stumpwm" ensure_link "src/dotfiles/vim" ".vim" ensure_link "src/dotfiles/vim/vimrc" ".vimrc" +ensure_link "src/dotfiles/vim/vimrc-minimal" ".vimrc-minimal" ensure_link "src/dotfiles/w3m-keymap" ".w3m/keymap" ensure_link "src/dotfiles/w3m-config" ".w3m/config" ensure_link "src/dotfiles/weechat" ".weechat" diff -r fdb4a84069f3 -r c4bb62cd1c7f bin/csvconcat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/csvconcat Tue Oct 03 13:15:18 2023 -0400 @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -euo pipefail + +head -n1 "$1" +tail --quiet -n +2 "$@" diff -r fdb4a84069f3 -r c4bb62cd1c7f bin/heic-conv-all --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/heic-conv-all Tue Oct 03 13:15:18 2023 -0400 @@ -0,0 +1,44 @@ +#!/bin/bash + +# from https://github.com/lokarithm/HandyBashCommands/blob/main/heic-converter/heic-converter.sh + +if ! command -v heif-convert &> /dev/null +then + echo "heif-convert COMMAND could not be found." + echo "Please install 'libheif-examples' first." + echo "To install 'libheif-examples', run the following command:" + echo " sudo apt install libheif-examples" + exit +else + fileExtension="jpg" + + while getopts :p flag; do + case ${flag} in + # -p flag: convert heic files to png format instead + p) fileExtension="png" + ;; + esac + done + + start_time=$(date +%s.%3N) + + # look for files in current path that contains ".heic" in a case-insensitive manner + for file in $( ls | grep -iF ".heic") + do + echo "Converting file: $file" + + # file extension of current file + currFileExtension=`echo $file | grep -iFo "heic"` + sedCommand="s/${currFileExtension}/${fileExtension}/g;s/HEIC/${fileExtension}/g" + + #replace original file name by changing the extension from heic to jpg + outputFileName=`echo $file | sed -e $sedCommand` + heif-convert $file $outputFileName + done + + end_time=$(date +%s.%3N) + + elapsed=$(echo "scale=3; $end_time - $start_time" | bc) + echo -e "\nElapsed time: \e[32m$elapsed \e[39mmilliseconds." + +fi diff -r fdb4a84069f3 -r c4bb62cd1c7f fish/config.fish --- a/fish/config.fish Mon Sep 18 08:57:48 2023 -0400 +++ b/fish/config.fish Tue Oct 03 13:15:18 2023 -0400 @@ -10,6 +10,7 @@ function em; nvim ~/.mutt/muttrc; end function es; pushd ~/src/stumpwm; e ~/.stumpwmrc; popd; end function ev; nvim ~/.vimrc; end +function evm; nvim ~/.vimrc-minimal; end function eff; nvim ~/.config/fish/functions; end function efh; nvim ~/.local/share/fish/fish_history; end # I have visited https://github.com/fish-shell/fish-shell/issues/862 nine thousand times and I'm fucking sick of opening a web browser to figure out where the fuck fish keeps its equivalent of ~/.bash_history function essh; nvim ~/.ssh/config; end diff -r fdb4a84069f3 -r c4bb62cd1c7f remote/bootstrap.sh --- a/remote/bootstrap.sh Mon Sep 18 08:57:48 2023 -0400 +++ b/remote/bootstrap.sh Tue Oct 03 13:15:18 2023 -0400 @@ -22,6 +22,7 @@ mkdir -p ~/.config/fish mkdir -p ~/.config/nvim mkdir -p ~/bin +mkdir -p ~/.vim ensure_link "src/dotfiles/gitconfig" ".gitconfig" ensure_link "src/dotfiles/gitignore" ".gitignore" @@ -30,3 +31,6 @@ ensure_link "src/dotfiles/ffignore" ".ffignore" ensure_link "src/dotfiles/config.fish" ".config/fish/config.fish" ensure_link "src/dotfiles/hushlogin" ".hushlogin" +ensure_link "src/dotfiles/vimrc" ".vimrc" +ensure_link "src/dotfiles/vim-colors" ".vim/colors" +ensure_link "src/dotfiles/vimrc-remote-local" ".vimrc_remote_local" diff -r fdb4a84069f3 -r c4bb62cd1c7f remote/vim-colors --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/remote/vim-colors Tue Oct 03 13:15:18 2023 -0400 @@ -0,0 +1,1 @@ +../vim/bundle/badwolf/colors/ \ No newline at end of file diff -r fdb4a84069f3 -r c4bb62cd1c7f remote/vimrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/remote/vimrc Tue Oct 03 13:15:18 2023 -0400 @@ -0,0 +1,1 @@ +../vim/vimrc-minimal \ No newline at end of file diff -r fdb4a84069f3 -r c4bb62cd1c7f remote/vimrc-remote-local --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/remote/vimrc-remote-local Tue Oct 03 13:15:18 2023 -0400 @@ -0,0 +1,1 @@ +colorscheme badwolf diff -r fdb4a84069f3 -r c4bb62cd1c7f stumpwmrc --- a/stumpwmrc Mon Sep 18 08:57:48 2023 -0400 +++ b/stumpwmrc Tue Oct 03 13:15:18 2023 -0400 @@ -769,6 +769,7 @@ ("H-F8" "screen-external")) (define-top-keys ;; layout + ("s-H-o" "only") ("s-H-t" "restore-from-file thirds") ("s-H-m" "restore-from-file dev") ("s-H-s" "restore-from-file streaming") diff -r fdb4a84069f3 -r c4bb62cd1c7f vim/ftplugin/snakemake/folding.vim --- a/vim/ftplugin/snakemake/folding.vim Mon Sep 18 08:57:48 2023 -0400 +++ b/vim/ftplugin/snakemake/folding.vim Tue Oct 03 13:15:18 2023 -0400 @@ -9,16 +9,25 @@ let thisline = getline(a:lnum) - " blank lines end folds + " two blank lines end folds if thisline =~? '\v^\s*$' + if ActualPreviousLineNonblank(a:lnum) + return "=" + endif return '-1' " start fold on top level rules or python objects elseif thisline =~? '\v^(rule|def|checkpoint|class)' return ">1" elseif thisline =~? '\v^\S' - if PreviousLineIndented(a:lnum) && NextRuleIndented(a:lnum) - return ">1" + if IsEmpty(a:lnum+1) + if IsEmpty(a:lnum+2) + return ">1" + endif endif + return "0" + " if PreviousLineIndented(a:lnum) && NextRuleIndented(a:lnum) + " return ">1" + " endif endif return "=" @@ -59,3 +68,35 @@ return 0 endfunction + +function! ActualPreviousLineNonblank(lnum) + let current = a:lnum - 1 + + if current >= 1 + let thisline = getline(current) + if thisline =~? '\v^\s*\S' + return 1 + else + return 0 + endif + endwhile + + return 0 +endfunction + +function! IsEmpty(lnum) + let numlines = line('$') + if a:lnum > numlines + return 0 + elseif a:lnum < 1 + return 0 + else + let thisline = getline(a:lnum) + if thisline =~? '\v^$' + return 1 + else + return 0 + endif + endif +endfunction + diff -r fdb4a84069f3 -r c4bb62cd1c7f vim/vimrc --- a/vim/vimrc Mon Sep 18 08:57:48 2023 -0400 +++ b/vim/vimrc Tue Oct 03 13:15:18 2023 -0400 @@ -2,8 +2,9 @@ " Author: Steve Losh " Source: https://hg.stevelosh.com/dotfiles/file/tip/vim/vimrc +" See also vimrc-minimal for the rest of this. + " Preamble ---------------------------------------------------------------- {{{ -" set shell=/bin/bash\ --login filetype off @@ -12,39 +13,12 @@ set nocompatible " }}} -" Basic options ----------------------------------------------------------- {{{ - -set modelines=0 -set autoindent -set showmode -set showcmd -set hidden -set visualbell -set ttyfast -set ruler -set backspace=indent,eol,start -set nonumber -set norelativenumber -set laststatus=2 -set history=1000 -set undofile -set undoreload=10000 -set list -set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮ -set lazyredraw -set matchtime=3 -set showbreak=↪ -set splitbelow -set splitright -set autowrite -set autoread -set shiftround -set title -set linebreak -set colorcolumn=+1 -set diffopt+=vertical - -" Spelling +" Load Minimal ------------------------------------------------------------ {{{ + +source ~/.vimrc-minimal + +" }}} +" Spelling ---------------------------------------------------------------- {{{ " " There are three dictionaries I use for spellchecking: " @@ -63,136 +37,9 @@ set spellfile=~/.vim/custom-dictionary.utf-8.add,~/.vim-local-dictionary.utf-8.add nnoremap zG 2zg -" Don't try to highlight lines longer than 500 characters. -set synmaxcol=500 - -" Time out on key codes but not mappings. -" Basically this makes terminal Vim work sanely. -set notimeout -set ttimeout -set ttimeoutlen=10 - -" Make Vim able to edit crontab files again. -set backupskip=/tmp/*,/private/tmp/*" - -" Better Completion -set complete=.,w,b,u,t -set completeopt=longest,menuone -inoremap - -" Save when losing focus -au FocusLost * :silent! wall - -" Leader -let mapleader = "," -let maplocalleader = "\\" - -" Cursorline {{{ -" Only show cursorline in the current window and in normal mode. - -augroup cline - au! - au WinLeave,InsertEnter * set nocursorline - au WinEnter,InsertLeave * set cursorline -augroup END - " }}} -" cpoptions+=J, dammit {{{ - -" Something occasionally removes this. If I manage to find it I'm going to -" comment out the line and replace all its characters with 'FUCK'. -augroup twospace - au! - au BufRead * :set cpoptions+=J -augroup END - -" }}} -" Trailing whitespace {{{ -" Only shown when not in insert mode so I don't go insane. - -augroup trailing - au! - au InsertEnter * :set listchars-=trail:⌴ - au InsertLeave * :set listchars+=trail:⌴ -augroup END - -" }}} -" Wildmenu completion {{{ - -set wildmenu -set wildmode=list:longest - -set wildignore+=.hg,.git,.svn " Version control -set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files -set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images -set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files -set wildignore+=*.spl " compiled spelling word lists -set wildignore+=*.sw? " Vim swap files -set wildignore+=*.DS_Store " OSX bullshit - -set wildignore+=*.luac " Lua byte code - -set wildignore+=migrations " Django migrations -set wildignore+=*.pyc " Python byte code - -set wildignore+=*.orig " Merge resolution files - -set wildignore+=*.fasl " Lisp FASLs -set wildignore+=*.dx64fsl " CCL -set wildignore+=*.lx64fsl " CCL - -" }}} -" Line Return {{{ - -" Make sure Vim returns to the same line when you reopen a file. -" Thanks, Amit -augroup line_return - au! - au BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ execute 'normal! g`"zvzz' | - \ endif -augroup END - -" }}} -" Tabs, spaces, wrapping {{{ - -set tabstop=8 -set shiftwidth=4 -set softtabstop=4 -set expandtab -set wrap -set textwidth=80 -set formatoptions=qrn1j -set colorcolumn=+1 - -" }}} -" Backups {{{ - -set backup " enable backups -set noswapfile " it's 2013, Vim. - -set undodir=~/.vim/tmp/undo// " undo files -set backupdir=~/.vim/tmp/backup// " backups -set directory=~/.vim/tmp/swap// " swap files - -" Make those folders automatically if they don't already exist. -if !isdirectory(expand(&undodir)) - call mkdir(expand(&undodir), "p") -endif -if !isdirectory(expand(&backupdir)) - call mkdir(expand(&backupdir), "p") -endif -if !isdirectory(expand(&directory)) - call mkdir(expand(&directory), "p") -endif - -" }}} -" Color scheme {{{ - -syntax on -set termguicolors -set background=dark +" Color scheme ------------------------------------------------------------ {{{ + let g:badwolf_tabline = 2 let g:badwolf_html_link_underline = 0 colorscheme goodwolf @@ -208,80 +55,8 @@ match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' " }}} - -" }}} -" Abbreviations & Digraphs ------------------------------------------------ {{{ - -iabbrev todo TODO - -silent! digr -. 8230 "U+2026=… HORIZONTAL ELLIPSIS -silent! digr !, 8816 "U+2270=≰ NEITHER LESS-THAN NOR EQUAL TO -silent! digr !. 8817 "U+2271=≱ NEITHER GREATER-THAN NOR EQUAL TO -silent! digr es 8337 "U+2091=ₑ SUBSCRIPT E -silent! digr xs 8339 "U+2093=ₓ SUBSCRIPT X -silent! digr ls 8343 "U+2097=ₗ SUBSCRIPT L -silent! digr ms 8344 "U+2098=ₗ SUBSCRIPT M -silent! digr ns 8345 "U+2099=ₙ SUBSCRIPT N -silent! digr ps 8346 "U+209A=ₚ SUBSCRIPT P -silent! digr ss 8347 "U+209B=ₛ SUBSCRIPT S -silent! digr ts 8348 "U+209C=ₜ SUBSCRIPT T -silent! digr >< 8652 "U+21cc=⇌ EQUILIBRIUM -silent! digr o+ 8853 "U+2295=⊕ CIRCLED PLUS -silent! digr -^ 8593 "U+2191=↑ UPWARDS ARROW - -silent! digr -- 8212 "U+2014=— EM DASH - -silent! digr // 9585 "U+2571=╱ BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT -silent! digr \\ 9586 "U+2572=╲ BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT - -silent! digr \|\| 8214 "U+2016=‖ DOUBLE VERTICAL LINE - -silent! digr ~~ 8967 "U+2307=⌇ WAVY LINE - -" }}} " Convenience mappings ---------------------------------------------------- {{{ -" Fuck you, help key. -noremap :checktime -inoremap :checktime - -" Stop it, hash key. -inoremap # X# - -" Kill window -nnoremap K :q - -" Save -nnoremap s :w - -" Man -nnoremap M K - -" Clean up windows -nnoremap - :wincmd = - -" Toggle line numbers -nnoremap n :setlocal number! - -" Sort lines -nnoremap s vip:sort -vnoremap s :sort - -" Tabs -nnoremap ( :tabprev -nnoremap ) :tabnext - -" My garbage brain can't ever remember digraph codes -inoremap :help digraph-table - -" Wrap -" mnemonic: less' -S command/option -nnoremap S :set wrap! - -" Inserting blank lines -" I never use the default behavior of and this saves me a keystroke... -nnoremap o - " Copying/pasting text to the system clipboard. noremap p "+p vnoremap y "+y @@ -296,21 +71,6 @@ nnoremap o "zyiW:call Open(@z) vnoremap o "zy:call Open(@z) -" Delete to black hole register -nnoremap dD "_dd -vnoremap D "_d - -" Yank to end of line -nnoremap Y y$ - -" Reselect last-pasted text -nnoremap gv `[v`] - -" I constantly hit "u" in visual mode when I mean to "y". Use "gu" for those rare occasions. -" From https://github.com/henrik/dotfiles/blob/master/vim/config/mappings.vim -vnoremap u -vnoremap gu u - " Rebuild Ctags (mnemonic RC -> CR -> ) nnoremap :silent !myctags >/dev/null 2>&1 &:redraw! @@ -319,164 +79,9 @@ \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" -" Clean trailing whitespace -nnoremap ww mz:%s/\s\+$//:let @/=''`z - " Send visual selection to paste.stevelosh.com vnoremap P :w !pb && open `pbpaste` -" Select entire buffer -nnoremap vaa ggvGg_ -nnoremap Vaa ggVG - -" Fix from spellcheck -" I can never remember if it's zg or z=, and the wrong one adds the word to -" the DB (lol), so fuck it, just add an easier mapping. -nnoremap zz z= -nnoremap z= :echo "use zz you idiot" - -" "Uppercase word" mapping. -" -" This mapping allows you to press in insert mode to convert the current -" word to uppercase. It's handy when you're writing names of constants and -" don't want to use Capslock. -" -" To use it you type the name of the constant in lowercase. While your -" cursor is at the end of the word, press to uppercase it, and then -" continue happily on your way: -" -" cursor -" v -" max_connections_allowed| -" -" MAX_CONNECTIONS_ALLOWED| -" ^ -" cursor -" -" It works by exiting out of insert mode, recording the current cursor location -" in the z mark, using gUiw to uppercase inside the current word, moving back to -" the z mark, and entering insert mode again. -" -" Note that this will overwrite the contents of the z mark. I never use it, but -" if you do you'll probably want to use another mark. -inoremap mzgUiw`za - -" Panic Button -nnoremap mzggg?G`z - -" zt is okay for putting something at the top of the screen, but when I'm -" writing prose I often want to put something at not-quite-the-top of the -" screen. zh is "zoom to head level" -nnoremap zh mzzt10`z - -" Diffoff -nnoremap D :diffoff! - -" Formatting, TextMate-style -nnoremap Q gqip -vnoremap Q gq - -" Reformat line. -" I never use l as a macro register anyway. -nnoremap ql gqq - -" Indent/dedent/autoindent what you just pasted. -nnoremap > V`]< -nnoremap > V`]> -nnoremap =- V`]= - -" Keep the cursor in place while joining lines -nnoremap J mzJ`z - -" Join an entire paragraph. -" -" Useful for writing GitHub comments in actual Markdown and then translating it -" to their bastardized version of Markdown. -nnoremap j mzvipJ`z - -" Split line (sister to [J]oin lines) -" The normal use of S is covered by cc, so don't worry about shadowing it. -nnoremap S i^mwgk:silent! s/\v +$//:noh`w - -" Substitute -nnoremap :%s/ -vnoremap :s/ - -" Marks and Quotes -noremap ' ` -noremap æ ' -noremap ` - -" Select (charwise) the contents of the current line, excluding indentation. -" Great for pasting Python lines into REPLs. -nnoremap vv ^vg_ - -" Typos -command! -bang E e -command! -bang Q q -command! -bang W w -command! -bang QA qa -command! -bang Qa qa -command! -bang Wa wa -command! -bang WA wa -command! -bang Wq wq -command! -bang WQ wq -command! -bang Wqa wqa - -" Unfuck my screen -nnoremap U :syntax sync fromstart:redraw! - -" Zip Right -" -" Moves the character under the cursor to the end of the line. Handy when you -" have something like: -" -" foo -" -" And you want to wrap it in a method call, so you type: -" -" println()foo -" -" Once you hit escape your cursor is on the closing paren, so you can 'zip' it -" over to the right with this mapping. -" -" This should preserve your last yank/delete as well. -nnoremap zl :let @z=@"x$p:let @"=@z - -" Indent from insert mode -" has to be imap because we want to be able to use the "go-indent" mapping -imap gi - -" Diff Navigation -nnoremap ]d ]c -nnoremap [d [c - -" Typo navigation -nnoremap ]z ]S -nnoremap [z [S -nnoremap ]Z ]Sz= -nnoremap [Z [Sz= - -" Header Lines -nnoremap - o80a-kJ079lD - -" Insert Mode Completion {{{ - -inoremap -inoremap -inoremap - -" }}} - -" Window Resizing {{{ -" right/up : bigger -" left/down : smaller -nnoremap :vertical resize +3 -nnoremap :vertical resize -3 -nnoremap :resize +3 -nnoremap :resize -3 -" }}} - " }}} " Quick editing ----------------------------------------------------------- {{{ @@ -492,7 +97,8 @@ nnoremap eln :vsplit ~/lab/README.markdown nnoremap eq :vsplit ~/Dropbox/quotes.txtGzz nnoremap et :vsplit ~/.tmux.conf -nnoremap ev :vsplit ~/.vimrc +nnoremap evf :vsplit ~/.vimrc +nnoremap evm :vsplit ~/.vimrc-minimal " }}} " Status Line ------------------------------------------------------------- {{{ @@ -604,189 +210,6 @@ " set statusline+=%= " }}} -" Searching and movement -------------------------------------------------- {{{ - -" Use sane regexes. -nnoremap / /\v -vnoremap / /\v - -set ignorecase -set smartcase -set incsearch -set showmatch -set hlsearch -set gdefault - -set scrolloff=5 -set sidescroll=1 -set sidescrolloff=10 - -set virtualedit+=block - -noremap :noh:call clearmatches() - -runtime macros/matchit.vim -map % -silent! unmap [% -silent! unmap ]% - -" Made D behave -nnoremap D d$ - -" Don't move on * -" I'd use a function for this but Vim clobbers the last search when you're in -" a function so fuck it, practicality beats purity. -nnoremap * :let stay_star_view = winsaveview()*:call winrestview(stay_star_view) - -" Jumping to tags. -" -" Basically, jumps to tags (like normal) and opens the tag in a new -" split instead. -" -" Both of them will align the destination line to the upper middle part of the -" screen. Both will pulse the cursor line so you can see where the hell you -" are. will also fold everything in the buffer and then unfold just -" enough for you to see the destination line. -" -function! JumpTo(jumpcommand) - execute a:jumpcommand - call FocusLine() - Pulse -endfunction -function! JumpToInSplit(jumpcommand) - execute "normal! \v" - execute a:jumpcommand - Pulse -endfunction - -function! JumpToTag() - call JumpTo("normal! \") -endfunction -function! JumpToTagInSplit() - call JumpToInSplit("normal \") -endfunction - -nnoremap :silent! call JumpToTag() -nnoremap :silent! call JumpToTagInSplit() - -" Keep search matches in the middle of the window. -nnoremap n nzzzv -nnoremap N Nzzzv - -" Same when jumping around -nnoremap g; g;zz -nnoremap g, g,zz -nnoremap zz - -" Easier to type, and I never use the default behavior. -noremap H ^ -noremap L $ -vnoremap L g_ - -" Heresy -inoremap I -inoremap A -cnoremap -cnoremap - -" go indent -nnoremap gi mzVap=`z -nnoremap gI mzgg=G`z - -" Fix linewise visual selection of various text objects -nnoremap VV V -nnoremap Vit vitVkoj -nnoremap Vat vatV -nnoremap Vab vabV -nnoremap VaB vaBV - -" Directional Keys {{{ - -" It's 2013. -noremap j gj -noremap k gk -noremap gj j -noremap gk k - -" Easy buffer navigation -noremap h -noremap j -noremap k -noremap l - -noremap v v - -" }}} -" Visual Mode */# from Scrooloose {{{ - -function! s:VSetSearch() - let temp = @@ - norm! gvy - let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') - let @@ = temp -endfunction - -vnoremap * :call VSetSearch()// -vnoremap # :call VSetSearch()?? - -" }}} -" List navigation {{{ - -nnoremap :cprevzvzz -nnoremap :cnextzvzz -nnoremap :lprevzvzz -nnoremap :lnextzvzz - -" }}} - -" }}} -" Folding ----------------------------------------------------------------- {{{ - -set foldlevelstart=0 - -" Space to toggle folds. -nnoremap za -vnoremap za - -" Make zO recursively open whatever fold we're in, even if it's partially open. -nnoremap zO zczO - -" "Focus" the current line. Basically: -" -" 1. Close all folds. -" 2. Open just the folds containing the current line. -" 3. Move the line to a bit (25 lines) down from the top of the screen. -" 4. Pulse the line. -" -" This mapping wipes out the z mark, which I never use. -" -" I use :sus for the rare times I want to actually background Vim. -function! FocusLine() - let oldscrolloff = &scrolloff - set scrolloff=0 - execute "keepjumps normal! mzzMzvzt25\`z:Pulse\" - let &scrolloff = oldscrolloff -endfunction -nnoremap :call FocusLine() - -function! MyFoldText() " {{{ - let line = getline(v:foldstart) - - let nucolwidth = &fdc + &number * &numberwidth - let windowwidth = winwidth(0) - nucolwidth - 3 - let foldedlinecount = v:foldend - v:foldstart - - " expand tabs into spaces - let onetab = strpart(' ', 0, &tabstop) - let line = substitute(line, '\t', onetab, 'g') - - let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) - let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' -endfunction " }}} -set foldtext=MyFoldText() - -" }}} " Filetype-specific ------------------------------------------------------- {{{ " Assembly {{{ @@ -2558,68 +1981,6 @@ " }}} " }}} -" Text objects ------------------------------------------------------------ {{{ - -" Folds {{{ - -onoremap if :normal! [zv]z -onoremap af :normal! [zV]z -vnoremap if :normal! ]zv[z -vnoremap af :normal! ]zV[z - -" }}} -" Shortcut for [] {{{ - -onoremap ir i[ -onoremap ar a[ -vnoremap ir i[ -vnoremap ar a[ - -" }}} -" Numbers {{{ - -" Motion for numbers. Great for CSS. Lets you do things like this: -" -" margin-top: 200px; -> daN -> margin-top: px; -" ^ ^ -" TODO: Handle floats. - -onoremap N :call NumberTextObject(0) -xnoremap N :call NumberTextObject(0) -onoremap aN :call NumberTextObject(1) -xnoremap aN :call NumberTextObject(1) -onoremap iN :call NumberTextObject(1) -xnoremap iN :call NumberTextObject(1) - -function! s:NumberTextObject(whole) - let num = '\v[0-9]' - - " If the current char isn't a number, walk forward. - while getline('.')[col('.') - 1] !~# num - normal! l - endwhile - - " Now that we're on a number, start selecting it. - normal! v - - " If the char after the cursor is a number, select it. - while getline('.')[col('.')] =~# num - normal! l - endwhile - - " If we want an entire word, flip the select point and walk. - if a:whole - normal! o - - while col('.') > 1 && getline('.')[col('.') - 2] =~# num - normal! h - endwhile - endif -endfunction - -" }}} - -" }}} " Mini-plugins ------------------------------------------------------------ {{{ " Stuff that should probably be broken out into plugins, but hasn't proved to be " worth the time to do so just yet. diff -r fdb4a84069f3 -r c4bb62cd1c7f vim/vimrc-minimal --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/vimrc-minimal Tue Oct 03 13:15:18 2023 -0400 @@ -0,0 +1,667 @@ +" .vimrc-minimal +" Author: Steve Losh +" Source: https://hg.stevelosh.com/dotfiles/file/tip/vim/vimrc + +" A minimal subset of my vimrc settings, suitable for syncing on its own to +" a server so I have some basic settings, but don't have to install the whole +" hog. + +" Preamble ---------------------------------------------------------------- {{{ + +set shell=/bin/bash\ --login + +" }}} +" Basic options ----------------------------------------------------------- {{{ + +set modelines=0 +set autoindent +set showmode +set showcmd +set hidden +set visualbell +set ttyfast +set ruler +set backspace=indent,eol,start +set nonumber +set norelativenumber +set laststatus=2 +set history=1000 +set undofile +set undoreload=10000 +set list +set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮ +set lazyredraw +set matchtime=3 +set showbreak=↪ +set splitbelow +set splitright +set autowrite +set autoread +set shiftround +set title +set linebreak +set colorcolumn=+1 +set diffopt+=vertical + +" Don't try to highlight lines longer than 500 characters. +set synmaxcol=500 + +" Time out on key codes but not mappings. +" Basically this makes terminal Vim work sanely. +set notimeout +set ttimeout +set ttimeoutlen=10 + +" Make Vim able to edit crontab files again. +set backupskip=/tmp/*,/private/tmp/*" + +" Better Completion +set complete=.,w,b,u,t +set completeopt=longest,menuone +inoremap + +" Save when losing focus +au FocusLost * :silent! wall + +" Leader +let mapleader = "," +let maplocalleader = "\\" + +" Cursorline {{{ +" Only show cursorline in the current window and in normal mode. + +augroup cline + au! + au WinLeave,InsertEnter * set nocursorline + au WinEnter,InsertLeave * set cursorline +augroup END + +" }}} +" cpoptions+=J, dammit {{{ + +" Something occasionally removes this. If I manage to find it I'm going to +" comment out the line and replace all its characters with 'FUCK'. +augroup twospace + au! + au BufRead * :set cpoptions+=J +augroup END + +" }}} +" Trailing whitespace {{{ +" Only shown when not in insert mode so I don't go insane. + +augroup trailing + au! + au InsertEnter * :set listchars-=trail:⌴ + au InsertLeave * :set listchars+=trail:⌴ +augroup END + +" }}} +" Wildmenu completion {{{ + +set wildmenu +set wildmode=list:longest + +set wildignore+=.hg,.git,.svn " Version control +set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files +set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files +set wildignore+=*.spl " compiled spelling word lists +set wildignore+=*.sw? " Vim swap files +set wildignore+=*.DS_Store " OSX bullshit + +set wildignore+=*.luac " Lua byte code + +set wildignore+=migrations " Django migrations +set wildignore+=*.pyc " Python byte code + +set wildignore+=*.orig " Merge resolution files + +set wildignore+=*.fasl " Lisp FASLs +set wildignore+=*.dx64fsl " CCL +set wildignore+=*.lx64fsl " CCL + +" }}} +" Line Return {{{ + +" Make sure Vim returns to the same line when you reopen a file. +" Thanks, Amit +augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif +augroup END + +" }}} +" Tabs, spaces, wrapping {{{ + +set tabstop=8 +set shiftwidth=4 +set softtabstop=4 +set expandtab +set wrap +set textwidth=80 +set formatoptions=qrn1j +set colorcolumn=+1 + +" }}} +" Backups {{{ + +set backup " enable backups +set noswapfile " it's 2013, Vim. + +set undodir=~/.vim/tmp/undo// " undo files +set backupdir=~/.vim/tmp/backup// " backups +set directory=~/.vim/tmp/swap// " swap files + +" Make those folders automatically if they don't already exist. +if !isdirectory(expand(&undodir)) + call mkdir(expand(&undodir), "p") +endif +if !isdirectory(expand(&backupdir)) + call mkdir(expand(&backupdir), "p") +endif +if !isdirectory(expand(&directory)) + call mkdir(expand(&directory), "p") +endif + +" }}} +" Color scheme {{{ + +syntax on +set termguicolors +set background=dark + +" }}} + +" }}} +" Abbreviations & Digraphs ------------------------------------------------ {{{ + +iabbrev todo TODO + +silent! digr -. 8230 "U+2026=… HORIZONTAL ELLIPSIS +silent! digr !, 8816 "U+2270=≰ NEITHER LESS-THAN NOR EQUAL TO +silent! digr !. 8817 "U+2271=≱ NEITHER GREATER-THAN NOR EQUAL TO +silent! digr es 8337 "U+2091=ₑ SUBSCRIPT E +silent! digr xs 8339 "U+2093=ₓ SUBSCRIPT X +silent! digr ls 8343 "U+2097=ₗ SUBSCRIPT L +silent! digr ms 8344 "U+2098=ₗ SUBSCRIPT M +silent! digr ns 8345 "U+2099=ₙ SUBSCRIPT N +silent! digr ps 8346 "U+209A=ₚ SUBSCRIPT P +silent! digr ss 8347 "U+209B=ₛ SUBSCRIPT S +silent! digr ts 8348 "U+209C=ₜ SUBSCRIPT T +silent! digr >< 8652 "U+21cc=⇌ EQUILIBRIUM +silent! digr o+ 8853 "U+2295=⊕ CIRCLED PLUS +silent! digr -^ 8593 "U+2191=↑ UPWARDS ARROW + +silent! digr -- 8212 "U+2014=— EM DASH + +silent! digr // 9585 "U+2571=╱ BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT +silent! digr \\ 9586 "U+2572=╲ BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT + +silent! digr \|\| 8214 "U+2016=‖ DOUBLE VERTICAL LINE + +silent! digr ~~ 8967 "U+2307=⌇ WAVY LINE + +" }}} +" Convenience mappings ---------------------------------------------------- {{{ + +" Fuck you, help key. +noremap :checktime +inoremap :checktime + +" Stop it, hash key. +inoremap # X# + +" Kill window +nnoremap K :q + +" Save +nnoremap s :w + +" Man +nnoremap M K + +" Clean up windows +nnoremap - :wincmd = + +" Toggle line numbers +nnoremap n :setlocal number! + +" Sort lines +nnoremap s vip:sort +vnoremap s :sort + +" Tabs +nnoremap ( :tabprev +nnoremap ) :tabnext + +" My garbage brain can't ever remember digraph codes +inoremap :help digraph-table + +" Wrap +" mnemonic: less' -S command/option +nnoremap S :set wrap! + +" Inserting blank lines +" I never use the default behavior of and this saves me a keystroke... +nnoremap o + +" Delete to black hole register +nnoremap dD "_dd +vnoremap D "_d + +" Yank to end of line +nnoremap Y y$ + +" Reselect last-pasted text +nnoremap gv `[v`] + +" I constantly hit "u" in visual mode when I mean to "y". Use "gu" for those rare occasions. +" From https://github.com/henrik/dotfiles/blob/master/vim/config/mappings.vim +vnoremap u +vnoremap gu u + +" Clean trailing whitespace +nnoremap ww mz:%s/\s\+$//:let @/=''`z + +" Select entire buffer +nnoremap vaa ggvGg_ +nnoremap Vaa ggVG + +" Fix from spellcheck +" I can never remember if it's zg or z=, and the wrong one adds the word to +" the DB (lol), so fuck it, just add an easier mapping. +nnoremap zz z= +nnoremap z= :echo "use zz you idiot" + +" "Uppercase word" mapping. +" +" This mapping allows you to press in insert mode to convert the current +" word to uppercase. It's handy when you're writing names of constants and +" don't want to use Capslock. +" +" To use it you type the name of the constant in lowercase. While your +" cursor is at the end of the word, press to uppercase it, and then +" continue happily on your way: +" +" cursor +" v +" max_connections_allowed| +" +" MAX_CONNECTIONS_ALLOWED| +" ^ +" cursor +" +" It works by exiting out of insert mode, recording the current cursor location +" in the z mark, using gUiw to uppercase inside the current word, moving back to +" the z mark, and entering insert mode again. +" +" Note that this will overwrite the contents of the z mark. I never use it, but +" if you do you'll probably want to use another mark. +inoremap mzgUiw`za + +" Wrap Toggle +nnoremap :set nowrap! + +" zt is okay for putting something at the top of the screen, but when I'm +" writing prose I often want to put something at not-quite-the-top of the +" screen. zh is "zoom to head level" +nnoremap zh mzzt10`z + +" Diffoff +nnoremap D :diffoff! + +" Formatting, TextMate-style +nnoremap Q gqip +vnoremap Q gq + +" Reformat line. +" I never use l as a macro register anyway. +nnoremap ql gqq + +" Indent/dedent/autoindent what you just pasted. +nnoremap > V`]< +nnoremap > V`]> +nnoremap =- V`]= + +" Keep the cursor in place while joining lines +nnoremap J mzJ`z + +" Join an entire paragraph. +" +" Useful for writing GitHub comments in actual Markdown and then translating it +" to their bastardized version of Markdown. +nnoremap j mzvipJ`z + +" Split line (sister to [J]oin lines) +" The normal use of S is covered by cc, so don't worry about shadowing it. +nnoremap S i^mwgk:silent! s/\v +$//:noh`w + +" Substitute +nnoremap :%s/ +vnoremap :s/ + +" Marks and Quotes +noremap ' ` +noremap æ ' +noremap ` + +" Select (charwise) the contents of the current line, excluding indentation. +" Great for pasting Python lines into REPLs. +nnoremap vv ^vg_ + +" Typos +command! -bang E e +command! -bang Q q +command! -bang W w +command! -bang QA qa +command! -bang Qa qa +command! -bang Wa wa +command! -bang WA wa +command! -bang Wq wq +command! -bang WQ wq +command! -bang Wqa wqa + +" Unfuck my screen +nnoremap U :syntax sync fromstart:redraw! + +" Zip Right +" +" Moves the character under the cursor to the end of the line. Handy when you +" have something like: +" +" foo +" +" And you want to wrap it in a method call, so you type: +" +" println()foo +" +" Once you hit escape your cursor is on the closing paren, so you can 'zip' it +" over to the right with this mapping. +" +" This should preserve your last yank/delete as well. +nnoremap zl :let @z=@"x$p:let @"=@z + +" Diff Navigation +nnoremap ]d ]c +nnoremap [d [c + +" Typo navigation +nnoremap ]z ]S +nnoremap [z [S +nnoremap ]Z ]Sz= +nnoremap [Z [Sz= + +" Header Lines +nnoremap - o80a-kJ079lD + +" Insert Mode Completion +inoremap +inoremap +inoremap + +" Window Resizing +" right/up : bigger +" left/down : smaller +nnoremap :vertical resize +3 +nnoremap :vertical resize -3 +nnoremap :resize +3 +nnoremap :resize -3 + +" }}} +" Searching and movement -------------------------------------------------- {{{ + +" Use sane regexes. +nnoremap / /\v +vnoremap / /\v + +set ignorecase +set smartcase +set incsearch +set showmatch +set hlsearch +set gdefault + +set scrolloff=5 +set sidescroll=1 +set sidescrolloff=10 + +set virtualedit+=block + +noremap :noh:call clearmatches() + +runtime macros/matchit.vim +map % +silent! unmap [% +silent! unmap ]% + +" Made D behave +nnoremap D d$ + +" Don't move on * +" I'd use a function for this but Vim clobbers the last search when you're in +" a function so fuck it, practicality beats purity. +nnoremap * :let stay_star_view = winsaveview()*:call winrestview(stay_star_view) + +" Jumping to tags. +" +" Basically, jumps to tags (like normal) and opens the tag in a new +" split instead. +" +" Both of them will align the destination line to the upper middle part of the +" screen. Both will pulse the cursor line so you can see where the hell you +" are. will also fold everything in the buffer and then unfold just +" enough for you to see the destination line. +" +function! JumpTo(jumpcommand) + execute a:jumpcommand + call FocusLine() + Pulse +endfunction +function! JumpToInSplit(jumpcommand) + execute "normal! \v" + execute a:jumpcommand + Pulse +endfunction + +function! JumpToTag() + call JumpTo("normal! \") +endfunction +function! JumpToTagInSplit() + call JumpToInSplit("normal \") +endfunction + +nnoremap :silent! call JumpToTag() +nnoremap :silent! call JumpToTagInSplit() + +" Keep search matches in the middle of the window. +nnoremap n nzzzv +nnoremap N Nzzzv + +" Same when jumping around +nnoremap g; g;zz +nnoremap g, g,zz +nnoremap zz + +" Easier to type, and I never use the default behavior. +noremap H ^ +noremap L $ +vnoremap L g_ + +" Heresy +inoremap I +inoremap A +cnoremap +cnoremap + +" go indent +nnoremap gi mzVap=`z +nnoremap gI mzgg=G`z + +" Fix linewise visual selection of various text objects +nnoremap VV V +nnoremap Vit vitVkoj +nnoremap Vat vatV +nnoremap Vab vabV +nnoremap VaB vaBV + + +" Directional Keys {{{ + +" It's 2013. +noremap j gj +noremap k gk +noremap gj j +noremap gk k + +" Easy buffer navigation +noremap h +noremap j +noremap k +noremap l + +noremap v v + +" }}} +" Visual Mode */# from Scrooloose {{{ + +function! s:VSetSearch() + let temp = @@ + norm! gvy + let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') + let @@ = temp +endfunction + +vnoremap * :call VSetSearch()// +vnoremap # :call VSetSearch()?? + +" }}} +" List navigation {{{ + +nnoremap :cprevzvzz +nnoremap :cnextzvzz +nnoremap :lprevzvzz +nnoremap :lnextzvzz + +" }}} + +" }}} +" Folding ----------------------------------------------------------------- {{{ + +set foldlevelstart=0 + +" Space to toggle folds. +nnoremap za +vnoremap za + +" Make zO recursively open whatever fold we're in, even if it's partially open. +nnoremap zO zczO + +" "Focus" the current line. Basically: +" +" 1. Close all folds. +" 2. Open just the folds containing the current line. +" 3. Move the line to a bit (25 lines) down from the top of the screen. +" 4. Pulse the line. +" +" This mapping wipes out the z mark, which I never use. +" +" I use :sus for the rare times I want to actually background Vim. +function! FocusLine() + let oldscrolloff = &scrolloff + set scrolloff=0 + execute "keepjumps normal! mzzMzvzt25\`z:Pulse\" + let &scrolloff = oldscrolloff +endfunction +nnoremap :call FocusLine() + +function! MyFoldText() " {{{ + let line = getline(v:foldstart) + + let nucolwidth = &fdc + &number * &numberwidth + let windowwidth = winwidth(0) - nucolwidth - 3 + let foldedlinecount = v:foldend - v:foldstart + + " expand tabs into spaces + let onetab = strpart(' ', 0, &tabstop) + let line = substitute(line, '\t', onetab, 'g') + + let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) + let fillcharcount = windowwidth - len(line) - len(foldedlinecount) + return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' +endfunction " }}} +set foldtext=MyFoldText() + +" }}} +" Text objects ------------------------------------------------------------ {{{ + +" Folds {{{ + +onoremap if :normal! [zv]z +onoremap af :normal! [zV]z +vnoremap if :normal! ]zv[z +vnoremap af :normal! ]zV[z + +" }}} +" Shortcut for [] {{{ + +onoremap ir i[ +onoremap ar a[ +vnoremap ir i[ +vnoremap ar a[ + +" }}} +" Numbers {{{ + +" Motion for numbers. Great for CSS. Lets you do things like this: +" +" margin-top: 200px; -> daN -> margin-top: px; +" ^ ^ +" TODO: Handle floats. + +onoremap N :call NumberTextObject(0) +xnoremap N :call NumberTextObject(0) +onoremap aN :call NumberTextObject(1) +xnoremap aN :call NumberTextObject(1) +onoremap iN :call NumberTextObject(1) +xnoremap iN :call NumberTextObject(1) + +function! s:NumberTextObject(whole) + let num = '\v[0-9]' + + " If the current char isn't a number, walk forward. + while getline('.')[col('.') - 1] !~# num + normal! l + endwhile + + " Now that we're on a number, start selecting it. + normal! v + + " If the char after the cursor is a number, select it. + while getline('.')[col('.')] =~# num + normal! l + endwhile + + " If we want an entire word, flip the select point and walk. + if a:whole + normal! o + + while col('.') > 1 && getline('.')[col('.') - 2] =~# num + normal! h + endwhile + endif +endfunction + +" }}} + +" }}} +" Optional Remote-Local Vimrc --------------------------------------------- {{{ + +if filereadable(expand('~/.vimrc_remote_local')) + source ~/.vimrc_remote_local +endif + +" }}}