From ca48415e5ef8dcd90ffd935884946585f0061262 Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Sun, 17 Dec 2017 15:23:47 +0100 Subject: [PATCH] Vim reconfig --- .gitmodules | 15 +- .vim/after/ftplugin/java.vim | 2 + .vim/after/ftplugin/javascript.vim | 2 + .vim/bundle/ag.vim | 1 - .vim/bundle/nerdcommenter | 2 +- .vim/bundle/nerdtree | 1 - .vim/bundle/supertab | 2 +- .vim/bundle/tagbar | 1 - .vim/bundle/vim-fugitive | 1 - .vim/bundle/vim-gitgutter | 2 +- .vim/bundle/vim-go | 2 +- .vim/bundle/vim-javascript | 2 +- .vim/bundle/vim-lastplace | 1 + .vim/bundle/vim-startify | 2 +- .vimrc | 234 +++++++++++------------------ 15 files changed, 102 insertions(+), 168 deletions(-) create mode 100644 .vim/after/ftplugin/java.vim create mode 100644 .vim/after/ftplugin/javascript.vim delete mode 160000 .vim/bundle/ag.vim delete mode 160000 .vim/bundle/nerdtree delete mode 160000 .vim/bundle/tagbar delete mode 160000 .vim/bundle/vim-fugitive create mode 160000 .vim/bundle/vim-lastplace diff --git a/.gitmodules b/.gitmodules index 95a7aa6..2b27c38 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule ".vim/bundle/ag.vim"] - path = .vim/bundle/ag.vim - url = https://github.com/rking/ag.vim [submodule ".vim/bundle/ctrlp.vim"] path = .vim/bundle/ctrlp.vim url = https://github.com/kien/ctrlp.vim @@ -10,12 +7,6 @@ [submodule ".vim/bundle/nerdcommenter"] path = .vim/bundle/nerdcommenter url = https://github.com/scrooloose/nerdcommenter -[submodule ".vim/bundle/nerdtree"] - path = .vim/bundle/nerdtree - url = https://github.com/scrooloose/nerdtree -[submodule ".vim/bundle/vim-fugitive"] - path = .vim/bundle/vim-fugitive - url = https://github.com/tpope/vim-fugitive [submodule ".vim/bundle/vim-showmarks"] path = .vim/bundle/vim-showmarks url = https://github.com/jacquesbh/vim-showmarks @@ -31,9 +22,6 @@ [submodule ".vim/bundle/supertab"] path = .vim/bundle/supertab url = https://github.com/ervandew/supertab -[submodule ".vim/bundle/tagbar"] - path = .vim/bundle/tagbar - url = https://github.com/majutsushi/tagbar [submodule ".vim/bundle/vim-pathogen"] path = .vim/bundle/vim-pathogen url = https://github.com/tpope/vim-pathogen.git @@ -49,3 +37,6 @@ [submodule ".vim/bundle/vim-javascript"] path = .vim/bundle/vim-javascript url = https://github.com/pangloss/vim-javascript.git +[submodule ".vim/bundle/vim-lastplace"] + path = .vim/bundle/vim-lastplace + url = https://github.com/farmergreg/vim-lastplace.git diff --git a/.vim/after/ftplugin/java.vim b/.vim/after/ftplugin/java.vim new file mode 100644 index 0000000..5284eb6 --- /dev/null +++ b/.vim/after/ftplugin/java.vim @@ -0,0 +1,2 @@ +setlocal shiftwidth=4 +setlocal expandtab diff --git a/.vim/after/ftplugin/javascript.vim b/.vim/after/ftplugin/javascript.vim new file mode 100644 index 0000000..ad650e2 --- /dev/null +++ b/.vim/after/ftplugin/javascript.vim @@ -0,0 +1,2 @@ +setlocal shiftwidth=2 +setlocal expandtab diff --git a/.vim/bundle/ag.vim b/.vim/bundle/ag.vim deleted file mode 160000 index 4a0dd6e..0000000 --- a/.vim/bundle/ag.vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4a0dd6e190f446e5a016b44fdaa2feafc582918e diff --git a/.vim/bundle/nerdcommenter b/.vim/bundle/nerdcommenter index 2859027..fd61bc7 160000 --- a/.vim/bundle/nerdcommenter +++ b/.vim/bundle/nerdcommenter @@ -1 +1 @@ -Subproject commit 285902752f7ab2052ac700a6d29b263dd5788afb +Subproject commit fd61bc71f64c8accf86f06c633fd19b205efa85b diff --git a/.vim/bundle/nerdtree b/.vim/bundle/nerdtree deleted file mode 160000 index 5782b22..0000000 --- a/.vim/bundle/nerdtree +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5782b228e495c733af4ba2e547e5dc44ebc8bc25 diff --git a/.vim/bundle/supertab b/.vim/bundle/supertab index 22aac5c..40fe711 160000 --- a/.vim/bundle/supertab +++ b/.vim/bundle/supertab @@ -1 +1 @@ -Subproject commit 22aac5c2cb6a8ebe906bf1495eb727717390e62e +Subproject commit 40fe711e088e2ab346738233dd5adbb1be355172 diff --git a/.vim/bundle/tagbar b/.vim/bundle/tagbar deleted file mode 160000 index 59ea6d6..0000000 --- a/.vim/bundle/tagbar +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 59ea6d656a0b5190f6f8f3fff44197d752782cc6 diff --git a/.vim/bundle/vim-fugitive b/.vim/bundle/vim-fugitive deleted file mode 160000 index 8f60d1d..0000000 --- a/.vim/bundle/vim-fugitive +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8f60d1d459362771cb68c0097565efdf52e62ec3 diff --git a/.vim/bundle/vim-gitgutter b/.vim/bundle/vim-gitgutter index dc73a81..1e60667 160000 --- a/.vim/bundle/vim-gitgutter +++ b/.vim/bundle/vim-gitgutter @@ -1 +1 @@ -Subproject commit dc73a81bfe59a9de090b89a1312ded3c6f6a6f89 +Subproject commit 1e60667322b7cd1bfcba98762fbba746a888d21a diff --git a/.vim/bundle/vim-go b/.vim/bundle/vim-go index 52c5b1f..40e2e19 160000 --- a/.vim/bundle/vim-go +++ b/.vim/bundle/vim-go @@ -1 +1 @@ -Subproject commit 52c5b1f74dade7ef21b34675751cd4a7b3ee2d03 +Subproject commit 40e2e19926b2350f5664f12779d485fd2ef55856 diff --git a/.vim/bundle/vim-javascript b/.vim/bundle/vim-javascript index ee376ba..7c73d8e 160000 --- a/.vim/bundle/vim-javascript +++ b/.vim/bundle/vim-javascript @@ -1 +1 @@ -Subproject commit ee376ba5c828dc5f5266f80636c2ad212ac4806d +Subproject commit 7c73d8e1f9ce020ee8ea2ab0af60e9f8fef6c90d diff --git a/.vim/bundle/vim-lastplace b/.vim/bundle/vim-lastplace new file mode 160000 index 0000000..102b683 --- /dev/null +++ b/.vim/bundle/vim-lastplace @@ -0,0 +1 @@ +Subproject commit 102b68348eff0d639ce88c5094dab0fdbe4f7c55 diff --git a/.vim/bundle/vim-startify b/.vim/bundle/vim-startify index 7f910ed..c905a0c 160000 --- a/.vim/bundle/vim-startify +++ b/.vim/bundle/vim-startify @@ -1 +1 @@ -Subproject commit 7f910ed4367de96310fedc98d5a12b97173a405f +Subproject commit c905a0c9598c72cb4311ca88f3eb664d05e4d66b diff --git a/.vimrc b/.vimrc index 68c4d98..3af3ceb 100644 --- a/.vimrc +++ b/.vimrc @@ -6,82 +6,39 @@ set nocompatible " For multi-byte character support (CJK support, for example): set fileencodings=utf-8,cp1251,latin1 -" Indentation settings. Dragons ahead! -set tabstop=4 " The width of the TAB character, plain and simple. - -set shiftwidth=4 " Auto indentation, >>, <<, == - -set softtabstop=0 " Number of spaces that a counts for while performing editing - " operations, like inserting a or using . - -set copyindent " Copy the structure of the existing lines indent when - " autoindenting a new line (no tab-space reconstruction). - -set preserveindent " When changing the indent of the current line, preserve as much - " of the indent structure as possible. - -set noexpandtab " Use the appropriate number of spaces to insert a . - " Spaces are used in indents with the '>' and '<' commands - " and when 'autoindent' is on. To insert a real tab when - " 'expandtab' is on, use CTRL-V . - -set nowrap " No text wrapping - +set nowrap set modeline -" Suggested config options -set cf " Enable error files & error jumping -set clipboard+=unnamed " Yanks go to clipboard instead +" Enable error files and error jumping. +set cf -set number " Show line numbers. +" Show line numbers. +set number -set showmatch " When a bracket is inserted, briefly jump to the matching - " one. The jump is only done if the match can be seen on the - " screen. The time to show the match can be set with - " 'matchtime'. - -set hlsearch " When there is a previous search pattern, highlight all - " its matches. +" Highlight matching bracket. +set showmatch +" Search options. +set hlsearch set ignorecase -set smartcase " Override the 'ignorecase' option if the search pattern - " contains upper case characters. +set smartcase -set formatoptions=c,q,r " This is a sequence of letters which describes how - " automatic formatting is to be done. - " - " letter meaning when present in 'formatoptions' - " ------ --------------------------------------- - " c Auto-wrap comments using textwidth, inserting - " the current comment leader automatically. - " q Allow formatting of comments with "gq". - " r Automatically insert the current comment leader - " after hitting in Insert mode. - " t Auto-wrap text using textwidth (does not apply - " to comments) - -set background=dark " When set to "dark", Vim will try to use colors that look - " good on a dark background. When set to "light", Vim will - " try to use colors that look good on a light background. - " Any other value is illegal. - -set list " Display tabs and trailing spaces +" Display tabs and trailing spaces. +set list if has("mouse") - set mouse=a " Enable the use of the mouse. + " Enable the use of the mouse. + set mouse=a endif if exists("+undofile") - " Enable the persistent undo file(s) + " Enable the persistent undo file(s) set undodir=~/.vim/undo set undofile endif set switchbuf+=usetab " Switch to existing tab; open a new tab for the new buf -" Custom status line with Git Branch name -set statusline=%<%f\ %h%m%r\ %{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P - let mapleader="," filetype off @@ -89,46 +46,84 @@ filetype off runtime bundle/vim-pathogen/autoload/pathogen.vim execute pathogen#infect() -let g:SuperTabDefaultCompletionType = "context" -let g:go_fmt_command = "goimports" - +set background=dark colorscheme mydark -nnoremap ` :ShowMarksOnce` -"command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | wincmd p +" Configure plugins. + +" supertab: tab-complete based on preceding characters (::, ->, . etc). +let g:SuperTabDefaultCompletionType = "context" + +" vim-go: not just format the code; insert imports, too. +let g:go_fmt_command = "goimports" -" saving cursor pos and such " Tell vim to remember certain things when we exit -" '10 : marks will be remembered for up to 10 previously edited files -" "100 : will save up to 100 lines for each register -" :20 : up to 20 lines of command-line history will be remembered +" 'N : marks will be remembered for up to N previously edited files +" "N : will save up to N lines for each register +" :N : up to N lines of command-line history will be remembered " % : saves and restores the buffer list " n... : where to save the viminfo files -set viminfo='10,\"100,:20,n~/.viminfo -function! ResCur() - if line("'\"") <= line("$") - normal! g`" - return 1 - endif -endfunction - -augroup resCur - autocmd! - autocmd BufWinEnter * call ResCur() -augroup END +set viminfo='10,\"100,:100,n~/.viminfo +" Line width limit hint. augroup EditorWidth - autocmd BufEnter * highlight OverLength ctermbg=darkred - autocmd BufEnter * match OverLength /\%81v.*/ - autocmd BufEnter *.go match OverLength /\%101v.*/ - autocmd BufEnter *.yml match OverLength /\%151v.*/ - autocmd BufEnter *.data match OverLength /\%151v.*/ - autocmd BufEnter *.java match OverLength /\%101v.*/ + " colorcolumn breaks copy from terminal, so we use this instead. + au! + au BufEnter * highlight OverLength ctermbg=darkred + au BufEnter * match OverLength /\%81v./ + + au BufEnter *.go match OverLength /\%101v./ + au BufEnter *.java match OverLength /\%101v./ + + au BufEnter *.yml match OverLength /$$/ + au BufEnter *.data match OverLength /$$/ + au BufEnter .vimrc match OverLength /$$/ augroup END -" Window navigation map +" Custom filetypes. +au BufNewFile,BufRead *.pi setf python + +filetype indent off + +" Automatically insert the current comment leader after hitting in Insert mode. +set formatoptions=r + +" Indentation settings. + +" Width of the TAB column displayed on the screen, in spaces. A value of 8 +" means that it will be consistent with console, printer and others. +set tabstop=8 + +" Number of spaces inserted when pressing TAB, or removed when pressing +" BACKSPACE. If 0, TAB inserts spaces, and automatically converts +" them to TAB characters per and . +set softtabstop=0 + +" shiftwidth: number of spaces inserted when using indentation methods, +" like >>, <<, ==. If shiftwidth=tabstop, a TAB character is inserted instead +" of spaces. When shifting, spaces will be replaced by TAB characters as +" necessary. +set shiftwidth=8 +" smarttab: typing TAB in front of the line behaves like >>, while in text, +" typing TAB will add spaces and convert spaces to TAB +" characters per and . +set smarttab + +" When a new line is added, keep indentation level of the previous line. +set autoindent +" When a new line is added, copy exactly indentation level of the previous +" line (i.e. do not try to replace spaces with tabs). +set copyindent +set preserveindent + +" expandtab: ALWAYS insert spaces when typing TAB. +set noexpandtab + +" Shortcuts. +nnoremap ` :ShowMarksOnce` noremap :let @/ = "" +" Window navigation map. fu! Amap(key, cmd, ...) let l:cr="" let l:p=":" @@ -147,52 +142,19 @@ fu! Amap(key, cmd, ...) exe "imap " . l:key . " " . l:key . "" endf -"call Amap("C-t", "tabnew") -"call Amap("C-b", ":ls:b", 0) -"call Amap("C-w", "close") - -"call Amap("F2", "update") -"call Amap("F3", "NERDTreeToggle") -"call Amap("F7", "TagbarToggle") - -" Navigate by tabs with Shift+Left/Right -"call Amap("S-Left", "tabprev") -"call Amap("S-Right", "tabnext") - -" Navigate by windows with Ctrl+direction -"call Amap("C-Left", "wincmd h") -"call Amap("C-Down", "wincmd j") -"call Amap("C-Up", "wincmd k") -"call Amap("C-Right", "wincmd l") - -" Resize windows with Alt+direction -call Amap("M-Left", "vertical resize -1") -call Amap("M-Down", "resize +1") -call Amap("M-Up", "resize -1") -call Amap("M-Right", "vertical resize +1") - -" Move windows with Ctrl+Shift+direction -"call Amap("C-S-Left", "wincmd H") -"call Amap("C-S-Down", "wincmd J") -"call Amap("C-S-Up", "wincmd K") -"call Amap("C-S-Right", "wincmd L") +call Amap("C-t", "tabnew") +call Amap("C-b", ":ls:b", 0) +call Amap("C-w", "close") " Backspace navigates 'Back' nmap nmap -"call Amap("C-p", "cp") -"call Amap("C-n", "cn") -" Working with SSH clipboard +" Working with clipboard over SSH " This doesn't paste; it prepares vim to do so. Use ^D when finished. call Amap("zp", "r !cat", 1) -"setl noai nocin nosi inde= formatoptions-=c formatoptions-=r formatoptions-=o nonumber " This doesn't yank; it (un)prepares vim to do so. -"call Amap("zy", "setl paste! number! list! NoShowMarks GitGutterToggle", 1) - -"noremap y :w !printf "\e]52;c;$(base64 -w0)\a" -"noremap y :w !printf "\eP\e]52;c;$(base64 -w0)\a\e\\" - +call Amap("zy", "setl paste! number! list! NoShowMarks GitGutterToggle", 1) " https://github.com/mobile-shell/mosh/issues/637 D'oh, really Mosh?! " Well at least works with SecureShell + screen. noremap y :w !printf " @@ -200,12 +162,8 @@ noremap y :w !printf " \\e]52;c;$(base64 -w0)\a \$([[ "${TERM/-*/}" == screen ]] && printf "\e\\")" -" custom filetypes -au BufNewFile,BufRead *.fasm setf fasm -au BufNewFile,BufRead *.pi setf python - +" Convenient write commands. w!! for sudo, others for holding Shift for too long. cmap w!! %!sudo tee >/dev/null % - command WQ wq command Wq wq command W w @@ -213,23 +171,7 @@ command Q q command Qa qa command QA qa -" keep in sync with https://github.com/dasfoo/travis/blob/master/go.sh -let g:go_metalinter_command = "gometalinter " . - \ "--disable=unconvert " . - \ "--disable=dupl " . - \ "--disable=gas " . - \ "--enable=testify " . - \ "--enable=test ". - \ "--enable=goimports " . - \ "--enable=gofmt " . - \ "--enable=lll " . - \ "--enable=misspell " . - \ "--deadline=1m " . - \ "--line-length=100 " . - \ "--exclude='\.pb\.go:' " . - \ "./..." - - +" Local machine overrides. if filereadable(expand("~/.vimrc_local")) source ~/.vimrc_local endif