From a8329ff6814fda7857e75b4dfcaf081ca4457a4e Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 6 Nov 2019 22:58:51 -0500 Subject: [PATCH] vim: fall cleaning, small vimrc improvements * ToggleColorColumn: now defaults to textwidth if set * Removed "PasteFromClipboard" in favor of ":put" - This is a little cleaner on the Vimscript * Changed nasty "copy whole file" mapping to use ":yank" properly - Added benefit of not redrawing the screen with * Removed outdated c.vim ftplugin - Not using YCM at all these days * Removed Dark/Light nnoremaps - While I used to use this when I coded outside... I don't code outside often these days :) * Removed terminal mapping attempt at standardizing "go to insert mode" 1. I use tmux over the terminal almost always 2. I should give the defaults another shot... --- vim/autoload/vimrc.vim | 12 +++++------- vim/ftplugin/c.vim | 4 ---- vim/vimrc | 21 ++------------------- 3 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 vim/ftplugin/c.vim diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim index 9d1223b..e0079b6 100644 --- a/vim/autoload/vimrc.vim +++ b/vim/autoload/vimrc.vim @@ -3,14 +3,12 @@ " See `:h autoload-functions` for explanation of autoloading and performance function! vimrc#ToggleColorColumn() abort if &colorcolumn == "" - set colorcolumn=80 + if &textwidth > 0 + exe "set colorcolumn=" . &textwidth + else + set colorcolumn=80 + endif else set colorcolumn="" endif endfunction - -function! vimrc#SetPasteAndPasteFromClipboard() abort - set paste - normal! "+p - set nopaste -endfunction diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim deleted file mode 100644 index 652c632..0000000 --- a/vim/ftplugin/c.vim +++ /dev/null @@ -1,4 +0,0 @@ -" for neovim development! -if exists( "g:loaded_youcompleteme" ) - nnoremap :YcmCompleter GoTo -endif diff --git a/vim/vimrc b/vim/vimrc index 8f589c3..8d87f36 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -102,7 +102,6 @@ if (($TERM =~# '256color' && has("termguicolors")) || has('gui_running')) && colorscheme gruvbox " See :h xterm-true-color for tmux+termguicolors - " TODO: is this safe to blindly set always (in 256 color mode)? if &term =~# '^\(tmux\|st\|screen\)' let &t_8f = "\[38;2;%lu;%lu;%lum" let &t_8b = "\[48;2;%lu;%lu;%lum" @@ -119,7 +118,6 @@ else set background=light colorscheme vc endif - " }}} " KEY MAPPINGS {{{ @@ -132,18 +130,8 @@ nnoremap k nnoremap h nnoremap l -" Terminal mappings -" NOTE: a couple limitations here: -" 1) Vim interprets arrows as escape sequences --> remapping escape is no-go -" 2) Alacritty cannot handle meta on mac (currently) -" -" With this in mind, the goal is to make cross-vim keys consistent -if has('terminal') || has('nvim') - tnoremap -endif - " Paste from clipboard without any formatting issues -nnoremap :call vimrc#SetPasteAndPasteFromClipboard() +nnoremap :set paste \| put + \| set nopaste " Clear trailing whitespace (through regexp) nnoremap :call utils#CMDPreserve("%s/\\s\\+$//e") @@ -153,10 +141,6 @@ nnoremap e :e %:h/ nnoremap v :vsp %:h/ nnoremap s :sp %:h/ -" quick toggle for light/dark background -nnoremap L :set background=light -nnoremap D :set background=dark - " toggle color column (to ensure short lines) nnoremap C vimrc#ToggleColorColumn() @@ -175,7 +159,7 @@ nnoremap G :Ggrep! :copen nnoremap w :set list! " Yank entire file -nnoremap y gg"+yG +nnoremap y :0,$y + " Edit vimrc nnoremap V :edit $HOME/.vim/vimrc @@ -185,7 +169,6 @@ inoremap u " }}} " COMMANDS {{{ -command! -nargs=1 GitGrep call vimrc#GitGrep('') | copen command! CD exe 'cd ' . expand('%:h') " }}} -- libgit2 0.28.4