Skip to content

Instantly share code, notes, and snippets.

@musicq
Created March 27, 2019 01:42
Show Gist options
  • Save musicq/ff5545dd24f2f6e5840a952fc5bd456c to your computer and use it in GitHub Desktop.
Save musicq/ff5545dd24f2f6e5840a952fc5bd456c to your computer and use it in GitHub Desktop.
Vim Config
" vundle 环境设置
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
" Define bundles via github repos
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/YouCompleteMe'
Plugin 'marijnh/tern_for_vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'vim-airline/vim-airline'
Plugin 'leafgarland/typescript-vim'
Plugin 'Yggdroot/indentLine'
Plugin 'w0rp/ale'
" theme
Plugin 'dracula/vim'
Plugin 'liuchengxu/space-vim-dark'
call vundle#end()
filetype plugin indent on
set nocompatible
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
let mapleader=";"
" Highlight current line
set cursorline
" history存储长度
set history=1000
" Syntax hightlight
syntax enable
" 允许用指定语法高亮配色方案替换默认方案
syntax on
" Basic Settings
" 相对行号
set relativenumber
" Numbers
set number
set numberwidth=5
set ruler
set laststatus=2
set showcmd
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
" turn backup off
set nobackup
set nowb
set noswapfile
set ai
set si
set so=15
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" 开启实时搜索功能
set hlsearch
set ignorecase
set smartcase
set incsearch
" vim 自身命令行模式智能补全
set wildmenu
" Softtabs, 2 spaces
" 将制表符扩展为空格
set expandtab
" 设置编辑时制表符占用空格数
set tabstop=2
" 设置格式化时制表符占用空格数
set shiftwidth=2
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=2
set shiftround
" Display extra whitespace
set list listchars=tab:▸\ ,trail:·,precedes:←,extends:→
" Make it obvious where 80 characters is
set textwidth=120
set colorcolumn=+1
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
inoremap <S-Tab> <c-n>
" Nerd Tree
let NERDChristmasTree=0
let NERDTreeWinSize=40
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos="right"
let NERDTreeShowHidden=1
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
nmap <F5> :NERDTreeToggle<cr>
" IndentLine
let g:indentLine_setColors = 239
let g:indentLine_char = '¦'
nnoremap <leader>i :IndentLinesToggle<cr>
" Snippets author
let g:snips_author = 'Musicq'
" theme
" colorscheme dracula
" set background=dark
" let g:enable_bold_font=1
" colorscheme molokai
" set background=dark
" let g:molokai_original = 1
colorscheme space-vim-dark
set termguicolors
hi Comment guifg=#5C6370 ctermfg=59
hi LineNr ctermbg=NONE guibg=NONE
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_loc_list_height = 5
"" Checkers
""" javascript
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
""" typescript
" let g:typescript_indent_disable = 1
let g:syntastic_typescript_checkers = ['tslint']
let g:syntastic_typescript_tslint_exec = 'tslint'
let g:syntastic_typescript_tsc_fname = ''
" YouCompleteMe
let g:ycm_error_symbol = '>>'
let g:ycm_warning_symbol = '>*'
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
" ctrlp
let g:ctrlp_map = '<leader>ff'
let g:ctrlp_cmd = 'CtrlP'
map <leader>fp :CtrlPMRU<CR>
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files.
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" Ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|node_modules)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
" powerline
" let g:Powerline_symbols = 'fancy'
set encoding=utf-8
set laststatus=2
" 鼠标样式
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" switch tab
nnoremap <leader>2 :tabnext<cr>
nnoremap <leader>1 :tabprevious<cr>
" ALE
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'tslint'],
\}
"" Set this variable to 1 to fix files when you save them.
let g:ale_fix_on_save = 1
"" Enable completion where available.
" let g:ale_completion_enabled = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment