Skip to content

Instantly share code, notes, and snippets.

@coderek
Last active February 11, 2022 09:45
Show Gist options
  • Save coderek/008dc4a36b99cfdf7434ce2588f7b498 to your computer and use it in GitHub Desktop.
Save coderek/008dc4a36b99cfdf7434ce2588f7b498 to your computer and use it in GitHub Desktop.
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim/
let path='~/vimfiles/bundle'
call vundle#begin(path)
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'xolox/vim-misc'
Plugin 'scrooloose/nerdtree'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'dbakker/vim-projectroot'
Plugin 'maxmellon/vim-jsx-pretty'
Plugin 'prettier/vim-prettier'
Plugin 'godlygeek/tabular'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'junegunn/vim-easy-align'
Plugin 'tomtom/tlib_vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tpope/vim-surround'
" Plugin 'bling/vim-airline'
Plugin 'itchyny/lightline.vim'
Plugin 'rakr/vim-one'
Plugin 'jdkanani/vim-material-theme'
Plugin 'mileszs/ack.vim'
Plugin 'groenewege/vim-less'
Plugin 'NLKNguyen/papercolor-theme'
Plugin 'franbach/miramare'
Plugin 'honza/vim-snippets'
" Plugin 'bagrat/vim-buffet'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'gosukiwi/vim-atom-dark'
Plugin 'preservim/nerdcommenter'
Plugin 'moll/vim-bbye'
Plugin 'airblade/vim-gitgutter'
Plugin 'shmup/vim-sql-syntax'
Plugin 'fatih/vim-go'
Plugin 'isruslan/vim-es6'
Plugin 'tmhedberg/SimpylFold'
Plugin 'plasticboy/vim-markdown'
Plugin 'junegunn/goyo.vim'
Plugin 'junegunn/limelight.vim'
Plugin 'morhetz/gruvbox'
Plugin 'joshdick/onedark.vim'
Plugin 'sheerun/vim-polyglot'
Plugin 'wsdjeg/vim-fetch'
" Plugin 'ryanoasis/vim-devicons'
Plugin 'stephpy/vim-yaml'
Plugin 'junegunn/fzf.vim'
Plugin 'pbogut/fzf-mru.vim'
Plugin 'arcticicestudio/nord-vim'
Plugin 'tpope/vim-abolish'
Plugin 'PsychoLlama/further.vim'
Plugin 'nvie/vim-ini'
Plugin 'mattn/emmet-vim'
Plugin 'vim-scripts/django.vim'
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'google/yapf', { 'rtp': 'plugins/vim' }
Plugin 'tpope/vim-fugitive'
Plugin 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
Plugin 'Shougo/deoplete.nvim'
Plugin 'Shougo/neosnippet.vim'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'Shougo/context_filetype.vim'
Plugin 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
" Remove ALL autocommands for current group
autocmd!
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
syntax on
set nonumber
set history=700
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set list
set listchars=tab:>-,trail:-
" Add a bit extra margin to the left
set foldcolumn=1
" Use Unix as the standard file type
set ffs=unix,dos,mac
set noeol
set nobackup
set nowb
set noswapfile
set nowritebackup
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=2
set tabstop=2
" Linebreak on 500 characters
set nolbr
set textwidth=0
set wrapmargin=0
set ai "Auto indent
set smartindent " No Smart indent
" \*/src,
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,
\*/dashboard/static,
\*/my_django/static,
\*/tmp/*,
\*.pyc,*.log,
\*.less.css,
\*.class,
\*_jst.js,
\*-templates.js,
\*/__pycache__,
\*/.DS_Store,
\*.pg_dump,
\*/.frontend_tests,
\*/coverage,
\*/public,
\*/target,
\*/node_modules,
\*/storybook-static,
let g:vim_markdown_folding_disabled=1
let g:colorizer_auto_map = 1
let g:colorizer_auto_color = 1
let g:lightline = {
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ],
\ [ 'ctrlpmark', 'git', 'diagnostic', 'cocstatus', 'filename', 'method' ]
\ ],
\ 'right':[
\ [ 'filetype', 'fileencoding', 'lineinfo', 'percent' ],
\ [ 'blame' ]
\ ],
\ },
\ 'component_function': {
\ 'blame': 'LightlineGitBlame',
\ }
\ }
function! LightlineGitBlame() abort
let blame = get(b:, 'coc_git_blame', '')
return winwidth(0) > 120 ? blame : ''
endfunction
let g:lightline = { 'colorscheme': 'PaperColor' }
autocmd FileType html,css,jsx,typescriptreact,jinja EmmetInstall
let g:emmet_html5 = 1
let g:user_emmet_settings = {
\ 'typescriptreact' : {
\ 'extends' : 'jsx',
\ },
\}
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" indent json files on save
" autocmd BufWritePre *.json %!python -m json.tool
set diffopt=vertical
set cursorline
" set colorcolumn=100
let NERDTreeIgnore=[]
let NERDTreeShowBookmarks = 1
let NERDTreeRespectWildIgnore = 1
let NERDTreeChDirMode = 2
set nowrap
nnoremap <Leader>cd :cd %:p:h<CR>
let g:easy_align_delimiters = {
\ '<': { 'pattern': '<-' },
\ '"': { 'pattern': '"' },
\ }
set foldmethod=indent
set foldlevel=99
vnoremap // y/<C-R>"<CR>
nnoremap <Leader><Leader> :vsplit $MYVIMRC<cr>
set splitright
set splitbelow
nnoremap <Leader>q :Bdelete<CR>
nnoremap <Leader>qa :bufdo :Bdelete<CR>
set statusline+=%#warningmsg#
set statusline+=%*
let g:javascript_enable_domhtmlcss = 1
" search word under cursor without jumping to next
" nnoremap * *##*
function! EditDotFile()
let file_name=$HOME . '/.' . input('Edit .')
exe 'edit' file_name
endfunction
nnoremap <leader>nc :NERDTreeClose<CR>
nnoremap <leader>nl :nohlsearch<CR>
nnoremap <leader>. :call EditDotFile()<CR>
let g:signify_vcs_list = [ 'git' ]
let g:ackhighlight = 1
set t_Co=256
set makeprg="gradle test"
set nolist
" ctrl slash
noremap <C-_> :call Comment()<CR>
au BufRead *.md setlocal nonu wrap textwidth=80
" au BufRead *.ts setlocal shiftwidth=2 tabstop=2
"
" au BufRead *.js setlocal filetype=typescript
set foldcolumn=0
map <Leader>ddd :bufdo bdelete<CR>
set isfname+=@-@ " for angular
set suffixesadd=.java,.ts,.tsx,.jsx,.py,.js,.d.ts,.go
set laststatus=2 " always show status
set guitablabel=%t
set autoread
set backupcopy=yes
set guioptions=
let g:vue_disable_pre_processors=1
let g:ackprg = "ag --column --ignore node_modules --hidden --ignore .git --ignore .vim --ignore .vscode"
hi ColorColumn NONE
hi Search cterm=NONE ctermfg=14 ctermbg=8
hi LineNr ctermfg=green
hi Visual ctermfg=3
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
" set includeexpr=substitute(v:fname,'@app/\\(.*\\)','\\1','')
let g:javascript_plugin_flow = 1
function! OpenBitBucket()
let n = line('.')
let p = expand('%:p')
let r = getcwd()
let c = substitute(p, r.'/', '', '')
let bbRepo = 'git remote get-url --push origin | sed -e "s/ssh:\/\/git@git.ninjavan.co:7999\/\(.*\)\/\(.*\).git/https:\/\/git.ninjavan.co\/projects\/\1\/repos\/\2\/browse\//g"'
let a = system(bbRepo)
exe '!open '.trim(a).trim(c).'\#'.n
endfunction
nmap <leader>O :call OpenBitBucket() <CR><CR>
set stal=1
let &t_SI.="\e[5 q" "SI = INSERT mode
let &t_SR.="\e[4 q" "SR = REPLACE mode
let &t_EI.="\e[1 q" "EI = NORMAL mode (ELSE)
nnoremap <C-N> :set number!<CR>
"if (has("nvim"))
" "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
" let $NVIM_TUI_ENABLE_TRUE_COLOR=1
"endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
set termguicolors
set nu
set shada='100,<1000,s1000,h
set clipboard=unnamedplus
" Plugin 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 <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=3 concealcursor=niv
endif
let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
au BufRead *.svg :set filetype=html
let g:neosnippet#snippets_directory='/Users/derekzeng/.snippets/'
nmap <leader>1 :1tabn<CR>
nmap <leader>2 :2tabn<CR>
nmap <leader>3 :3tabn<CR>
nmap <leader>4 :4tabn<CR>
nmap <leader>5 :5tabn<CR>
nmap <leader>6 :6tabn<CR>
nmap <leader>7 :7tabn<CR>
nmap <leader>8 :8tabn<CR>
nmap <leader>9 :9tabn<CR>
nmap <leader>0 :10tabn<CR>
noremap <Tab> :bn<CR>
noremap <S-Tab> :bp<CR>
noremap <Leader><Tab> :Bw<CR>
noremap <Leader><S-Tab> :Bw!<CR>
noremap <C-t> :tabnew split<CR>
au! BufEnter .vimrc setlocal filetype=vim
if has("gui_running")
auto VimEnter * NERDTree hr
auto VimEnter * CocStart
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
" if strftime("%H") < 19
" set background=light
" colorscheme miramare
" else
set background=dark
" colorscheme PaperColor
" endif
au UIEnter * :NERDTree saas
else
colorscheme one
endif
" else
" let g:coc_enabled_pattern = "pre-employment\\|noah\\|Vault"
"au BufAdd * let b:coc_enabled=expand("%:p:h")=~ g:coc_enabled_pattern
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [[ <Plug>(coc-diagnostic-prev)
nmap <silent> ]] <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
nnoremap <leader>l :CocList<CR>
" Run jest for current project
command! -nargs=0 Jest :call CocAction('runCommand', 'jest.projectTest')
" Run jest for current file
command! -nargs=0 JestCurrent :call CocAction('runCommand', 'jest.fileTest', ['%'])
" Run jest for current test
nnoremap <leader>te :call CocAction('runCommand', 'jest.singleTest')<CR>
" Init jest in current cwd, require global jest command exists
command! JestInit :call CocAction('runCommand', 'jest.init')
autocmd BufEnter *.{js,jsx,ts,tsx} :syntax sync fromstart
autocmd BufLeave *.{js,jsx,ts,tsx} :syntax sync clear
let g:coc_global_extensions = [
\ 'coc-highlight',
\ 'coc-tsserver',
\ 'coc-prettier',
\ 'coc-eslint',
\ 'coc-json',
\ 'coc-pyright',
\ 'coc-imselect',
\ 'coc-git',
\ 'coc-html',
\ 'coc-css',
\ 'coc-flutter',
\ ]
let b:coc_root_patterns = ["node_modules"]
" endif
set iskeyword-=-
au! BufRead .*rc setlocal filetype=dosini
au! BufRead .jsx setlocal filetype=javascriptreact
nnoremap <Leader>n :NERDTreeToggle<CR>
function! FoldImport()
endfunction
let g:python3_host_prog = '~/.pyenv/shims/python3'
set rtp+=/usr/local/opt/fzf
set relativenumber
set number
set number relativenumber
noremap <C-p> :Files<CR>
" navigate chunks of current buffer
nmap [g <Plug>(coc-git-prevchunk)
nmap ]g <Plug>(coc-git-nextchunk)
" navigate conflicts of current buffer
nmap [c <Plug>(coc-git-prevconflict)
nmap ]c <Plug>(coc-git-nextconflict)
" show chunk diff at current position
nmap gs <Plug>(coc-git-chunkinfo)
" show commit contains current position
nmap gc <Plug>(coc-git-commit)
cnoreabbrev Ack Ack!
let NERDSpaceDelims=1
let NERDDefaultAlign='left'
command Ball :bufdo Bdelete!
" let g:airline_powerline_fonts = 1
" let g:airline_theme='gruvbox'
let g:vim_markdown_conceal = 0
let g:dart_format_on_save = 0
autocmd FileType python set shiftwidth=2
autocmd FileType python set tabstop=2
autocmd FileType python set softtabstop=2
" neodvide settings
let g:neovide_cursor_animation_length=0.01
let g:neovide_cursor_trail_length=0.01
let g:neovide_cursor_antialiasing=v:false
let g:neovide_cursor_vfx_mode = "railgun"
let g:neovide_transparency=1
let $BAT_THEME='zenburn'
map <leader><space> :FZFMru<cr>
let g:fzf_mru_no_sort = 1
nnoremap <silent> <space>g :<C-u>CocList --normal gstatus<CR>
" re-enable Gblame from fugitive
command! -bang Gblame :Git blame
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" highlight CocFloating ctermbg=7 guibg=#888888
highlight CocHighlightText ctermfg=7 guifg=darkblue guibg=#f8f8f8
" highlight Pmenu ctermbg=7 guibg=#888888
function! DeleteOtherBuffers(bang)
let current_buf = bufnr()
let l:bufs = tabpagebuflist()
for l:buf_id in l:bufs
if current_buf isnot# l:buf_id
execute 'silent bwipe' . a:bang . " " . l:buf_id
endif
endfor
endfunction
command! -bang -nargs=? Bonly call DeleteOtherBuffers(<q-bang>, <q-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment