Skip to content

Instantly share code, notes, and snippets.

@frizbee
Last active July 24, 2020 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frizbee/8174f50d6863666efb217615bc1ecfac to your computer and use it in GitHub Desktop.
Save frizbee/8174f50d6863666efb217615bc1ecfac to your computer and use it in GitHub Desktop.
my current .vimrc
syntax on
set hidden
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set incsearch
set guifont=Monaco:h14
" set encoding=utf-8a " This option is required by YCM.
set backspace=indent,eol,start
"
:set cryptmethod=blowfish2
"" set softtabstop=0 noexpandtab
"" For indents that consist of 4 space characters but are entered with the tab key ""
"" set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
" Plugins
" https://vimawesome.com/plugin/trailing-whitespace
""
"" fix quotes in json files
""
let vim_json_syntax_conceal=0
set colorcolumn=80
highlight ColorColumn ctermbg=233
" highlight ColorColumn ctermbg=0 guibg=lightgrey
call plug#begin('~/.vim/plugged')
Plug 'ycm-core/YouCompleteMe'
Plug 'morhetz/gruvbox'
" Plug 'sainnhe/gruvbox-material'
Plug 'jremmen/vim-ripgrep'
Plug 'tpope/vim-fugitive'
Plug 'vim-utils/vim-man'
" Plug 'lyuts/vim-rtags'
" Plug 'ctrlpvim/ctrlp.vim'
Plug 'mbbill/undotree'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-ragtag'
Plug 'tpope/vim-endwise'
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'preservim/nerdcommenter'
Plug 'dense-analysis/ale'
Plug 'bronson/vim-trailing-whitespace'
""""""" snipMate
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()
" YouCompleteMe autocomplete for thos listed langs
" let s:lsp = '~/.vim/extra/lsp-examples'
" let g:ycm_language_server = [
" \ {
" \ 'name': 'dart',
" \ 'cmdline': [ 'dart', expand( s:lsp . '/dart/analysis_server.dart.snapshot' ), '--lsp' ],
" \ 'filetypes': [ 'dart' ],
" \ },
" \ {
" \ 'name': 'yaml',
" \ 'cmdline': [ 'node', expand( s:lsp . '/yaml/node_modules/.bin/yaml-language-server' ), '--stdio' ],
" \ 'filetypes': [ 'yaml' ],
" \ },
" \ {
" \ 'name': 'ruby',
" \ 'cmdline': [ expand( s:lsp . '/ruby/bin/solargraph' ), 'stdio' ],
" \ 'filetypes': [ 'ruby' ],
" \ },
" \ {
" \ 'name': 'vue',
" \ 'filetypes': [ 'vue' ],
" \ 'cmdline': [ expand( s:lsp . '/vue/node_modules/.bin/vls' ) ]
" \ },
" \ ]
" colorscheme gruvbox
" important!!
if has('termguicolors')
set termguicolors
endif
let g:gruvbox_material_background = 'soft'
let g:airline_theme = 'gruvbox' " _material'
colorscheme gruvbox " -material
set background=dark
if executable('rg')
let g:rg_derive_root='true'
endif
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let mapleader = " "
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
" hide some extra popup window
let g:netrw_browse_split = 2
let g:netrw_banner = 0
let g:netrw_winsize = 25
let g:ctrlp_use_caching = 0
" let g:surround_{char2nr('-')} = "<% \r %>"
" let g:surround_{char2nr('=')} = "<%= \r %>"
" Linter from ALE plugin
let g:ale_linters = {
\ 'ruby': ['standardrb', 'rubocop'],
\ 'javascript': ['eslint'],
\}
nnoremap <leader>n :NERDTreeToggle<CR>
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>ut :UndotreeShow<CR>
nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
nnoremap <Leader>ps :Rg<SPACE>
nnoremap <silent> <Leader>+ :vertical resize +5<CR>
nnoremap <silent> <Leader>- :vertical resize -5<CR>
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Always enable preview window on the right with 60% width
let g:fzf_preview_window = 'right:60%'
" cmap asdf :%s/\r//g
" tpope/vim-figutive
nmap <leader>gs :G<CR>
nmap <leader>gr :diffget //3<CR>
nmap <leader>gl :diffget //2<CR>
:set diffopt+=vertical
" Go linter
" https://github.com/golang/lint
" Usage run :Lint within open file or golint in root
set rtp+=$GOPATH/src/golang.org/x/lint/misc/vim
" This will be running on save :w
autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow
" fzf vim
nmap <leader>gf :GFile<CR>
map <c-p> :FZF<CR>
fun! GoYCM()
nnoremap <buffer> <silent> <leader>gd :YcmCompleter GoTo<CR>
nnoremap <buffer> <silent> <leader>gr :YcmCompleter GoToReferences<CR>
nnoremap <buffer> <silent> <leader>rr :YcmCompleter RefactorRename<space>
endfun
" upper/lower word
nmap <leader>U mQviwU`Q
nmap <leader>L mQviwu`Q
" upper/lower first char of word
" nmap <leader>U mQgewvU`Q
" nmap <leader>L mQgewvu`Q
if has("gui_macvim") && has("gui_running")
" Map command-[ and command-] to indenting or outdenting
" while keeping the original selection in visual mode
vmap <D-]> >gv
vmap <D-[> <gv
nmap <D-]> >>
nmap <D-[> <<
omap <D-]> >>
omap <D-[> <<
imap <D-]> <Esc>>>i
imap <D-[> <Esc><<i
" Bubble single lines
nmap <D-Up> [e
nmap <D-Down> ]e
nmap <D-k> [e
nmap <D-j> ]e
" Bubble multiple lines
vmap <D-Up> [egv
vmap <D-Down> ]egv
vmap <D-k> [egv
vmap <D-j> ]egv
" Map Command-# to switch tabs
map <D-0> 0gt
imap <D-0> <Esc>0gt
map <D-1> 1gt
imap <D-1> <Esc>1gt
map <D-2> 2gt
imap <D-2> <Esc>2gt
map <D-3> 3gt
imap <D-3> <Esc>3gt
map <D-4> 4gt
imap <D-4> <Esc>4gt
map <D-5> 5gt
imap <D-5> <Esc>5gt
map <D-6> 6gt
imap <D-6> <Esc>6gt
map <D-7> 7gt
imap <D-7> <Esc>7gt
map <D-8> 8gt
imap <D-8> <Esc>8gt
map <D-9> 9gt
imap <D-9> <Esc>9gt
else
" Map command-[ and command-] to indenting or outdenting
" while keeping the original selection in visual mode
vmap <A-]> >gv
vmap <A-[> <gv
nmap <A-]> >>
nmap <A-[> <<
omap <A-]> >>
omap <A-[> <<
imap <A-]> <Esc>>>i
imap <A-[> <Esc><<i
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
nmap <C-k> [e
nmap <C-j> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
vmap <C-k> [egv
vmap <C-j> ]egv
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
" Map Control-# to switch tabs
map <C-0> 0gt
imap <C-0> <Esc>0gt
map <C-1> 1gt
imap <C-1> <Esc>1gt
map <C-2> 2gt
imap <C-2> <Esc>2gt
map <C-3> 3gt
imap <C-3> <Esc>3gt
map <C-4> 4gt
imap <C-4> <Esc>4gt
map <C-5> 5gt
imap <C-5> <Esc>5gt
map <C-6> 6gt
imap <C-6> <Esc>6gt
map <C-7> 7gt
imap <C-7> <Esc>7gt
map <C-8> 8gt
imap <C-8> <Esc>8gt
map <C-9> 9gt
imap <C-9> <Esc>9gt
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment