Skip to content

Instantly share code, notes, and snippets.

@pluskid
Last active June 14, 2016 18:50
Show Gist options
  • Save pluskid/5479284 to your computer and use it in GitHub Desktop.
Save pluskid/5479284 to your computer and use it in GitHub Desktop.
" vim: set foldmarker={,} foldlevel=0 foldmethod=marker:
"=======================================
" Initialization {
"=======================================
set nocompatible
call pathogen#infect()
filetype plugin indent on
"}
"========================================
" Basic setting {
"========================================
set visualbell " disable sound bell
set noshowmatch " do not jump to the matched bracket
set backup
set backupdir=~/.vim/cache/backup/ " backup directory
set directory=~/.vim/cache/swap/ " swap directory
set formatoptions+=mB
"}
"========================================
" UI {
"========================================
set t_Co=256 " force terminal 256 color
if has('gui_running')
set guifont=Operator\ Mono\ Light:h12
set linespace=2
set macligatures " ligatures (only for MacVIM)
syntax enable
set background=dark
colorscheme onedark
"set background=light
"colorscheme PaperColor
" set search highlight color
autocmd BufEnter * :hi Search guibg=LightSkyBlue guifg=black
set guioptions-=T " remove toolbar
set lines=50
set columns=120
else
set background=dark
colorscheme flattown
" " Change cursor shape between insert and normal mode in iTerm2.app
" if $TERM_PROGRAM =~ "iTerm"
" let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
" let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
" endif
end
syntax on
let g:load_doxygen_syntax=1
" Syntax coloring lines that are too long just slows down the world
set synmaxcol=512
set mouse=a " automatically enable mouse
set mousemodel=popup " mouse popup
"set cursorline " highlight current line
set nu " line number
set nostartofline " cursor do not jump to sol when switching buffer
"--------------------
" status line {
set laststatus=2
set noruler
if has('gui_running')
" let g:lightline = {
" \ 'colorscheme': 'PaperColor',
" \ 'component': {
" \ 'readonly': '%{&readonly?"":""}',
" \ },
" \ 'separator': { 'left': '', 'right': '' },
" \ 'subseparator': { 'left': '', 'right': '' }
" \ }
else
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
end
"}
"}
"========================================
" Basic editing {
"========================================
let mapleader = "\<Space>" " space as the <leader>
set autochdir " auto switch to current file directory
set virtualedit=onemore " allow for cursor beyond last character
set hidden " allow buffer switching without saving
set backspace=indent,eol,start " better backspace
set incsearch " search as you type
set hlsearch " highlight search terms
set ignorecase " case insensitive search
set smartcase " case sensitive when typing capital letters
set wildmenu " show list instead of just completing
set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all.
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to
set nowrap
set autoindent
set shiftwidth=2 " indent is 4 spaces
set expandtab " expand tab into spaces
set tabstop=2
set softtabstop=2 " let backspace delete indent
" visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" windows key bindings Ctrl+C, Ctrl+V, etc.
source $VIMRUNTIME/mswin.vim
set completeopt=menuone,menu,longest
" use q to start visual block selection, qq to do macro recording
nnoremap q <c-v>
nnoremap qq q
" easier formatting of paragraphs
vmap Q gq
nmap Q gqap
" d is now delete -- the *real* delete
" <leader>d is cut (delete and copy)
nnoremap x "_x
nnoremap d "_d
nnoremap D "_D
nnoremap c "_c
vnoremap d "_d
nnoremap <leader>d ""d
nnoremap <leader>D ""D
vnoremap <leader>d ""d
"}
"========================================
" Utility plugins {
"========================================
"--------------------
" NERDTree {
map <F7> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr', '\.o$', '\.hi$']
"}
"--------------------
" ctrlp {
let g:ctrlp_root_markers = ['.ctrlp', '.git']
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_prompt_mappings = {
\ 'PrtSelectMove("j")': ['<c-n>', '<down>'],
\ 'PrtSelectMove("k")': ['<c-p>', '<up>'],
\ 'PrtHistory(-1)': ['<c-j>'],
\ 'PrtHistory(1)': ['<c-k>'],
\ }
let g:ctrlp_working_path_mode = 2
let g:ctrlp_dotfiles = 0
set wildignore+=*/tmp/*,*.so,*.swp,*.o,*/_compiled/*,*/doc/*,*/data/*,*.pyc,*~
map <F2> :CtrlPBuffer<CR>
imap <F2> <C-O>:CtrlPBuffer<CR>
"}
"--------------------
" local-vimrc {
let g:local_vimrc = {'names':['.localvimrc'], 'hash_fun':'LVRHashOfFile'}
"}
"}
"========================================
" Editing plugins {
"========================================
"--------------------
" YouCompleteMe {
let g:ycm_path_to_python_interpreter = '/usr/bin/python'
" turn off Python semantic completion as it is too slow, high-CPU consumption
let g:ycm_filetype_specific_completion_to_disable = {
\ 'python': 1
\}
"}
"--------------------
" EasyAlign {
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. <Leader>aip)
nmap <Leader>a <Plug>(EasyAlign)
let g:easy_align_delimiters = {
\ ':': { 'pattern': ':\+', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0 }
\ }
"--------------------
" neosnippet {
" imap <C-j> <Plug>(neosnippet_expand_or_jump)
" smap <C-j> <Plug>(neosnippet_expand_or_jump)
" xmap <C-j> <Plug>(neosnippet_expand_target)
"
" " For snippet_complete marker.
" if has('conceal')
" set conceallevel=2 concealcursor=i
" endif
"
" " my snippets
" let g:neosnippet#snippets_directory='~/.vim/snippets'
"}
"}
"========================================
" LaTeX {
"========================================
let g:tex_flavor = 'latex'
let g:vimtex_view_general_viewer = 'open'
let g:vimtex_view_general_options = '-a Skim'
"let g:LatexBox_viewer = 'open -a Skim'
"let g:LatexBox_latexmk_async=1
"let g:LatexBox_custom_indent=0
autocmd FileType tex set spell
autocmd FileType tex set textwidth=100
" those improves editing response speed
autocmd FileType tex set foldmethod=manual
autocmd FileType tex set nocursorline
"}
"========================================
" File Types {
"========================================
"--------------------
" pandoc {
" let g:pandoc#modules#disabled = ["folding"]
" autocmd FileType pandoc nnoremap <buffer> j gj
" autocmd FileType pandoc nnoremap <buffer> k gk
" autocmd FileType pandoc vnoremap <buffer> j gj
" autocmd FileType pandoc vnoremap <buffer> k gk
" autocmd FileType pandoc vnoremap <buffer> 0 g0
" autocmd FileType pandoc vnoremap <buffer> $ g$
" autocmd FileType pandoc setlocal display=lastline
" autocmd FileType pandoc setlocal nojoinspaces
" autocmd FileType pandoc setlocal wrap
" autocmd FileType pandoc setlocal nocursorline
" "autocmd FileType pandoc setlocal conceallevel=0
" autocmd FileType pandoc setlocal nospell
" "autocmd FileType pandoc setlocal nolinebreak
"
" autocmd FileType pandoc setlocal noimdisable " auto switch input method in normal mode
" autocmd FileType pandoc setlocal imi=0
" autocmd FileType pandoc setlocal ims=1
" "autocmd FileType pandoc NeoCompleteLock " disable neocomplete here b/c it does not work with noimdisable
" autocmd FileType pandoc inoremap <CR> <CR>
"
" autocmd FileType pandoc set makeprg=md2pdf\ %
" autocmd FileType pandoc nnoremap \ll :make<CR>
" autocmd FileType pandoc nnoremap \lv :silent !open -a Skim %:r.pdf<CR>
"}
"--------------------
" ruby {
autocmd FileType ruby setlocal shiftwidth=2
autocmd FileType ruby setlocal expandtab
autocmd FileType ruby setlocal tabstop=2
autocmd FileType ruby setlocal softtabstop=2
"}
"--------------------
" c++ {
autocmd FileType c setlocal cindent
autocmd FileType cpp setlocal cindent
"}
"--------------------
" HTML, Javascript {
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
"}
"--------------------
" Ocaml {
autocmd FileType ocaml source /Users/chiyuan/.opam/system/share/typerex/ocp-indent/ocp-indent.vim
"}
"--------------------
" Julia {
let g:latex_to_unicode_tab = 1
let g:latex_to_unicode_auto = 0
"}
"--------------------
" Python {
let g:python_version_2 = 1
"}
"
"--------------------
" ReST {
let g:riv_disable_folding = 1
autocmd BufEnter *.rst setlocal textwidth=80
autocmd BufEnter *.rst setlocal formatoptions+=t
"}
"}
let g:UltiSnipsExpandTrigger="<c-h>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment