Skip to content

Instantly share code, notes, and snippets.

@dorajam
Created November 19, 2016 01: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 dorajam/9252a27ad0a75f60e9fca14beb723a42 to your computer and use it in GitHub Desktop.
Save dorajam/9252a27ad0a75f60e9fca14beb723a42 to your computer and use it in GitHub Desktop.
My friend, Vim
" Exc mapped to jk
:imap jk <Esc>
syntax on
let $FZF_DEFAULT_OPTS .= ' --inline-info'
set rtp+=~/.fzf
set bg=dark
set nowrap
set so=5
set synmaxcol=200
set nocursorline
set re=1
set nu
set rnu
set shiftwidth=4
set tabstop=4
set smartcase
set smartindent
set nobackup
set nowritebackup
set noswapfile
set mouse=a
set nojoinspaces
" fix copy paste
set clipboard=unnamed
" Search
set hlsearch
noremap <silent> gl :nohl<cr>
" Custom leader keys
let mapleader = "\<Space>"
let maplocalleader = "\\"
" Qucksave
nnoremap <Leader>w :up<CR>
" Move between arguments
nmap ]i vIna<esc>`<
nmap [i vIla<esc>`<
" Tab movement
nnoremap <Leader>tn :tabnew<CR>
nnoremap <Leader>tc :tabclose<CR>
nnoremap <Leader>te :tabedit<CR>
execute "set <A-{>=\e{"
execute "set <A-}>=\e}"
nnoremap <silent> <A-{> :tabprevious<CR>
nnoremap <silent> <A-}> :tabnext<CR>
" Buffer movement
nnoremap <leader>q :b#<CR>
noremap gbq :b#<CR>
noremap gbn :bn<CR>
noremap gbp :bp<CR>
noremap gbd :bd<CR>
noremap gbh :hide<CR>
" Format part files
command -range=% PartFormat :<line1>,<line2>!part_format
noremap gpff :PartFormat<CR>
noremap gpfl :.PartFormat<CR>
" Trim whitespace
command -range=% TrimWhitespace :<line1>,<line2>s/\s\+$//e
augroup TrimWhitespace
autocmd!
autocmd BufWritePre *.rb :TrimWhitespace
autocmd BufWritePre *.py :TrimWhitespace
autocmd BufWritePre *.c :TrimWhitespace
autocmd BufWritePre *.h :TrimWhitespace
autocmd BufWritePre *.m :TrimWhitespace
autocmd BufWritePre *.cpp :TrimWhitespace
autocmd BufWritePre *.js :TrimWhitespace
autocmd BufWritePre *.java :TrimWhitespace
autocmd BufWritePre *.scala :TrimWhitespace
augroup END
" Ctags
set tags=.git/tags
command UpdateCTags :Dispatch! git ctags <CR>
autocmd BufWritePost * :UpdateCTags
" Quick Search
let g:ackprg = '/usr/local/bin/rg --vimgrep --smart-case'
cnoreabbrev ag Ack
cnoreabbrev aG Ack
cnoreabbrev Ag Ack
cnoreabbrev AG Ack
nnoremap gA :Ack
" Jump to errors
nmap <Leader>ll :ll<CR>
nmap <Leader>ln :lne<CR>
nmap <Leader>lp :lr<CR>
call plug#begin('~/.vim/autoload')
Plug 'Chiel92/vim-autoformat'
Plug 'godlygeek/tabular'
Plug 'michaeljsmith/vim-indent-object'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar'
Plug 'kshenoy/vim-signature'
Plug 'unblevable/quick-scope'
Plug 'Shougo/deoplete.nvim'
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/neosnippet.vim'
Plug 'zchee/deoplete-jedi'
Plug 'mileszs/ack.vim'
Plug 'w0rp/ale'
Plug 'chrisbra/vim-autoread'
" Language support
Plug 'derekwyatt/vim-scala'
Plug 'elzr/vim-json'
Plug 'fatih/vim-go'
Plug 'indentpython.vim'
Plug 'jalvesaq/Nvim-R'
Plug 'julialang/julia-vim'
Plug 'kchmck/vim-coffee-script'
Plug 'keith/swift.vim'
Plug 'msanders/cocoa.vim'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-rails'
Plug 'tshirtman/vim-cython'
Plug 'svermeulen/vim-easyclip'
" Plug 'vim-pandoc/vim-pandoc'
" Plug 'vim-pandoc/vim-pandoc-syntax'
" Plug 'chrisbra/csv.vim'
" Colors
Plug 'flazz/vim-colorschemes'"
" Colour Schemes
Plug 'romainl/flattened'
call plug#end()
" Plugin Settings
" Autoformat
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0
nnoremap <localleader>f :Autoformat<CR>
" Ale
let g:ale_lint_on_save=1
let g:ale_lint_on_text_changed=0
let g:ale_linters = {
\ 'python': ['flake8'],
\}
" Vim Go
let g:go_def_mapping_enabled = 0
" FZF
let g:fzf_tags_command = 'ctags -R --languages=-json'
nmap <c-p> :FZF<CR>
nmap <c-t> :BTags<CR>
nmap <c-y> :Tags<CR>
nmap <c-@> :Buffers<CR>
nmap gsm :Marks<CR>
nmap gsgt :Tags<CR>
nmap gst :BTags<CR>
nmap gsl :Lines<CR>
nmap gsb :Buffers<CR>
nmap gsc :Colors<CR>
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Tagbar
nmap <c-w>t :TagbarToggle<CR>
let g:tagbar_ctags_bin = '/usr/local/bin/ctags'
let g:tagbar_sort = 0
let g:tagbar_compact = 1
let g:tagbar_type_yaml = {
\ 'ctagstype' : 'Yaml',
\ 'kinds' : [
\ 'f:flow:1:0',
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'f' : 'flow',
\ },
\ 'scope2kind' : {
\ 'flow' : 'f',
\ }
\ }
" Initialize Project dependant settings
function! SetupEnvironment()
let l:path = expand('%:p')
if l:path =~ 'shopify'
if &filetype == 'yaml'
augroup ShopifyAugroup
autocmd!
autocmd FileType ruby setlocal shiftwidth=2 softtabstop=2 expandtab
autocmd FileType yml setlocal shiftwidth=2 tabstop=2 colorcolumn=80 spell expandtab
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 colorcolumn=80 spell expandtab
autocmd Filetype sql setlocal shiftwidth=2 tabstop=2 expandtab
augroup END
endif
endif
endfunction
autocmd! FileReadPost,BufFilePost,BufReadPost,BufNewFile,BufEnter * call SetupEnvironment()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment