Skip to content

Instantly share code, notes, and snippets.

@ryanzyy
Last active March 27, 2020 10:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanzyy/7dbf6f070f2ec6fe1978 to your computer and use it in GitHub Desktop.
Save ryanzyy/7dbf6f070f2ec6fe1978 to your computer and use it in GitHub Desktop.
vimrc
" ------ Plug ----- {{{
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive' " IDE - Git
Plug 'ludovicchabant/vim-gutentags' " IDE - Ctags
Plug 'dracula/vim', {'as': 'dracula'} " IDE - Color
Plug 'junegunn/fzf' " IDE - Directory
Plug 'junegunn/fzf.vim' " IDE - Directory
Plug 'scrooloose/nerdtree' " IDE - Directory
Plug 'mileszs/ack.vim' " IDE - Find
Plug 'rust-lang/rust.vim' " L - Rust
Plug 'ElmCast/elm-vim' " L - Elm
Plug 'gluon-lang/vim-gluon' " L - Gluon
Plug 'rsmenon/vim-mathematica' " L - Mma
Plug 'sheerun/vim-polyglot' " IDE - Syntax Highlighting
Plug 'itchyny/lightline.vim' " IDE - Status Line
Plug 'easymotion/vim-easymotion' " IDE - Naviation
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " Lang - GO
" Manual Install
Plug '~/.vim/plugged/YouCompleteMe' " Autocompletion - Engine
call plug#end()
" }}}
" ------ General - Search Very Magic ----- {{{
nnoremap / /\v
" }}}
" ------ General - New Buffer Location ----- {{{
set splitbelow
" }}}
" ------ General - Encoding ----- {{{
set encoding=utf-8
" }}}
" ------ General - Line Number ----- {{{
set number
set relativenumber
" }}}
" ------ General - Indentation ----- {{{
set expandtab
set tabstop=2
set shiftwidth=2
" }}}
" ------ General - Color ----- {{{
set background=dark
colorscheme dracula
" }}}
" ------ Font & GUI & Platform Settings ----- {{{
if has("gui_win32")
au GUIEnter * simalt ~X
set guifont=Consolas:h11:cANSI
elseif has('unix')
let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
else
set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
endif
" }}}
" ------ Plugin - LightLine ----- {{{
set noshowmode
let g:lightline = {
\ 'colorscheme': 'darcula',
\ 'mode_map': {
\ 'n': 'N', 'i': 'I', 'R': 'R', 'v': 'V', 'V': 'V-LINE', "\<C-v>": 'V-BLOCK',
\ 'c': 'COMMAND', 's': 'SELECT', 'S': 'S-LINE', "\<C-s>": 'S-BLOCK', 't': 'TERMINAL'
\ },
\ 'inactive': {
\ 'left': [ [ '' ], [ 'filenameshort' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ] ],
\ },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ],
\ 'right': [
\ [ 'lineinfo' ], [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ],
\ ],
\ },
\ 'component_type': { 'lineinfo': 'raw', },
\ 'component_function': {
\ 'mode': 'LightlineMode',
\ 'filename': 'LightlineFilename',
\ 'filenameshort': 'LightlineFilenameShort',
\ 'fugitive': 'LightlineFugitive',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'lineinfo': 'LightlineLineinfo',
\ 'percent': 'LightlinePercent',
\ },
\ }
" ------ Function - LightlineFileformat ----- {{{
function! LightlineFileformat()
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
return winwidth(0) > 70 ? &fileformat : ''
endfunction
" }}}
" ------ Function - LightlineFiletype ----- {{{
function! LightlineFiletype()
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : '<unknown>') : ''
endfunction
" }}}
" ------ Function - LightlineFileencoding ----- {{{
function! LightlineFileencoding()
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
" }}}
" ------ Function - LightlineFilename ----- {{{
function! LightlineFilename(...)
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
let l:exp = a:0 ? a:1 : '%'
let l:modified = &modified ? '*' : ''
let l:readonly = &readonly ? ' [RO] ' : ''
let l:filename = '' != expand('%') ? expand(l:exp) : '[No Name]'
return l:filename . l:modified . l:readonly
endfunction
function! LightlineFilenameShort()
return LightlineFilename('%:t')
endfunction
" }}}
" ------ Function - LightlineFugitive ----- {{{
function! LightlineFugitive()
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
if exists('*fugitive#head')
return fugitive#head()
endif
return ''
endfunction
" }}}
" ------ Function - LightlineMode ----- {{{
function! LightlineMode()
if &ft ==? 'fzf' | return 'FZF' | endif
if &ft ==? 'nerdtree' | return 'NERDTree' | endif
return winwidth(0) > 70 ? lightline#mode() : ''
endfunction
" }}}
" ------ Function - LightlinePercent ----- {{{
function! LightlinePercent()
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
return (line('.') * 100 / line('$')) . '%'
endfunction
" }}}
" ------ Function - LightlineLineinfo ----- {{{
function! LightlineLineinfo()
if &ft ==? 'fzf' | return '' | endif
if &ft ==? 'nerdtree' | return '' | endif
return printf("%3d:%-2d", line('.'), col('.'))
endfunction
" }}}
" }}}
" ------ Plugin - FZF ----- {{{
let g:fzf_layout = { 'down': '~20%' }
" }}}
" ------ Plugin - Ack ----- {{{
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" }}}
" ------ Plugin - YouCompleteMe ----- {{{
let g:ycm_key_list_select_completion = ['<C-j>', '<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<C-p>', '<Up>']
let g:ycm_show_diagnostics_ui = 0 " Disable Syntax Check
" }}}
" ------ Plugin - Gutentags ----- {{{
let g:gutentags_ctags_extra_args = [
\ '--tag-relative',
\ ]
let g:gutentags_ctags_tagfile = '.git/tags'
let g:gutentags_ctags_exclude = [
\ 'node_modules',
\ ]
" }}}
" ------ Function - ClearTrailingSpaces ----- {{{
function! g:ClearTrailingSpaces()
:%s/\s\+$//e
endfunction
" }}}
" ------ Function - CopyFilePath ----- {{{
function! g:CopyFilePath()
let @+ = expand('%:p')
endfunction
" }}}
" ------ Function - LaunchExplorer ----- {{{
function! g:LaunchExplorer()
call system("explorer.exe " . expand('%:h'))
endfunction
" }}}
" ------ Command - VBitsClearTSpaces ----- {{{
command! VBitsClearTSpaces call ClearTrailingSpaces()
" }}}
" ------ Command - VBitsCopyFPath ----- {{{
command! VBitsCopyFPath call CopyFilePath()
" }}}
" ------ Command - VBitsExplorer ----- {{{
if has('win32') || has('win64')
command! VBitsExplorer call LaunchExplorer()
endif
" }}}
" ------ KeyMaps - Leader ----- {{{
let mapleader = ','
" }}}
" ------ KeyMaps - Registers ----- {{{
noremap " r
noremap r "
" }}}
" ------ KeyMaps - NerdTree ----- {{{
nnoremap <C-n> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
" }}}
" ------ KeyMaps - Fugitive ----- {{{
nnoremap <leader>lcd :Glcd<CR>
nnoremap <leader>cd :Gcd<CR>
" }}}
" ------ KeyMaps - Window ----- {{{
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" }}}
" ------ KeyMaps - FZF ----- {{{
nnoremap <C-p> :Files<CR>
" }}}
" ------ Auto-command - Clear Trailing Spaces ----- {{{
augroup el_clear_trailing_space
autocmd!
autocmd FileType ruby,python,javascript,json,c,cpp,html,vue,mma,rust,elm
\ autocmd BufWritePre <buffer> :call ClearTrailingSpaces()
augroup END
" }}}
" ------ Auto-command - VIM Script Folding ----- {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" ------ Lang - elm ----- {{{
let g:ycm_semantic_triggers = {
\ 'elm' : ['.'],
\}
" }}}
" ------ Lang - rust ----- {{{
let g:rustfmt_autosave = 1
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment