mirror of
https://github.com/amix/vimrc
synced 2025-07-06 16:05:01 +08:00
Delete useless plugins, modify default configs and add my personal configs.
This commit is contained in:
@ -37,16 +37,12 @@ set history=500
|
||||
filetype plugin on
|
||||
filetype indent on
|
||||
|
||||
" Set to auto read when a file is changed from the outside
|
||||
set autoread
|
||||
au FocusGained,BufEnter * checktime
|
||||
|
||||
" With a map leader it's possible to do extra key combinations
|
||||
" like <leader>w saves the current file.
|
||||
" To override this behavior and set it back to '\' (or any other
|
||||
" character) add the following to your ~/.vim_runtime/eden_configs.vim file:
|
||||
" let g:amix_leader='\'
|
||||
" The method comes from sfp13/spf13-vim.
|
||||
" The method comes from spf13/spf13-vim.
|
||||
if !exists('g:amix_leader')
|
||||
let mapleader = ','
|
||||
else
|
||||
@ -56,7 +52,7 @@ endif
|
||||
" Fast saving
|
||||
nmap <leader>w :w!<cr>
|
||||
|
||||
" :W sudo saves the file
|
||||
" :W sudo saves the file
|
||||
" (useful for handling the permission-denied error)
|
||||
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
|
||||
|
||||
@ -68,7 +64,7 @@ command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
|
||||
set so=7
|
||||
|
||||
" Avoid garbled characters in Chinese language windows OS
|
||||
let $LANG='en'
|
||||
let $LANG='en'
|
||||
set langmenu=en
|
||||
source $VIMRUNTIME/delmenu.vim
|
||||
source $VIMRUNTIME/menu.vim
|
||||
@ -107,16 +103,16 @@ set smartcase
|
||||
set hlsearch
|
||||
|
||||
" Makes search act like search in modern browsers
|
||||
set incsearch
|
||||
set incsearch
|
||||
|
||||
" Don't redraw while executing macros (good performance config)
|
||||
set lazyredraw
|
||||
set lazyredraw
|
||||
|
||||
" For regular expressions turn magic on
|
||||
set magic
|
||||
|
||||
" Show matching brackets when text indicator is over them
|
||||
set showmatch
|
||||
set showmatch
|
||||
" How many tenths of a second to blink when matching brackets
|
||||
set mat=2
|
||||
|
||||
@ -140,7 +136,7 @@ set foldcolumn=1
|
||||
" => Colors and Fonts
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Enable syntax highlighting
|
||||
syntax enable
|
||||
syntax enable
|
||||
|
||||
" Enable 256 colors palette in Gnome Terminal
|
||||
if $COLORTERM == 'gnome-terminal'
|
||||
@ -212,49 +208,7 @@ vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Moving around, tabs, windows and buffers
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
|
||||
map <space> /
|
||||
map <C-space> ?
|
||||
|
||||
" Disable highlight when <leader><cr> is pressed
|
||||
map <silent> <leader><cr> :noh<cr>
|
||||
|
||||
" Smart way to move between windows
|
||||
map <C-j> <C-W>j
|
||||
map <C-k> <C-W>k
|
||||
map <C-h> <C-W>h
|
||||
map <C-l> <C-W>l
|
||||
|
||||
" Close the current buffer
|
||||
map <leader>bd :Bclose<cr>:tabclose<cr>gT
|
||||
|
||||
" Close all the buffers
|
||||
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>
|
||||
map <leader>to :tabonly<cr>
|
||||
map <leader>tc :tabclose<cr>
|
||||
map <leader>tm :tabmove
|
||||
map <leader>t<leader> :tabnext
|
||||
|
||||
" Let 'tl' toggle between this and the last accessed tab
|
||||
let g:lasttab = 1
|
||||
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
|
||||
au TabLeave * let g:lasttab = tabpagenr()
|
||||
|
||||
|
||||
" Opens a new tab with the current buffer's path
|
||||
" Super useful when editing files in the same directory
|
||||
map <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/
|
||||
|
||||
" Switch CWD to the directory of the open buffer
|
||||
map <leader>cd :cd %:p:h<cr>:pwd<cr>
|
||||
|
||||
" Specify the behavior when switching between buffers
|
||||
" Specify the behavior when switching between buffers
|
||||
try
|
||||
set switchbuf=useopen,usetab,newtab
|
||||
set stal=2
|
||||
@ -278,22 +232,6 @@ set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Editing mappings
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Remap VIM 0 to first non-blank character
|
||||
map 0 ^
|
||||
|
||||
" 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
|
||||
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
|
||||
|
||||
if has("mac") || has("macunix")
|
||||
nmap <D-j> <M-j>
|
||||
nmap <D-k> <M-k>
|
||||
vmap <D-j> <M-j>
|
||||
vmap <D-k> <M-k>
|
||||
endif
|
||||
|
||||
" Delete trailing white space on save, useful for some filetypes ;)
|
||||
fun! CleanExtraSpaces()
|
||||
let save_cursor = getpos(".")
|
||||
|
@ -1,46 +1,23 @@
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Important:
|
||||
" Important:
|
||||
" This requries that you install https://github.com/amix/vimrc !
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => GUI related
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set font according to system
|
||||
if has("mac") || has("macunix")
|
||||
set gfn=IBM\ Plex\ Mono:h14,Hack:h14,Source\ Code\ Pro:h15,Menlo:h15
|
||||
elseif has("win16") || has("win32")
|
||||
set gfn=IBM\ Plex\ Mono:h14,Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
|
||||
elseif has("gui_gtk2")
|
||||
set gfn=IBM\ Plex\ Mono\ 14,:Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
|
||||
elseif has("linux")
|
||||
set gfn=IBM\ Plex\ Mono\ 14,:Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
|
||||
elseif has("unix")
|
||||
set gfn=Monospace\ 11
|
||||
endif
|
||||
|
||||
" Disable scrollbars (real hackers don't use scrollbars for navigation!)
|
||||
set guioptions-=r
|
||||
set guioptions-=R
|
||||
set guioptions-=l
|
||||
set guioptions-=L
|
||||
|
||||
" Colorscheme
|
||||
set background=dark
|
||||
colorscheme peaksea
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Fast editing and reloading of vimrc configs
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
map <leader>e :e! ~/.vim_runtime/my_configs.vim<cr>
|
||||
" autocmd! bufwritepost ~/.vim_runtime/my_configs.vim source ~/.vim_runtime/my_configs.vim
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Turn persistent undo on
|
||||
" => Turn persistent undo on
|
||||
" means that you can undo even when you close a buffer/VIM
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
try
|
||||
@ -53,48 +30,14 @@ endtry
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Command mode related
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Smart mappings on the command line
|
||||
cno $h e ~/
|
||||
cno $d e ~/Desktop/
|
||||
cno $j e ./
|
||||
cno $c e <C-\>eCurrentFileDir("e")<cr>
|
||||
|
||||
" $q is super useful when browsing on the command line
|
||||
" it deletes everything until the last slash
|
||||
cno $q <C-\>eDeleteTillSlash()<cr>
|
||||
|
||||
" Bash like keys for the command line
|
||||
cnoremap <C-A> <Home>
|
||||
cnoremap <C-E> <End>
|
||||
cnoremap <C-K> <C-U>
|
||||
cnoremap <C-A> <Home>
|
||||
cnoremap <C-E> <End>
|
||||
cnoremap <C-K> <C-U>
|
||||
|
||||
cnoremap <C-P> <Up>
|
||||
cnoremap <C-N> <Down>
|
||||
|
||||
" Map ½ to something useful
|
||||
map ½ $
|
||||
cmap ½ $
|
||||
imap ½ $
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Parenthesis/bracket
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
|
||||
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
|
||||
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
|
||||
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
|
||||
vnoremap $q <esc>`>a'<esc>`<i'<esc>
|
||||
vnoremap $e <esc>`>a`<esc>`<i`<esc>
|
||||
|
||||
" Map auto complete of (, ", ', [
|
||||
inoremap $1 ()<esc>i
|
||||
inoremap $2 []<esc>i
|
||||
inoremap $3 {}<esc>i
|
||||
inoremap $4 {<esc>o}<esc>O
|
||||
inoremap $q ''<esc>i
|
||||
inoremap $e ""<esc>i
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => General abbreviations
|
||||
@ -117,31 +60,6 @@ if executable('ag')
|
||||
let g:ackprg = 'ag --vimgrep --smart-case'
|
||||
endif
|
||||
|
||||
" When you press gv you Ack 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
|
||||
|
||||
" 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:
|
||||
" <leader>cc
|
||||
"
|
||||
" To go to the next search result do:
|
||||
" <leader>n
|
||||
"
|
||||
" To go to the previous search results do:
|
||||
" <leader>p
|
||||
"
|
||||
map <leader>cc :botright cope<cr>
|
||||
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
|
||||
map <leader>n :cn<cr>
|
||||
map <leader>p :cp<cr>
|
||||
|
||||
" Make sure that enter is never overriden in the quickfix window
|
||||
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
|
||||
|
||||
@ -149,26 +67,4 @@ autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Helper functions
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
func! DeleteTillSlash()
|
||||
let g:cmd = getcmdline()
|
||||
|
||||
if has("win16") || has("win32")
|
||||
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
|
||||
else
|
||||
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
|
||||
endif
|
||||
|
||||
if g:cmd == g:cmd_edited
|
||||
if has("win16") || has("win32")
|
||||
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
|
||||
else
|
||||
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
|
||||
endif
|
||||
endif
|
||||
|
||||
return g:cmd_edited
|
||||
endfunc
|
||||
|
||||
func! CurrentFileDir(cmd)
|
||||
return a:cmd . " " . expand("%:p:h") . "/"
|
||||
endfunc
|
||||
|
@ -59,13 +59,13 @@ 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
|
||||
" if exists('$TMUX')
|
||||
" if has('nvim')
|
||||
" set termguicolors
|
||||
" else
|
||||
" set term=screen-256color
|
||||
" endif
|
||||
" endif
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
|
@ -37,9 +37,6 @@ map <leader>f :MRU<CR>
|
||||
""""""""""""""""""""""""""""""
|
||||
let g:yankstack_yank_keys = ['y', 'd']
|
||||
|
||||
nmap <C-p> <Plug>yankstack_substitute_older_paste
|
||||
nmap <C-n> <Plug>yankstack_substitute_newer_paste
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => CTRL-P
|
||||
@ -60,13 +57,6 @@ let g:ctrlp_max_height = 20
|
||||
let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee'
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => ZenCoding
|
||||
""""""""""""""""""""""""""""""
|
||||
" Enable all functions in all modes
|
||||
let g:user_zen_mode='a'
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => snipMate (beside <TAB> support <CTRL-j>)
|
||||
""""""""""""""""""""""""""""""
|
||||
@ -93,25 +83,9 @@ map <leader>nb :NERDTreeFromBookmark<Space>
|
||||
map <leader>nf :NERDTreeFind<cr>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => vim-multiple-cursors
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:multi_cursor_use_default_mapping=0
|
||||
|
||||
" Default mapping
|
||||
let g:multi_cursor_start_word_key = '<C-s>'
|
||||
let g:multi_cursor_select_all_word_key = '<A-s>'
|
||||
let g:multi_cursor_start_key = 'g<C-s>'
|
||||
let g:multi_cursor_select_all_key = 'g<A-s>'
|
||||
let g:multi_cursor_next_key = '<C-s>'
|
||||
let g:multi_cursor_prev_key = '<C-p>'
|
||||
let g:multi_cursor_skip_key = '<C-x>'
|
||||
let g:multi_cursor_quit_key = '<Esc>'
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => surround.vim config
|
||||
" Annotate strings with gettext
|
||||
" Annotate strings with gettext
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
vmap Si S(i_<esc>f)
|
||||
au FileType mako vmap Si S"i${ _(<esc>2f"a) }<esc>
|
||||
@ -121,53 +95,16 @@ au FileType mako vmap Si S"i${ _(<esc>2f"a) }<esc>
|
||||
" => lightline
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'wombat',
|
||||
\ 'colorscheme': 'gruvbox',
|
||||
\ 'active': {
|
||||
\ 'left': [ ['mode', 'paste'],
|
||||
\ ['fugitive', 'readonly', 'filename', 'modified'] ],
|
||||
\ 'right': [ [ 'lineinfo' ], ['percent'] ]
|
||||
\ 'left': [ [ 'mode', 'paste' ],
|
||||
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
|
||||
\ },
|
||||
\ 'component': {
|
||||
\ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}',
|
||||
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
|
||||
\ 'fugitive': '%{exists("*FugitiveHead")?FugitiveHead():""}'
|
||||
\ 'component_function': {
|
||||
\ 'gitbranch': 'FugitiveHead'
|
||||
\ },
|
||||
\ 'component_visible_condition': {
|
||||
\ 'readonly': '(&filetype!="help"&& &readonly)',
|
||||
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
|
||||
\ 'fugitive': '(exists("*FugitiveHead") && ""!=FugitiveHead())'
|
||||
\ },
|
||||
\ 'separator': { 'left': ' ', 'right': ' ' },
|
||||
\ 'subseparator': { 'left': ' ', 'right': ' ' }
|
||||
\ }
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Vimroom
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:goyo_width=100
|
||||
let g:goyo_margin_top = 2
|
||||
let g:goyo_margin_bottom = 2
|
||||
nnoremap <silent> <leader>z :Goyo<cr>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Ale (syntax checker and linter)
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let g:ale_linters = {
|
||||
\ 'javascript': ['jshint'],
|
||||
\ 'python': ['flake8'],
|
||||
\ 'go': ['go', 'golint', 'errcheck']
|
||||
\}
|
||||
|
||||
nmap <silent> <leader>a <Plug>(ale_next_wrap)
|
||||
|
||||
" Disabling highlighting
|
||||
let g:ale_set_highlights = 0
|
||||
|
||||
" Only run linting when saving the file
|
||||
let g:ale_lint_on_text_changed = 'never'
|
||||
let g:ale_lint_on_enter = 0
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Git gutter (Git diff)
|
||||
|
Reference in New Issue
Block a user