2016-11-10 18:12:45 +01:00
|
|
|
" -- BEGIN: Vundle config --
|
|
|
|
set nocompatible " be iMproved, required
|
|
|
|
filetype off " required
|
|
|
|
|
|
|
|
" set the runtime path to include Vundle and initialize
|
|
|
|
set rtp+=~/.vim/bundle/Vundle.vim
|
|
|
|
call vundle#begin()
|
|
|
|
" alternatively, pass a path where Vundle should install plugins
|
|
|
|
"call vundle#begin('~/some/path/here')
|
|
|
|
|
|
|
|
" let Vundle manage Vundle, required
|
|
|
|
Plugin 'VundleVim/Vundle.vim'
|
|
|
|
|
|
|
|
" The following are examples of different formats supported.
|
|
|
|
" Keep Plugin commands between vundle#begin/end.
|
|
|
|
|
|
|
|
" Displays git information in airline.
|
|
|
|
Plugin 'tpope/vim-fugitive'
|
|
|
|
|
|
|
|
" Displays git-tracked C*UD ops within gutter.
|
|
|
|
Plugin 'airblade/vim-gitgutter'
|
2016-12-16 17:00:08 +01:00
|
|
|
|
|
|
|
" Fuzzy-finder
|
2016-11-10 18:12:45 +01:00
|
|
|
Plugin 'kien/ctrlp.vim'
|
2016-12-16 17:00:08 +01:00
|
|
|
|
|
|
|
" Grep file contents
|
2016-11-10 18:12:45 +01:00
|
|
|
Plugin 'mileszs/ack.vim'
|
2016-12-16 17:00:08 +01:00
|
|
|
|
|
|
|
" JS support
|
2016-11-10 18:12:45 +01:00
|
|
|
Plugin 'pangloss/vim-javascript'
|
2016-12-16 17:00:08 +01:00
|
|
|
|
|
|
|
" Visual dir-tree navigation
|
2016-11-10 18:12:45 +01:00
|
|
|
Plugin 'scrooloose/nerdtree'
|
|
|
|
|
2016-11-11 21:20:00 +01:00
|
|
|
" Syntax Highlighting Support
|
|
|
|
Plugin 'lambdatoast/elm.vim'
|
|
|
|
|
2016-11-30 19:24:08 +01:00
|
|
|
" Elixir Plugins
|
|
|
|
Plugin 'elixir-lang/vim-elixir'
|
|
|
|
Plugin 'slashmili/alchemist.vim'
|
2016-12-02 00:29:58 +01:00
|
|
|
Plugin 'powerman/vim-plugin-AnsiEsc'
|
2016-11-30 19:24:08 +01:00
|
|
|
|
|
|
|
" TypeScript Plugins
|
|
|
|
Plugin 'rschmukler/typescript-vim'
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Themes
|
|
|
|
Plugin 'sickill/vim-monokai'
|
|
|
|
Plugin 'altercation/vim-colors-solarized'
|
2016-11-30 19:24:08 +01:00
|
|
|
Plugin 'mhartington/oceanic-next'
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
" Executes shell commands and pipes output into new Vim buffer.
|
|
|
|
Plugin 'sjl/clam.vim'
|
|
|
|
|
|
|
|
" Multiple cursors for simultaneous edits.
|
|
|
|
" NOTE: use <C-n> to run miltiple cursors not <C-d>
|
|
|
|
Plugin 'terryma/vim-multiple-cursors'
|
|
|
|
|
|
|
|
" Visualize buffers
|
|
|
|
Plugin 'vim-airline/vim-airline'
|
|
|
|
Plugin 'vim-airline/vim-airline-themes'
|
|
|
|
|
2016-12-04 22:54:42 +01:00
|
|
|
" Visually align assignments
|
|
|
|
Plugin 'godlygeek/tabular'
|
|
|
|
|
2016-12-06 16:04:20 +01:00
|
|
|
" Visually Highlight and comment code.
|
|
|
|
Plugin 'tpope/vim-commentary'
|
|
|
|
|
2016-12-26 06:40:14 +01:00
|
|
|
" Macros for quotes, parens, etc.
|
|
|
|
Plugin 'tpope/vim-surround'
|
|
|
|
|
|
|
|
" Allows Plugins to be repeated with `.` character
|
|
|
|
Plugin 'tpope/vim-repeat'
|
|
|
|
|
2016-12-12 06:24:22 +01:00
|
|
|
" Seamlessly navigate Vim and Tmux with similar bindings.
|
|
|
|
Plugin 'christoomey/vim-tmux-navigator'
|
|
|
|
|
|
|
|
" Async `:make` for code linting etc.
|
|
|
|
Plugin 'neomake/neomake'
|
|
|
|
|
2016-12-16 17:00:08 +01:00
|
|
|
" Color pack
|
|
|
|
Plugin 'flazz/vim-colorschemes'
|
|
|
|
|
2016-12-20 02:53:45 +01:00
|
|
|
" Dash integration (macOS only)
|
|
|
|
Plugin 'rizzatti/dash.vim'
|
|
|
|
|
2016-12-30 11:20:13 +01:00
|
|
|
" Better buffer mgt than CtrlP
|
|
|
|
Plugin 'yegappan/mru'
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
call vundle#end() " required
|
|
|
|
filetype plugin indent on " required
|
|
|
|
" Put your non-Plugin stuff after this line
|
|
|
|
" -- END: Vundle config --
|
|
|
|
|
|
|
|
|
2016-12-22 16:05:11 +01:00
|
|
|
" Basic settings
|
|
|
|
set number
|
|
|
|
set wrap!
|
|
|
|
set tabstop=2
|
|
|
|
set expandtab
|
|
|
|
set shiftwidth=2
|
|
|
|
set background=dark
|
|
|
|
|
|
|
|
syntax enable
|
|
|
|
colorscheme hybrid
|
|
|
|
|
|
|
|
set termguicolors
|
|
|
|
|
|
|
|
set history=1000
|
|
|
|
set undolevels=1000
|
|
|
|
|
|
|
|
set t_Co=255
|
|
|
|
|
|
|
|
" Support italics
|
|
|
|
highlight Comment cterm=italic
|
|
|
|
|
|
|
|
" Changes <leader> to <space> character.
|
|
|
|
let mapleader = " "
|
|
|
|
|
|
|
|
|
2016-12-26 06:40:14 +01:00
|
|
|
" Auto resize window splits
|
|
|
|
autocmd VimResized * wincmd =
|
|
|
|
|
|
|
|
|
2016-12-12 06:24:22 +01:00
|
|
|
" Neomake Settings
|
|
|
|
autocmd! BufWritePost * Neomake
|
|
|
|
|
|
|
|
" Elixir linting
|
|
|
|
let g:neomake_elixir_credo_maker = {
|
|
|
|
\ 'exe': 'mix',
|
|
|
|
\ 'args': ['credo', 'list', '%:p', '--format=oneline'],
|
|
|
|
\ 'errorformat':
|
|
|
|
\ '%W[F] %. %f:%l:%c %m,' .
|
|
|
|
\ '%W[F] %. %f:%l %m,' .
|
|
|
|
\ '%W[R] %. %f:%l:%c %m,' .
|
|
|
|
\ '%W[R] %. %f:%l %m,' .
|
|
|
|
\ '%I[C] %. %f:%l:%c %m,' .
|
|
|
|
\ '%I[C] %. %f:%l %m,' .
|
|
|
|
\ '%-Z%.%#'
|
|
|
|
\ }
|
|
|
|
|
|
|
|
|
2016-12-20 02:53:45 +01:00
|
|
|
" Alchemist settings
|
|
|
|
let g:alchemist#elixir_erlang_src = '/usr/local/share/src'
|
|
|
|
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Airline Settings
|
|
|
|
" Enables the list of buffers.
|
|
|
|
let g:airline#extensions#tabline#enabled = 1
|
|
|
|
|
2016-12-16 17:00:08 +01:00
|
|
|
" Buffer numbers alongside files
|
|
|
|
let g:airline#extensions#tabline#buffer_nr_show = 1
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Shows the filename only.
|
|
|
|
let g:airline#extensions#tabline#fnamemod = ':t'
|
|
|
|
|
|
|
|
" Allow glyphs in airline
|
|
|
|
let g:airline_powerline_fonts = 1
|
|
|
|
|
2016-12-12 06:24:22 +01:00
|
|
|
" Change Airline theme
|
2016-12-16 17:00:08 +01:00
|
|
|
let g:airline_theme = 'hybrid'
|
|
|
|
|
|
|
|
|
|
|
|
" Jump to buffers.
|
|
|
|
nmap <F1> :1b<CR>
|
|
|
|
nmap <F2> :2b<CR>
|
|
|
|
nmap <F3> :3b<CR>
|
|
|
|
nmap <F4> :4b<CR>
|
|
|
|
nmap <F5> :5b<CR>
|
|
|
|
nmap <F6> :6b<CR>
|
|
|
|
nmap <F7> :7b<CR>
|
|
|
|
nmap <F8> :8b<CR>
|
|
|
|
nmap <F9> :9b<CR>
|
|
|
|
|
2016-12-12 06:24:22 +01:00
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" It's the twenty-first century...no swaps.
|
|
|
|
set noswapfile
|
|
|
|
|
|
|
|
|
|
|
|
" Allow visual tab completion in command mode
|
|
|
|
set wildmenu
|
|
|
|
|
|
|
|
|
|
|
|
" Show Vim commands as they're being input.
|
|
|
|
set showcmd
|
|
|
|
|
|
|
|
|
2016-11-10 23:57:12 +01:00
|
|
|
" Code folding
|
|
|
|
set foldmethod=indent
|
|
|
|
set foldnestmax=10
|
|
|
|
set nofoldenable
|
|
|
|
set foldlevel=4
|
|
|
|
|
2016-11-16 21:12:22 +01:00
|
|
|
|
|
|
|
" Use relative line numbers
|
|
|
|
set relativenumber
|
|
|
|
|
|
|
|
|
2016-12-26 06:40:14 +01:00
|
|
|
" emulate ci" and ci' behavior
|
2016-12-30 11:20:13 +01:00
|
|
|
nnoremap ci( f(%ci(
|
|
|
|
nnoremap ci[ f[%ci[
|
2016-12-26 06:40:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
" extend functionality of <C-e> & <C-y> scrolling
|
|
|
|
nnoremap <C-e> <C-e>j
|
2016-12-30 11:20:13 +01:00
|
|
|
vnoremap <C-e> <C-e>j
|
2016-12-26 06:40:14 +01:00
|
|
|
nnoremap <C-y> <C-y>k
|
2016-12-30 11:20:13 +01:00
|
|
|
vnoremap <C-y> <C-y>k
|
2016-12-26 06:40:14 +01:00
|
|
|
|
|
|
|
|
2016-11-10 23:57:12 +01:00
|
|
|
" Opens all folds within the buffer
|
|
|
|
nnoremap ZZ zR
|
|
|
|
|
|
|
|
" Closes all folds within the buffer
|
|
|
|
nnoremap zz zM
|
|
|
|
|
|
|
|
" Opens all folds beneath the cursor
|
|
|
|
" NOTE: j is the character to go down
|
|
|
|
nnoremap zJ zO
|
|
|
|
|
|
|
|
" Opens single fold beneath the cursor
|
|
|
|
" NOTE: j is the character to go down
|
|
|
|
nnoremap zj zo
|
|
|
|
|
|
|
|
" Opens single fold beneath the cursor
|
|
|
|
" NOTE: k is the character to go down
|
|
|
|
nnoremap zK zC
|
|
|
|
|
|
|
|
" Opens single fold beneath the cursor
|
|
|
|
" NOTE: k is the character to go down
|
|
|
|
nnoremap zk zc
|
|
|
|
|
|
|
|
|
2016-12-20 02:53:45 +01:00
|
|
|
" Lookup Dash word under cursor in Dash
|
|
|
|
nnoremap <leader>j :Dash<CR>
|
|
|
|
|
|
|
|
|
|
|
|
" Save shortcut
|
|
|
|
nnoremap <C-s> :w<CR>
|
|
|
|
|
|
|
|
|
2016-12-02 23:34:29 +01:00
|
|
|
" Switch to MRU'd buffer
|
|
|
|
nnoremap <leader><leader> <C-^>
|
|
|
|
|
|
|
|
|
2016-12-30 11:20:13 +01:00
|
|
|
" Alternative MRU to CtrlP MRU
|
|
|
|
nnoremap <leader>b :MRU<CR>
|
|
|
|
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Supports mouse interaction.
|
|
|
|
set mouse=a
|
|
|
|
|
|
|
|
|
|
|
|
" Highlights matches during a search.
|
|
|
|
set hlsearch
|
|
|
|
|
2016-12-30 11:20:13 +01:00
|
|
|
" Clear highlight
|
|
|
|
noremap <leader>/ :nohlsearch<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
" backspace settings
|
|
|
|
set backspace=2
|
|
|
|
set backspace=indent,eol,start
|
|
|
|
|
|
|
|
|
|
|
|
" Javascript specific variables
|
|
|
|
let g:javascript_plugin_jsdoc = 1
|
|
|
|
|
|
|
|
" GlobalListchars
|
|
|
|
set list
|
2016-11-18 00:05:52 +01:00
|
|
|
set listchars=tab:··,trail:·,nbsp:·
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
" Keeps everything concealed at all times. Even when cursor is on the word.
|
|
|
|
set conceallevel=1
|
|
|
|
set concealcursor=nvic
|
|
|
|
|
|
|
|
|
|
|
|
" map jk to <Esc>
|
|
|
|
inoremap jk <Esc>
|
|
|
|
|
|
|
|
|
|
|
|
" Conventional Emacs line-editor defaults
|
2016-12-22 16:05:11 +01:00
|
|
|
" NOTE: <C-a> interferes w/ current tmux prefix
|
2016-11-10 18:12:45 +01:00
|
|
|
inoremap <C-a> <Esc>I
|
|
|
|
inoremap <C-e> <Esc>A
|
|
|
|
|
|
|
|
|
|
|
|
" Manage Vertical and Horizontal splits
|
2016-12-16 17:00:08 +01:00
|
|
|
nnoremap sl <Esc>:vs<CR><C-w>l
|
|
|
|
nnoremap sh <Esc>:vs<CR>
|
|
|
|
nnoremap sj <Esc>:sp<CR><C-w>j
|
|
|
|
nnoremap sk <Esc>:sp<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
2016-12-02 23:34:29 +01:00
|
|
|
" Delete (i.e. "close") the currently opened buffer
|
2016-12-12 06:24:22 +01:00
|
|
|
" TODO: unless it's a split window, which should be :q
|
2016-12-02 23:34:29 +01:00
|
|
|
nnoremap <leader>q :bdelete<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
2016-12-30 11:20:13 +01:00
|
|
|
" Set CtrlP runtime path
|
2016-12-06 16:04:20 +01:00
|
|
|
set runtimepath^=~/.vim/bundle/ctrlp.vim
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
" Buffer creation and management
|
|
|
|
" Buffer movement
|
2016-12-12 06:24:22 +01:00
|
|
|
nnoremap <Tab> :1bnext<CR>
|
|
|
|
nnoremap <S-Tab> :1bprevious<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
" make Y do what is intuitive given:
|
|
|
|
" D: deletes until EOL
|
|
|
|
" C: changes until EOL
|
2016-11-10 23:57:12 +01:00
|
|
|
" Y: (should) yank until EOL
|
2016-11-10 18:12:45 +01:00
|
|
|
nnoremap Y y$
|
|
|
|
|
|
|
|
|
|
|
|
" scrolling and maintaing mouse position
|
2016-12-12 06:24:22 +01:00
|
|
|
" nnoremap <C-j> j<C-e>
|
|
|
|
" nnoremap <C-k> k<C-y>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
2016-12-16 17:00:08 +01:00
|
|
|
" Shorter binding for window rotations
|
|
|
|
nnoremap <C-r> <C-w><C-r>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
2016-12-16 17:00:08 +01:00
|
|
|
" remap redo key that is eclipsed by `rotate` currently
|
|
|
|
nnoremap U :redo<CR>
|
|
|
|
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Define highlighting groups
|
|
|
|
" NOTE: The ANSII aliases for colors will change when iTerm2 settings are
|
|
|
|
" changed.
|
|
|
|
highlight InterestingWord1 ctermbg=Magenta ctermfg=Black
|
|
|
|
highlight InterestingWord2 ctermbg=Blue ctermfg=Black
|
|
|
|
|
|
|
|
" h1 highlighting
|
|
|
|
nnoremap <silent> <leader>1 :execute '2match InterestingWord1 /\<<c-r><c-w>\>/'<CR>
|
|
|
|
nnoremap <silent> <leader>x1 :execute '2match none'<CR>
|
2016-12-06 16:04:20 +01:00
|
|
|
vnoremap <silent> <leader>1 :execute '2match InterestingWord1 /\<<c-r><c-w>\>/'<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
" h2 highlighting
|
|
|
|
nnoremap <silent> <leader>2 :execute '3match InterestingWord2 /\<<c-r><c-w>\>/'<CR>
|
|
|
|
nnoremap <silent> <leader>x2 :execute '3match none'<CR>
|
|
|
|
|
|
|
|
"clear all highlighted groups
|
|
|
|
nnoremap <silent> <leader>xx :execute '2match none'<CR> :execute '3match none'<CR> hh
|
|
|
|
|
|
|
|
|
|
|
|
" pasteboard copy & paste
|
|
|
|
nnoremap <C-c> V"+y
|
|
|
|
vnoremap <C-c> "+y
|
|
|
|
|
|
|
|
inoremap <C-v> <Esc>"+pa
|
2016-12-16 17:00:08 +01:00
|
|
|
" nnoremap <C-v> o<Esc>"+p
|
2016-11-10 18:12:45 +01:00
|
|
|
vnoremap <C-v> "+p
|
|
|
|
|
|
|
|
|
|
|
|
" Manage 80 char line limits
|
2016-12-04 22:39:59 +01:00
|
|
|
highlight OverLength1 ctermbg=Magenta ctermfg=Black
|
|
|
|
highlight OverLength2 ctermbg=LightMagenta ctermfg=Black
|
|
|
|
highlight OverLength3 ctermbg=White ctermfg=Black
|
|
|
|
" match OverLength3 /\%81v.\+/
|
|
|
|
match OverLength2 /\%91v.\+/
|
|
|
|
" match OverLength3 /\%101v.\+/
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
" Toggle word-wrapping
|
|
|
|
nnoremap <leader>w :set wrap!<CR>
|
|
|
|
|
|
|
|
|
|
|
|
" Resize split to 10,20,...,100 chars
|
|
|
|
" Uncomment the next lines for support at those sizes.
|
|
|
|
" These bindings interfere with the highlight groups, however.
|
|
|
|
" Increases the width of a vertical split.
|
|
|
|
" nnoremap <leader>1 :vertical resize 10<CR>
|
|
|
|
" nnoremap <leader>2 :vertical resize 20<CR>
|
|
|
|
nnoremap <leader>3 :vertical resize 30<CR>
|
|
|
|
nnoremap <leader>4 :vertical resize 40<CR>
|
|
|
|
nnoremap <leader>5 :vertical resize 50<CR>
|
|
|
|
nnoremap <leader>6 :vertical resize 60<CR>
|
|
|
|
nnoremap <leader>7 :vertical resize 70<CR>
|
|
|
|
nnoremap <leader>8 :vertical resize 80<CR>
|
|
|
|
nnoremap <leader>9 :vertical resize 90<CR>
|
|
|
|
nnoremap <leader>0 :vertical resize 100<CR>
|
|
|
|
|
2016-11-16 21:12:22 +01:00
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Increases the height of a horizontal split.
|
|
|
|
nnoremap <leader>v1 :resize 5<CR>
|
|
|
|
nnoremap <leader>v2 :resize 10<CR>
|
|
|
|
nnoremap <leader>v3 :resize 15<CR>
|
|
|
|
nnoremap <leader>v4 :resize 20<CR>
|
|
|
|
nnoremap <leader>v5 :resize 25<CR>
|
|
|
|
nnoremap <leader>v6 :resize 30<CR>
|
|
|
|
nnoremap <leader>v7 :resize 35<CR>
|
|
|
|
nnoremap <leader>v8 :resize 40<CR>
|
2016-12-06 16:04:20 +01:00
|
|
|
nnoremap <leader>v9 :resize 45<CR>
|
|
|
|
nnoremap <leader>v0 :resize 50<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
2016-11-10 20:49:13 +01:00
|
|
|
" NERDTree settings
|
|
|
|
" Show hidden files by default. (Toggle with capital 'i')
|
2016-12-02 23:34:29 +01:00
|
|
|
let NERDTreeShowHidden = 1
|
2016-11-10 20:49:13 +01:00
|
|
|
|
2016-12-02 00:29:58 +01:00
|
|
|
" View Directory tree with ctrl + n
|
2016-12-02 23:34:29 +01:00
|
|
|
nnoremap <leader>n :NERDTreeToggle<CR>
|
2016-11-10 18:12:45 +01:00
|
|
|
|
2016-11-10 20:49:13 +01:00
|
|
|
" View open buffer location in tree.
|
2016-12-02 23:34:29 +01:00
|
|
|
nnoremap <leader>f :NERDTreeFind<CR>
|
2016-11-10 20:49:13 +01:00
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
|
2016-12-02 00:29:58 +01:00
|
|
|
" Jump to the top / bottom of the Viewport
|
|
|
|
nnoremap K H
|
|
|
|
nnoremap J L
|
|
|
|
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" BOL and EOL
|
|
|
|
nnoremap H ^
|
|
|
|
vnoremap H ^
|
|
|
|
nnoremap L $
|
|
|
|
vnoremap L $
|
|
|
|
|
|
|
|
|
2016-11-30 20:01:58 +01:00
|
|
|
" Search for visually selected text
|
2016-12-12 06:24:22 +01:00
|
|
|
vnoremap // y/<C-r>"<CR>N
|
2016-11-30 20:01:58 +01:00
|
|
|
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" trim trailing whitespace on save
|
2016-12-16 17:00:08 +01:00
|
|
|
autocmd BufWritePre *.{js,py,tpl,less,html,ex,exs,txt} :%s/\s\+$//e
|
2016-11-10 18:12:45 +01:00
|
|
|
|
|
|
|
|
2016-12-02 00:29:58 +01:00
|
|
|
" Use .gitignore file to populate Ctrl-P
|
|
|
|
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
|
|
|
|
|
|
|
|
|
2016-11-10 18:12:45 +01:00
|
|
|
" Ignores dirs and files
|
|
|
|
let g:ctrlp_custom_ignore = {
|
|
|
|
\ 'dir': 'node_modules',
|
|
|
|
\ 'file': '\v\.(exe|dll|png|jpg|jpeg)$'
|
|
|
|
\}
|
|
|
|
|
2016-12-06 21:53:44 +01:00
|
|
|
|
2016-12-08 16:17:00 +01:00
|
|
|
" WIP: Run elixir tests on that line
|
2016-12-22 16:05:11 +01:00
|
|
|
" TODO: only register binding in *.exs? file extensions
|
2016-12-08 16:17:00 +01:00
|
|
|
nnoremap <leader>t :call ExTestToggle()<CR>
|
|
|
|
|
|
|
|
|
|
|
|
" Jumps from an Elixir module file to an Elixir test file.
|
|
|
|
fun! ExTestToggle()
|
|
|
|
if expand('%:e') == "ex"
|
2016-12-16 17:00:08 +01:00
|
|
|
|
|
|
|
let test_file_name = expand('%:t:r') . "_test.exs"
|
|
|
|
let test_file_dir = substitute(expand('%:p:h'), "/lib/", "/test/", "")
|
|
|
|
let full_test_path = join([test_file_dir, test_file_name], "/")
|
2016-12-08 16:17:00 +01:00
|
|
|
|
|
|
|
e `=full_test_path`
|
|
|
|
|
|
|
|
elseif match(expand('%:t'), "_test.exs") != -1
|
2016-12-16 17:00:08 +01:00
|
|
|
|
|
|
|
let test_file_name = expand('%:t:r')
|
|
|
|
let offset_amt = strlen(test_file_name) - strlen("_test")
|
|
|
|
let module_file_name = strpart(test_file_name, 0, offset_amt) . ".ex"
|
|
|
|
let module_file_dir = substitute(expand('%:p:h'), "/test/", "/lib/", "")
|
|
|
|
let full_module_path = join([module_file_dir, module_file_name], "/")
|
2016-12-08 16:17:00 +01:00
|
|
|
|
|
|
|
e `=full_module_path`
|
|
|
|
|
2016-12-16 17:00:08 +01:00
|
|
|
endif
|
2016-12-08 16:17:00 +01:00
|
|
|
endfun
|
|
|
|
|
2016-12-12 06:24:22 +01:00
|
|
|
|
|
|
|
" Creates intermediate directories and file to match current buffer's filepath
|
|
|
|
fun! CreateNonExistingDirsAndFile()
|
|
|
|
! echo "Creating directory..." && mkdir -p %:p:h && echo "Created directory." && echo "Creating file..." && touch %:t:p && echo "Created file."
|
|
|
|
|
|
|
|
" Write the buffer to the recently created file.
|
|
|
|
w
|
|
|
|
endfun
|
|
|
|
|