Skip to content

Instantly share code, notes, and snippets.

@alexfaber2011
Created April 22, 2019 17:11
Show Gist options
  • Save alexfaber2011/b2aca6da51ddb0cbc0a98b54945a5781 to your computer and use it in GitHub Desktop.
Save alexfaber2011/b2aca6da51ddb0cbc0a98b54945a5781 to your computer and use it in GitHub Desktop.
Alex's semi-ultra-dank .vimrc
" Specify a directory for plugins
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'itchyny/lightline.vim'
Plug 'airblade/vim-gitgutter'
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-fugitive'
Plug 'editorconfig/editorconfig-vim'
Plug 'Quramy/tsuquyomi'
Plug 'vim-ruby/vim-ruby'
Plug 'flazz/vim-colorschemes'
Plug 'tpope/vim-unimpaired'
Plug 'ryanoasis/vim-devicons'
Plug 'vim-scripts/BufOnly.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'xolox/vim-session'
Plug 'xolox/vim-misc'
Plug 'heavenshell/vim-jsdoc'
Plug 'mileszs/ack.vim'
Plug 'Raimondi/delimitMate'
Plug 'tpope/vim-surround'
Plug 'kana/vim-textobj-entire'
Plug 'kana/vim-textobj-user'
Plug 'jiangmiao/auto-pairs'
Plug 'w0rp/ale'
Plug 'nelstrom/vim-visual-star-search'
Plug 'digitaltoad/vim-pug'
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
call plug#end()
" Configure VIM's settings
set hidden
set encoding=UTF-8
set number
set linebreak
set showbreak=+++
set textwidth=100
set showmatch
set visualbell
set hlsearch
set smartcase
set ignorecase
set incsearch
set autoindent
set expandtab
set shiftwidth=2
set smartindent
set smarttab
set softtabstop=2
set ruler
set cursorline
set undolevels=1000
set backspace=indent,eol,start
set laststatus=2
set noshowmode
set wildmenu
set wildmode=full
set history=200
set clipboard=unnamed
set signcolumn=yes
" Change the command height to make for better error viewing
set cmdheight=2
" Use tab for trigger completion with characters ahead and navigate.
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> for trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use `[g` and `]g` for navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
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 for show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
vmap <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
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
vmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Use `:Format` for format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` for fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add diagnostic info for https://github.com/itchyny/lightline.vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'cocstatus': 'coc#status'
\ },
\ }
" Crew a new-line without going into insert mode
nmap <S-Cr> o<Esc>
" Easy expansion of the active file directory
cnoremap <expr> %% getcmdtype() == ':'?expand('%:h').'/' : '%%'
" Configure Vim for Ruby use as specified by
" https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport
set nocompatible
syntax on
filetype on
filetype indent on
filetype plugin on
runtime macros/matchit.vim
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
" Set the theme
colorscheme railscasts
" Configure Nerd Commenter
let g:NERDCustomDelimiters = { 'typescript.tsx': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' } }
" Configure ALE (for linting)
let g:ale_linters = {'typescript': ['tslint']}
let b:ale_fixers = {'typescript': ['tslint']}
let g:ale_fixers = {'typescript': ['tslint']}
let g:ale_fix_on_save = 1
" Configure ack.vim to use the_silver_searcher
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Configure vim-fugitive to have vertical splits
set diffopt+=vertical
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment