Skip to content

Instantly share code, notes, and snippets.

@jrmce
Created February 19, 2018 00:45
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 jrmce/2579b8f9305d069c888686859145ef94 to your computer and use it in GitHub Desktop.
Save jrmce/2579b8f9305d069c888686859145ef94 to your computer and use it in GitHub Desktop.
call plug#begin('~/.vim/plugged')
Plug 'ctrlpvim/ctrlp.vim'
Plug 'w0rp/ale'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'Chiel92/vim-autoformat'
Plug 'ervandew/supertab'
call plug#end()
set nocompatible
filetype plugin indent on
let mapleader=","
syntax on
colorscheme marklar
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
set autoindent
set number
set numberwidth=5
set showcmd
set cursorline
set wildmenu
set lazyredraw
set showmatch
set incsearch
set hlsearch
set noswapfile
set history=50
set laststatus=2
set autowrite
set backspace=2
set formatoptions+=t
set ruler
set textwidth=130
set colorcolumn=+1
set list listchars=tab:»·,trail:·,nbsp:·
" Open vimrc in new tab
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" First character of line
nnoremap <leader>a ^
" Quick save
nnoremap <leader>w :w!<cr>
" Quick set paste
nnoremap <leader>p :set paste<cr>
" Quick set no paste
nnoremap <leader>np :set nopaste<cr>
" Quick ESC
inoremap jj <ESC>
" Delete current file
nnoremap <Leader>rm :call delete(expand('%')) \| bdelete!<CR>
" Ctrlp search with files
nnoremap <Leader>. :CtrlP<cr>
nnoremap <Leader>m :CtrlPTag<cr>
" Index ctags
map <Leader>ct :!ctags -R --exclude=node_modules --exclude=coverage --exclude=dist --exclude=.git<CR>
" Clear search using spacebar
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" No arrows
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" Switch between the last two files
nnoremap <Leader><Leader> <c-^>
" Edit vimrc
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" Dont index tags in these folders
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|coverage'
" Omnicomplete options
set complete=.,b,u,w,t,]
set wildmode=longest,list:longest
set completeopt=longest,menu,preview
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Omnicomplete menu colors
hi Pmenu cterm=reverse ctermfg=NONE ctermbg=NONE
hi PmenuSel cterm=reverse,bold ctermfg=NONE ctermbg=White
" Enable ALE completion
let g:ale_completion_enabled = 1
" Turn off background highlights
let g:ale_set_highlights = 0
" Only show 10 items in omnicomplete
let g:ale_completion_max_suggestions = 10
" Previous error
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
" Next error
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" Show errors/warnings in status line
set statusline=%{LinterStatus()}
function! LinterStatus() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? 'OK' : printf(
\ '%dW %dE',
\ all_non_errors,
\ all_errors
\)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment