Skip to content

Instantly share code, notes, and snippets.

@mddub
Created October 4, 2018 20:47
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 mddub/9632e1dac680922bddaf33a7613b3c79 to your computer and use it in GitHub Desktop.
Save mddub/9632e1dac680922bddaf33a7613b3c79 to your computer and use it in GitHub Desktop.
set nocompatible
" ---------- plugins ---------
execute pathogen#infect()
" Syntastic
let g:syntastic_auto_loc_list=1
let g:syntastic_html_checkers=[]
let g:syntastic_python_checkers = ['flake8', 'pylint', 'mypy']
" XXX filtering out pylint errors caused by not being in a venv and namedtuples being considered not callable
let g:syntastic_python_pylint_quiet_messages = { "level" : "warnings", "regex": ["import-error", "no-member", "not-callable", "semicolon", "unsubscriptable-object"] }
let g:syntastic_python_mypy_args = "--follow-imports skip --ignore-missing-imports --strict-optional"
" Cannot find module named 'asynq'
let g:syntastic_python_mypy_quiet_messages = { "regex": ["No library stub file for module", "asynq"] }
let g:syntastic_ruby_mri_quiet_messages = { "regex": 'interpreted as argument prefix' }
let g:syntastic_eruby_ruby_quiet_messages = { "regex": "possibly useless use of a variable in void context"}
let g:syntastic_c_include_dirs = ['/Users/mark/Library/Application Support/Pebble SDK/SDKs/current/sdk-core/pebble/basalt/include', 'build/basalt']
let g:syntastic_c_remove_include_errors = 1
" Tagbar
let g:tagbar_sort = 0
let g:tagbar_compact = 1
let g:tagbar_autofocus = 1
" jedi-vim
let g:jedi#auto_vim_configuration = 0
" muscle memory from Ropevim
let g:jedi#goto_command = "<C-c>g"
let g:jedi#goto_assignments_command = ""
let g:jedi#completions_enabled = 0
" 0 if you want to enable it later via :RainbowToggle
"let g:rainbow_active = 1
" ---------- settings ---------
let mapleader = ","
set mouse=a
" Filetype highlighting
filetype plugin indent on
syntax on
set modelines=5
" Show what you are typing mid-command
set showcmd
" Indentation/tabs
set autoindent
" 4 spaces by default
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" Python: spaces, not tabs
autocmd BufWinEnter *.py setlocal expandtab
autocmd BufWinEnter *.html setlocal tabstop=2
autocmd BufWinEnter *.html setlocal shiftwidth=2
autocmd BufWinEnter *.html setlocal softtabstop=2
autocmd BufWinEnter *.js setlocal tabstop=2
autocmd BufWinEnter *.js setlocal shiftwidth=2
autocmd BufWinEnter *.js setlocal softtabstop=2
autocmd BufWinEnter *.rb setlocal tabstop=2
autocmd BufWinEnter *.rb setlocal shiftwidth=2
autocmd BufWinEnter *.rb setlocal softtabstop=2
autocmd BufWinEnter *.css setlocal tabstop=2
autocmd BufWinEnter *.css setlocal shiftwidth=2
autocmd BufWinEnter *.css setlocal softtabstop=2
autocmd BufWinEnter *.scss setlocal tabstop=2
autocmd BufWinEnter *.scss setlocal shiftwidth=2
autocmd BufWinEnter *.scss setlocal softtabstop=2
" Google Apps Script
autocmd BufWinEnter *.gs setlocal syntax=javascript
" waf
autocmd BufWinEnter wscript setlocal syntax=python
" highlight trailing whitespace and non-tab indents
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter *.* match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Color scheme and font
"colorscheme smyck
colorscheme xoria256
set guifont=Monaco:h12
" Highlight current line
set cursorline
" Statusline
set laststatus=2 " Show statusline even when there is a single window
set statusline=%F%m%r%h%w%{fugitive#statusline()}
set statusline+=[%l,%v][%p%%]
" Maintain more text around the cursor
set scrolloff=3
" Show line numbers
set number
" More intelligent backspace and left/right movement
set backspace=eol,start,indent
set whichwrap=b,s,h,l,<,>,[,]
" Hidden buffer support
set hidden
" Disable annoying messages, swap file already exists
set autoread
set shortmess+=IA
" Longer history
set history=1000
" Case-smart searching (case-sensitive only if capital letter in search)
set ignorecase
set smartcase
" Incremental search
set incsearch
" Tab completion
set wildmode=longest,list
set wildignore=*.pyc,*/node_modules/*
" Visual bell instead of beep
set visualbell
" keep backups and temp files in ~.vim/
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
" set default split opening position to be below and to the right of currently active split
set splitbelow
set splitright
" Filetypes
autocmd BufEnter *.mako setlocal filetype=html
" ctrlp
let g:ctrlp_working_path_mode = 0
let g:ctrlp_switch_buffer = 0
" Support editing crontab
au! BufNewFile,BufRead crontab.* set nobackup | set nowritebackup
"
" Highlight the 80th column, for python files
highlight ColorColumn ctermbg=black
autocmd BufEnter *.py setlocal colorcolumn=80
" Fugitive git grep, skip showing a shell with results
:command -nargs=+ Ggr execute 'silent Ggrep!' <q-args> | cw | redraw!
" ---------- mappings ---------
" Typos and things I don't want to do
nmap Q <ESC>
nmap :Q :q
nmap :W :w
nmap :E :w
nmap :WQ :wq
nmap :Wq :wq
nmap :Vs :vs
nmap :VS :vs
nmap :Spl :spl
" Windows
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-H> <C-W>h
map <C-L> <C-W>l
" Function key shortcuts
map <F1> <nop>
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
map <F3> :set hlsearch! hlsearch?<CR>
map <F6> :NERDTreeClose<CR>
" TODO combine with F6 to make toggle
map <F7> :NERDTreeFind<CR>
map <F8> :TagbarToggle<CR>
" Leader shortcuts
map <Leader>v :tabe ~/.vimrc<CR>
map <Leader>e :tabe
" open a file in same directory as current file
map <Leader>E :e <C-R>=expand('%:p:h') . '/'<CR>
" open current buffer in new tab
map <Leader>s :tab split<CR>
map <Leader>n :tabnew<CR>
map <Leader>Q :tabc<CR>
map <Leader>m :tabm
map <Leader>w :w<CR>
map <Leader>q :q<CR>
map <Leader>L :lclose<CR>
map <Leader>c :copen<CR>
map <Leader>C :cclose<CR>
map <Leader>z :cp<CR>
map <Leader>x :cn<CR>
" open url on curent line (osx)
map <Leader>u :exec "!open ".shellescape(getline("."), 1)<CR>
" git diff in new tab
map <Leader>f :tab split<CR>:Gdiff HEAD<CR>
" see Ggr definition above
map <Leader>g :tab split<CR>:Ggr -i
" Ggr for word under cursor
map <Leader>G :Ggr <cword><CR>
" git blame (ignoring whitespace)
map <Leader>l :Gblame -w<CR>
" commit log for current file
map <Leader>o :Glog -- %<CR>:copen<CR>
map <Leader>i Oimport ipdb; ipdb.set_trace()<ESC>
"map <Leader>I Obinding.pry<ESC>
map <Leader>I OAPP_LOG(APP_LOG_LEVEL_DEBUG, <ESC>
" muscle memory from command-t
map <Leader>t :CtrlP<CR>
" open pebble header file
map <Leader>p :tabe /Users/mark/Library/Application\ Support/Pebble\ SDK/SDKs/current/sdk-core/pebble/basalt/include/pebble.h<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment