Skip to content

Instantly share code, notes, and snippets.

@asmyshlyaev177
Last active November 7, 2020 05:29
Show Gist options
  • Save asmyshlyaev177/a0d85e993ae7892ac18e6a92c0e60d45 to your computer and use it in GitHub Desktop.
Save asmyshlyaev177/a0d85e993ae7892ac18e6a92c0e60d45 to your computer and use it in GitHub Desktop.
My vimrc config
" run on first start
" PluginInstall
" install vim-plug
" PlugInstall
" brew install the_silver_searcher
" install https://github.com/Valloric/YouCompleteMe#full-installation-guide
set nocompatible
set mouse=a
if !has('nvim')
set ttymouse=xterm
endif
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set backupcopy=yes
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugin 'SirVer/ultisnips'
Plugin 'VundleVim/Vundle.vim'
" for use nvim in vscode
if !exists('g:vscode')
Plugin 'NLKNguyen/papercolor-theme'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'Yggdroot/indentLine'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'ddrscott/vim-side-search'
Plugin 'frazrepo/vim-rainbow'
Plugin 'vim-airline/vim-airline'
Plugin 'jparise/vim-graphql'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'djoshea/vim-autoread'
Plugin 'itchyny/vim-gitbranch'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-sleuth'
Plugin 'gabesoft/vim-ags'
Plugin 'maxmellon/vim-jsx-pretty'
Plugin 'styled-components/vim-styled-components'
Plugin 'stephpy/vim-yaml'
Plugin 'elzr/vim-json'
Plugin 'easymotion/vim-easymotion'
Plugin 'ap/vim-css-color' " colors
Plugin 'pangloss/vim-javascript'
" Plugin 'leafgarland/typescript-vim'
Plugin 'neoclide/coc.nvim'
Plugin 'benmills/vimux'
endif
" Plugin 'chemzqm/vim-jsx-improve'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'morhetz/gruvbox'
Plugin 'rakr/vim-one'
Plugin 'scrooloose/nerdcommenter'
" coc-eslint coc-css coc-html coc-json coc-sh coc-tsserver coc-snippets coc-tslint
" if have problems :call coc#util#install()
call vundle#end()
" install vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" Plug 'sbdchd/neoformat'
call plug#end()
" Typescript
" typescript-vim plugin
" let g:typescript_indent_disable = 1
" autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html Prettier
" Coc.nvim
" use <tab> for trigger completion and navigate to the next complete item
" let g:coc_snippet_next = '<Tab>'
"
" disable docs for method/object
set completeopt-=preview
" use <tab> for trigger completion and navigate to the next complete item
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
let g:airline_detect_spelllang=0
let g:airline_section_b=''
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#ignore_bufadd_pat = 'defx|gundo|startify|tagbar|undotree|vimfiler'
let g:rainbow_active = 0
autocmd BufRead,BufNewFile *.test.js,*.spec.js call rainbow#load()
let g:rainbow_ctermfgs = ['lightgreen', 'yellow', 'red', 'magenta']
" autocmd FileType javascript syntax clear jsFuncBlock jsFuncArgs
set updatetime=1000
filetype indent plugin on
set hlsearch
set visualbell
set number
syntax on
set shiftwidth=2
set softtabstop=2
set copyindent
set preserveindent
set tabstop=2
set expandtab
set foldmethod=manual
set foldnestmax=1
set novisualbell
set foldlevel=20
set showcmd
set noswapfile
set incsearch
let mapleader = "\<Space>"
nnoremap M :noh<cr>
nnoremap :te<cr> :tabe<cr>
set clipboard=unnamed
set background=dark
autocmd BufEnter * :syntax sync fromstart
autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css
autocmd BufRead,BufNewFile *.js setlocal filetype=javascript
autocmd BufRead,BufNewFile *.jsx setlocal filetype=javascript
autocmd BufRead,BufNewFile *.js.snap setlocal filetype=javascript.css
autocmd BufRead,BufNewFile *.ts setlocal filetype=typescript
autocmd BufRead,BufNewFile *.tsx setlocal filetype=typescript.tsx
autocmd BufRead,BufNewFile *.json set foldmethod=manual
autocmd FileChangedShell * echohl WarningMsg | echo "File changed shell." | echohl None
set t_Co=256
set wildignore+=**/node_modules/**
" open in new tab from quickfix and search
set switchbuf+=usetab,newtab
" save file
nnoremap <Leader>w :w<CR>
"copy relative path to file
nmap <Leader>cf :let @+ = expand("%")<CR>
"copy absolut path to file
nmap <Leader>cF :let @+ = expand("%:p")<CR>
" auto open search window
augroup myvimrc
autocmd!
autocmd QuickFixCmdPost [^l]* cwindow
autocmd QuickFixCmdPost l* lwindow
augroup END" copy/paster to system clipboard
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
nmap <Leader>q :q<CR>
" center line to search
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
" How should we execute the search?
" --heading and --stats are required!
let g:side_search_prg = 'ag --word-regexp'
\. " --ignore={'.js.map','node_modules','dist','public'}"
\. " --heading --stats -B 1 -A 4"
" Can use `vnew` or `new`
let g:side_search_splitter = 'vnew'
" I like 40% splits, change it if you don't
let g:side_search_split_pct = 0.4
" SideSearch current word and return to original window
nnoremap <Leader>ss :SideSearch <C-r><C-w><CR> | wincmd p
" Create an shorter `SS` command
command! -complete=file -nargs=+ SS execute 'SideSearch <args>'
" or command abbreviation
cabbrev SS SideSearch
" word wrap
set linebreak
set dy=lastline
" ignore case when search
set ic
" check one time after 4s of inactivity in normal mode
set autoread
setl autoread
au CursorHold * checktime
au FocusGained,BufEnter * :silent! !
" au FocusGained,BufEnter * :checktime
" :bufdo e!
set noconfirm
let g:vim_json_syntax_conceal = 0
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:jsx_ext_required = 0
let g:javascript_plugin_jsdoc = 1
let g:ycm_show_diagnostics_ui = 0
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_add_preview_to_completeopt = 0
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
hi EasyMotionShade ctermbg=none ctermfg=none
" hi EasyMotionIncSearch ctermbg=black ctermfg=green
let g:EasyMotion_use_upper = 1
let g:EasyMotion_keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ;'
let g:EasyMotion_enter_jump_first = 1
let g:EasyMotion_off_screen_search = 1
" let g:EasyMotion_landing_highlight = 1
nmap s <Plug>(easymotion-sn)
" let g:EasyMotion_add_search_history = 0
nnoremap <Leader>a :Ags -Q --ignore yarn.lock --ignore node_modules --ignore build --ignore coverage --ignore public<Space>
" Ags open in new tab
autocmd FileType agsv nnoremap <buffer> ot
\ :exec 'tab split ' . ags#filePath(line('.'))<CR>
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> {Left-Mapping} :TmuxNavigateLeft<cr>
nnoremap <silent> {Down-Mapping} :TmuxNavigateDown<cr>
nnoremap <silent> {Up-Mapping} :TmuxNavigateUp<cr>
nnoremap <silent> {Right-Mapping} :TmuxNavigateRight<cr>
nnoremap <silent> {Previous-Mapping} :TmuxNavigatePrevious<cr>
nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
noremap <silent> <A-Right> :execute 'silent! tabmove ' . (tabpagenr()+1)<CR>
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
" set t_Co=256 " This is may or may not needed.
set noshowmode " disable show insert\normal mode
" let g:lightline = {
" \ 'active': {
" \ 'left': [ [ 'mode', 'paste' ],
" \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
" \ },
" \ 'component_function': {
" \ 'gitbranch': 'gitbranch#name',
" \ 'filename': 'LightLineFilename'
" \ },
" \ }
" function! LightLineFilename()
" return expand('%')
" endfunction
set laststatus=2
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
let g:ft = ''
function! NERDCommenter_before()
if &ft == 'vue'
let g:ft = 'vue'
let stack = synstack(line('.'), col('.'))
if len(stack) > 0
let syn = synIDattr((stack)[0], 'name')
if len(syn) > 0
exe 'setf ' . substitute(tolower(syn), '^vue_', '', '')
endif
endif
endif
endfunction
function! NERDCommenter_after()
if g:ft == 'vue'
setf vue
let g:ft = ''
endif
endfunction
nmap <leader>c <plug>NERDCommenterToggle
vmap <leader>c <plug>NERDCommenterToggle
" Disable default t mapping
" map ,omg <plug>NERDCommenterComment
" don't overwrite yank buffer
" nnoremap d "_d
" vnoremap d "_d
nmap <leader>n :NERDTreeToggle<cr>
let g:quickfix_is_open = 0
function! QuickfixToggle()
if g:quickfix_is_open
cclose
let g:quickfix_is_open = 0
else
copen
let g:quickfix_is_open = 1
endif
endfunction
" ctrlp open files in new tab
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<2-LeftMouse>'],
\ 'AcceptSelection("t")': ['<cr>'],
\ }
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/coverage/*,*/node_modules/*
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|coverage|cypress-coverage|node_modules|build|dist)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
" clear search cache after switch branch
"autocmd User fugitive command! -bar -buffer -nargs=* CtrlPClearAllCaches && Gci :Git checkout <args>
colorscheme PaperColor
" colorscheme atom-dark-256
" colorscheme spacegray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment