Skip to content

Instantly share code, notes, and snippets.

@lmansur
Created September 1, 2019 12:40
Show Gist options
  • Save lmansur/2d721a77ee730c25898bf956f7d3876a to your computer and use it in GitHub Desktop.
Save lmansur/2d721a77ee730c25898bf956f7d3876a to your computer and use it in GitHub Desktop.
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()
Plug 'thinca/vim-localrc' " Local .vimrc files
Plug 'vim-ruby/vim-ruby'
Plug 'scrooloose/nerdcommenter' " Comments
Plug 'tpope/vim-surround' " Easily change surrounding characters
Plug 'w0rp/ale' " Asynchronous Linting
Plug 'ervandew/supertab' " Autocomplete
Plug 'mileszs/ack.vim' " Ack (and ag)
Plug 'shime/vim-livedown' " Markdown Preview
Plug 'terryma/vim-multiple-cursors' " Multiple Cursor Support
Plug 'tpope/vim-eunuch' " UNIX commands
Plug 'markonm/traces.vim' " Preview pattern and replacement in :s
Plug 'waiting-for-dev/vim-www'
Plug 'tpope/vim-dispatch'
Plug 'janko-m/vim-test'
" Statusline
Plug 'itchyny/lightline.vim' " Status Line
Plug 'maximbaz/lightline-ale' " Lightline ALE integration
" Focus
Plug 'junegunn/limelight.vim' " Focus on the current block of code/text
Plug 'junegunn/goyo.vim' " Distraction-free writing
Plug 'amix/vim-zenroom2'
" Snippets
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
Plug 'mattn/emmet-vim'
" Rails
Plug 'tpope/vim-rails'
Plug 'tpope/vim-haml'
" Git (and Github)
Plug 'tpope/vim-fugitive' " Git for vim
Plug 'tpope/vim-rhubarb' " Github with vim.fugitive
Plug 'junegunn/gv.vim' " Commit browser
Plug 't9md/vim-ruby-xmpfilter'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'junegunn/vim-peekaboo'
set rtp+=~/.fzf
Plug 'junegunn/fzf.vim'
call plug#end()
set nocompatible " choose no compatibility with legacy vi
set encoding=utf-8
set showcmd " display incomplete commands
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
" Use ack instead of grep
set grepprg=ag
" Use ag instead of ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Jump between ale errors
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" Enable line numbers
set number
" Enable ruler
set ruler
" Insert newline after/before cursor and goes to Normal Mode
nmap <S-Enter> O<Esc>
nmap <CR> o<Esc>
" Relocate tab
nmap <C-h> <Esc>:tabm -1<Enter>
nmap <C-l> <Esc>:tabm +1<Enter>
" Copy current file path to clipboard
nmap ,cs :let @+=expand("%")<CR>
nmap ,cl :let @+=expand("%:p")<CR>
" Fold block of code
nmap <space> :call folding#ToggleFold()<CR>
vmap <space> zf
" ALE
" Clear gutter column
highlight clear SignColumn
" Ale highlighting
highlight clear ALEWarning
highlight clear ALEWarningSign
highlight clear ALEErrorSign
hi link ALEErrorSign Error
hi Error ctermfg=1
hi Error ctermbg=255
" Ale signs
let g:ale_sign_error = '•'
let g:ale_sign_warning = '•'
" Does not lint when text changed, only on save.
let g:ale_lint_on_text_changed = 'never'
" Livedown - Markdown preview
nmap <Leader>md :LivedownToggle<CR>
let g:livedown_port = 1337
let g:livedown_browser = "firefox"
" Quick string interpolation for Ruby - stolen from @benoit_tgt
nnoremap <Leader>3 bi"#{<esc>wwi}"<esc>
nnoremap <Leader># bi#{<esc>wwi}<esc>
nnoremap <Leader>let :call LettifyAssignment()<cr>
vnoremap <Leader>let :call LettifyAssignments()<cr>
" Limelight
let g:limelight_conceal_ctermfg = 'gray'
nnoremap <Leader>ll :Limelight!!<esc>
" Lightline
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'component_expand': {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok'
\ },
\ 'component_function': {
\ 'filetype': 'LightlineFiletype'
\ },
\ 'component_type': {
\ 'linter_checking': 'left',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'left'
\ },
\ 'active': {
\ 'right': [
\ [
\ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok'
\ ],
\ [ 'lineinfo' ],
\ [ 'filetype']
\ ]
\ }
\ }
function! LightlineFiletype()
if &filetype ==? 'ruby'
return ''
elseif &filetype ==? 'javascript'
return ''
endif
return &filetype
endfunction
let g:lightline#ale#indicator_checking = "\uf110"
let g:lightline#ale#indicator_warnings = "\uf071"
let g:lightline#ale#indicator_errors = "\uf05e"
let g:lightline#ale#indicator_ok = "\uf00c"
let g:www_shortcut_engines = { 'devdocs': ['Devdocs', '<Leader>doc'] }
let g:fzf_layout = { 'down': '~30%' }
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
nnoremap <c-p> :FZF<cr>
" Search for word under cursor using Ag
map <Leader>ag "zyiw:Ag @z<CR>
" Enable seeing-is-believing mappings only for Ruby
let g:xmpfilter_cmd = "seeing_is_believing"
autocmd FileType ruby nmap <buffer> <F4> <Plug>(seeing_is_believing-mark)
autocmd FileType ruby xmap <buffer> <F4> <Plug>(seeing_is_believing-mark)
autocmd FileType ruby imap <buffer> <F4> <Plug>(seeing_is_believing-mark)
autocmd FileType ruby nmap <buffer> <F6> <Plug>(seeing_is_believing-clean)
autocmd FileType ruby xmap <buffer> <F6> <Plug>(seeing_is_believing-clean)
autocmd FileType ruby imap <buffer> <F6> <Plug>(seeing_is_believing-clean)
autocmd FileType ruby nmap <buffer> <F5> <Plug>(seeing_is_believing-run)
autocmd FileType ruby xmap <buffer> <F5> <Plug>(seeing_is_believing-run)
autocmd FileType ruby imap <buffer> <F5> <Plug>(seeing_is_believing-run)
let test#strategy = "dispatch_background"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment