Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
994 lines (783 sloc) 29.2 KB
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Source:
" http://github.com/basepi/dotfiles
"
" Author:
" Colton Myers (basepi)
" http://github.com/basepi
" colton.myers@gmail.com
" Twitter: @basepi
"
" Credits:
" Many cool features I've implemented here were inspired by amix's vimrc,
" blogged about at the following link:
" http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Installation Instructions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Please see README.md for installation instructions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Define installation-specific functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MySys function defines your system type. Uncomment correct line
function! MySys()
return 'mac' " Mac is default, since it's what I use most
" return 'windows'
" return 'linux'
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Commands that need to be defined FIRST
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" <leader> keys must be defined before any commands which use them
" Map <leader> key
let mapleader = ","
let g:mapleader = ","
" Map <localleader> key
let maplocalleader = ","
let g:maplocalleader = ","
" Vim Plug automatic installation (https://github.com/junegunn/vim-plug/wiki/faq#automatic-installation)
" Plugins via plug.vim
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 | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" Appearance and statusline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'thomwiggers/vim-colors-solarized'
" Project navigation
Plug 'kien/ctrlp.vim'
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] }
Plug 'basepi/netrw'
" Buffer management
Plug 'vim-scripts/bufexplorer.zip'
" Rename file support
Plug 'vim-scripts/Rename2'
" Search
"Plug 'haya14busa/incsearch-easymotion.vim'
Plug 'haya14busa/incsearch-fuzzy.vim'
Plug 'haya14busa/incsearch.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'Alok/notational-fzf-vim'
" Git
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-git'
Plug 'airblade/vim-gitgutter'
" Python
Plug 'vim-scripts/pep8', { 'for': 'python' }
Plug 'alfredodeza/pytest.vim', { 'for': 'python' }
Plug 'fs111/pydoc.vim', { 'for': 'python' }
Plug 'jmcantrell/vim-virtualenv', { 'for': 'python' }
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
" Other filetype stuff
Plug 'wlangstroth/vim-racket', { 'for': 'racket' }
Plug 'saltstack/salt-vim', { 'for': 'sls' }
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'basepi/follow-markdown-links', { 'for': 'markdown' }
" Repeat plugin operations with .
Plug 'tpope/vim-repeat'
" Enhanced vim motions
Plug 'easymotion/vim-easymotion'
" Browse undo tree
Plug 'sjl/gundo.vim'
" Lint and syntax checking
Plug 'scrooloose/syntastic'
" Clipboard history
Plug 'vim-scripts/YankRing.vim'
" Code navigation
Plug 'majutsushi/tagbar'
" Navigate TODO and similar tags
Plug 'vim-scripts/TaskList.vim'
" Tab completion
Plug 'ervandew/SuperTab'
" Manage tags/quotes/brackets dynamically
Plug 'tpope/vim-surround'
" Move between vim/tmux splits seamlessly
Plug 'christoomey/vim-tmux-navigator'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugin
filetype plugin on
filetype plugin indent on
" Set to auto read when a file is changed from the outside
set autoread
" When vimrc is edited, reload it
" if MySys() == "windows"
" autocmd! bufwritepost vimrc,.vimrc,_vimrc source C:\\vim\\_vimrc
" else
" autocmd! bufwritepost vimrc,.vimrc,_vimrc source ~/.vimrc
" endif
" Default file types
set ffs=unix,mac,dos
" Try to set locale
try
lang en_US.UTF-8
catch
endtry
" Set encoding
set encoding=utf-8
" Jump to last position when re-opening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Make vim save and load the folding of the document each time it loads
" Also places the cursor in the last place that it was left
"au BufWinLeave * mkview
"au BufWinEnter * silent loadview
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 2 line scroll-offset
set scrolloff=2
" Set 10 character side scroll-offset
"set sidescrolloff=10 " Jumps too much, can't read earlier in line
" Status line (see Airline Plugin section)
" Always show the statusline
set laststatus=2
" Format the statusline (ignored, because of airline plugin)
set statusline=\ %{HasTabs()}%{HasPaste()}\ [%F%m%r%h]\ %w\ [Line:\ %l/%L:%c]\ [%{fugitive#head()}]
" Turn on wildmenu
set wildmenu
" Setup tab completion modes
set wildmode=list:longest,full
" Ignore when tab-completing
set wildignore+=*.o,*.obj,.git,*.rbc,*~
" Turn off line numbers
" set nonumber
" Turn on relative line numbers
set number
set relativenumber
" Relative line numbers only when relevant
autocmd InsertEnter * silent! :set norelativenumber
autocmd InsertLeave,BufNewFile,VimEnter * silent! :set relativenumber
" Toggle relative line numbers when necessary
nnoremap <silent><leader>r :set rnu!<cr>
" Always show current cursor position
set ruler
" Set commandbar height
set cmdheight=2
" Enable mouse in console
set mouse=a
" Allow hiding buffers even though they contain modifications
" which have not yet been written back to the associated file
set hidden
" Set backspace config
" Allow backspacing over everything in insert mode
set backspace=eol,start,indent
" Allow certain movement commands to wrap across linebreaks
set whichwrap+=<,>,h,l
" Searching
" Ignore case when searching
set ignorecase
" If search contains capital letter(s), case-sensitive search
set smartcase
" Enable search highlighting (disable by using "set nohl")
set hlsearch
" Search as you type (instant)
set incsearch
" Don't redraw while executing macros
set nolazyredraw
" Allows regex (pattern-matching) with special characters
set magic
" Allow cursor to go out of the defined text boundaries
"set virtualedit=all
" Show matching code pieces (brackets, etc)
set showmatch
" Length of time (tenths of second) to blink matching code piece
set mat=2
" No sound or visual cues on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500 " What does this do?
" Turn off vi compatibility
set nocompatible
" Get rid of toolbar in gui mode
set guioptions-=T
" Set tab label
set guitablabel=%t
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Window Sizing and Split Configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Always keep windows at equal size except for winwidth/winheight of current
" window
" set equalalways
" When windows are split, new window appears on bottom
"set splitbelow " disabled due to bug in netrw
" When windows are vsplit, new window appears on right
set splitright
" Set minimum winwidth
" set winwidth=80
" Set minimum winheight
"set winheight=40
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable backups and swap files
set backup
set writebackup
set swapfile
" Directories for swp files and backup (~) files
if MySys() == "windows"
set backupdir=C:\\vim\\vimfiles\\backup
set directory=C:\\vim\\vimfiles\\backup
else
set backupdir=~/.vim/backup
set directory=~/.vim/backup
endif
" Don't backup crontabs
set backupskip=/tmp/*,/private/tmp/*
" Set undo directory and enable undo file
if MySys() == "windows"
set undodir=C:\\vim\\vimfiles\\undodir
set undofile
else
set undodir=~/.vim/undodir
set undofile
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, Tab, Indent, Whitespace, Folding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Don't soft-wrap lines
set nowrap
" Set tabstop size
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Expand tabs to <tabstop> spaces instead of \t character
set expandtab
" Enable smart indenting and autoindenting
set smartindent
set autoindent
" Set folding method and level (start with no folds)
set foldmethod=indent
set foldlevel=99
" Highlights related to tabs
au ColorScheme * highlight TabWhitespace ctermbg=black guibg=#101010
au InsertEnter * 2match TabWhitespace /\t/
au InsertLeave * 2match TabWhitespace /\t/
au BufWinEnter * 2match TabWhitespace /\t/
" Highlight trailing whitespace (with support for buffer and
" colorscheme matching)
" Also note that it won't highlight trailing whitespace on
" a line currently being edited
au ColorScheme * highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhitespace /\s\+$/
au BufWinEnter * match ExtraWhitespace /\s\+$/
" Turn on column 80 highlighting and textwidth 0 for all buffers by default
set colorcolumn=80,90
set textwidth=0
" Set textwidth for certain filetypes
au FileType tex set textwidth=79
au FileType text set textwidth=79
au FileType markdown set textwidth=79
au FileType rst set textwidth=79
" Modify column highlighting for specified filetypes on BufEnter
au BufEnter COMMIT_EDITMSG set colorcolumn=73
" Handle textwidth for various filetypes (used for autoformatting, gq)
au BufEnter COMMIT_EDITMSG set textwidth=72
" Define FileTypes which use normal tab characters instead of spaces
au FileType make set noexpandtab
" Highlight line on which the cursor resides
set cursorline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax on
" Define custom extension(s) for syntax highlighting
au BufNewFile,BufRead *.md set filetype=markdown
au BufNewFile,BufRead *.tex set filetype=tex
au BufNewFile,BufRead *.grm.sx set filetype=racket
"au BufNewFile,BufRead COMMIT_EDITMSG set filetype=diff
" Set shell
if MySys() != "windows"
set shell=/bin/zsh
endif
" Set font
" Find the Inconsolata font here:
" http://www.levien.com/type/myfonts/inconsolata.html
set gfn=Inconsolata:h12
" Set terminal color-count
set t_Co=256
" Set background color/style
set background=dark
" Colorscheme
" Uncomment the following line if not using custom iTerm2 solarized colors
"let g:solarized_termcolors=256
colorscheme solarized
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" In visual mode * or # will search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map <leader><cr> to no highlight (clear highlight after search)
nnoremap <silent> <leader><cr> :noh<cr>
" Smart way to move between windows
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" Close the current buffer
nnoremap <leader>bd :Bclose<cr>
command! Bclose call <SID>BufcloseCloseIt()
" Close all the buffers
nnoremap <leader>baaa :1,300 bd!<cr>
" Buffer switching
nnoremap <S-l> :bn<cr>
nnoremap <S-h> :bp<cr>
nnoremap <right> :bn<cr>
nnoremap <left> :bp<cr>
" Tab switching
nnoremap <up> gt
nnoremap <down> gT
" Tab configuration
nnoremap <leader>tn :tabnew<cr>
nnoremap <leader>te :tabedit
nnoremap <leader>tc :tabclose<cr>
nnoremap <leader>tm :tabmove
" When pressing <leader>cd switch to the directory of the open buffer
nnoremap <leader>cd :cd %:p:h<cr>
" Specify the behavior when switching between buffers
try
" Tell vim to first search the tab and window list for requested buffer
set switchbuf=usetab
" Always show tab bar
"set stal=2
catch
endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Other key bindings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map visual-mode spacebar to center screen on cursor
nnoremap <space> zz
" Map normal-, visual-, and insert-mode F1 to Esc to avoid accidental help
" calls
noremap <F1> <Esc>
inoremap <F1> <Esc>
" Map <leader>pp to toggle paste mode
nnoremap <leader>pp :setlocal paste!<cr>
" Map <leader>bb to change to parent directory
nnoremap <leader>bb :cd ..<cr>
" Remove the Windows ^M - when the encodings gets messed up
nnoremap <leader>cr mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Move a line of text using CTRL+SHIFT+[jk]
" (Used to be <C-m> and <C-n>, but apparently <C-m> and <CR> are equivalent to
" vim)
nnoremap <leader>m mz:m+<cr>`z
nnoremap <leader>M mz:m-2<cr>`z
vnoremap <leader>m :m'>+<cr>`<my`>mzgv`yo`z
vnoremap <leader>M :m'<-2<cr>`>my`<mzgv`yo`z
" Easy exit from insert mode using jj (often not available in
" vim emulation plugins in IDEs, etc, so you might not want
" to get reliant on this.)
" inoremap jj <Esc>
" Set breakindent for when wrapping is on
if has('patch-7.4.338')
set breakindent
set showbreak=••••
end
" Toggle between wrap and no wrap with <leader>w
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
if &wrap
echo "Wrap OFF"
setlocal nowrap
set virtualedit=all
else
echo "Wrap ON"
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
endif
endfunction
" Easily toggle between tabs and spaces
nnoremap <F3> :set expandtab!<CR>
" Easily toggle between line numbers and no line numbers
nnoremap <F4> :set number!<CR>:set relativenumber!<CR>
" Toggle line numbers and fold column for easy copying via <F2>:
nnoremap <F2> :set nonumber!<CR>:set relativenumber!<CR>:GitGutterToggle<CR>:set foldcolumn=0<CR>
" Move through vim's location lists (for example, syntastic errors)
nnoremap <leader>j :lnext<CR>
nnoremap <leader>J :lprev<CR>
nnoremap <leader>k :lprev<CR>
" Open quickfix window, move through error list
nnoremap <leader>cc :botright cope<cr>
nnoremap <leader>n :cn<cr>
nnoremap <leader>N :cp<cr>
nnoremap <leader>p :cp<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => netrw
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Shortcut for refresh
augroup netrw_mapping
autocmd!
autocmd filetype netrw call NetrwMapping()
augroup END
function! NetrwMapping()
noremap <buffer> <c-r> <c-l>
endfunction
" Preview
let g:netrw_liststyle=0 " thin (change to 3 for tree)
let g:netrw_altv=1 " open files on right
let g:netrw_preview=1
let g:netrw_winsize=30
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Abbreviations
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Shortcut for the date/time
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Pressing <leader>ss will toggle spell checking
nnoremap <leader>ss :setlocal spell!<cr>
"Shortcuts using <leader>
noremap <leader>sn ]s
noremap <leader>sp [s
noremap <leader>sa zg
noremap <leader>s? z=
""""""""""""""""""""""""""""""
" => Python
""""""""""""""""""""""""""""""
" Save and execute python3 file being edited with <leader>e:
nnoremap <leader>e :w<CR>:!/usr/bin/env python3 % <CR>
" Save and execute python2 file being edited with <leader><Shift+e>:
nnoremap <leader><S-e> :w<CR>:!/usr/bin/env python % <CR>
" Disable smartindent for python files (fixes # jumping to beginning of line)
au FileType python set nosmartindent
""""""""""""""""""""""""""""""
" => Vim grep
""""""""""""""""""""""""""""""
" Define directories for vimgrep to skip
let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated .git'
" Define grep program (I don't know a built-in one for Windows,
" so Windows will not define this.)
if MySys() != "windows"
set grepprg=/bin/grep\ -nH
endif
""""""""""""""""""""""""""""""
" => Airline plugin
""""""""""""""""""""""""""""""
" Use powerline fonts (needs patched font, Inconsolata for Powerline)
let g:airline_powerline_fonts = 1
" Add tabs to the normal section A
let g:airline_section_a = '%#__accent_bold#%{airline#util#wrap(airline#parts#mode(),0)}%#__restore__#%{airline#util#append(airline#parts#crypt(),0)}%{airline#util#append(airline#parts#paste(),0)}%{airline#util#append(HasTabs(),0)}%{airline#util#append("",0)}%{airline#util#append(airline#parts#iminsert(),0)}'
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
""""""""""""""""""""""""""""""
" => Tagbar plugin
""""""""""""""""""""""""""""""
" Toggle tagbar
nmap <silent> <leader>tt :TagbarToggle<CR>
" Tagbar config
let g:tagbar_width = 40
" Automatically open tagbar for supported files
" autocmd VimEnter * nested :call tagbar#autoopen(1)
""""""""""""""""""""""""""""""
" => vim-gitgutter plugin
""""""""""""""""""""""""""""""
" Turn on gutter by default
set signcolumn=yes
""""""""""""""""""""""""""""""
" => Syntastic plugin
""""""""""""""""""""""""""""""
" Check syntax on open
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_enable_highlighting = 0
let g:syntastic_error_symbol = 'E'
let g:syntastic_style_error_symbol = 'S'
let g:syntastic_warning_symbol = 'W'
let g:syntastic_style_warning_symbol = 'S'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
nmap <silent> <leader>y :SyntasticCheck<cr>
let g:syntastic_python_checkers = ['python']
let g:syntastic_tex_checkers = []
set statusline+=\ %#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
""""""""""""""""""""""""""""""
" => NERDTree plugin
""""""""""""""""""""""""""""""
" Map <leader>f to open a NERDTree buffer
nnoremap <silent> <leader>f :call NERDTreeToggleInCurDir()<CR>
" Close vim if nerdtree is the last window open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Close after opening a file
let NERDTreeQuitOnOpen = 1
" Use NerdTreeFind by default for toggle
function! NERDTreeToggleInCurDir()
" If NERDTree is open in the current buffer
if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1)
exe ":NERDTreeClose"
else
if (expand("%:t") != '')
exe ":NERDTreeFind"
else
exe ":NERDTreeToggle"
endif
endif
endfunction
""""""""""""""""""""""""""""""
" => UltiSnips plugin
""""""""""""""""""""""""""""""
" Split window when editing snippets
let g:UltiSnipsEditSplit="vertical"
" Change shortcut to list snippets to something that works
let g:UltiSnipsListSnippets="<F5>"
" Use TextMate-like triggers
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
""""""""""""""""""""""""""""""
" => Gundo plugin
""""""""""""""""""""""""""""""
" Map the undo tree (Gundo) toggle
nnoremap <c-g> :GundoToggle<CR>
""""""""""""""""""""""""""""""
" => notational-fzf
""""""""""""""""""""""""""""""
" Search Path
let g:nv_search_paths = ['./']
" String. Set to '' (the empty string) if you don't want an extension appended by default.
" Don't forget the dot, unless you don't want one.
let g:nv_default_extension = '.md'
" Shortcut
nnoremap <silent> <c-a> :NV<CR>
" String. Controls how new note window is created.
let g:nv_create_note_window = 'e'
" String. Must be in the form 'ctrl-KEY' or 'alt-KEY'
let g:nv_create_note_key = 'ctrl-x'
" Boolean. If set, will truncate each path element to a single character. If
" you have colons in your pathname, this will fail. Not set by default.
let g:nv_use_short_pathnames = 0
""""""""""""""""""""""""""""""
" => CtrlP plugin
""""""""""""""""""""""""""""""
" Set mapping and command
let g:ctrlp_map = '<leader>.'
let g:ctrlp_cmd = 'CtrlP'
" Set method for finding local directory
let g:ctrlp_working_path_mode = 'ra'
" Set exclusions
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
""""""""""""""""""""""""""""""
" => PEP8 plugin
""""""""""""""""""""""""""""""
" Set key to trigger PEP8
let g:pep8_map='<leader>8'
""""""""""""""""""""""""""""""
" => SuperTab plugin (and other tab-completion-related-stuff)
""""""""""""""""""""""""""""""
" Set up context-sensitive completion
au FileType python set omnifunc=jedi#completions
"let g:SuperTabDefaultCompletionType = "context"
" Don't automatically autocomplete on dots
let g:jedi#popup_on_dot = 0
" Enable menu and pydoc preview
set completeopt=menuone,longest,preview
" Make sure the current directory is in the python path (for omni-completion)
py3 << EOF
import sys
import os
sys.path.append(os.getcwd())
EOF
""""""""""""""""""""""""""""""
" => Ack plugin
""""""""""""""""""""""""""""""
" Bind key to search for what's under the cursor in Ack
nnoremap <leader>a <Esc>:Ack!
""""""""""""""""""""""""""""""
" => PyDoc plugin
""""""""""""""""""""""""""""""
" Specify pydoc executable
let g:pydoc_cmd = '/usr/bin/pydoc'
""""""""""""""""""""""""""""""
" => Powerline plugin (not currently installed)
""""""""""""""""""""""""""""""
" Set theme and colorscheme
let g:Powerline_theme = 'default'
let g:Powerline_colorscheme = 'solarized16'
" Other options
let g:Powerline_stl_path_style = 'short'
""""""""""""""""""""""""""""""
" => YankRing plugin
""""""""""""""""""""""""""""""
" Map <leader>yr to open a NERDTree buffer
nnoremap <silent> <leader>yr :YRShow<CR>
""""""""""""""""""""""""""""""
" => EasyMotion plugin
""""""""""""""""""""""""""""""
" Turn on smartcase
let g:EasyMotion_smartcase = 1
" Use ; instead of <leader><leader> for prefix
nmap ; <Plug>(easymotion-prefix)
" Make ;f bidirectional, and cross-window in normal mode
map ;f <Plug>(easymotion-bd-f)
nmap ;f <Plug>(easymotion-overwin-f)
" Make ;j and ;k bidirectional, and cross-window in normal mode
map ;j <Plug>(easymotion-bd-jk)
map ;k <Plug>(easymotion-bd-jk)
nmap ;j <Plug>(easymotion-overwin-line)
nmap ;k <Plug>(easymotion-overwin-line)
" Use ;l and ;h to search on your line
map ;l <Plug>(easymotion-lineforward)
map ;h <Plug>(easymotion-linebackward)
" Make ;w bidirectional, and cross-window in normal mode
map ;w <Plug>(easymotion-bd-w)
nmap ;w <Plug>(easymotion-overwin-w)
" Use ;s for a bidirectional, two-letter search like ;f
map ;s <Plug>(easymotion-s2)
" Use easymotion incremental search
"map / <Plug>(easymotion-sn)
"omap / <Plug>(easymotion-tn)
" These `n` & `N` mappings are options. You do not have to map `n` & `N` to EasyMotion.
" Without these mappings, `n` & `N` works fine. (These mappings just provide
" different highlight method and have some other features )
"map n <Plug>(easymotion-next)
"map N <Plug>(easymotion-prev)
""""""""""""""""""""""""""""""
" => incsearch, incsearch-fuzzy, incsearch-easymotion plugins
""""""""""""""""""""""""""""""
" incsearch.vim with easymotion
" function! s:incsearch_config(...) abort
" return incsearch#util#deepextend(deepcopy({
" \ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
" \ 'keymap': {
" \ "\<CR>": '<Over>(easymotion)'
" \ },
" \ 'is_expr': 0
" \ }), get(a:, 1, {}))
" endfunction
"
" noremap <silent><expr> / incsearch#go(<SID>incsearch_config())
" noremap <silent><expr> ? incsearch#go(<SID>incsearch_config({'command': '?'}))
" noremap <silent><expr> g/ incsearch#go(<SID>incsearch_config({'is_stay': 1}))
" incsearch-fuzzy.vim with easymotion
" function! s:config_easyfuzzymotion(...) abort
" return extend(copy({
" \ 'converters': [incsearch#config#fuzzyword#converter()],
" \ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
" \ 'keymap': {"\<CR>": '<Over>(easymotion)'},
" \ 'is_expr': 0,
" \ 'is_stay': 1
" \ }), get(a:, 1, {}))
" endfunction
"
" noremap <silent><expr> <Space>/ incsearch#go(<SID>config_easyfuzzymotion())
"
" map z/ <Plug>(incsearch-fuzzyspell-/)
" map z? <Plug>(incsearch-fuzzyspell-?)
" map zg/ <Plug>(incsearch-fuzzyspell-stay)
" incsearch without easymotion
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" incsearch-fuzzy without easymotion
map z/ <Plug>(incsearch-fuzzy-/)
map z? <Plug>(incsearch-fuzzy-?)
map zg/ <Plug>(incsearch-fuzzy-stay)
""""""""""""""""""""""""""""""
" => Pytest plugin
""""""""""""""""""""""""""""""
" Bind a key for quickly running pytest on the current file
map <leader>z :Pytest file<CR>
map <leader>zx :Pytest file verbose<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Helper function called by the VisualSearch() function
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" Search function
" If you pass 'gv' parameter, will vimgrep after selected text
" If you pass 'f' or 'b' parameters, will search for current selection
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Function used to close the current buffer
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Get current working directory, abbreviating if in home directory (edit
" home directory as necessary for your username, etc)
function! CurDir()
if MySys() == "mac"
let curdir = substitute(getcwd(), '/Users/basepi/', "~/", "g")
elseif MySys() == "windows"
let curdir = substitute(getcwd(), 'C:\\Users\\basepi\\', "~\\", "g")
elseif MySys() == "linux"
let curdir = substitute(getcwd(), '/home/basepi/', "~/", "g")
else
let curdir = getcwd()
endif
return curdir
endfunction
" Check for paste mode
function! HasPaste()
return &paste ? '[PASTE]' : ''
endfunction
" Check for tabs (noexpandtab mode)
function! HasTabs()
return &expandtab ? '' : 'TABS'
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Possible alternate configuration stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"##################FOR USE WITH VIM <7.3 ######################
" 80-character limit highlighting for vim <7.3 Replace colorcolumn commands with
" the following commands
" Highlight 78-80 in 'Search' color
"au BufWinEnter * let w:m1=matchadd('Search', '\%<81v.\%>77v', -1)
" Highlight past column 80 in 'ErrorMsg' color
"au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)