dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit 0093388b4cd1220da368e5df6b9e202a939231a4
parent bbad1d25b94b981019c132bca5be7dcbbb5a9024
Author: Hayden Hamilton <hayden@haydenvh.com>
Date:   Mon,  9 Mar 2020 23:36:40 +0000

Another nvim payload.... ahh, the smell of vim in the morning

Diffstat:
M.config/nvim/init.vim | 40+++++++++++++++++++++++++++++-----------
A.config/nvim/modules/netrw.vim | 4++++
M.config/nvim/modules/splits.vim | 14++++++++++++--
M.config/nvim/modules/statusline.vim | 47+++++++++++++++++++++++++++++++++++++++++------
A.config/nvim/modules/tabs.vim | 12++++++++++++
A.config/nvim/modules/term.vim | 10++++++++++
A.config/nvim/netrw.sh | 4++++
D.config/nvim/plugin/system_copy.vim | 148-------------------------------------------------------------------------------
8 files changed, 112 insertions(+), 167 deletions(-)

diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim @@ -11,8 +11,9 @@ " surround - allows operation on surrounding characters " commentary - comments stuff out " repeat - repeat things -" vimling (ipa, deadkeys, prose) - deadkeys +" vimling (ipa, deadkeys) - deadkeys " vimagit - git in vim +" v(org)im (written by me) - emulating org mode in vim "Leader let mapleader="," @@ -50,6 +51,8 @@ noremap <leader>c :!sudo make all install clean \| set linebreak<CR> noremap <leader>oc :!groff -T pdf % - > /tmp/grff \| zathura -<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left> noremap <Leader>sv :!sent % \| set linebreak<CR> noremap <leader>sc :setlocal spell! spelllang=en_us \| set linebreak<CR> +noremap <leader>sf mm[s1z=`m<CR> +noremap <leader>ssf z=<CR> noremap <leader>ff :r !find \| set linebreak<CR> noremap <leader>fl :r !ls \| set linebreak<CR> noremap <leader>bd :bdelete \| set linebreak<CR> @@ -120,11 +123,11 @@ noremap <leader>ld :call ToggleDeadKeys()<CR> inoremap <leader>ld <esc>:call ToggleDeadKeys()<CR>a noremap <leader>li :call ToggleIPA()<CR> inoremap <leader>li <esc>:call ToggleIPA()<CR>a -noremap <F8> :call ToggleProse()<CR> "An erotic file-browser noremap <leader>eh :Sex \| set linebreak<CR> noremap <leader>ev :Vex \| set linebreak<CR> +noremap <leader>ee :Explore \| set linebreak<CR> noremap <leader>eo :browse oldfiles \| set linebreak<CR> noremap <leader>eb 100j let g:netrw_liststyle=3 @@ -141,11 +144,33 @@ ino <Down> <Nop> ino <Left> <Nop> ino <Right> <Nop> +"Search +nnoremap <leader>CS :let @/=''<CR> + "Registers -nnoremap <leader>yy "*y -inoremap <leader><leader>yy "*y +nnoremap <c-y> "*y +inoremap <c-y> "*y + +"Terminals +nnoremap <leader>Tt :vsplit term://zsh<CR><c-h><c-l> +nnoremap <leader>TT :split term://zsh<CR><c-k><c-j> +tnoremap <leader><Esc> <C-\><C-n> + +"Modules +source ~/.config/nvim/modules/theme.vim +source ~/.config/nvim/modules/abbrs.vim +source ~/.config/nvim/modules/statusline.vim +source ~/.config/nvim/modules/splits.vim +source ~/.config/nvim/modules/buffs.vim +source ~/.config/nvim/modules/netrw.vim +source ~/.config/nvim/modules/term.vim +source ~/.config/nvim/modules/tabs.vim +"Automatic commands augroup autocmd + "netrw + autocmd FileType,WinEnter,BufEnter netrw call Configurenetrw() + "Get rid of shitty indenting autocmd FileType html :normal gg=G @@ -156,10 +181,3 @@ augroup autocmd autocmd FileType C :noremap <buffer> <leader>end $a;<esc> autocmd FileType C :inoremap <buffer> <leader><leader>end <esc>$a;<esc> augroup END - -"Modules -source ~/.config/nvim/modules/theme.vim -source ~/.config/nvim/modules/abbrs.vim -source ~/.config/nvim/modules/statusline.vim -source ~/.config/nvim/modules/splits.vim -source ~/.config/nvim/modules/buffs.vim diff --git a/.config/nvim/modules/netrw.vim b/.config/nvim/modules/netrw.vim @@ -0,0 +1,4 @@ +function! Configurenetrw() + silent! nunmap! <buffer> <c-l> + nnoremap <buffer> <c-l> <c-w>l +endfunction diff --git a/.config/nvim/modules/splits.vim b/.config/nvim/modules/splits.vim @@ -1,16 +1,26 @@ set splitbelow splitright -noremap <leader>z :vsplit \| set linebreak<CR> -noremap <leader>Z :split \| set linebreak<CR> +noremap <leader>z :vsplit +noremap <leader>Z :split + noremap <C-h> <C-w>h noremap <C-j> <C-w>j noremap <C-k> <C-w>k noremap <C-l> <C-w>l noremap <C-c> <C-w>c +noremap <A-j> <C-w>+ +noremap <A-k> <C-w>- +noremap <A-h> <C-w>< +noremap <A-l> <C-w>> + inoremap <C-h> <C-w>h inoremap <C-j> <C-w>j inoremap <C-k> <C-w>k inoremap <C-l> <C-w>l inoremap <C-c> <C-w>c +inoremap <A-j> <C-w>+ +inoremap <A-k> <C-w>- +inoremap <A-h> <C-w>< +inoremap <A-l> <C-w>> function! Netrwmap(filetype) if a:filetype == 'netrw' diff --git a/.config/nvim/modules/statusline.vim b/.config/nvim/modules/statusline.vim @@ -1,3 +1,4 @@ +hi Statusbar ctermbg=0 ctermfg=0 hi Modecol ctermbg=10 ctermfg=254 gui=bold hi Basecol ctermbg=0 hi Filecol ctermbg=2 ctermfg=7 gui=bold @@ -72,7 +73,7 @@ function! Inactivestatus() return s endfunction -function! Netrwstatus() +function! NetrwAstatus() ""Remimder let s="%#Filecol#" let s.=" %y " @@ -81,24 +82,58 @@ function! Netrwstatus() return s endfunction +function! NetrwIstatus() + ""Remimder + let s="%#Basecol#" + let s.=" %y " + + return s +endfunction + +function! TermAstatus() + ""Reminder + let s="%#Filecol#" + let s.=" [terminal] " + let s.="%#Basecol#" + + return s +endfunction + +function! TermIstatus() + ""Reminder + let s="%#Basecol#" + let s.=" [terminal] " + + return s +endfunction + augroup Statusline autocmd! + autocmd FileType netrw let _filetype=&filetype + autocmd FileType netrw let &l:statusline=Choosestatus(1, _filetype) autocmd WinEnter,BufEnter * let _filetype=&filetype autocmd WinEnter,BufEnter * let &l:statusline=Choosestatus(1, _filetype) - autocmd WinLeave,BufLeave * let &l:statusline=Choosestatus(0, "null") + autocmd WinLeave,BufLeave * let &l:statusline=Choosestatus(0, _filetype) augroup END function! Choosestatus(active, filetype) "Set active or inactive - if a:active == '1' && a:filetype != 'netrw' + if a:active == '1' let statusline=Activestatus() else let statusline=Inactivestatus() endif - "Overwrite if netrw - if a:filetype == 'netrw' - let statusline=Netrwstatus() + "Overwrite if special + let s="term" + if a:filetype == 'netrw' && a:active == '1' + let statusline=NetrwAstatus() + elseif a:filetype == 'netrw' + let statusline=NetrwIstatus() + elseif stridx(expand('%:p'), s) == '0' && a:active == '1' + let statusline=TermAstatus() + elseif stridx(expand('%:p'), s) == '0' + let statusline=TermIstatus() endif return statusline diff --git a/.config/nvim/modules/tabs.vim b/.config/nvim/modules/tabs.vim @@ -0,0 +1,12 @@ +nnoremap <leader>te :tabedit +nnoremap <leader>tf :tabfind +nnoremap <leader>tc :tabclose<CR> +nnoremap <leader>to :tabonly<CR> +nnoremap <leader>tb :tab ball<CR> +nnoremap <leader>th :tab help +nnoremap <leader>tz :tab split<CR> +nnoremap <leader>tZ :tab split<CR> +nnoremap <leader>tn :tabn<CR> +nnoremap <leader>tp :tabp<CR> +nnoremap <leader>tN :tablast<CR> +nnoremap <leader>tP :tabfirst<CR> diff --git a/.config/nvim/modules/term.vim b/.config/nvim/modules/term.vim @@ -0,0 +1,10 @@ +function! Termstart() + let s="term" + if stridx(expand('%:p'), s) == '0' + setlocal nonumber norelativenumber + endif +endfunction + +augroup terminal + autocmd WinNew,BufNew,BufNewFile,BufEnter,WinEnter * call Termstart() +augroup END diff --git a/.config/nvim/netrw.sh b/.config/nvim/netrw.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +mv /{usr,usr/local}/share/nvim/runtime/plugin/netrw* ~/.config/nvim/plugin/ +mv /{usr,usr/local}/share/nvim/runtime/autoload/netrw* ~/.config/nvim/autoload/ diff --git a/.config/nvim/plugin/system_copy.vim b/.config/nvim/plugin/system_copy.vim @@ -1,148 +0,0 @@ -if exists('g:loaded_system_copy') || v:version < 700 - finish -endif -let g:loaded_system_copy = 1 - -let s:blockwise = 'blockwise visual' -let s:visual = 'visual' -let s:motion = 'motion' -let s:linewise = 'linewise' -let s:mac = 'mac' -let s:windows = 'windows' -let s:linux = 'linux' - -function! s:system_copy(type, ...) abort - let mode = <SID>resolve_mode(a:type, a:0) - let unnamed = @@ - if mode == s:linewise - let lines = { 'start': line("'["), 'end': line("']") } - silent exe lines.start . "," . lines.end . "y" - elseif mode == s:visual || mode == s:blockwise - silent exe "normal! `<" . a:type . "`>y" - else - silent exe "normal! `[v`]y" - endif - let command = s:CopyCommandForCurrentOS() - silent call system(command, getreg('@')) - echohl String | echon 'Copied to clipboard using: ' . command | echohl None - let @@ = unnamed -endfunction - -function! s:system_paste(type, ...) abort - let mode = <SID>resolve_mode(a:type, a:0) - let command = <SID>PasteCommandForCurrentOS() - let unnamed = @@ - if mode == s:linewise - let lines = { 'start': line("'["), 'end': line("']") } - silent exe lines.start . "," . lines.end . "d" - silent exe "set paste | normal! O" . system(command) - silent exe "set nopaste" - elseif mode == s:visual || mode == s:blockwise - silent exe "normal! `<" . a:type . "`>c" . system(command) - else - silent exe "normal! `[v`]c" . system(command) - endif - echohl String | echon 'Pasted to clipboard using: ' . command | echohl None - let @@ = unnamed -endfunction - -function! s:system_paste_line() abort - let command = <SID>PasteCommandForCurrentOS() - put =system(command) - echohl String | echon 'Pasted to vim using: ' . command | echohl None -endfunction - -function! s:resolve_mode(type, arg) - let visual_mode = a:arg != 0 - if visual_mode - return (a:type == '') ? s:blockwise : s:visual - elseif a:type == 'line' - return s:linewise - else - return s:motion - endif -endfunction - -function! s:currentOS() - let os = substitute(system('uname'), '\n', '', '') - let known_os = 'unknown' - if has("gui_mac") || os ==? 'Darwin' - let known_os = s:mac - elseif has("gui_win32") || os =~? 'cygwin' || os =~? 'MINGW' - let known_os = s:windows - elseif os ==? 'Linux' - let known_os = s:linux - else - exe "normal \<Esc>" - throw "unknown OS: " . os - endif - return known_os -endfunction - -function! s:CopyCommandForCurrentOS() - if exists('g:system_copy#copy_command') - return g:system_copy#copy_command - endif - let os = <SID>currentOS() - if os == s:mac - return 'pbcopy' - elseif os == s:windows - return 'clip' - elseif os == s:linux - if !empty($WAYLAND_DISPLAY) - return 'wl-copy' - else - return 'xsel --clipboard --input' - endif - endif -endfunction - -function! s:PasteCommandForCurrentOS() - if exists('g:system_copy#paste_command') - return g:system_copy#paste_command - endif - let os = <SID>currentOS() - if os == s:mac - return 'pbpaste' - elseif os == s:windows - return 'paste' - elseif os == s:linux - if !empty($WAYLAND_DISPLAY) - return 'wl-paste -n' - else - return 'xsel --clipboard --output' - endif - endif -endfunction - -xnoremap <silent> <Plug>SystemCopy :<C-U>call <SID>system_copy(visualmode(),visualmode() ==# 'V' ? 1 : 0)<CR> -nnoremap <silent> <Plug>SystemCopy :<C-U>set opfunc=<SID>system_copy<CR>g@ -nnoremap <silent> <Plug>SystemCopyLine :<C-U>set opfunc=<SID>system_copy<Bar>exe 'norm! 'v:count1.'g@_'<CR> -xnoremap <silent> <Plug>SystemPaste :<C-U>call <SID>system_paste(visualmode(),visualmode() ==# 'V' ? 1 : 0)<CR> -nnoremap <silent> <Plug>SystemPaste :<C-U>set opfunc=<SID>system_paste<CR>g@ -nnoremap <silent> <Plug>SystemPasteLine :<C-U>call <SID>system_paste_line()<CR> - -if !hasmapto('<Plug>SystemCopy', 'n') || maparg('cp', 'n') ==# '' - nmap cp <Plug>SystemCopy -endif - -if !hasmapto('<Plug>SystemCopy', 'v') || maparg('cp', 'v') ==# '' - xmap cp <Plug>SystemCopy -endif - -if !hasmapto('<Plug>SystemCopyLine', 'n') || maparg('cP', 'n') ==# '' - nmap cP <Plug>SystemCopyLine -endif - -if !hasmapto('<Plug>SystemPaste', 'n') || maparg('cv', 'n') ==# '' - nmap cv <Plug>SystemPaste -endif - -if !hasmapto('<Plug>SystemPaste', 'v') || maparg('cv', 'v') ==# '' - xmap cv <Plug>SystemPaste -endif - -if !hasmapto('<Plug>SystemPasteLine', 'n') || maparg('cV', 'n') ==# '' - nmap cV <Plug>SystemPasteLine -endif -" vim:ts=2:sw=2:sts=2