Skip to content

Instantly share code, notes, and snippets.

@sighingnow
Last active September 29, 2021 17:35
Show Gist options
  • Save sighingnow/086ac1b32f8ea3ba84d4 to your computer and use it in GitHub Desktop.
Save sighingnow/086ac1b32f8ea3ba84d4 to your computer and use it in GitHub Desktop.
VIM config file.
if &compatible
set nocompatible " Be iMproved
endif
set number
set confirm
set autoread
set spell
set clipboard+=unnamed
set mouse+=a
set ignorecase
set hlsearch
set incsearch
set showmatch
set matchtime=10
set nobackup
set noundofile
set noswapfile
set bufhidden=hide
set tabstop=4
set shiftwidth=4
set softtabstop=0
set expandtab
set smarttab
set autoindent
set smartindent
set nobomb
set encoding=utf-8
set fileencoding=utf-8
set fileformats=unix,dos,mac
set whichwrap+=<,>,h,l,[,]
set backspace=indent,eol,start
filetype plugin indent on
syntax on
syntax enable
" set formatoptions=tcrpn
" set nowrap
" set foldmethod=syntax
" disable bell.
" set novisualbell
autocmd GUIEnter * set vb t_vb=
source $VIMRUNTIME/mswin.vim
behave mswin
set guifont=YaHei\ Consolas\ Hybrid:h9
set wildmenu
set ruler
set scrolloff=3
" Uncomment the following to have Vim jump to the last position when
" reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\ %H:%M\")}
function! CurDir()
let curdir = substitute(getcwd(), $HOME, "~", "g")
return curdir
endfunction
set statusline=[%n]\ %f%m%r%h\ %=\|\ %l,%c\ %p%%\ \|\ ascii=%b%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\
" set statusline=[%n]\ %f%m%r%h\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\
set laststatus=2 " 总是显示状态栏
highlight cursorline guibg=#333333
highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue
highlight Cursor guifg=black guibg=white
highlight MatchParen cterm=underline ctermbg=green ctermfg=red
highlight MatchParen gui=underline guibg=green guifg=red
call plug#begin('~/.vim/plugged')
Plug 'altercation/vim-colors-solarized'
Plug 'crusoexia/vim-monokai'
Plug 'dag/vim2hs'
Plug 'davidhalter/jedi-vim'
Plug 'def-lkb/vimbufsync'
Plug 'fatih/subvim'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'JuliaEditorSupport/julia-vim'
Plug 'neomake/neomake'
Plug 'neovimhaskell/haskell-vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'othree/vim-autocomplpop'
Plug 'posva/vim-vue'
Plug 'raichoo/smt-vim'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/syntastic'
Plug 'Shougo/neocomplcache.vim'
Plug 'Shougo/neocomplete.vim'
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/vimproc.vim', {'build' : 'make'}
Plug 'solarnz/thrift.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-pathogen'
Plug 'vim-erlang/vim-erlang-compiler'
Plug 'vim-erlang/vim-erlang-runtime'
Plug 'vim-erlang/vim-erlang-omnicomplete'
Plug 'vim-scripts/L9'
Plug 'wincent/command-t'
call plug#end()
""""""""""""""""""""""""""neocomplete """"""""""""""""""""""
"set completeopt=menu,menuone
let neocomplete#enable_debug = 0
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#auto_complete_delay = 50
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 2
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $VIMRUNTIME.'/.vimshell_hist',
\ 'scheme' : $VIMRUNTIME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
let g:neocomplete#use_vimproc = 1
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
" return neocomplete#close_popup() . "\<CR>"
" For no inserting <CR> key.
return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" inoremap <expr><CR> pumvisible() ? "\<C-n>" : "\<CR>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" For cursor moving in insert mode(Not recommended)
" inoremap <expr><Left> neocomplete#close_popup() . "\<Left>"
" inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
" inoremap <expr><Up> neocomplete#close_popup() . "\<Up>"
" inoremap <expr><Down> neocomplete#close_popup() . "\<Down>"
inoremap <expr><Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr><Down> pumvisible() ? "\<C-n>" : "\<Down>"
" Or set this.
"let g:neocomplete#enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplete#enable_insert_char_pre = 1
" AutoComplPop like behavior.
let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType python set omnifunc=python3complete#Complete
autocmd FileType python setlocal completeopt-=preview
autocmd FileType ruby set omnifunc=rubycomplete#Complete
autocmd FileType sql set omnifunc=sqlcomplete#Complete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType syntax set omnifunc=syntaxcomplete#Complete
autocmd FileType java setlocal omnifunc=javacomplete#Complete
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
""""""""""""""""""""""""""END"""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""" vim-nerdtree-tabs """""""""""""""""""""""""""
let g:nerdtree_tabs_open_on_gui_startup = 0
let g:nerdtree_tabs_open_on_console_startup = 0
"""""""""""""""""""""""""" vim-nerdtree-tabs end""""""""""""""""""""""""
""""""""""""""""""""""""" neosnippet """"""""""""""""""""""""""""""""""
" Plugin neosnippet key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
""""""""""""""""""""""""" neosnippet end """"""""""""""""""""""""""""""
""""""""""""""""""""""""" haskell-vim """"""""""""""""""""""""""""""""""
let g:haskell_enable_quantification = 1
let g:haskell_enable_recursivedo = 1
let g:haskell_enable_arrowsyntax = 1
let g:haskell_enable_pattern_synonyms = 1
let g:haskell_enable_typeroles = 1
let g:haskell_enable_static_pointers = 1
let g:haskell_disable_TH = 0
let g:haskell_classic_highlighting = 1
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
let g:cabal_indent_section = 4
" hindent
if exists("g:loaded_hindent") || !executable("hindent")
" echo "hindent should exists in your PATH"
else
let g:loaded_hindent = 1
endif
function! HaskellFormat()
if !empty(v:char)
return 1
else
let l:filter = "hindent " .
\ " --line-length 100" .
\ " --indent-size 4"
let l:command = v:lnum.','.(v:lnum+v:count-1).'!'.l:filter
execute l:command
execute ":StripWhitespace"
endif
endfunction
if has("autocmd")
autocmd FileType haskell setlocal formatexpr=HaskellFormat()
endif
""""""""""""""""""""""""" haskell-vim end """"""""""""""""""""""""""""""
""""""""""""""""""""""""""""""" vim-clang """""""""""""""""""""""""""""""""""
" disable auto completion for vim-clang, don't select the first element automatically.
let g:clang_auto = 0
" default 'longest' can not work with neocomplete
let g:clang_c_completeopt = 'menuone,' " noinsert,preview'
let g:clang_cpp_completeopt = 'menuone' " noinsert,preview'
autocmd FileType cpp setlocal omnifunc=ClangComplete
" use neocomplete
" input patterns
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
" for c and c++
let g:neocomplete#force_omni_input_patterns.c =
\ '[^.[:digit:] *\t]\%(\.\|->\)\w*\h\w*'
let g:neocomplete#force_omni_input_patterns.cpp =
\ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*\|\h\w*'
let g:clang_exec = 'clang++'
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++14 -Wall -pedantic-errors'
let g:clang_diagsopt = '' " disable diagnostics
let g:clang_pwheight = 0
let g:clang_verbose_pmenu = 1
""""""""""""""""""""""""""""""" vim-clang end """""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""" clang-format """""""""""""""""""""""""""""""""""
if !exists('g:clang_format_auto')
let g:clang_format_auto = 0
endif
if !exists('g:clang_format_exec')
let g:clang_format_exec = 'clang-format'
endif
if !exists('g:clang_format_style')
let g:clang_format_style = '{BasedOnStyle: Google, ColumnLimit: 100, NamespaceIndentation: Inner, IndentWidth: 4, TabWidth: 4, UseTab: Never, ContinuationIndentWidth: 8, ConstructorInitializerIndentWidth: 8, AlignAfterOpenBracket: Align, BreakBeforeBinaryOperators: All, Cpp11BracedListStyle: true, Standard: Cpp11, AlignAfterOpenBracket: DontAlign, SpaceBeforeParens: SBPO_ControlStatements}'
end
if !exists('g:clang_enable_format_command')
let g:clang_enable_format_command = 1
endif
func! s:ClangFormat()
let l:view = winsaveview()
let l:command = printf("%s -style=\"%s\" ", g:clang_format_exec, g:clang_format_style)
silent execute '%!'. l:command
call winrestview(l:view)
endf
if g:clang_enable_format_command
if !exists('ClangFormat')
com! ClangFormat call <SID>ClangFormat()
endif
endif
""""""""""""""""""""""""""""""" clang-format end """""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""" jedi-vim """"""""""""""""""""""""""""""""""""""
autocmd FileType python set splitbelow
""""""""""""""""""""""""""""" jedi-vim end """"""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""" syntastic """"""""""""""""""""""""""""""""""""""""""
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_python_checkers = ['python', 'pylint', 'mypy']
let g:syntastic_python_pylint_args = "-d missing-docstring,invalid-name"
let g:syntastic_python_mypy_args = "--ignore-missing-imports"
let g:syntastic_clang_check_config_file = "C:/Users/sighi/.vim/.syntastic_clang_check_config"
let g:syntastic_c_checkers = ['clang_check', 'clang_tidy']
" let g:syntastic_cpp_checkers = ['clang_check', 'clang_tidy']
let g:syntastic_cpp_checkers = ['gcc']
let g:syntastic_cpp_compiler_options = '-std=c++17 -Wall -pedantic-errors -D_CRT_SECURE_NO_WARNINGS'
let g:syntastic_haskell_checkers = ['ghc-mod', 'hlint']
"""""""""""""""""""""""""""""" syntastic end """"""""""""""""""""""""""""""""""""""""""
" au BufNewFile,BufRead *.cpp set syntax=cpp11
" au BufNewFile,BufRead *.cxx set syntax=cpp11
" command to view full path of current file.
if !exists(':NFile')
command NFile :normal :echo expand('%:p')<Return>
endif
func! s:FixLineEnd()
silent execute 'e ++ff=dos'
execute 'set ff=unix'
endfunction
if !exists(':FixLineEnd')
com! FixLineEnd call <SID>FixLineEnd()
endif
" autocmd BufWritePre * :%s/\s\+$//e
" autocmd BufWritePre * StripWhitespace
" set cmdheight=2
let $LANG = 'en_US'
set langmenu=en_US
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set guioptions+=m
set guioptions-=T
set lines=30
set columns=125
" set background=dark
" if has("GUI")
" colorscheme evening
" else
" colorscheme default
" endif
let g:monokai_term_italic = 1
let g:monokai_gui_italic = 1
set t_Co=256
" colorscheme solarized
colorscheme monokai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment