Created
April 24, 2019 07:45
-
-
Save keelii/5dfd1c2bbfa1adb601d33069d2725d51 to your computer and use it in GitHub Desktop.
vimrc for ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Neovim/vim configurations @keelii | |
| " Varible {{{ | |
| let mapleader="\<Space>" | |
| let g:html_indent_script1 = "inc" | |
| let g:html_indent_style1 = "inc" | |
| let g:html_indent_autotags = "html" | |
| let g:python_host_skip_check=1 | |
| let g:python_host_prog = '/usr/bin/python' | |
| let g:python3_host_skip_check=1 | |
| let g:python3_host_prog = '/usr/local/bin/python3' | |
| let g:XkbSwitchEnabled = 1 | |
| " }}} | |
| " Autocmd {{{ | |
| " 打开文件总是定位到上次编辑的位置 | |
| autocmd BufReadPost * | |
| \ if line("'\"") > 1 && line("'\"") <= line("$") | | |
| \ exe "normal! g`\"<space>" | | |
| \ endif | |
| augroup VimReload | |
| autocmd! | |
| autocmd BufWritePost $MYVIMRC source $MYVIMRC | |
| augroup END | |
| "augroup FastEscape | |
| " autocmd! | |
| " au InsertEnter *.js CocEnable | |
| " au InsertLeave *.js CocDisable | |
| "augroup END | |
| " autocmd FileType javascript setlocal signcolumn=yes | |
| augroup filetype_vim | |
| autocmd! | |
| autocmd FileType vim setlocal foldmethod=marker | |
| autocmd FileType vim setlocal foldlevel=0 | |
| augroup END | |
| " }}} | |
| " Function {{{ | |
| " Remove trailing whitespace when writing a buffer, but not for diff files. | |
| " From: Vigil | |
| " @see http://blog.bs2.to/post/EdwardLee/17961 | |
| function! RemoveTrailingWhitespace() | |
| if &ft != "diff" | |
| let b:curcol = col(".") | |
| let b:curline = line(".") | |
| silent! %s/\s\+$// | |
| silent! %s/\(\s*\n\)\+\%$// | |
| call cursor(b:curline, b:curcol) | |
| endif | |
| endfunction | |
| " autocmd BufWritePre * call RemoveTrailingWhitespace() | |
| " }}} | |
| " Plug {{{ | |
| call plug#begin('~/.vim/plugged') | |
| Plug 'mhinz/vim-startify' | |
| Plug 'morhetz/gruvbox' | |
| Plug 'othree/yajs.vim', { 'for': 'typescript' } | |
| Plug 'cakebaker/scss-syntax.vim', { 'for': ['scss', 'sass'] } | |
| Plug 'mattn/emmet-vim', { 'for': ['html', 'sass', 'css'] } | |
| Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | |
| Plug '/usr/local/opt/fzf' | |
| Plug 'junegunn/fzf.vim' | |
| Plug 'pbogut/fzf-mru.vim' | |
| Plug 'Valloric/YouCompleteMe', { 'do': './install.py --js-completer' } | |
| Plug 'lyokha/vim-xkbswitch' | |
| Plug 'terryma/vim-multiple-cursors' | |
| Plug 'godlygeek/tabular', { 'on': 'Tabularize' } | |
| Plug 'roxma/vim-tmux-clipboard' | |
| Plug 'christoomey/vim-tmux-navigator' | |
| Plug 'SirVer/ultisnips' | |
| Plug 'keelii/vim-snippets' | |
| Plug 'airblade/vim-rooter' | |
| Plug 'easymotion/vim-easymotion', { 'on': '<Plug>(easymotion-jumptoanywhere)' } | |
| Plug 'tweekmonster/startuptime.vim' | |
| Plug 'prettier/vim-prettier', { | |
| \ 'do': 'yarn install', | |
| \ 'for': ['javascript', 'typescript', 'css', 'scss', 'markdown'] } | |
| Plug 'leafgarland/typescript-vim', { 'for': 'typescript' } | |
| Plug 'mhartington/nvim-typescript', {'do': './install.sh', 'for': ['typescript'] } | |
| " linter runner | |
| " Plug 'w0rp/ale', {'for': ['javascript', 'typescript'] } | |
| " YCM {{{ | |
| let g:ycm_key_list_select_completion = ['<Down>'] | |
| let g:ycm_key_list_previous_completion = ['<Up>'] | |
| let g:ycm_max_num_candidates = 10 | |
| let g:ycm_error_symbol = '✘' | |
| let g:ycm_warning_symbol = '!' | |
| let g:ycm_add_preview_to_completeopt = 1 | |
| let g:ycm_key_detailed_diagnostics = '<leader>i' | |
| autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | |
| autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | |
| autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS | |
| autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | |
| " }}} | |
| call plug#end() | |
| " }}} | |
| " coc {{{ | |
| nmap <silent> <leader>m <Plug>(coc-diagnostic-info) | |
| nmap <silent> <leader>n <Plug>(coc-diagnostic-next) | |
| nmap <silent> <leader>p <Plug>(coc-diagnostic-prev) | |
| " }}} | |
| " Easymotion {{{ | |
| nmap s <Plug>(easymotion-jumptoanywhere) | |
| vmap s <Plug>(easymotion-jumptoanywhere) | |
| " nmap S <Plug>(easymotion-overwin-w) | |
| " vmap S <Plug>(easymotion-overwin-w) | |
| " }}} | |
| " Prettier {{{ | |
| let g:prettier#config#tab_width = 4 | |
| let g:prettier#config#semi = 'false' | |
| " }}} | |
| " Ncm {{{ | |
| " fix conflict with multiple cursors | |
| "function! Multiple_cursors_before() | |
| " exe 'CocDisable' | |
| "endfunction | |
| " | |
| "function! Multiple_cursors_after() | |
| " exe 'CocEnable' | |
| "endfunction | |
| " }}} | |
| " Ale {{{ | |
| let g:ale_sign_error = '✘' | |
| let g:ale_sign_warning = '!' | |
| highlight clear ALEErrorSign | |
| highlight clear ALEWarningSign | |
| let g:ale_linters_explicit = 1 | |
| let g:ale_linters = { | |
| \ 'javascript': ['eslint'], | |
| \} | |
| " }}} | |
| " NerdTree {{{ | |
| "let NERDTreeIgnore=['\.vscode[[dir]]', '\.idea[[dir]]', '\.pyc$[[file]]'] | |
| let NERDTreeIgnore=['node_modules[[dir]]', 'build[[dir]]', '\.vscode[[dir]]', '\.idea[[dir]]', '\.pyc$[[file]]'] | |
| let NERDTreeBookmarksFile = '/Users/zhouqili/.NERDTreeBookmark' | |
| let NERDTreeBookmarksSort = 0 | |
| let NERDTreeMinimalUI = 1 | |
| let NERDTreeShowBookmarks = 1 | |
| let NERDTreeQuitOnOpen=1 | |
| " }}} | |
| " UltiSnips {{{ | |
| let g:UltiSnipsExpandTrigger="<tab>" | |
| let g:UltiSnipsJumpForwardTrigger="<tab>" | |
| let g:UltiSnipsJumpBackwardTrigger="<S-tab>" | |
| let g:UltiSnipsEditSplit="vertical" | |
| " }}} | |
| " Fzf {{{ | |
| let g:fzf_action = { | |
| \ 'ctrl-t': 'tab split', | |
| \ 'ctrl-x': 'split', | |
| \ 'ctrl-v': 'vsplit' } | |
| let g:fzf_mru_relative = 1 | |
| nmap <C-p> :execute 'Files' fnameescape(getcwd())<cr> | |
| nmap <C-e> :FZFMru<CR> | |
| let g:fzf_action = { 'ctrl-e': 'edit' } | |
| " }}} | |
| " Startify {{{ | |
| let g:startify_fortune_use_unicode = 0 | |
| let g:startify_enable_special = 0 | |
| let g:startify_files_number = 10 | |
| let g:startify_lists = [ | |
| \ { 'type': 'dir', 'header': [' MRU '. getcwd()] }, | |
| \ ] | |
| let g:startify_custom_header_quotes = [ | |
| \ ["Beautiful is better than ugly. | |
| \ -- 优美优于丑陋"], | |
| \ ["Explicit is better than implicit. | |
| \ -- 明了胜于晦涩"], | |
| \ ["Simple is better than complex. | |
| \ -- 简洁胜于复杂"], | |
| \ ["Complex is better than complicated. | |
| \ -- 复杂胜于凌乱"], | |
| \ ["Flat is better than nested. | |
| \ -- 扁平胜于嵌套"], | |
| \ ["Sparse is better than dense. | |
| \ -- 间隔胜于紧凑"], | |
| \ ["Readability counts. | |
| \ -- 可读性很重要"], | |
| \ ["Special cases aren't special enough to break the rules. | |
| \ -- 特殊情况并没有特殊到足以打破规则"], | |
| \ ["Although practicality beats purity. | |
| \ -- 尽管有的时候理想会被现实打败"], | |
| \ ["Errors should never pass silently. Unless explicitly silenced. | |
| \ -- 错误不应该被悄悄的忽略,除非确定要悄悄忽略"], | |
| \ ["In the face of ambiguity, refuse the temptation to guess. | |
| \ -- 当存在多种可能,不要尝试去猜测"], | |
| \ ["There should be one-- and preferably only one --obvious way to do it. | |
| \ -- 应该有且只有一种完美而且显而易见的解决方案"], | |
| \ ["Now is better than never. Although never is often better than *right* now. | |
| \ -- 实践优于空想,虽然空想不会出错"], | |
| \ ["If the implementation is hard to explain, it's a bad idea. | |
| \ -- 如果你无法向人描述你的方案,那肯定不是一个好方案"], | |
| \ ["If the implementation is easy to explain, it may be a good idea. | |
| \ -- 如果你的方案很容易描述,那才会是一个好方案"], | |
| \ ["Namespaces are one honking great idea -- let's do more of those! | |
| \ -- 命名空间是一种绝妙的理念,我们应当多加利用"] | |
| \] | |
| "}}} | |
| " General {{{ | |
| filetype indent plugin on | |
| set nocompatible | |
| set nobackup | |
| set noswapfile | |
| set history=2048 | |
| set autochdir | |
| set whichwrap=b,s,<,>,[,] | |
| set matchpairs+=<:>,「:」,“:”,『:』 | |
| set wrap | |
| set nobomb | |
| set backspace=indent,eol,start whichwrap+=<,>,[,] | |
| " Vim 的默认寄存器和系统剪贴板共享 | |
| set clipboard+=unnamed | |
| " 设置 alt 键不映射到菜单栏 | |
| set winaltkeys=no | |
| set path+=** | |
| set wildmenu | |
| set timeoutlen=300 | |
| set ttimeoutlen=0 | |
| " Lang & Encoding | |
| set fileencodings=ucs-bom,utf-8,gbk2312,gbk,gb18030,cp936 | |
| set encoding=utf-8 | |
| " }}} | |
| " GUI {{{ | |
| colorscheme gruvbox | |
| set background=dark | |
| set guicursor+=a:blinkon0 | |
| set completeopt-=preview | |
| let $LANG = 'en_US.UTF-8' | |
| set laststatus=2 | |
| " set cursorline | |
| set hlsearch | |
| set nonumber | |
| " 窗口大小 | |
| " set lines=35 columns=140 | |
| " 分割出来的窗口位于当前窗口下边/右边 | |
| set splitbelow | |
| set splitright | |
| "不显示工具/菜单栏 | |
| set guioptions-=T | |
| set guioptions-=m | |
| set guioptions-=L | |
| set guioptions-=r | |
| set guioptions-=b | |
| " 使用内置 tab 样式而不是 gui | |
| set guioptions-=e | |
| set list | |
| set showbreak=› | |
| set completeopt-=preview | |
| set completeopt=noinsert,menuone,noselect | |
| set foldlevel=10 | |
| set statusline = | |
| set statusline +=‣%f | |
| set statusline +=\ %M | |
| set statusline +=%r | |
| set statusline +=%= | |
| set statusline +=\ #%{len(filter(range(1,bufnr('$')),'buflisted(v:val)'))} | |
| set statusline +=\ %l,%L | |
| set statusline +=\ [%{''.(&fenc!=''?&fenc:&enc).''}] | |
| set statusline +=\ %y | |
| set hidden | |
| " }}} | |
| " Format {{{ | |
| set formatoptions+=m | |
| set formatoptions+=t | |
| set breakindent | |
| set autoindent | |
| set smartindent | |
| set tabstop=4 | |
| set shiftwidth=4 | |
| set softtabstop=4 | |
| set expandtab | |
| set foldmethod=indent | |
| set nojoinspaces | |
| syntax on | |
| " }}} | |
| " Keymap {{{ | |
| " nnoremap <D-k> 5k | |
| " nnoremap <D-j> 5j | |
| " nmap <leader>s :source $MYVIMRC<cr> | |
| nmap <leader>e :e $MYVIMRC<cr> | |
| nmap <leader>0 :set foldlevel=0<cr> | |
| nmap <leader>1 :set foldlevel=1<cr> | |
| nmap <leader>2 :set foldlevel=2<cr> | |
| nmap <leader>3 :set foldlevel=3<cr> | |
| nmap <leader>t2 :set shiftwidth=2 tabstop=2 softtabstop=2<cr> | |
| nmap <leader>t4 :set shiftwidth=2 tabstop=4 softtabstop=4<cr> | |
| nmap <leader>f :Prettier<cr> | |
| nmap <leader>d :NERDTreeToggle <cr> | |
| noremap j gj | |
| noremap k gk | |
| nmap tn :tabnew<cr> | |
| nmap th :tabprev<cr> | |
| nmap tl :tabnext<cr> | |
| nmap tc :tabclose<cr> | |
| nmap bp :bprev<cr> | |
| nmap bn :bnext<cr> | |
| " 移动分割窗口 | |
| nmap <C-j> <C-W>j | |
| nmap <C-k> <C-W>k | |
| nmap <C-h> <C-W>h | |
| nmap <C-l> <C-W>l | |
| " 正常模式下 alt+j,k,h,l 调整分割窗口大小 | |
| nnoremap <M-j> :resize +5<cr> | |
| nnoremap <M-k> :resize -5<cr> | |
| nnoremap <M-h> :vertical resize -5<cr> | |
| nnoremap <M-l> :vertical resize +5<cr> | |
| " 插入模式移动光标 alt + 方向键 | |
| inoremap <M-j> <Down> | |
| inoremap <M-k> <Up> | |
| inoremap <M-h> <left> | |
| inoremap <M-l> <Right> | |
| " IDE like delete | |
| inoremap <C-BS> <Esc>bdei | |
| nnoremap K :q<cr> | |
| " Block select at first line | |
| nnoremap B Vf{% | |
| " Handle $, ^ and % with easy. | |
| nmap E g_ | |
| vmap E g_ | |
| nmap F ^ | |
| vmap F ^ | |
| nmap vv ^vg_ | |
| " 命令模式下的行首尾 | |
| cnoremap <C-a> <home> | |
| cnoremap <C-e> <end> | |
| nnoremap <F2> :setlocal number!<cr> | |
| nnoremap <leader>w :setlocal wrap!<cr> | |
| " 打开当前目录 | |
| nmap <silent> <leader>ex :!open %:p:h<CR> | |
| " }}} | |
| if exists('veonim') | |
| " built-in plugin manager | |
| Plug 'sheerun/vim-polyglot' | |
| Plug 'tpope/vim-surround' | |
| " extensions for web dev | |
| let g:vscode_extensions = [ | |
| \'vscode.typescript-language-features', | |
| \'vscode.css-language-features', | |
| \'vscode.html-language-features', | |
| \] | |
| " multiple nvim instances | |
| nno <silent> <c-t>c :Veonim vim-create<cr> | |
| nno <silent> <c-g> :Veonim vim-switch<cr> | |
| nno <silent> <c-t>, :Veonim vim-rename<cr> | |
| " workspace functions | |
| nno <silent> ,f :Veonim files<cr> | |
| nno <silent> ,e :Veonim explorer<cr> | |
| nno <silent> ,b :Veonim buffers<cr> | |
| nno <silent> ,d :Veonim change-dir<cr> | |
| "or with a starting dir: nno <silent> ,d :Veonim change-dir ~/proj<cr> | |
| " searching text | |
| nno <silent> <space>fw :Veonim grep-word<cr> | |
| vno <silent> <space>fw :Veonim grep-selection<cr> | |
| nno <silent> <space>fa :Veonim grep<cr> | |
| nno <silent> <space>ff :Veonim grep-resume<cr> | |
| nno <silent> <space>fb :Veonim buffer-search<cr> | |
| " language features | |
| nno <silent> sr :Veonim rename<cr> | |
| nno <silent> sd :Veonim definition<cr> | |
| nno <silent> si :Veonim implementation<cr> | |
| nno <silent> st :Veonim type-definition<cr> | |
| nno <silent> sf :Veonim references<cr> | |
| nno <silent> sh :Veonim hover<cr> | |
| nno <silent> sl :Veonim symbols<cr> | |
| nno <silent> so :Veonim workspace-symbols<cr> | |
| nno <silent> sq :Veonim code-action<cr> | |
| nno <silent> sk :Veonim highlight<cr> | |
| nno <silent> sK :Veonim highlight-clear<cr> | |
| nno <silent> ,n :Veonim next-usage<cr> | |
| nno <silent> ,p :Veonim prev-usage<cr> | |
| nno <silent> sp :Veonim show-problem<cr> | |
| nno <silent> <c-n> :Veonim next-problem<cr> | |
| nno <silent> <c-p> :Veonim prev-problem<cr> | |
| endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment