mirror of
https://github.com/amix/vimrc
synced 2025-07-19 10:05:00 +08:00
merge
This commit is contained in:
@ -44,7 +44,7 @@
|
||||
" => General
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Sets how many lines of history VIM has to remember
|
||||
set history=10
|
||||
set history=500
|
||||
|
||||
" Enable filetype plugins
|
||||
filetype plugin on
|
||||
@ -84,9 +84,9 @@ set wildmenu
|
||||
" Ignore compiled files
|
||||
set wildignore=*.o,*~,*.pyc
|
||||
if has("win16") || has("win32")
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
||||
else
|
||||
set wildignore+=.git\*,.hg\*,.svn\*
|
||||
else
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
||||
endif
|
||||
|
||||
"Always show current position
|
||||
@ -102,11 +102,6 @@ set hid
|
||||
set backspace=eol,start,indent
|
||||
set whichwrap+=<,>,h,l
|
||||
|
||||
" In many terminal emulators the mouse works just fine, thus enable it.
|
||||
if has('mouse')
|
||||
set mouse=a
|
||||
endif
|
||||
|
||||
" Ignore case when searching
|
||||
set ignorecase
|
||||
|
||||
@ -136,6 +131,12 @@ set novisualbell
|
||||
set t_vb=
|
||||
set tm=500
|
||||
|
||||
" Properly disable sound on errors on MacVim
|
||||
if has("gui_macvim")
|
||||
autocmd GUIEnter * set vb t_vb=
|
||||
endif
|
||||
|
||||
|
||||
" Add a bit extra margin to the left
|
||||
set foldcolumn=1
|
||||
|
||||
@ -146,6 +147,11 @@ set foldcolumn=1
|
||||
" Enable syntax highlighting
|
||||
syntax enable
|
||||
|
||||
" Enable 256 colors palette in Gnome Terminal
|
||||
if $COLORTERM == 'gnome-terminal'
|
||||
set t_Co=256
|
||||
endif
|
||||
|
||||
try
|
||||
colorscheme desert
|
||||
catch
|
||||
@ -204,17 +210,13 @@ set wrap "Wrap lines
|
||||
""""""""""""""""""""""""""""""
|
||||
" Visual mode pressing * or # searches for the current selection
|
||||
" Super useful! From an idea by Michael Naumann
|
||||
vnoremap <silent> * :call VisualSelection('f', '')<CR>
|
||||
vnoremap <silent> # :call VisualSelection('b', '')<CR>
|
||||
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
|
||||
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Moving around, tabs, windows and buffers
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Treat long lines as break lines (useful when moving around in them)
|
||||
map j gj
|
||||
map k gk
|
||||
|
||||
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
|
||||
map <space> /
|
||||
map <c-space> ?
|
||||
@ -229,10 +231,13 @@ map <C-h> <C-W>h
|
||||
map <C-l> <C-W>l
|
||||
|
||||
" Close the current buffer
|
||||
map <leader>bd :Bclose<cr>
|
||||
map <leader>bd :Bclose<cr>:tabclose<cr>gT
|
||||
|
||||
" Close all the buffers
|
||||
map <leader>ba :1,1000 bd!<cr>
|
||||
map <leader>ba :bufdo bd<cr>
|
||||
|
||||
map <leader>l :bnext<cr>
|
||||
map <leader>h :bprevious<cr>
|
||||
|
||||
" Useful mappings for managing tabs
|
||||
map <leader>tn :tabnew<cr>
|
||||
@ -262,12 +267,7 @@ catch
|
||||
endtry
|
||||
|
||||
" Return to last edit position when opening files (You want this!)
|
||||
autocmd BufReadPost *
|
||||
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
||||
\ exe "normal! g`\"" |
|
||||
\ endif
|
||||
" Remember info about open buffers on close
|
||||
set viminfo^=%
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
@ -277,7 +277,7 @@ set viminfo^=%
|
||||
set laststatus=2
|
||||
|
||||
" Format the status line
|
||||
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
|
||||
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
@ -286,7 +286,7 @@ set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\
|
||||
" Remap VIM 0 to first non-blank character
|
||||
map 0 ^
|
||||
|
||||
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
|
||||
" Move a line of text using ALT+[jk] or Command+[jk] on mac
|
||||
nmap <M-j> mz:m+<cr>`z
|
||||
nmap <M-k> mz:m-2<cr>`z
|
||||
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
|
||||
@ -310,21 +310,21 @@ autocmd BufWrite *.coffee :call DeleteTrailingWS()
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Ack searching and cope displaying
|
||||
" requires ack.vim - it's much better than vimgrep/grep
|
||||
" => Ag searching and cope displaying
|
||||
" requires ag.vim - it's much better than vimgrep/grep
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" When you press gv you Ack after the selected text
|
||||
" When you press gv you Ag after the selected text
|
||||
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
|
||||
|
||||
" Open Ack and put the cursor in the right position
|
||||
map <leader>g :Ack
|
||||
" Open Ag and put the cursor in the right position
|
||||
map <leader>g :Ag
|
||||
|
||||
" When you press <leader>r you can search and replace the selected text
|
||||
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
|
||||
|
||||
" Do :help cope if you are unsure what cope is. It's super useful!
|
||||
"
|
||||
" When you search with Ack, display your results in cope by doing:
|
||||
" When you search with Ag, display your results in cope by doing:
|
||||
" <leader>cc
|
||||
"
|
||||
" To go to the next search result do:
|
||||
@ -383,17 +383,13 @@ function! VisualSelection(direction, extra_filter) range
|
||||
let l:saved_reg = @"
|
||||
execute "normal! vgvy"
|
||||
|
||||
let l:pattern = escape(@", '\\/.*$^~[]')
|
||||
let l:pattern = escape(@", "\\/.*'$^~[]")
|
||||
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
||||
|
||||
if a:direction == 'b'
|
||||
execute "normal ?" . l:pattern . "^M"
|
||||
elseif a:direction == 'gv'
|
||||
call CmdLine("Ack \"" . l:pattern . "\" " )
|
||||
if a:direction == 'gv'
|
||||
call CmdLine("Ag '" . l:pattern . "' " )
|
||||
elseif a:direction == 'replace'
|
||||
call CmdLine("%s" . '/'. l:pattern . '/')
|
||||
elseif a:direction == 'f'
|
||||
execute "normal /" . l:pattern . "^M"
|
||||
endif
|
||||
|
||||
let @/ = l:pattern
|
||||
@ -405,7 +401,7 @@ endfunction
|
||||
function! HasPaste()
|
||||
if &paste
|
||||
return 'PASTE MODE '
|
||||
en
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
@ -429,3 +425,8 @@ function! <SID>BufcloseCloseIt()
|
||||
execute("bdelete! ".l:currentBufNum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Make VIM remember position in file after reopen
|
||||
" if has("autocmd")
|
||||
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
"endif
|
||||
|
@ -10,21 +10,17 @@
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set font according to system
|
||||
if has("mac") || has("macunix")
|
||||
set gfn=Source\ Code\ Pro:h15,Menlo:h15
|
||||
set gfn=Hack:h14,Source\ Code\ Pro:h15,Menlo:h15
|
||||
elseif has("win16") || has("win32")
|
||||
set gfn=Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
|
||||
set gfn=Hack:h14,Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
|
||||
elseif has("gui_gtk2")
|
||||
set gfn=Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
|
||||
elseif has("linux")
|
||||
set gfn=Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
|
||||
set gfn=Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
|
||||
elseif has("unix")
|
||||
set gfn=Monospace\ 11
|
||||
endif
|
||||
|
||||
" Open MacVim in fullscreen mode
|
||||
if has("gui_macvim")
|
||||
set fuoptions=maxvert,maxhorz
|
||||
au GUIEnter * set fullscreen
|
||||
endif
|
||||
|
||||
" Disable scrollbars (real hackers don't use scrollbars for navigation!)
|
||||
set guioptions-=r
|
||||
set guioptions-=R
|
||||
@ -32,20 +28,15 @@ set guioptions-=l
|
||||
set guioptions-=L
|
||||
|
||||
" Colorscheme
|
||||
if has("gui_running")
|
||||
set background=dark
|
||||
colorscheme peaksea
|
||||
else
|
||||
colorscheme desert
|
||||
let g:colors_name="desert"
|
||||
endif
|
||||
set background=dark
|
||||
colorscheme peaksea
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Fast editing and reloading of vimrc configs
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
map <leader>e :e! ~/.vim_runtime/my_configs.vim<cr>
|
||||
autocmd! bufwritepost vimrc source ~/.vim_runtime/my_configs.vim
|
||||
autocmd! bufwritepost ~/.vim_runtime/my_configs.vim source ~/.vim_runtime/my_configs.vim
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
@ -103,7 +94,6 @@ inoremap $3 {}<esc>i
|
||||
inoremap $4 {<esc>o}<esc>O
|
||||
inoremap $q ''<esc>i
|
||||
inoremap $e ""<esc>i
|
||||
inoremap $t <><esc>i
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
@ -12,11 +12,14 @@ au FileType python map <buffer> F :set foldmethod=indent<cr>
|
||||
au FileType python inoremap <buffer> $r return
|
||||
au FileType python inoremap <buffer> $i import
|
||||
au FileType python inoremap <buffer> $p print
|
||||
au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
|
||||
au FileType python inoremap <buffer> $f #--- <esc>a
|
||||
au FileType python map <buffer> <leader>1 /class
|
||||
au FileType python map <buffer> <leader>2 /def
|
||||
au FileType python map <buffer> <leader>C ?class
|
||||
au FileType python map <buffer> <leader>D ?def
|
||||
au FileType python set cindent
|
||||
au FileType python set cinkeys-=0#
|
||||
au FileType python set indentkeys-=0#
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
@ -30,7 +33,7 @@ au FileType javascript imap <c-t> $log();<esc>hi
|
||||
au FileType javascript imap <c-a> alert();<esc>hi
|
||||
|
||||
au FileType javascript inoremap <buffer> $r return
|
||||
au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi
|
||||
au FileType javascript inoremap <buffer> $f //--- PH<esc>FP2xi
|
||||
|
||||
function! JavaScriptFold()
|
||||
setl foldmethod=syntax
|
||||
@ -54,3 +57,21 @@ endfunction
|
||||
au FileType coffee call CoffeeScriptFold()
|
||||
|
||||
au FileType gitcommit call setpos('.', [0, 1, 1, 0])
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Shell section
|
||||
""""""""""""""""""""""""""""""
|
||||
if exists('$TMUX')
|
||||
if has('nvim')
|
||||
set termguicolors
|
||||
else
|
||||
set term=screen-256color
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Twig section
|
||||
""""""""""""""""""""""""""""""
|
||||
autocmd BufRead *.twig set syntax=html filetype=html
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Important:
|
||||
" Important:
|
||||
" This requries that you install https://github.com/amix/vimrc !
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
@ -30,13 +30,10 @@ map <leader>f :MRU<CR>
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => YankRing
|
||||
" => YankStack
|
||||
""""""""""""""""""""""""""""""
|
||||
if has("win16") || has("win32")
|
||||
" Don't do anything
|
||||
else
|
||||
let g:yankring_history_dir = '~/.vim_runtime/temp_dirs/'
|
||||
endif
|
||||
nmap <c-p> <Plug>yankstack_substitute_older_paste
|
||||
nmap <c-P> <Plug>yankstack_substitute_newer_paste
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
@ -76,8 +73,12 @@ set grepprg=/bin/grep\ -nH
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Nerd Tree
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:NERDTreeWinPos = "right"
|
||||
let NERDTreeShowHidden=0
|
||||
let NERDTreeIgnore = ['\.pyc$', '__pycache__']
|
||||
let g:NERDTreeWinSize=35
|
||||
map <leader>nn :NERDTreeToggle<cr>
|
||||
map <leader>nb :NERDTreeFromBookmark
|
||||
map <leader>nb :NERDTreeFromBookmark<Space>
|
||||
map <leader>nf :NERDTreeFind<cr>
|
||||
|
||||
|
||||
@ -96,9 +97,32 @@ au FileType mako vmap Si S"i${ _(<esc>2f"a) }<esc>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => vim-airline config (force color)
|
||||
" => lightline
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:airline_theme="luna"
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'wombat',
|
||||
\ }
|
||||
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'wombat',
|
||||
\ 'active': {
|
||||
\ 'left': [ ['mode', 'paste'],
|
||||
\ ['fugitive', 'readonly', 'filename', 'modified'] ],
|
||||
\ 'right': [ [ 'lineinfo' ], ['percent'] ]
|
||||
\ },
|
||||
\ 'component': {
|
||||
\ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}',
|
||||
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
|
||||
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
|
||||
\ },
|
||||
\ 'component_visible_condition': {
|
||||
\ 'readonly': '(&filetype!="help"&& &readonly)',
|
||||
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
|
||||
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
|
||||
\ },
|
||||
\ 'separator': { 'left': ' ', 'right': ' ' },
|
||||
\ 'subseparator': { 'left': ' ', 'right': ' ' }
|
||||
\ }
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Vimroom
|
||||
@ -109,7 +133,37 @@ let g:goyo_margin_bottom = 2
|
||||
nnoremap <silent> <leader>z :Goyo<cr>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Vim-go
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:go_fmt_command = "goimports"
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Syntastic (syntax checker)
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Python
|
||||
let g:syntastic_python_checkers=['pyflakes']
|
||||
|
||||
" Javascript
|
||||
let g:syntastic_javascript_checkers = ['jshint']
|
||||
|
||||
" Go
|
||||
let g:syntastic_auto_loc_list = 1
|
||||
let g:syntastic_go_checkers = ['go', 'golint', 'errcheck']
|
||||
|
||||
" Custom CoffeeScript SyntasticCheck
|
||||
func! SyntasticCheckCoffeescript()
|
||||
let l:filename = substitute(expand("%:p"), '\(\w\+\)\.coffee', '.coffee.\1.js', '')
|
||||
execute "tabedit " . l:filename
|
||||
execute "SyntasticCheck"
|
||||
execute "Errors"
|
||||
endfunc
|
||||
nnoremap <silent> <leader>c :call SyntasticCheckCoffeescript()<cr>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Git gutter (Git diff)
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:gitgutter_enabled=0
|
||||
nnoremap <silent> <leader>d :GitGutterToggle<cr>
|
||||
|
Reference in New Issue
Block a user