diff --git a/simpleDots/vim/vimrc b/simpleDots/vim/vimrc index f411627..f4c7e2f 100755 --- a/simpleDots/vim/vimrc +++ b/simpleDots/vim/vimrc @@ -1,262 +1,81 @@ -" -" Basics -" -set nocompatible " be iMproved, required -filetype off " required -filetype plugin indent on " required - " " Install plugins " +set nocompatible " be iMproved, required +filetype off " required + call plug#begin('~/.vim/vimplug-plugins') -Plug 'Raimondi/delimitMate' " Autoclose quotes, parenthesis, brackets, etc. -Plug 'airblade/vim-gitgutter' " Git-indicators on the left -Plug 'dhruvasagar/vim-table-mode' " Nice ascii tables -Plug 'itchyny/lightline.vim' " Status-line -Plug 'junegunn/vim-easy-align' " Align at any chars -Plug 'ntpeters/vim-better-whitespace' " Complain on evil eol whitespace -Plug 'scrooloose/nerdtree' " Nerdtree... -Plug 'tpope/vim-fugitive' " git integration +Plug 'Raimondi/delimitMate' " Autoclose quotes, parenthesis, brackets, etc. +Plug 'airblade/vim-gitgutter' " Git-indicators on the left +Plug 'dhruvasagar/vim-table-mode' " Nice ascii tables +Plug 'itchyny/lightline.vim' " Status-line +Plug 'junegunn/vim-easy-align' " Align at any chars +Plug 'ntpeters/vim-better-whitespace' " Complain on evil eol whitespace +Plug 'scrooloose/nerdtree' " Nerdtree... +Plug 'tpope/vim-fugitive' " git integration call plug#end() +filetype plugin indent on +syntax on +syntax sync minlines=256 " " Settings " -set noerrorbells " No beeps -set number " Show line numbers -set backspace=indent,eol,start " Makes backspace key more powerful. -set showcmd " Show me what I'm typing -set showmode " Show current mode. - -set noswapfile " Don't use swapfile -set nobackup " Don't create annoying backup files -set nowritebackup -set splitright " Split vertical windows right to the current windows -set splitbelow " Split horizontal windows below to the current windows -set encoding=utf-8 " Set default encoding to UTF-8 -set autowrite " Automatically save before :next, :make etc. +set autoindent set autoread " Automatically reread changed files without asking me anything -set laststatus=2 -set hidden - -set ruler " Show the cursor position all the time -au FocusLost * :wa " Set vim to save the file on focus out. - +set autowrite " Automatically save before :next, :make etc. +set backspace=indent,eol,start " Makes backspace key more powerful. +set complete=.,w,b,u,t +set completeopt=longest,menuone +set display+=lastline +set encoding=utf-8 " Set default encoding to UTF-8 set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats - -set showmatch " Show matching brackets by flickering -set noshowmode " We show the mode with airlien or lightline -set incsearch " Shows the match while typing -set hlsearch " Highlight found searches -set ignorecase " Search case insensitive... -set smartcase " ... but not when search pattern contains upper case characters -set ttyfast -set lazyredraw " Wait to redraw " - -" speed up syntax highlighting +set hidden +set history=500 +set hlsearch +set ignorecase +set incsearch +set laststatus=2 +set lazyredraw +set nobackup " Don't create annoying backup files set nocursorcolumn set nocursorline - -syntax sync minlines=256 -set synmaxcol=300 +set noerrorbells " No beeps +set noshowmode " We show the mode with airlien or lightline +set noswapfile " Don't use swapfile +set nowritebackup +set nrformats-=octal +set number " Show line numbers set re=1 - -" open help vertically -command! -nargs=* -complete=help Help vertical belowright help -autocmd FileType help wincmd L +set ruler " Show the cursor position all the time +set scrolloff=7 +set showcmd " Show me what I'm typing +set showmatch " Show matching brackets by flickering +set sidescrolloff=7 +set smartcase +set splitbelow " Split horizontal windows below to the current windows +set splitright " Split vertical windows right to the current windows +set synmaxcol=300 +set tabpagemax=50 +set ttyfast " Make Vim to handle long lines nicely. set wrap set textwidth=79 set formatoptions=qrn1 -" mail line wrapping -au BufRead /tmp/mutt-* set tw=72 - -set autoindent -set complete-=i -set smarttab - -set tabstop=4 -set shiftwidth=4 -set expandtab - -set nrformats-=octal -set shiftround - - " Time out on key codes but not mappings. -" Basically this makes terminal Vim work sanely. set notimeout set ttimeout set ttimeoutlen=10 -" Different Cursorshapes for the modes -let &t_SI = "\[6 q" -let &t_SR = "\[4 q" -let &t_EI = "\[2 q" - -" Better Completion -set complete=.,w,b,u,t -set completeopt=longest,menuone - -if &history < 1000 - set history=50 -endif - -if &tabpagemax < 50 - set tabpagemax=50 -endif - -if !empty(&viminfo) - set viminfo^=! -endif - -if !&scrolloff - set scrolloff=1 -endif -if !&sidescrolloff - set sidescrolloff=5 -endif -set display+=lastline - -" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, -" so that you can undo CTRL-U after inserting a line break. -inoremap u - -" Only do this part when compiled with support for autocommands. -if has("autocmd") - - " Enable file type detection. - " Use the default filetype settings, so that mail gets 'tw' set to 72, - " 'cindent' is on in C files, etc. - " Also load indent files, to automatically do language-dependent indenting. - filetype plugin indent on - - " Put these in an autocmd group, so that we can delete them easily. - augroup vimrcEx - au! - - " For all text files set 'textwidth' to 78 characters. - autocmd FileType text setlocal textwidth=78 - - " When editing a file, always jump to the last known cursor position. - " Don't do it when the position is invalid or when inside an event handler - " (happens when dropping a file on gvim). - " Also don't do it when the mark is in the first line, that is the default - " position when opening a file. - autocmd BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif - - augroup END -else -endif " has("autocmd") - - -syntax enable if has('gui_running') "set transparency=3 - " fix js regex syntax - set regexpengine=1 - syntax enable + set regexpengine=1 " fix js regex syntax endif -" This comes first, because we have mappings that depend on leader -" With a map leader it's possible to do extra key combinations -" i.e: w saves the current file let mapleader = "," -let g:mapleader = "," -let maplocalleader = ";" - -" This trigger takes advantage of the fact that the quickfix window can be -" easily distinguished by its file-type, qf. The wincmd J command is -" equivalent to the Ctrl+W, Shift+J shortcut telling Vim to move a window to -" the very bottom (see :help :wincmd and :help ^WJ). -autocmd FileType qf wincmd J - -" Dont show me any output when I build something -" Because I am using quickfix for errors -"nmap m :make - -" Some useful quickfix shortcuts -":cc see the current error -":cn next error -":cp previous error -":clist list all errors -map :cn -map :cp - -nnoremap q :Sayonara - -" Replace the current buffer with the given new file. That means a new file -" will be open in a buffer while the old one will be deleted -com! -nargs=1 -complete=file Breplace edit | bdelete # - -function! DeleteInactiveBufs() - "From tabpagebuflist() help, get a list of all buffers in all tabs - let tablist = [] - for i in range(tabpagenr('$')) - call extend(tablist, tabpagebuflist(i + 1)) - endfor - - "Below originally inspired by Hara Krishna Dara and Keith Roberts - "http://tech.groups.yahoo.com/group/vim/message/56425 - let nWipeouts = 0 - for i in range(1, bufnr('$')) - if bufexists(i) && !getbufvar(i,"&mod") && index(tablist, i) == -1 - "bufno exists AND isn't modified AND isn't in the list of buffers open in windows and tabs - silent exec 'bwipeout' i - let nWipeouts = nWipeouts + 1 - endif - endfor - echomsg nWipeouts . ' buffer(s) wiped out' -endfunction - -command! Ball :call DeleteInactiveBufs() - -" Toggle line numbers -nmap ll :set number! -nmap lr :set relativenumber! - -" Close quickfix easily -nnoremap a :cclose - -" Remove search highlight -nnoremap :nohlsearch - -" Better split switching -map j -map k -map h -map l - -" Center the screen -nnoremap zz - -" Move up and down on splitted lines (on small width screens) -map gk -map gj -map k gk -map j gj - -nnoremap :setlocal spell! spell? - -" Search mappings: These will make it so that going to the next one in a -" search will center on the line it's found in. -nnoremap n nzzzv -nnoremap N Nzzzv - -"nnoremap . :lcd %:p:h -autocmd BufEnter * silent! lcd %:p:h - -" trim all whitespaces away -nnoremap W :%s/\s\+$//:let @/='' - -" Do not show stupid q: window -map q: :q " dont save .netrwhist history let g:netrw_dirhistmax=0 @@ -264,72 +83,98 @@ let g:netrw_dirhistmax=0 " Allow saving of files as sudo when I forgot to start vim using sudo. cmap w!! w !sudo tee > /dev/null % -" never do this again --> :set paste :set no paste -let &t_SI .= "\[?2004h" -let &t_EI .= "\[?2004l" +" open help vertically +command! -nargs=* -complete=help Help vertical belowright help -inoremap [200~ XTermPasteBegin() +" Different Cursorshapes for the modes +let &t_SI = "\[6 q" +let &t_SR = "\[4 q" +let &t_EI = "\[2 q" -function! XTermPasteBegin() - set pastetoggle=[201~ - set paste - return "" -endfunction +" ==================== Remap Keys ==================== +" Remaps % to tab so navigate to matching brackets +nnoremap % +vnoremap % -" set 80 character line limit -"if exists('+colorcolumn') -" set colorcolumn=80 -"else -" au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1) -"endif +" Visual mode pressing * or # searches for the current selection +vnoremap * :call VisualSelection('f') +vnoremap # :call VisualSelection('b') -" ----------------------------------------- " -" File Type settings " -" ----------------------------------------- " +" Center, kill hl +nnoremap n nzzzv +nnoremap N Nzzzv +nnoremap :nohlsearch +nnoremap zz -au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4 -au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 -au BufNewFile,BufRead *.md setlocal noet ts=4 sw=4 -au BufNewFile,BufRead *.yml,*.yaml setlocal expandtab ts=2 sw=2 -au BufNewFile,BufRead *.cpp setlocal expandtab ts=2 sw=2 -au BufNewFile,BufRead *.hpp setlocal expandtab ts=2 sw=2 -au BufNewFile,BufRead *.json setlocal expandtab ts=2 sw=2 +" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, +" so that you can undo CTRL-U after inserting a line break. +inoremap u -augroup filetypedetect - au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux - au BufNewFile,BufRead .nginx.conf*,nginx.conf* setf nginx -augroup END +" Toggle line numbers and rulers +nmap ll :set number! +nmap lr :set relativenumber! +nmap cc :set cursorcolumn! +nmap cl :set cursorline! -au FileType nginx setlocal noet ts=4 sw=4 sts=4 +" Better split switching +map j +map k +map h +map l +map j +map k +map h +map l -" Go settings -au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4 +" Move up and down on split lines +map gk +map gj +map k gk +map j gj -" scala settings -autocmd BufNewFile,BufReadPost *.scala setl shiftwidth=2 expandtab +" Spell checking +nnoremap :setlocal spell! spell? +map ss :setlocal spell! +map sn ]s +map sp [s +map sa zg +map s? z= -" Markdown Settings -autocmd BufNewFile,BufReadPost *.md setl ts=4 sw=4 sts=4 expandtab +" trim all whitespaces away +nnoremap W :%s/\s\+$//:let @/='' -" lua settings -autocmd BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4 +" Do not show stupid q: window +map q: :q -" Dockerfile settings -autocmd FileType dockerfile set noexpandtab +" Paste Mode +set pastetoggle= -" shell/config/systemd settings -autocmd FileType fstab,systemd set noexpandtab -autocmd FileType gitconfig,sh,toml set noexpandtab +" ==================== File Type settings ==================== +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set noexpandtab +set shiftround +set smarttab -" python indent -autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab +au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.md setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.json setlocal et ts=2 sw=2 sts=2 +au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.md setlocal et ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.py setlocal et ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.yml,*.yaml setlocal et ts=2 sw=2 sts=2 +au BufNewFile,BufRead *.htm,*.html setlocal noet ts=4 sw=4 sts=4 -" toml settings -au BufRead,BufNewFile MAINTAINERS set ft=toml +au FileType dockerfile setlocal et ts=2 sw=2 sts=2 +au FileType nginx setlocal noet ts=4 sw=4 sts=4 +au FileType fstab,systemd set noet +au FileType gitconfig,sh,toml set noet -" Wildmenu completion {{{ +" ==================== Wildmenu ==================== set wildmenu -" set wildmode=list:longest set wildmode=list:full set wildignore+=.hg,.git,.svn " Version control @@ -348,17 +193,13 @@ set wildignore+=*.pyc " Python byte code set wildignore+=*.orig " Merge resolution files -" ----------------------------------------- " -" Plugin configs " -" ----------------------------------------- " - -" ==================== Fugitive ==================== +" ==================== PLUGIN: Fugitive ==================== nnoremap ga :Git add %:p nnoremap gs :Gstatus nnoremap gp :Gpush vnoremap gb :Gblame -" ==================== Lightline ==================== +" ==================== PLUGIN: Lightline ==================== " let g:lightline = { \ 'active': { @@ -459,7 +300,7 @@ let g:ctrlp_status_func = { \ 'prog': 'CtrlPStatusFunc_2', \ } -" ==================== NerdTree ==================== +" ==================== PLUGIN: NerdTree ==================== " For toggling nmap :NERDTreeToggle noremap n :NERDTreeToggle