Skip to content

Instantly share code, notes, and snippets.

@jondkinney
Last active December 14, 2023 06:39
Show Gist options
  • Save jondkinney/2040114 to your computer and use it in GitHub Desktop.
Save jondkinney/2040114 to your computer and use it in GitHub Desktop.
jondkinney's console vim setup

Console VIM and Tmux setup compatible with Mac OS X and Linux.

Installation

Install by running the following command in your terminal:

exec 3<&1;bash <&3 <(curl https://gist.githubusercontent.com/jondkinney/2040114/raw/vim.sh 2> /dev/null)

The bash redirects allow this script to prompt for user input including preserving an existing ~/.vim directory by appending "-bak" to any files/directories that are written, overwriting an existing setup destructively or skipping any of the configurations individually, or choosing r to keep a ~/.vimrc_main file sync'd across multiple machines. Here's how it would look:

***** Note: You already have a Vim configuration...
Would you like to (b)ack it up, (o)verwrite it, (r)efresh ~/.vimrc_main, or (s)kip Vim setup (B/o/r/s)?

Typing r and pressing return then outputs this message:

Refreshing ~/.vimrc_main and leaving the rest of your Vim setup untouched.

Prerequisites:

Required:

  • brew install git
  • brew install neovim
  • brew install ag
  • brew install tmux
  • brew install reattach-to-user-namespace

Optional:

Customizations To The Defaults

Tmux:

Vim:

  • ~/.vimrc loads:
    • Plugins through vim-plug
    • Sources ~/.vimrc_main which holds the actual Vim config
    • Allow user customizations through ~/.vimrc_custom
  • <leader> re-mapped to ,
  • Navigate between splits with just ctrl + movement (h, j, k, or l)
  • Resizing splits vertically with _/+ and horizontally with option -/=
  • Save files with SS. If you need to type actual SS, toggle paste in insert mode with F2

Headway Vim / Tmux Guide and Cheat Sheet Reference

Hints, workflow optimizations, and plugins that we use for daily Rails and JS dev with the shared Headway Vim/Tmux setup.

See these links for general Vim and Tmux cheat sheets:

Configuring Karabiner Elements

https://www.youtube.com/watch?v=DN0BDSiuKsY

Setting Up Projects with Tmuxinator

rvm @global do gem install tmuxinator

Adding tmuxinator to the global gemset per ruby will allow you to launch projects regardless of their ruby version.

Navigating Vim/Tmux splits:

Hold <ctrl> down and type a movement key: hjkl to move left, down, up, or right, respectively. This even works across/between Vim/Tmux splits.

Remapped Leader Key

The default <leader> key in Vim is \, but we remap it to ,. We also have a few commands nested under the <localleader> subset and we have <localleader> mapped to \. Anywhere in the documentation that you see a command referred to by <leader>KEY_HERE you should interpret it as comma KEY_HERE.

Running Specs

I recommend having the source file in a left vertical split, the test in a right vertical split, and the tmux pane in a vertical split on the far right. This setup allows you to see the console level output of your test run while easily staying in the context of editing the test file itself.

There are multiple ways to achieve this layout / setup, but the easiest is to launch vim, then open a 33% tmux vertical split by typing <ctrl-a>T. From here, open your user.rb file, then type :AV which will enter Vim's "Command" mode (the colon does that) and execute the command to open the "alternate file" of your current buffer in a new vertical split. This will automatically open the user_spec.rb file for you! Then type <leader>t anywhere in the spec file to run the whole spec. The right hand tmux split will refresh and your test will be executed. If you want to run a specific test, type <leader>T on a line inside a given context or it block.

Plugins

Fuzzy Finder: fzf

<ctrl-f>

This brings up a list of files that you can "fuzzy seaarch" through. So if you want to open the users_controller.rb you can type <ctrl-f> and then usercont or possibly ucont or usertroller. If a given entry isn't coming up for you, prefix it with the folder structure as is often necessary when pulling up the user.rb model.

Project-Wide Search: Ack/Ag

<leader><ctrl-f>

Ag (aka the silver searcher) greatly improves the speed of project-wide search. Ag is a replacement for Ack, which is a replacement for Grep. But most people still call it "grepping" or ask "can you grep for that method?".

Once you have a result set populated in the "Quickfix" you can navigate forward and backward by typing ]q to go forward or [q to go backwards.

Note: You must have ag installed via Brew for the searching to work. brew install ag

NERDTree

NERDTree is our "project drawer" and it's setup to sync across all open tabs (which is really nice for keeping context). You can navigate NERDTree just like any other Vim split (because it is one) with h,j,k,l. Type o to open the current directory, and type gi to preview the file under your cursor while keeping NERDTree in focus. This is helpful if you're looking for something but don't remember what file it's in or what to grep for. Another handy tip is to "reveal the current file in the tree" you can type <leader>D. I'll do this frequently if I am on a users/show.html.slim view, but want to edit the users/edit.html.slim view. It's faster to type <leader>D then navigate up or down one or two files, and press s to open the file in a vertical split. Typing i on a file in the NERDTree will open it in a horizontal split. You can see many more shortcuts by typing ? anywhere in NERDTree which brings up their built-in help. Take some time to look around! Just because we're in Vim doesn't mean we have to abandon traditional IDE project drawers!

o            Open the current directory
gi           Preview the current file but keep cursor on NERDTree
I            Show hidden files in NERD tree
R/r          Reload NERD tree root / current node
,D           Sync NERD tree to current file
,d           Show/hide NERD tree
t            Open file in new tab
s            Open file in new vertical split
i            Open file horzontal split
m            Open file operation menu on the current node (to move/rename/delete)

More Command Details

General Vim

<ctrl-N>     Autocomplete
<ctrl-^>     Open most recent file in jump list
p <ctrl-p>   Paste then cycle through clipboard history
,b           Open buffer list in buffergator
,[space]     Clear highlights
*            Search for word under cursor
,cl          Comment selected lines
,ci          Uncomment selected lines
gq           Wrap selected text with hard returns
,ev          Edit vim config in new tab
J            Join two lines
<ctrl-]>     Jump to ctag definition

Rails.vim

:A           Open alternate file
:AV          Open alternate file in vertical split
gf           Go to the file under the cursor. Works to go to gems, too.

Split manipulation

<ctrl-w>R    Swap top/bottom or left/right split
<ctrl-w>o    Zoom current split. repeat to unzoom
,-           Open new horizontal split
,|           Open new vertical split

Search and replace

viw          Visually select in word. Then <ctrl-n> or <ctrl-x> to select more or fewer matchds
             after which you can perform an action like d to delete them all, or c to change them all with multiple cursors
,s           Start local buffer search and replace for the word under the cursor
%s/f/r/gc    [f]ind and [r]eplace in buffer with [c]onfirm, [g]lobally
,<ctrl-f>    Start global search.
<ctrl-r>w    Pastes the word under the cursor to the Vim command mode line. Hold <ctrl> down and press r, release r, then press w

Fuzzy Finder

<ctrl-f>     Open fuzzy finder
<ctrl-t>     From fuzzy finder - open file in new tab
<ctrl-i>     From fuzzy finder - open file in new split

Quickfix

,cq          Close quickfix window
,co          Open quickfix window
]q           Next quickfix item
[q           Previous quickfix item

Vim Diff

do           Diffget + diffupdate
dp           Diffput + diffupdate
:dif         Refresh dif window
]c           Next change
[c           Previous change

Vim Fugative / Git

,gd          :Gdiff<cr>
,gst         :Gstatus<cr>
,gw          :Gwrite<cr>
,ge          :Gedit<cr>
,gb          :Gblame -w -M<cr>
,gB          :Gitv!<cr>
,gco         :Gread<cr>
,gcm         :Gcommit<cr> (or press C in the status window)
,glg         :Glog<cr>

Tmux Cheat Sheet

Note: All commands start with <ctrl-a>

d            detach tmux session
T            open new vertical split
t            open new horz split
N            open new window
[number]     jump to n window
n            jump to next window
R            reload config
[up arrow]   zoom current tmux split. repeat to unzoom.
x            kill process and close current pane
{ or }       move tmux pane left or right
< or >       move tmux window left or right
[            enter VIM mode which allows scrolling and searching with “/"
project_name: hack
project_root: ~/Sites
on_project_first_start: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
windows:
- editor:
layout: 79ef,362x88,0,0{242x88,0,0,8,119x88,243,0,11}
panes:
- vim
- clear
- shell:
- console: rc
- database: pgcli some_app_development
- logs:
panes:
- rails s
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let g:python2_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
let &packpath = &runtimepath
source ~/.vimrc
#!/bin/sh
cat | nc -N localhost 2222
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>localhost.pbcopy</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/pbcopy</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>2222</string>
<key>SockNodeName</key>
<string>127.0.0.1</string>
</dict>
</dict>
</dict>
</plist>
#!/bin/sh
nc localhost 2223
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>localhost.pbpaste</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/pbpaste</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>2223</string>
<key>SockNodeName</key>
<string>127.0.0.1</string>
</dict>
</dict>
</dict>
</plist>
""" INITIALIZE PLUGIN SYSTEM START
call plug#begin('~/.vim/plugged')
Plug 'ciaranm/securemodelines' " Secure the modelines, apparently. https://linux.slashdot.org/story/19/06/15/0314215/vim-and-neo-editors-vulnerable-to-high-severity-bug
""" IDE CAPABILITIES
Plug 'LStinson/TagmaTasks' " Show project wide list of TODO, NOTE, FIXME
Plug 'coderifous/textobj-word-column.vim' " Better vertical column selection / changing (vic will visual in column)
Plug 'jeetsukumaran/vim-buffergator' " Easily switch between buffers
Plug 'majutsushi/tagbar' " Drawer showing ctags
Plug 'sjl/gundo.vim' " Undo tree history navigation
Plug 'tell-k/vim-browsereload-mac' " Browser Reloading from Vim
Plug 'Shougo/vimproc.vim' " Dependency of vim-browserreload-mac
Plug 'tpope/vim-projectionist' " Define alternate files
Plug 'vim-scripts/YankRing.vim' " Cycle through yanks/deletes in a visual window or after pasting
Plug 'w0rp/ale' " Async linting
" Plug 'prettier/vim-prettier', {
" \ 'do': 'yarn install',
" \ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] } " Autoformat code
" function! DoRemote(arg)
" UpdateRemotePlugins
" endfunction
" Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') }
" Plug 'roxma/nvim-yarp' " deoplete dependency
" Plug 'roxma/vim-hug-neovim-rpc' " deoplete dependency
" Plug 'uplus/deoplete-solargraph', { 'for': 'ruby', 'do': 'pip3 install solargraph-utils.py --user' } " deoplete ruby source
Plug 'ternjs/tern_for_vim', { 'for': 'javascript' }
" Plug 'carlitux/deoplete-ternjs', { 'for': 'javascript', 'do': 'npm install -g tern' } " deoplete javascript source
" Plug 'SevereOverfl0w/deoplete-github' "Broken for now: https://github.com/SevereOverfl0w/deoplete-github/issues/5<Paste>
"""" COC Config
" Use release branch (Recommend)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"""" TAB COMPLETION LIKE TEXTMATE FOR SNIPPETS
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
""""" LANGUAGE SPECIFIC SNIPPETS
" Plug 'greg-js/vim-react-es6-snippets' " vim-react-snippets:
Plug 'tellijo/vim-react-native-snippets'
Plug 'mlaursen/vim-react-snippets'
"""" PROJECT DRAWER
Plug 'Xuyuanp/nerdtree-git-plugin' " Show changed files in NERDTree
Plug 'jistr/vim-nerdtree-tabs' " Makes NERDTree awesome if you use tabs
Plug 'scrooloose/nerdtree' " Project drawer
""" GIT
Plug 'airblade/vim-gitgutter' " Show diff in the left gutter
Plug 'gregsexton/gitv' " Tig inside of vim with more power to traverse file history
Plug 'mattn/gist-vim' " Gist things
Plug 'mattn/webapi-vim' " Dependency of gist-vim
Plug 'tpope/vim-fugitive' " Git wrapper
Plug 'tpope/vim-git' " Some vim runtime files that are more up to date than those distributed with vim itself
Plug 'tpope/vim-rhubarb' " GitHub extension for fugitive.vim
""" BUFFER NAVIGATION / TEXT MANIPULATION
Plug 'Lokaltog/vim-easymotion' " <leader><leader>w jump to highlighted word
Plug 'christoomey/vim-tmux-navigator' " Navigate with C-h/j/k/l in tmux and vim
Plug 'godlygeek/tabular' " Align code
Plug 'gorkunov/smartpairs.vim' " Smart selection between pairs (viv)
Plug 'itspriddle/vim-stripper' " Strip trailing whitespace on save
Plug 'justincampbell/vim-eighties' " Ensures windows are at least 80 chars wide (my PR added the ability to ignore a list of additional bufnames)
Plug 'scrooloose/nerdcommenter' " Comment multiple lines
Plug 'tpope/vim-endwise' " Auto adds end to method definitions, blocks, etc
Plug 'tpope/vim-ragtag' " Some nice text wrappers for editing erb or html, ctrl+x in insert mode then type = or - or @ or #,etc
Plug 'tpope/vim-repeat' " Repeat surround (and other) changes with .
Plug 'tpope/vim-surround' " Easily change what something is surrounded by
Plug 'tpope/vim-unimpaired' " Allows for moving blocks of text up and down in place like you could in textmate
Plug 'vim-scripts/ZoomWin' " Lets you ctrl+w+o to toggle out a split to it's own buffer (easily can go back with the same command)
Plug 'alvan/vim-closetag' " Automatically close an html tag when you type the opening of it
Plug 'rstacruz/vim-closer' " Like auto-pairs, but more conservative, only adds the closing when you press enter
""" THEME / PRESENTATION
Plug 'bfontaine/Brewfile.vim' " Brewfile syntax
Plug 'edkolev/tmuxline.vim'
Plug 'lifepillar/vim-solarized8' " The best possible color scheme ever
Plug 'mustache/vim-mustache-handlebars' " Handlebars templates
Plug 'nathanaelkane/vim-indent-guides' " Show indent guides to the left of the methods
Plug 'terryma/vim-multiple-cursors' " like sublime multiple cursors
Plug 'tmux-plugins/vim-tmux' " Tmux config syntax hilighting
Plug 'tpope/vim-bundler' " Highlights Gemfile and wraps bundle open
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-dotenv' " .env file editing in vim (syntax highlighting, mostly)
""" LANAUAGE SPECIFIC
"""" RUBY
Plug 'vim-ruby/vim-ruby'
Plug 'bruno-/vim-ruby-fold' " Auto-fold files upon open. Disable session-wide with: <leader>nf
Plug 'ecomba/vim-ruby-refactoring' " refactor model names
Plug 'tpope/vim-abolish' " Dependency of vim-ruby-refactoring
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'tpope/vim-rails'
Plug 'KurtPreston/vim-autoformat-rails'
Plug 'thoughtbot/vim-rspec' " thoughtbot vim-rspec send to tmux, vim-dispatch, etc
Plug 'onemanstartup/vim-slim' " Slim template syntax highlighting
Plug 'tpope/vim-haml' " Enabled .haml extension
Plug 'jondkinney/vim-cucumber' " Enabled .feature files
"""" YAML
Plug 'avakhov/vim-yaml' " Yaml stuff
"""" JAVASCRIPT
""""" BASE
Plug 'othree/yajs.vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'othree/es.next.syntax.vim'
Plug 'gavocanov/vim-js-indent'
Plug 'isRuslan/vim-es6' " es-6 help
""""" FLAVORS
Plug 'kchmck/vim-coffee-script' " enable coffeescript
Plug 'leafgarland/typescript-vim'
Plug 'glanotte/vim-jasmine'
""""" REACT
Plug 'MaxMEllon/vim-jsx-pretty' " Better than: Plug 'mxw/vim-jsx'
Plug 'psychollama/further.vim' " Follow JavaScript imports to their source
"""" ELIXIR
Plug 'elixir-editors/vim-elixir'
Plug 'mhinz/vim-mix-format'
Plug 'slashmili/alchemist.vim'
Plug 'slime-lang/vim-slime-syntax'
""" SEARCH
Plug 'henrik/vim-indexed-search' " Gives a count of the number of matches, configured to stay on current match with indexed_search_dont_move=1
Plug 'nelstrom/vim-visual-star-search' " Don't jump to the next search, stay on current one
Plug 'haya14busa/incsearch.vim' " better incremental search, highlights in realtime everywhere as you type
Plug 'henrik/vim-qargs' " Project wide find and replace http://thepugautomatic.com/2012/07/project-wide-search-and-replace-in-vim-with-qdo/
Plug 'junegunn/fzf',
\ { 'dir': '~/.fzf', 'do': './install --all' } " Fuzzy Find
Plug 'mileszs/ack.vim' " project wide search
Plug 'yssl/QFEnter' " open splits from quickfix
""" WRITING PROSE
Plug 'itspriddle/vim-marked'
Plug 'kana/vim-textobj-user'
Plug 'plasticboy/vim-markdown'
Plug 'reedes/vim-lexical'
Plug 'reedes/vim-litecorrect'
Plug 'reedes/vim-pencil'
Plug 'reedes/vim-textobj-quote'
Plug 'reedes/vim-textobj-sentence'
Plug 'suan/vim-instant-markdown'
"""" SPELLING
Plug 'jonhiggs/MacDict.vim'
""" WIKI
Plug 'vimwiki/vimwiki'
Plug 'mattn/calendar-vim'
""" TESTING
Plug 'benmills/vimux' " Send to tmux pane
Plug 'jgdavey/vim-turbux' " Send to tmux pane
Plug 'janko-m/vim-test' " Test runner
Plug 'jondkinney/rspec.vim' " RSpec syntax highlighting improvements
Plug 'killphi/vim-legend' " Parses and displays x or check in the gutter for covered lines through cadre.
Plug 'wfleming/vim-codeclimate'
""" DASH DOCS
if has("unix")
let s:uname = system("uname")
if s:uname == "Darwin\n"
" Do Mac stuff here
Plug 'rizzatti/funcoo.vim'
Plug 'rizzatti/dash.vim'
endif
endif
""" DEPRECATED
Plug 'chrisbra/csv.vim'
Plug 'ervandew/supertab'
Plug 'tpope/vim-rake'
Plug 'tmux-plugins/vim-tmux-focus-events' " Regain focus events for terminal vim
""" INITIALIZE PLUGIN SYSTEM END
call plug#end()
""" Vim Plug automatically manage plugin installation and cleaning on load
let s:need_install = keys(filter(copy(g:plugs), '!isdirectory(v:val.dir)'))
let s:need_clean = len(s:need_install) + len(globpath(g:plug_home, '*', 0, 1)) > len(filter(values(g:plugs), 'stridx(v:val.dir, g:plug_home) == 0'))
let s:need_install = join(s:need_install, ' ')
if has('vim_starting')
if s:need_clean
autocmd VimEnter * PlugClean!
endif
if len(s:need_install)
execute 'autocmd VimEnter * PlugInstall --sync' s:need_install '| source $MYVIMRC'
finish
endif
else
if s:need_clean
PlugClean!
endif
if len(s:need_install)
execute 'PlugInstall --sync' s:need_install '| source $MYVIMRC'
finish
endif
endif""
"" vim:fdm=expr:fdl=0
"" vim:fde=getline(v\:lnum)=~'^""'?'>'.(matchend(getline(v\:lnum),'""*')-2)\:'='
snippet note
# NOTE: (`strftime("%Y-%m-%d")`) `system("whoami | tr -d '\n'")` => ${1}
snippet fixme
# FIXME: (`strftime("%Y-%m-%d")`) `system("whoami | tr -d '\n'")` => ${1}
snippet todo
# TODO: (`strftime("%Y-%m-%d")`) `system("whoami | tr -d '\n'")` => ${1}
snippet pryp
binding.pry${1}
snippet bye
require 'byebug'; byebug${1}
#cucumber
snippet sc
Scenario: ${1:title}
${2}
snippet sco
Scenario Outline: ${1:eating}
Given ${2: there are <start> cucumbers}
When ${3: I eat <eat> cucumbers}
Then ${4: I should have <left> cucumbers}
Examples:
| ${5:start} | ${6:eat} | ${7:left} |
| ${8:12} | ${9:5} | ${10:7} |
| ${11}
snippet sce
Scenario: ${1:title}
Given ${2:context}
When ${3:event}
Then ${4:outcome}
${5}
snippet fea
Feature: ${1:Title}
In order to ${2:value/benefit}
As a ${3:role}
I want ${4:feature}
${5}
snippet mafk
add_foreign_key :${1:table_name}, :${0:plural_association_name}
snippet macc
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
macc${4}
snippet mycol
t.${1:type} :${2:column_name}
mycol${3}
snippet mytab
create_table :${1:table_name} do |t|
t.${1:type} :${2:column_name}
mycol${4}
end
snippet mydrp
drop_table :${1:table_name}
snippet errors
errors.add(:base, "${1:Error text}")
snippet letb
let(:${1:object}) { build(:${2:object}) }
${3}
snippet letc
let(:${1:object}) { create(:${2:object}) }
${3}
snippet cre
create(:${1:object})
snippet build
build(:${1:object})
${2}
snippet bs
build_stubbed(:${1:object})
${2}
snippet assigns
assigns[:${1:instance_variable}]${2}
${3}
snippet allow
allow(${1:object}).to ${0}
snippet expect
expect(${1:object}).to ${0}
snippet receive
receive(:${1:object})${0}
snippet eq
eq(${1:value})${0}
snippet mydesc
describe "${1:class_name}" do
${2}
end
snippet lt
link_to "${1:Text}", ${2:Object}
snippet csl
console.log("${1:Description}", ${2});
snippet rp
= render partial: '${1:partial_name}', locals: {${2:key}: ${3:value}}${4}
snippet sop
save_and_open_page
snippet rbcop
# rubocop:disable Metrics/LineLength,
snippet rbcop
# rubocop:disable Metrics/MethodLength
snippet rbcop
# rubocop:disable Metrics/CyclomaticComplexity
snippet rbcop
# rubocop:disable Metrics/PerceivedComplexity
# Create a new ssh prompt which will open in a new window
bind S command-prompt -p ssh: "new-window -n '^ %2' 'ssh %1'"
# Create a new named window
bind N command-prompt -p name: "new-window -n '%1'"
# Setting the prefix from C-b to C-a
unbind C-b
set -g prefix C-a
set -g base-index 1
setw -g pane-base-index 1
set -g default-terminal 'screen-256color'
set -ga terminal-overrides ',xterm-256color:Tc'
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# splitting panes
bind t split-window -p 15
bind T split-window -h -p 33
bind E split-window -h -l 80
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# set the status line's colors
set -g status-style fg=white,bg=black
# set the color of the window list
setw -g window-status-style fg=cyan,bg=default,dim
# set colors for the active window
setw -g window-status-current-style fg=white,bg=red,bright
# Command / message line colors
set -g message-style fg=white,bg=black,bright
# Status line left side
set -g status-left-length 8
set -g status-left "#[fg=green]S:#S"
# Center the window list
set -g status-justify centre
# enable vi keys.
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Quick pane selection
bind -r C-p select-window -t :-
bind -r C-n select-window -t :+
set -g mouse on
# focus pane (this toggles)
bind Up resize-pane -Z
# Make Vim responsive to esc
set -s escape-time 2
# NOTES
# -----
# prefix space will toggle layouts
# prefix { will swap panes
# prefix C-o will swap panes too it seems
# break-pane
bind-key b break-pane
# join-pane
bind-key Enter command-prompt "joinp -t:%%" # %% = prompt for window.pane [-V|H] # vert|hor split
# Smart pane switching with awareness of vim splits
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n 'C-h' if-shell "$is_vim" "send-keys 'C-h'" "select-pane -L"
bind -n 'C-j' if-shell "$is_vim" "send-keys 'C-j'" "select-pane -D"
bind -n 'C-k' if-shell "$is_vim" "send-keys 'C-k'" "select-pane -U"
bind -n 'C-l' if-shell "$is_vim" "send-keys 'C-l'" "select-pane -R"
bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
# Status line right side to blank if we're in a cloud IDE like codio or cloud9
if-shell "test -d $HOME/workspace" "set -g status-right ''"
# Only source my tmux_mac config if we're on os x
if-shell 'test "$(uname)" = "Darwin"' 'source ${HOME}/.tmux_mac.conf'
if-shell 'test "$(uname)" = "Linux"' 'source ${HOME}/.tmux_linux.conf'
# List of plugins
# Supports `github_username/repo` or full git repo URLs
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-copycat \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-open \
tmux-plugins/tmux-pain-control \
tmux-plugins/vim-tmux-focus-events \
nhdaly/tmux-better-mouse-mode \
'
# Other examples:
# github_username/plugin_name \
# git@github.com/user/plugin \
# git@bitbucket.com/user/plugin \
setenv -g TMUX_PLUGIN_MANAGER_PATH "$HOME/.tmux/plugins/"
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && \
~/.tmux/plugins/tpm/bin/install_plugins'"
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'
# A few lines above this it says to keep the run-shell command "at the very
# bottom of this file", which is great if you want everything in tmux-sensible,
# but for some reason my display-time wasn't being honored when defined above,
# so just put it below to manually override tpm/tmux-sensible.
# timeout
set -g display-time 750
# allow clearing of screen in a shell
bind C-l send-keys 'C-l'
# For remote sync of clipboard from ssh'd Linux env
# -------------------------------------------------
bind C-c run "tmux save-buffer - | pbcopy-remote"
bind C-v run "tmux set-buffer $(pbpaste-remote); tmux paste-buffer"
# Set binding of `y` to use copy-pipe
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy-remote"
# Update default binding of `Enter` to also use copy-pipe
unbind-key -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy-remote"
# For Local Linux Usage (not ssh'd to a Linux box)
# ------------------------------------------------
# Set binding of `y` to use copy-pipe
# bind-key -t vi-copy y copy-pipe "xclip -i -selection clipboard"
# Update default binding of `Enter` to also use copy-pipe
# unbind -t vi-copy Enter
# bind-key -t vi-copy Enter copy-pipe "xclip -i -selection clipboard"
# # Something Pete needed a while ago
# set-option -ga update-environment ' DISPLAY'
bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste);tmux paste-buffer"
# handled by tmux-sensible
# set-option -g default-command "reattach-to-user-namespace -l zsh"
# set -g default-shell /usr/local/bin/zsh
# Set binding of `y` to use copy-pipe
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind-key -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# The first few lines check for an existing Vim setup and ask you if you want
# to overwrite it or back it up. I recommend backing any current Vim settings
# up so you can refer to them later if need be.
while getopts dm name
do
case $name in
d)defaults='true';;
*)echo "Invalid arg";;
esac
done
if [[ -f "$HOME/bin/pbcopy-remote" ]]; then
has_pbcopy_remote="true"
fi
if [[ -f "$HOME/bin/pbpaste-remote" ]]; then
has_pbpaste_remote="true"
fi
if [[ -f "$HOME/Library/LaunchAgents/pbcopy.plist" ]]; then
has_pbcopy_local="true"
fi
if [[ -f "$HOME/Library/LaunchAgents/pbpaste.plist" ]]; then
has_pbpaste_local="true"
fi
if [[ -d "$HOME/.vim" && ! -L "$HOME/.vim" ]]; then
has_dot_vim="true"
fi
if [[ -f $HOME/.vimrc ]]; then
has_dot_vimrc="true"
fi
if [[ -f $HOME/.config/nvim/init.vim ]]; then
has_nvim_config="true"
fi
if [[ -f $HOME/.vim/vimrc_main ]]; then
has_vimrc_main="true"
fi
if [[ -f $HOME/.vimrc_custom ]]; then
has_vimrc_custom="true"
fi
if [[ -f $HOME/.tmux.conf ]]; then
has_tmux_conf="true"
fi
if [[ -d "$HOME/.tmuxinator" && ! -L "$HOME/.tmuxinator" ]]; then
has_tmuxinator="true"
fi
function refresh_vimrc_main(){
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/vimrc_main > $HOME/.vim/vimrc_main
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.vim/vimrc_main"
fi
}
function full_vim_setup(){
echo "!!!!! Creating the necessary Vim directories..."
mkdir -p $HOME/.vim/autoload
mkdir -p $HOME/.vim/backup
mkdir -p $HOME/.vim/snippets
mkdir -p $HOME/.vim/sessions
mkdir -p $HOME/.vim/undo
mkdir -p $HOME/.config/nvim
if [ "$defaults" != "true" ]; then
echo ">>>>> Writing Config Files..."
fi
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/plugins.vim > $HOME/.vim/plugins.vim
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.vim/plugins.vim"
echo "!!!!! Installing vim-plug"
fi
curl -s https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim > $HOME/.vim/autoload/plug.vim
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/vimrc > $HOME/.vimrc
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.vimrc"
fi
if [ "$has_vimrc_custom" != "true" ]; then
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/vimrc_custom > $HOME/.vimrc_custom
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.vimrc_custom"
fi
fi
if [ "$has_nvim_config" != "true" ]; then
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/nvim_init > $HOME/.config/nvim/init.vim
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.config/nvim/init.vim"
fi
fi
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/snippets > $HOME/.vim/snippets/_.snippets
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.vim/snippets/_.snippets"
fi
refresh_vimrc_main
}
function backup_current_vim_setup(){
echo ">>>>> Backing up Vim setup..."
echo "!!!!! Appending -bak to the relevant folders and files...."
# Remove any old backups
rm -rf $HOME/.vim-bak
rm -rf $HOME/.vimrc-bak
# Backup
mv -fv $HOME/.vim $HOME/.vim-bak
mv -fv $HOME/.vimrc $HOME/.vimrc-bak
}
if [ "$has_dot_vim" == "true" -o "$has_dot_vimrc" == "true" -o "$has_vimrc_main" == "true" -o "$has_vimrc_custom" == "true" -o "$has_nvim_config" ]; then
echo "***** Note: You already have a Vim configuration..."
if [ "$defaults" == "true" ]; then
backup_current_vim_setup
full_vim_setup
else
read -p "????? Would you like to (b)ack it up, (o)verwrite it, (r)efresh ~/.vimrc_main, or (s)kip Vim setup (B/o/r/s)?"
if [[ $REPLY =~ ^[Ss]$ ]]; then
echo ">>>>> Skipping Vim configuration..."
elif [[ $REPLY =~ ^[Rr]$ ]]; then
echo ">>>>> Refreshing $HOME/.vim/vimrc_main and leaving the rest of your Vim setup untouched"
refresh_vimrc_main
elif [[ $REPLY =~ ^[Oo]$ ]]; then
echo "!!!!! Deleting current Vim setup..."
sudo rm -rf $HOME/.vim
rm -f $HOME/.vimrc
rm -f $HOME/.vim/vimrc_main
rm -f $HOME/.config/nvim/init.vim
full_vim_setup
else
backup_current_vim_setup
full_vim_setup
fi
fi
else
if [ "$defaults" == "true" ]; then
full_vim_setup
else
read -p "????? No previous Vim setup detected, proceed with a full Vim configuration (Y/n)?"
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo ">>>>> Skipping Vim configuration..."
else
full_vim_setup
fi
fi
fi
function backup_tmux(){
echo "!!!!! Backing up Tmux setup. Appending -bak to the relevant files..."
mv -fv $HOME/.tmux.conf $HOME/.tmux.conf-bak
mv -fv $HOME/.tmux $HOME/.tmux-bak
}
function setup_tmuxinator(){
echo "!!!!! Creating the necessary tmuxinator directories..."
if [ "$has_tmuxinator" == "true" ]; then
echo "***** note: $HOME/.tmuxinator already exists"
else
mkdir -p $HOME/.tmuxinator
fi
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/hack.yml > $HOME/.tmuxinator/hack.yml
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.tmuxinator/hack.yml"
fi
}
function setup_tmux(){
echo ">>>>> Setting up Tmux..."
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/tmux.conf > $HOME/.tmux.conf
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.tmux.conf"
fi
if [[ $OSTYPE =~ ^[darwin] ]]; then
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/tmux_mac.conf > $HOME/.tmux_mac.conf
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.tmux_mac.conf"
fi
fi
if [[ $OSTYPE =~ ^[linux] ]]; then
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/tmux_linux.conf > $HOME/.tmux_linux.conf
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/.tmux_linux.conf"
fi
fi
mkdir -p $HOME/.tmux/plugins
if [ "$defaults" != "true" ]; then
echo "!!!!! Created $HOME/.tmux/plugins/"
fi
git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm
if [ "$defaults" != "true" ]; then
echo "!!!!! Cloned Tmux Plugin Manager into it"
fi
if [[ $TMUX == '' ]]; then
tmux start-server # start a server but don't attach to it
tmux new-session -d # create a new session but don't attach to it either
fi
bash $HOME/.tmux/plugins/tpm/scripts/install_plugins.sh # install the plugins
if [ "$defaults" != "true" ]; then
echo "!!!!! Installed specified tmux plugins"
fi
if [ "$defaults" != "true" ]; then
echo ">>>>> Tmux setup complete"
fi
if [ "$defaults" == "true" ]; then
setup_tmuxinator
else
read -p "????? Add rails dev tmuxinator yaml file to $HOME/.tmuxinator (Y/n)"
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo ">>>>> Skipping Tmuxinator rails dev config"
else
setup_tmuxinator
echo "***** NOTE: make sure to install the tmuxinator gem in your global gemset (or another accessible place if you don't use RVM)"
fi
fi
}
if [ "$has_tmux_conf" == "true" ]; then
echo "***** Note: You already have a Tmux configuration..."
if [ "$defaults" == "true" ]; then
backup_tmux
setup_tmux
else
read -p "????? Would you like to (b)ack it up, (o)verwrite it, or (s)kip Tmux all together (B/o/s)?"
if [[ $REPLY =~ ^[Oo]$ ]]; then
echo "!!!!! Deleting current Tmux setup..."
rm -fv $HOME/.tmux.conf
sudo rm -rf $HOME/.tmux
setup_tmux
elif [[ $REPLY =~ ^[Ss]$ ]]; then
echo ">>>>> Skipping Tmux"
else
backup_tmux
setup_tmux
fi
fi
else
if [ "$defaults" == "true" ]; then
setup_tmux
else
echo ">>>>> No previous Tmux config detected"
read -p "????? Would you like to add this Tmux config (Y/n)?"
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo ">>>>> Skipping Tmux"
else
setup_tmux
fi
fi
fi
function backup_remote_clipboard(){
echo "!!!!! Backing up remote clipboard setup. Appending -bak to the relevant files..."
mv -fv $HOME/bin/pbcopy-remote $HOME/bin/pbcopy-remote-bak
mv -fv $HOME/bin/pbpaste-remote $HOME/bin/pbpaste-remote-bak
}
function setup_remote_clipboard(){
echo ">>>>> Setting up remote clipboard..."
mkdir -p $HOME/bin/
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/pbcopy-remote > $HOME/bin/pbcopy-remote
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/pbpaste-remote > $HOME/bin/pbpaste-remote
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/bin/pbcopy-remote"
echo "!!!!! Wrote $HOME/bin/pbpaste-remote"
fi
read -p "????? What port would you like to setup for pbcopy? (Default: 2222) "
if [[ $REPLY =~ ^[0-9]{4}$ ]]; then
sed -i -e "s/2222/$REPLY/" $HOME/bin/pbcopy-remote
else
echo "!!!!! Invalid port number, keeping default of 2222..."
fi
read -p "????? What port would you like to setup for pbpaste? (Default: 2223) "
if [[ $REPLY =~ ^[0-9]{4}$ ]]; then
sed -i -e "s/2223/$REPLY/" $HOME/bin/pbpaste-remote
else
echo "!!!!! Invalid port number, keeping default of 2223..."
fi
chmod +x $HOME/bin/pb*-remote
}
if [[ $OSTYPE =~ ^[linux] ]]; then
if [ "$has_pbcopy_remote" == "true" -o "$has_pbpaste_remote" == "true" ]; then
echo "***** Note: You already have remote clipboard copy and/or paste setup..."
if [ "$defaults" == "true" ]; then
backup_remote_clipboard
setup_remote_clipboard
else
read -p "????? Would you like to (b)ack it up, (o)verwrite it, or (s)kip remote clipboard setup all together (B/o/s)?"
if [[ $REPLY =~ ^[Oo]$ ]]; then
echo "!!!!! Deleting current remote clipboard setup..."
rm -fv $HOME/bin/pbpaste-remote
rm -fv $HOME/bin/pbcopy-remote
setup_remote_clipboard
elif [[ $REPLY =~ ^[Ss]$ ]]; then
echo ">>>>> Skipping Remote Clipboard Setup"
else
backup_remote_clipboard
setup_remote_clipboard
fi
fi
else
if [ "$defaults" == "true" ]; then
setup_remote_clipboard
else
echo ">>>>> No previous remote clipboard setup detected"
read -p "????? Would you like to add remote clipboard capabilities (Y/n)?"
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo ">>>>> Skipping Remote Clipboard"
else
setup_remote_clipboard
fi
fi
fi
fi
function backup_local_clipboard(){
echo "!!!!! Backing up local clipboard setup. Appending -bak to the relevant files..."
mv -fv $HOME/Library/LaunchAgents/pbcopy.plist $HOME/Library/LaunchAgents/pbcopy.plist-bak
mv -fv $HOME/Library/LaunchAgents/pbpaste.plist $HOME/Library/LaunchAgents/pbpaste.plist-bak
}
function setup_local_clipboard(){
echo ">>>>> Setting up local clipboard..."
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/pbcopy.plist > $HOME/Library/LaunchAgents/pbcopy.plist
curl -s https://gist.githubusercontent.com/jondkinney/2040114/raw/pbpaste.plist > $HOME/Library/LaunchAgents/pbpaste.plist
if [ "$defaults" != "true" ]; then
echo "!!!!! Wrote $HOME/Library/LaunchAgents/pbcopy.plist"
echo "!!!!! Wrote $HOME/Library/LaunchAgents/pbpaste.plist"
fi
read -p "????? What port would you like to setup for pbcopy? (Default: 2222) "
if [[ $REPLY =~ ^[0-9]{4}$ ]]; then
sed -i -e "s/2222/$REPLY/" $HOME/Library/LaunchAgents/pbcopy.plist
pbcopy_local_port=$REPLY
else
echo "!!!!! Invalid port number, keeping default of 2222..."
pbcopy_local_port='2222'
fi
read -p "????? What port would you like to setup for pbpaste? (Default: 2223) "
if [[ $REPLY =~ ^[0-9]{4}$ ]]; then
sed -i -e "s/2223/$REPLY/" $HOME/Library/LaunchAgents/pbpaste.plist
pbpaste_local_port=$REPLY
else
echo "!!!!! Invalid port number, keeping default of 2223..."
pbpaste_local_port='2223'
fi
echo "!!!!! Setting up pbcopy and pbpaste for launchctl"
launchctl unload $HOME/Library/LaunchAgents/pbcopy.plist
launchctl unload $HOME/Library/LaunchAgents/pbpaste.plist
launchctl load $HOME/Library/LaunchAgents/pbcopy.plist
launchctl load $HOME/Library/LaunchAgents/pbpaste.plist
local_clipboard_was_setup="true"
}
if [[ $OSTYPE =~ ^[darwin] ]]; then
if [ "$has_pbcopy_local" == "true" -o "$has_pbpaste_local" == "true" ]; then
echo "***** Note: You already have local clipboard copy and/or paste setup..."
if [ "$defaults" == "true" ]; then
backup_local_clipboard
setup_local_clipboard
else
read -p "????? Would you like to (b)ack it up, (o)verwrite it, or (s)kip local clipboard setup all together (B/o/s)?"
if [[ $REPLY =~ ^[Oo]$ ]]; then
echo "!!!!! Deleting current local clipboard setup..."
rm -fv $HOME/Library/LaunchAgents/pbcopy.plist
rm -fv $HOME/Library/LaunchAgents/pbpaste.plist
setup_local_clipboard
elif [[ $REPLY =~ ^[Ss]$ ]]; then
echo ">>>>> Skipping Local Clipboard Setup"
else
backup_local_clipboard
setup_local_clipboard
fi
fi
else
if [ "$defaults" == "true" ]; then
setup_local_clipboard
else
echo ">>>>> No previous local clipboard setup detected"
read -p "????? Would you like to add local clipboard capabilities (Y/n)?"
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo ">>>>> Skipping Local Clipboard"
else
setup_local_clipboard
fi
fi
fi
fi
if [ "$local_clipboard_was_setup" == "true" ]; then
echo "!!!!! Please add the following configuration to your ~/.ssh/config file"
echo "
Host nickname_here
HostName ip_address_or_hostname_here
User your_username_here
# Pick something other than 3000 to avoid port collisions in a shared environment
LocalForward 3000 localhost:3000
RemoteForward $pbcopy_local_port 127.0.0.1:$pbcopy_local_port
RemoteForward $pbpaste_local_port 127.0.0.1:$pbpaste_local_port
ForwardAgent yes
!!!!! You will then be able to ssh to the host using the above preferences automatically: ssh nickname_here
!!!!! NOTE: For pbcopy-remote & pbpaste-remote to work properly, make sure ~/bin is in your PATH on the remote machine!!
"
fi
" this is the configuration file for linux and mac systems
" symlink this to your home folder as .vimrc
" It loads ~/.vim/vundle and loads all modules from ~/.vim/bundle.
" It then loads ~/.vim/vimrc_main which has the main
" configuration that works across all systems.
if has('nvim')
runtime! python_setup.vim
endif
source ~/.vim/plugins.vim
source ~/.vim/vimrc_main
source ~/.vimrc_custom
" Put platform specific stuff here.
" User customizations here
""" ELIXIR-LS
" This is specific to your machine. Manually install elixir-ls
" https://www.rockyourcode.com/developing-with-elixir-in-vim
"
" If you clone it to ~/.elixir-ls and compile in that folder, this should
" work. I'll see about automating this in the future.
let g:ale_elixir_elixir_ls_release="/Users/" . $USER . "/.elixir-ls/release"
"" vim:fdm=expr:fdl=0
"" vim:fde=getline(v\:lnum)=~'^""'?'>'.(matchend(getline(v\:lnum),'""*')-2)\:'='
""" SETTINGS
set nocompatible " Don't need to keep compatibility with Vi
filetype plugin indent on " enable detection, plugins and indenting in one step
syntax on " Turn on syntax highlighting
set synmaxcol=1000 " Don't try to highlight lines longer than 1000 characters
set showcmd " show incomplete cmds down the bottom
set noshowmode " don't show current mode down the bottom (set showmode does the opposite)
set showmatch " Set show matching parenthesis
set noexrc " Don't use the local config
set virtualedit=all " Allow the cursor to go in to 'invalid' places
set incsearch " Find the next match as we type the search
set hlsearch " Hilight searches by default
set ignorecase " Ignore case when searching
set smartcase " ...unless they contain at least one capital letter
set shiftwidth=2 " Number of spaces to use in each autoindent step
set shiftround " When at 3 spaces, and I hit > ... go to 4, not 5
set tabstop=2 " Two tab spaces
set softtabstop=2 " Number of spaces to skip or insert when <BS>ing or <Tab>ing
set expandtab " Spaces instead of tabs for better cross-editor compatibility
set smarttab " Use shiftwidth and softtabstop to insert or delete (on <BS>) blanks
set nowrap " No wrapping
set copyindent " Copy the previous indentation on autoindenting
set backspace=indent,eol,start " Allow backspacing over everything in insert mode
set noerrorbells " Don't make noise
set wildmenu " Make tab completion act more like bash
set wildmode=list:longest " Tab complete to longest common string, like bash
" set mouse-=a " Disable mouse automatically entering visual mode
set mouse=a " Enable mouse support in the terminal VIM and activate visual mode with dragging
if !has('nvim')
set ttymouse=xterm2 " Allow resizing of Vim splits inside tmux. See https://superuser.com/a/550482/648584
set ttyscroll=3 " Prefer redraw to scrolling for more than 3 lines TODO: see if I like this
endif
set bs=2 " This influences the behavior of the backspace option. See :help 'bs' for more details
set number " Show line numbers
set cmdheight=2 " Make the command line a little taller to hide 'press enter to viem more' text
set ttyfast " Improves screen redraw
set lazyredraw " Avoid redrawing the screen mid-command.
set splitbelow " New splits will be created below the current split
set splitright " New splits will be created to the right of the current split
set confirm " Ask to save changes
set encoding=utf-8 " Set utf-8 encoding
set pastetoggle=<F2> " Press F2 in insert mode to preserve tabs when pasting from clipboard into terminal
set updatetime=750 " Should 'fix' git-gutter weird highlighting issues
set notimeout ttimeout ttimeoutlen=10 "Quckly time out on keycodes, but never time out on mappings
set switchbuf=useopen,usetab "Attempt to edit currently open files instead of opening multiple buffers.
set modelineexpr
" TEST for react gf
set path=.,src
set suffixesadd=.js,.jsx
function! LoadMainNodeModule(fname)
let nodeModules = "./node_modules/"
let packageJsonPath = nodeModules . a:fname . "/package.json"
if filereadable(packageJsonPath)
return nodeModules . a:fname . "/" . json_decode(join(readfile(packageJsonPath))).main
else
return nodeModules . a:fname
endif
endfunction
set includeexpr=LoadMainNodeModule(v:fname)
" END Test for react gf
runtime macros/matchit.vim "Extend % for matching brackets, if/end, and more
set wildignore+=*/production_data/*,*/db/dumps/*,*/coverage/*,*/accredited_investor_questionnaires/*,*/accredited_verification_pdfs/*,*/HTML_DEMOS/*,*/docusign_docs/*,*/cookbooks/*,*/public/uploads/*,*/public/images/*,*/vim_sessions/*,*/node_modules/*,*/bower_components/*,*/tmp/*,*.so,*.swp,*.zip,*/sassdoc/* " MacOSX/Linux
let mapleader = "," "remap leader to ',' which is much easier than '\'
let maplocalleader = "\\" "add a local leader of '\'
" Reveal in Finder - opens finder to folder of the file that is currently open
command! Rif execute '!open %:p:h'
""" UNMAPS
" S command in normal mode substitutes the whole line after a motion. I don't
" like that, so we'll disable it here.
nmap S <nop>
" STOP the help from being so... HELPFULL ;)
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Disable some built in commands I don't like
" map K <Nop>
""" SPELLING
" Toggle spellcheck with F6 (highlighted and underlined in stark WHITE)
" ---------------------------------------------------------------------
" z= - view spelling suggestions for a misspelled word
" zg - add word to dictionary
" zug - undo add word to dict
hi SpellBad cterm=underline ctermfg=white
nn <F6> :setlocal spell! spell?<CR>
map <F11> "dyiw:call MacDict(@d)<CR>
""" CLIPBOARD
if has('nvim')
" Use unnamed registers for clipboard
set clipboard+=unnamedplus
else
" This allows you to share Vim's clipboard with OS X.
set clipboard=unnamed
endif
if has("unix")
let s:uname = system("uname")
if s:uname == "Linux\n"
" Remote Clipboard
function! PropagatePasteBufferToOSX()
let @n=getreg('"')
call system('pbcopy-remote', @n)
echo "done"
endfunction
function! PopulatePasteBufferFromOSX()
let @" = system('pbpaste-remote')
echo "done"
endfunction
nnoremap <leader>3 :call PopulatePasteBufferFromOSX()<cr>
nnoremap <leader>2 :call PropagatePasteBufferToOSX()<cr>
nnoremap yy yy:call PropagatePasteBufferToOSX()<cr>
function! YRRunAfterMaps()
nnoremap Y :<C-U>YRYankCount 'y$'<CR> <bar> :call PropagatePasteBufferToOSX()<CR>
vnoremap y y:call PropagatePasteBufferToOSX()<CR>
endfunction
endif
endif
""" COLORS & THEMES & BUFFER DISPLAY
if has("unix")
let s:uname = system("uname")
if s:uname != "Darwin\n"
set t_Co=256 "256 colors support
let g:solarized_termcolors=16
endif
endif
if has('termguicolors') && !has('gui_running')
set termguicolors
endif
let g:solarized_termtrans=1
set background=dark
" set background=light
colorscheme solarized8
" TMUX helper for solarized8
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Right column guide
set colorcolumn=81
" Right column guide (git commit message)
au BufNewFile,BufRead COMMIT_EDITMSG setlocal colorcolumn=51
" Spelling
hi SpellBad ctermfg=009 ctermbg=001 guifg=#ff0000 guibg=#ffffff
hi SpellCap ctermfg=009 ctermbg=001 guifg=#ff0000 guibg=#ffffff
" Cursor
" This switches the cursor into a pipe when in insert mode tmux will only
" forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if has('nvim')
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
else
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
endif
if has("gui_macvim")
set guifont=Monaco\ for\ Powerline:h12
endif
" TODO: (2018-02-24) jon => decide if I still want this
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
" | | | | | | | | | | |
" | | | | | | | | | | + current
" | | | | | | | | | | column
" | | | | | | | | | +-- current line
" | | | | | | | | +-- current % into file
" | | | | | | | +-- current syntax in
" | | | | | | | square brackets
" | | | | | | +-- current fileformat
" | | | | | +-- number of lines
" | | | | +-- preview flag in square brackets
" | | | +-- help flag in square brackets
" | | +-- readonly flag in square brackets
" | +-- modified flag in square brackets
" +-- full path to file in the buffer
" Show line endings and tabs (whitespace markers)
nmap <leader>il :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
" toggle hide numbers
map <leader>1 :set nonumber! number?<CR>
" toggle relative numbers
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
set number
else
set relativenumber
endif
endfunc
nnoremap <leader>l :call NumberToggle()<CR>
" Indent guides turned on with <leader>ig
let g:indent_guides_start_level=1
let g:indent_guides_guide_size=1
" Airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline_powerline_fonts = 1
let g:airline_detect_iminsert = 1
" tmux plugin for vim-airline https://github.com/edkolev/tmuxline.vim
let g:tmuxline_preset = 'full'
" Signify
"let g:signify_sign_color_guibg = '#032b36'
let g:signify_sign_color_inherit_from_linenr = 1
let g:signify_sign_weight = 'NONE'
let g:signify_update_on_bufenter = 1
""" NERDTree
" Open NERDTree with [<leader>d]
map <Leader>d :NERDTreeMirrorToggle<CR>
" Show current file in the NERDTree hierarchy
map <Leader>D :NERDTreeFind<CR>
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDTreeWinSize = 51
let NERDTreeShowLineNumbers=1
let g:nerdtree_tabs_focus_on_files=1
let g:nerdtree_tabs_open_on_console_startup=1
let g:nerdtree_tabs_smart_startup_focus=2
" list of file types I don't want to auto-open nerdtree for
autocmd FileType vim,tmux,gitcommit,gitconfig,gitrebase let g:nerdtree_tabs_open_on_console_startup=0
autocmd BufNewFile,BufRead vundle let g:nerdtree_tabs_open_on_console_startup=0
let NERDSpaceDelims=1 " For nerdcommenter, add one space after comment char
""" FUZZY FIND
nnoremap <C-f> :FZF<CR>
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-i': 'split',
\ 'ctrl-v': 'vsplit' }
"""" Ack in Project
" AckG matches file names in the project, regular Ack looks inside those files
map <Leader><C-t> :AckG<space>
" map <Leader><C-f> :Ack!<space>
" map <Leader><C-f> :Ag<space>
let g:ackprg = 'ag'
" Split rightward so as not to displace a left NERDTree
let g:ack_mappings = {
\ 'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
\ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J',
\ '<cr>': ':NERDTreeMirrorToggle<CR><CR>:NERDTreeMirrorToggle<CR><C-W>l' }
nnoremap <Leader><C-f> :tabnew <Bar> Ack!<Space>
""" VIMWIKI
let wiki0 = {}
let wiki0.path = '~/vimwiki/'
let wiki0.path_html = '~/vimwiki_html/'
let wiki0.auto_toc = 1
let wiki1 = {}
let wiki1.path = '~/vimwiki_headway/'
let wiki1.path_html = '~/vimwiki_headway_html/'
let wiki1.auto_toc = 1
" Run multiple wikis
let g:vimwiki_list = [wiki0, wiki1]
au BufRead,BufNewFile *.wiki set filetype=vimwiki
" Open diary with \d
:autocmd FileType vimwiki map <localleader>d :VimwikiMakeDiaryNote<CR>:Calendar<CR>
au! BufRead ~/vimwiki_headway/index.wiki !cd ~/vimwiki_headway;git pull
" au! BufWritePost ~/vimwiki_headway/* !cd ~/vimwiki_headway;git add -A;git commit -m "Auto commit + push.";git push
" let g:vimwiki_folding='expr'
""" SPLIT AND BUFFER MANAGEMENT
" Resize splits when the window is resized
au VimResized * :wincmd =
" Better split management, kept in sync with tmux' mappings of (<prefix>| and <prefix>-)
noremap <leader>- :sp<CR><C-w>j
noremap <leader>\| :vsp<CR><C-w>l
" Allow resizing splits with +/_ for down(bigger) / up(smaller) and ALT-=(bigger)/ALT–(smaller). Repeatable w/hold.
if bufwinnr(1)
" Alt =
map ≠ <C-W>>
" Alt -
map – <C-W><
map _ <C-W>-
map + <C-W>+
endif
" Adjusts all buffers to the same size
map <Leader>= <C-w>=
" Open splits from quickfix window like you can in ctrl-p
let g:qfenter_vopen_map = ['<C-v>']
let g:qfenter_hopen_map = ['<C-CR>', '<C-s>', '<C-x>', '<C-i>']
let g:qfenter_topen_map = ['<C-t>']
let g:eighties_bufname_additional_patterns = ['fugitiveblame','locationlist'] " Don't try to auto-resize a fugitive blame split to 80 chars
noremap <F5> :redraw!<cr>
""" SEARCH & FIND & REPLACE
"Search and replace the word under the cursor with whatever you type in
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
"Search and replace only within a given selection. This DOES NOT replace all
" instances on the line that the highlight is on, which is why it's awesome.
vnoremap <Leader>S :s/\%V//g<Left><Left><Left>
" Better search with insearch
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" Turn highlighting off after a search (and / or turn off highlights)
noremap <silent> <leader><space> :noh<cr>:call clearmatches()<cr>
" Keeps cursor on star search highlight
let g:indexed_search_dont_move=1
" http://vim.wikia.com/wiki/Make_search_results_appear_in_the_middle_of_the_screen
nnoremap <silent> <F4> :call <SID>SearchMode()<CR>
function! s:SearchMode()
" if !exists('s:searchmode') || s:searchmode == 0
if !exists('s:searchmode') || s:searchmode == 2
echo 'Search next: scroll hit to middle if not on same page'
nnoremap <silent> n n:call <SID>MaybeMiddle()<CR>
nnoremap <silent> N N:call <SID>MaybeMiddle()<CR>
let s:searchmode = 1
" elseif s:searchmode == 1
else
echo 'Search next: scroll hit to middle'
nnoremap n nzz
nnoremap N Nzz
let s:searchmode = 2
" else
" echo 'Search next: normal'
" nunmap n
" nunmap N
" let s:searchmode = 0
endif
endfunction
" If cursor is in first or last line of window, scroll to middle line.
function! s:MaybeMiddle()
if winline() == 1 || winline() == winheight(0)
normal! zz
endif
endfunction
augroup searchmode
au!
au BufRead * call s:SearchMode()
augroup END
""" SESSION MANAGEMENT AND OPENING FILES
" Create new session
nmap SC :Obsess ~/.vim/sessions/
" Open the last saved session
nmap SO :so ~/.vim/sessions/
nmap SQ :Obsess!<CR>
" OpenChangedFiles COMMAND
" Open a split for each dirty (or new) file in git
" Shamelessly stolen from Gary Bernhardt: https://github.com/garybernhardt/dotfiles
function! OpenChangedFiles()
only " Close all windows, unless they're modified
let modified_status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3')
let added_status = system('git status -s | grep "^ \?\(??\)" | cut -d " " -f 2')
let status = modified_status . added_status
let filenames = split(status, "\n")
if len(filenames) > 0
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "tabedit " . filename
endfor
end
endfunction
command! OpenChangedFiles :call OpenChangedFiles()
" nnoremap ,em :NERDTreeMirrorToggle<CR>:OpenChangedFiles<CR>:NERDTreeMirrorToggle<CR>
nnoremap ,em :OpenChangedFiles<CR>
function! OpenLastCommitFiles()
only " Close all windows, unless they're modified
let status = system('git log --pretty=format: --name-only --no-merges -n 1')
let filenames = split(status, "\n")
if len(filenames) > 0
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "tabedit " . filename
endfor
end
endfunction
command! OpenLastCommitFiles :call OpenLastCommitFiles()
nnoremap ,elc :OpenLastCommitFiles<CR>
" Make sure Vim returns to the same line when you reopen a file.
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
""" SAVING FILES AND BUFFERS
" Hit SS in insert or normal mode to save
noremap SS :w<CR>
inoremap SS <Esc>:w<CR>
" Force save the current file even if you don't have permission
map W!! :w !sudo tee % > /dev/null<CR>
cmap w!! w !sudo tee % >/dev/null
" autoread and autowrite http://albertomiorin.com/blog/2012/12/10/autoread-and-autowrite-in-vim/
augroup save
au!
au FocusLost * wall
augroup END
set nohidden
set nobackup
set noswapfile
set nowritebackup
set autoread
set autowrite
set autowriteall
" Persistent-undo
set undodir=$HOME/.vim/undo
set undofile
" Allow for typing various quit cmds while accidentally capitalizing a letter
command! -bar Q quit "Allow quitting using :Q
command! -bar -bang Q quit<bang> "Allow quitting without saving using :Q!
command! -bar QA qall "Quit all buffers
command! -bar Qa qall "Quit all buffers
command! -bar -bang QA qall<bang> "Allow quitting without saving using :Q!
command! -bar -bang Qa qall<bang> "Allow quitting without saving using :Q!
" NOTE - the above has nothing to do with the quit commands below
" Make Q useful and avoid the confusing Ex mode.
" Pressing Q with this mapping does nothing intentionally
noremap Q <nop>
" Close window.
noremap QQ :q<CR>
" close and write
noremap WQ :wq<CR>
" Close all.
noremap QA :qa<CR>
" Close, damn you!
noremap Q! :q!<CR>
" ,q to toggle quickfix window (where you have stuff like GitGrep)
" ,oq to open it back up (rare)
nmap <silent> ,cq :cclose<CR>
nmap <silent> ,co :copen<CR>
" With tmux-plugins/vim-tmux-focus-events, vim will load up a file on focus so write the file when switching away
let g:tmux_navigator_save_on_switch = 1
""" LINTING (ALE)
let g:ale_fixers = {
\ 'ruby': ['rubocop'],
\ 'javascript': ['prettier', 'eslint'],
\ 'json': ['prettier', 'eslint'],
\ 'elixir': ['mix_format'],
\}
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'ruby': ['ruby','rubocop','reek'],
\ 'erb': ['erb'],
\ 'slim': ['slim-lint'],
\ 'sass': ['sass-lint'],
\ 'elixir': ['elixir-ls'],
\}
" \ 'commitmessage': ['gitlint'],
" let g:ale_javascript_prettier_eslint_options = 'something can go here'
let g:ale_fix_on_save = 1
" highlight clear ALEErrorSign " otherwise uses error bg color (typically red)
" highlight clear ALEWarningSign " otherwise uses error bg color (typically red)
" hi Error cterm=bold gui=bold
" hi Warning cterm=bold gui=bold
" hi link ALEErrorSign Error
" hi link ALEWarningSign Warning
" highlight ALEErrorSign ctermbg=NONE ctermfg=red
" let g:ale_sign_error = '✘' " could use emoji
let g:ale_sign_error = '•' " could use emoji
" let g:ale_sign_warning = '•' " could use emoji
let g:ale_sign_warning = '💩' " could use emoji
let g:ale_statusline_format = ['X %d', '? %d', '']
" %linter% is the name of the linter that provided the message
" %s is the error or warning message
let g:ale_echo_msg_format = '%linter% says %s'
let g:ale_sign_column_always = 1
let g:ale_ruby_rubocop_options = '--except Lint/Debugger -D'
let g:ale_lint_on_text_changed='normal' " only lint when exiting insert and going into normal mode
let g:ale_lint_delay = 250
let g:ale_set_highlights = 1
" Map keys to navigate between lines with errors and warnings.
nnoremap <leader>an :ALENextWrap<cr>
nnoremap <leader>ap :ALEPreviousWrap<cr>
""" CTAGS
"Update CTags
nnoremap <silent> <leader>ct :!$(.git/hooks/ctags &)<cr> <bar> :redraw!<cr>
" ExCTags window (requires http://ctags.sourceforge.net/)
nmap <F8> :TagbarToggle<CR>
let g:tagbar_left = 1
let g:tagbar_autofocus = 1
let g:tagbar_compact = 1
let g:tagbar_autoclose = 1
" Open ctag in tab/vertical split
map <leader><C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" NOTE: Jump to previous file with <leader><C-^>
""" TABS
" Load up all buffers into tabs
nmap <localleader>bt :tab sball<CR>
" Switch to last active tab see https://stackoverflow.com/a/2120168/935514
let g:lasttab = 1
nmap <Leader>fl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" Close current tab
nmap <leader>fc :tabclose<CR>
" previous tab(shift-9), next tab (shift-0)
nnoremap ( :tabp<CR>
nnoremap ) :tabn<CR>
" switch tab order with Ctrl+<left>/<right>
map <Esc>[C :tabm +1<Esc>
map <Esc>[D :tabm -1<Esc>
function! MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
function! MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
" switch tab order with Ctrl+<up>/<down>
map <Esc>[B :call MoveToNextTab()<CR>
map <Esc>[A :call MoveToPrevTab()<CR>
""" ALIGNMENT
"if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
nmap <localleader>a, :Tabularize /,\zs<CR>
vmap <localleader>a, :Tabularize /,\zs<CR>
" Triggers align of cucumber tables when you close it out with a | and have at
" least two lines. Thanks tpope :)
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
""" FOLDING
" toggle folding with za.
" fold everything with zM
" unfold everything with zR.
" zm and zr can be used too
" set foldmethod=syntax "fold based on syntax (except for haml below)
" set foldnestmax=10 "deepest fold is 10 levels
" set nofoldenable "dont fold by default
autocmd BufNewFile,BufRead *.haml setl foldmethod=indent nofoldenable
autocmd! FileType nofile setl foldmethod=indent nofoldenable
autocmd BufNewFile,BufRead vimrc_main setl foldmethod=syntax nofoldenable
set foldlevelstart=99
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" Toggles folds being enabled for this vim session
function! FoldToggle()
if(&foldenable == 1)
au WinEnter * set nofen
au WinLeave * set nofen
au BufEnter * set nofen
au BufLeave * set nofen
:set nofen
else
au WinEnter * set fen
au WinLeave * set fen
au BufEnter * set fen
au BufLeave * set fen
:set fen
endif
endfunc
nnoremap <Leader>nf :call FoldToggle()<CR>
""" CODE COVERAGE AND TESTING
"""" Coverage via Cadre/github.com/killphi/vim-legend
let g:legend_active_auto = 0
let g:legend_hit_color = "ctermfg=64 cterm=bold gui=bold guifg=Green"
let g:legend_ignored_sign = "◌"
let g:legend_ignored_color = "ctermfg=234"
let g:legend_mapping_toggle = '<Leader>cv'
let g:legend_mapping_toggle_line = '<localleader>cv'
"""" vim-rspec & cucumber test runner mappings <leader>T
let VimuxHeight = "33" "this is percentage
let VimuxOrientation = "h"
let VimuxUseNearestPane = 1
let g:turbux_command_prefix = 'clear;'
nmap <leader>t <Plug>SendTestToTmux
nmap <leader>T <Plug>SendFocusedTestToTmux
" for rspec.vim (syntax highlighting enhancements for rspec)
autocmd BufReadPost,BufNewFile *_spec.rb set syntax=rspec
"""" CodeClimate Bindings
nmap <Leader>aa :CodeClimateAnalyzeProject<CR>
nmap <Leader>ao :CodeClimateAnalyzeOpenFiles<CR>
nmap <Leader>af :CodeClimateAnalyzeCurrentFile<CR>
""" PLUGIN SETTINGS
" Set super tab to start completion with ctrl+j and move down the list with
" more j's, move back with ctrl+k
let g:SuperTabMappingForward = '<c-k>'
let g:SuperTabMappingBackward = '<c-j>'
" YankRing plugin to manage yanked/deleted buffers
nnoremap <silent> <F7> :YRShow<CR>
let g:yankring_history_file = '.yankring-history'
" let g:yankring_zap_keys = 'f F t T / ?'
" Dig through the tree of undo possibilities for your current file
nnoremap <F3> :GundoToggle<CR>
let g:gundo_right = 1
let g:gundo_preview_bottom=1
let g:gundo_preview_height = 40
" Gist settings for mattn/gist-vim
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
let g:gist_post_private = 1
" Buffrgator settings
let g:buffergator_viewport_split_policy="B"
let g:buffergator_split_size=10
let g:buffergator_suppress_keymaps=1
let g:buffergator_sort_regime = "mru"
map <Leader>b :BuffergatorToggle<cr>
" Vim-stripper
let g:StripperIgnoreFileTypes = []
" reload current top window/tab of chrome
map <leader>rr :ChromeReload<CR>
let g:returnApp = "iTerm"
" Pull up the TODO And NOTE and FIXME definitions from the whole app
let g:TagmaTasksPrefix = '<localleader><localleader>t'
let g:TagmaTasksHeight = 10
map <Leader><Leader>tt :TagmaTasks * app/** config/** db/** doc/** features/** lib/** public/** spec/** test/** vendor/**<CR>
" Use deoplete (autocomplete) on startup
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 1
" deoplete.nvim
" inoremap <silent> <expr> <Tab> pumvisible() ? '\<C-n>' : deoplete#mappings#manual_complete()
" deoplete-ternjs
let g:deoplete#sources = {}
let g:deoplete#sources.javascript = ['ternjs']
" let g:deoplete#sources.gitcommit = ['github'] " currently broken https://github.com/SevereOverfl0w/deoplete-github/issues/5
" let g:deoplete#sources.ruby = ['solar']
let g:deoplete#omni#functions = {}
let g:deoplete#omni_patterns = {}
" tern_for_vim
let g:tern#command = ['tern']
let g:tern#arguments = ['--persistent']
let g:deoplete#omni#functions.javascript = ['tern#Complete']
let g:deoplete#omni_patterns.javascript = '\h\w*\|\h\w*\.\%(\h\w*\)\|[^. \t]\.\%(\h\w*\)'
" ruby
let g:deoplete#omni#functions.ruby = ['solar']
let g:deoplete#omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
"Add extra filetypes
let g:deoplete#sources#ternjs#filetypes = [
\ 'jsx',
\ 'javascript.jsx',
\ 'vue',
\ ]
" UltiSnips
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<c-tab>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsSnippetsDir='~/.vim/UltiSnips'
let g:ulti_expand_or_jump_res = 0
function! CleverTab()"{{{
call UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res
return ""
else
if pumvisible()
return "\<c-n>"
else
return "\<Tab>"
endif
endif
endfunction"}}}
inoremap <silent> <tab> <c-r>=CleverTab()<cr>
snoremap <silent> <tab> <esc>:call UltiSnips#ExpandSnippetOrJump()<cr>
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
map <leader>u :UltiSnipsEdit<cr>
if has("unix")
let s:uname = system("uname")
if s:uname == "Darwin\n"
" Do Mac stuff here
" Dash
"let g:dash_map = {
" \ 'ruby' : 'rails'
" \ }
au BufNewFile,BufRead *.rb :DashKeywords rails ruby<cr>
nmap <silent> <LocalLeader>d <Plug>DashSearch
nmap <silent> <LocalLeader>D <Plug>DashGlobalSearch
endif
endif
""" MARKDOWN & WRITING
map <localleader>m :MarkedOpen!<CR>
let g:marked_app = "Marked" " Need to specify v1 of the app
" let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0
let g:vim_markdown_frontmatter = 1
" Syntax highlight code in markdown files
let g:markdown_fenced_languages = ['javascript', 'js=javascript', 'json=javascript', 'ruby']
let g:vim_markdown_emphasis_multiline = 0
let g:vim_markdown_toc_autofit = 1
" Disable ]c for move to current header of vim-markdown
nmap <Plug>Markdown_MoveToCurHeader <Plug>Markdown_MoveToCurHeader
" function! s:Toc()
" if &filetype == 'markdown'
" :normal SS
" endif
" endfunction
" autocmd VimEnter *.m* call s:Toc()
" autocmd BufReadPost *.m* call s:Toc()
" autocmd BufWinEnter *.m* call s:Toc()
augroup ft_markdown
au!
au BufNewFile,BufRead *.m*down setlocal filetype=markdown foldlevel=1
" Use <localleader>1/2/3 to add headings.
au Filetype markdown nnoremap <buffer> <localleader>1 mzI# <ESC>
au Filetype markdown nnoremap <buffer> <localleader>2 mzI## <ESC>
au Filetype markdown nnoremap <buffer> <localleader>3 mzI### <ESC>
" au FileType markdown nnoremap <leader>al <Esc>`<i[<Esc>`>la](<Esc>"*]pa)<Esc>
"
" Create a Markdown-link structure for the current word or visual selection
" with leader 3. Paste in the URL later. Or use leader 4 to insert the
" current system clipboard as an URL.
au FileType markdown nnoremap <Leader>al ciw[<C-r>"]()<Esc>
au FileType markdown vnoremap <Leader>al c[<C-r>"]()<Esc>
" au FileType markdown nnoremap <Leader>ai <Esc>`<i[<Esc>`>la](<Esc>"*]pa)<Esc>
au FileType markdown vnoremap <Leader>ai <Esc>`<i[<Esc>`>la](<Esc>"*]pa)<Esc>
" au FileType markdown nnoremap <Leader>ai ciw[<C-r>"](<Esc>"*pli)<Esc>
" au FileType markdown vnoremap <Leader>ai c[<C-r>"](<Esc>"*]pa)<Esc>
" Use formd to transfer markdown from inline [to reference](to reference) links and vice versa
" see: http://drbunsen.github.com/formd/
au FileType markdown nmap <leader>fr :%! /usr/local/bin/formd/formd -r<CR>
au FileType markdown nmap <leader>fi :%! /usr/local/bin/formd/formd -i<CR>
" For some reason saving causes the Toc to go blank. Call it again to solve this for now. Then put cursor back.
" au FileType markdown noremap SS :w<CR>:Toc<CR><C-w>h
" au FileType markdown inoremap SS <Esc>:w<CR>:Toc<CR><C-w>h
augroup END
augroup textobj_quote
autocmd!
autocmd FileType markdown call textobj#quote#init({'educate': 0})
autocmd FileType html call textobj#quote#init({'educate': 0})
autocmd FileType textile call textobj#quote#init({'educate': 0})
autocmd FileType text call textobj#quote#init({'educate': 0})
autocmd FileType vimwiki call textobj#quote#init({'educate': 0})
augroup END
let g:pencil#mode_indicators = {'hard': '✐ hard', 'soft': '✎ soft', 'off': '✎ off',}
let g:airline_section_x = '%{PencilMode()}'
let g:pencil#map#suspend_af = 'K' " default is no mapping
augroup pencil
autocmd!
autocmd FileType markdown,md,vimwiki
\ call pencil#init({'wrap': 'soft', 'textwidth': 80})
\ | call litecorrect#init()
\ | call lexical#init()
\ | call textobj#sentence#init()
\ | setl spell spl=en_us
\ | setl fdo+=search
autocmd Filetype git,gitsendemail,*commit*,*COMMIT*
\ call pencil#init({'wrap': 'soft', 'textwidth': 72})
\ | call litecorrect#init()
\ | call lexical#init()
\ | call textobj#sentence#init()
\ | setl spell spl=en_us et sw=2 ts=2 noai
autocmd Filetype html,xml call pencil#init({'wrap': 'soft'})
\ | call litecorrect#init()
\ | setl spell spl=en_us et sw=2 ts=2
augroup END
" Vimwiki override to not check spelling when launching
autocmd FileType vimwiki setl nospell
""" FUGITIVE
set diffopt+=vertical
nnoremap <leader>gd :Gdiff<cr>
nnoremap <leader>gst :Gstatus<cr>
nnoremap <leader>gw :Gwrite<cr>
nnoremap <leader>ge :Gedit<cr>
nnoremap <leader>gb :Gblame -w -M<cr>
nnoremap <leader>gB :Gitv!<cr>
nnoremap <leader>gco :Gread<cr>
nnoremap <leader>gcm :Gcommit<cr>
nnoremap <leader>glg :Glog<cr>
""" TEXT OBJECT ENHANCEMENTS
" Motion for numbers. Great for CSS. Lets you do things like this:
"
" margin-top: 200px; -> ciN -> margin-top: px;
" ^ ^
" TODO: Handle floats.
onoremap N :<c-u>call <SID>NumberTextObject(0)<cr>
xnoremap N :<c-u>call <SID>NumberTextObject(0)<cr>
onoremap aN :<c-u>call <SID>NumberTextObject(1)<cr>
xnoremap aN :<c-u>call <SID>NumberTextObject(1)<cr>
onoremap iN :<c-u>call <SID>NumberTextObject(1)<cr>
xnoremap iN :<c-u>call <SID>NumberTextObject(1)<cr>
function! s:NumberTextObject(whole)
normal! v
while getline('.')[col('.')] =~# '\v[0-9]'
normal! l
endwhile
if a:whole
normal! o
while col('.') > 1 && getline('.')[col('.') - 2] =~# '\v[0-9]'
normal! h
endwhile
endif
endfunction
""" NAVIGATION
"""" hjkl movement
" Move by visual screen lines instead of file lines. (aka when navigating wrapped text)
" http://vim.wikia.com/wiki/Moving_by_screen_lines_instead_of_file_lines
" TODO: Determine if this is still necessary
noremap [A gk
noremap [B gj
inoremap [B <C-o>gj
inoremap [A <C-o>gk
" mapping to make movements operate on 1 screen line in wrap mode
" TODO: See if pencil works fine with this commented out
function! ScreenMovement(movement)
if &wrap
return "g" . a:movement
else
return a:movement
endif
endfunction
onoremap <silent> <expr> j ScreenMovement("j")
onoremap <silent> <expr> k ScreenMovement("k")
onoremap <silent> <expr> 0 ScreenMovement("0")
onoremap <silent> <expr> ^ ScreenMovement("^")
onoremap <silent> <expr> $ ScreenMovement("$")
nnoremap <silent> <expr> j ScreenMovement("j")
nnoremap <silent> <expr> k ScreenMovement("k")
nnoremap <silent> <expr> 0 ScreenMovement("0")
nnoremap <silent> <expr> ^ ScreenMovement("^")
nnoremap <silent> <expr> $ ScreenMovement("$")
"""" Easymotion
let g:EasyMotion_startofline = 0 "keep cursor colum JK motion
" change the default shading to something more readable with Solarized
hi EasyMotionTarget guifg=red guibg=NONE ctermfg=red ctermbg=NONE
hi EasyMotionTarget2First guifg=red guibg=NONE ctermfg=red ctermbg=NONE
hi EasyMotionTarget2Second guifg=red guibg=NONE ctermfg=red ctermbg=NONE
hi link EasyMotionShade Comment
"let g:EasyMotion_do_shade = 0
""" LINE & CHARACTER MANIPULATION
" Put cursor on the 81st column. Typically next action is to enter insert mode
" and press enter to create a linebreak for code.
noremap <leader>8 81\|
" Commands from insert mode. Go to beginning of line and end of line
" respecitvely and stay in insert mode to continue editing.
inoremap II <Esc>I
inoremap AA <Esc>A
" Break down multi-line method chains, or commas, or semicolons
" Insert a newline after each specified string (or before if use '!').
" If no arguments, use previous search.
command! -bang -nargs=* -range LineBreakAt <line1>,<line2>call LineBreakAt('<bang>', <f-args>)
function! LineBreakAt(bang, ...) range
let save_search = @/
if empty(a:bang)
let before = ''
let after = '\ze.'
let repl = '&\r'
else
let before = '.\zs'
let after = ''
let repl = '\r&'
endif
let pat_list = map(deepcopy(a:000), "escape(v:val, '/\\.*$^~[')")
let find = empty(pat_list) ? @/ : join(pat_list, '\|')
let find = before . '\%(' . find . '\)' . after
" Example: 10,20s/\%(arg1\|arg2\|arg3\)\ze./&\r/ge
execute a:firstline . ',' . a:lastline . 's/'. find . '/' . repl . '/ge'
let @/ = save_search
endfunction
nmap <localleader>. :LineBreakAt! .<CR>
nmap <localleader>, :LineBreakAt ,<CR>
nmap <localleader>; :LineBreakAt ;<CR>
" swap current with next word
nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>:noh<CR>
" Indent a file and return cursor to current spot
map <F9> mzgg=G`z
" DRAG IN VISUAL MODE
" -------------------
" <m-j> and <m-k> to drag lines in any mode (m is alt/option)
" this is the textmate move lines around thing that I used to do do with arrow
" keys but less fragile because it works in tmux or not
" -----------------
" ALT + h,j,k,l
" h ˙
" j ∆
" k ˚
" l ¬
" -----------------
noremap ∆ :m+<CR>
noremap ˚ :m-2<CR>
inoremap ∆ <Esc>:m+<CR>
inoremap ˚ <Esc>:m-2<CR>
vnoremap ∆ :m'>+<CR>gv
vnoremap ˚ :m-2<CR>gv
" set text wrapping toggles
nmap <silent> <leader><Leader>tw :set invwrap<CR>:set wrap?<CR>
" Tab/shift-tab to indent/outdent in visual mode.
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Keep selection when indenting/outdenting.
vnoremap > >gv
vnoremap < <gv
" quote, quotation, apostrophe, curly
map <silent> <leader>qc <Plug>ReplaceWithCurly
map <silent> <leader>qs <Plug>ReplaceWithStraight
:command! -bar -range=% Reverse <line1>,<line2>global/^/m<line1>-1
"""" Vim Surround Shortcuts
" ,# Surround a word with #{ruby interpolation}
vmap ,# c#{<C-R>"}<ESC>
" ," Surround a word with "quotes"
map ," ysiw"
vmap ," c"<C-R>""<ESC>
" ,' Surround a word with 'single quotes'
map ,' ysiw'
vmap ,' c'<C-R>"'<ESC>
" ,) or ,( Surround a word with (parens)
" The difference is in whether a space is put in
map ,( ysiw(
map ,) ysiw)
vmap ,( c( <C-R>" )<ESC>
vmap ,) c(<C-R>")<ESC>
" ,[ Surround a word with [brackets]
map ,] ysiw]
map ,[ ysiw[
vmap ,[ c[ <C-R>" ]<ESC>
vmap ,] c[<C-R>"]<ESC>
" ,{ Surround a word with {braces}
map ,} ysiw}
map ,{ ysiw{
vmap ,} c{ <C-R>" }<ESC>
vmap ,{ c{<C-R>"}<ESC>
map ,` ysiw`
""" LANGUAGE SPECIFIC
"""" Ruby
" inserts hashrocket in insert mode
inoremap <c-l> =>
" converts visually selected hashrockets to 1.9 syntax
vnoremap <c-l> :s/\:\([a-zA-Z_]*\)\s=>/\1\:/g<cr>:noh<cr>
"""" Rails
"From Gary Bernhardt
function! ShowRoutes()
" Requires 'scratch' plugin
:topleft 40 :split __Routes__
" Make sure Vim doesn't write __Routes__ as a file
:set buftype=nofile
" set a filetype so we can fold the output (to avoid the error / warning)
:set filetype=nofile
" Delete everything
:normal 1GdG
" Put routes output in buffer (NOTE: (2013-09-10) jonk => changed to " bin/rake)
:0r! bin/rake -s routes
"
" Size window to number of lines (1 plus rake output length)
" :exec ":normal " . line("$") . "_ "
"
" Move cursor to bottom
:normal 1GG
" Delete empty trailing line
:normal dd
" Expand all folds
:normal zR
endfunction
map <leader>gR :call ShowRoutes()<cr>
map <leader>gr :topleft 40 :split config/routes.rb<cr>
map <leader>gg :topleft 40 :split Gemfile<cr>
"""" Haml
nmap <localleader>h :%!html2haml --erb 2> /dev/null<CR>:set ft=haml<CR>
vmap <localleader>h :!html2haml --erb 2> /dev/null<CR>
"""" JavaScript
au BufNewFile,BufRead *.js.erb setlocal filetype=javascript
au BufNewFile,BufRead *.ejs set filetype=xml
let g:vim_jsx_pretty_colorful_config=1
""""" Prettier
" let g:prettier#autoformat = 0
" let g:prettier#exec_cmd_async = 1
" autocmd FileType javascript set formatprg=prettier-eslint\ --stdin
" autocmd FileType javascript set formatprg=$(npm\ bin)/prettier-eslint\ --stdin
" need to finish the prettier setup for vim ☝️
" autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.vue,*.yaml,*.html PrettierAsync
" autocmd BufWritePre *.js :normal gggqG
""""" JSON
" pretty up JSON data
nnoremap <Leader>j !!python -m json.tool<CR>
nnoremap <Leader>J :%!python -m json.tool<CR>
vnoremap <Leader>j :!python -m json.tool<CR>
""""" React
let g:jsx_ext_required = 0
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_close_shortcut = '<leader>>'
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.erb,*.js,*.jsx,*.tsx"
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ 'javascript.js': 'jsxRegion',
\ }
"""" XML
function! DoPrettyXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
command! PrettyXML call DoPrettyXML()
""" PROJECTIONS
let g:rails_projections = {
\ "config/projections.json": {
\ "command": "projections"
\ },
\ "app/serializers/*_serializer.rb": {
\ "command": "serializer",
\ "affinity": "model",
\ "test": "spec/serializers/%s_spec.rb",
\ "related": "app/models/%s.rb",
\ "template": "class %SSerializer < ActiveModel::Serializer\nend"
\ },
\ "app/services/*.rb": {
\ "command": "service",
\ "affinity": "model",
\ "alternate": ["spec/services/%s_spec.rb", "unit/services/%s_spec.rb"],
\ "template": "class %S\n\n def perform\n end\nend"
\ },
\ "app/presenters/*_presenter.rb": {
\ "command": "presenter",
\ "affinity": "model",
\ "alternate": ["spec/presenters/%s_presenter_spec.rb", "unit/presenters/%s_presenter_spec.rb"],
\ "related": "app/models/%s.rb",
\ "template": "class %SPresenter < SimpleDelegator\n def self.wrap(collection)\n collection.map{open} |object| new object {close}\n end\n\nend"
\ },
\ "spec/presenters/*_presenter.rb": {
\ "command": "specpresenter",
\ "affinity": "presenter",
\ "alternate": ["app/presenters/%s_presenter.rb"],
\ "related": "app/models/%s.rb",
\ "template": "require 'rails_helper'\n\nRSpec.describe %SPresenter, type: :presenter do\n\nend"
\ },
\ "features/cukes/*.feature": {
\ "alternate": ["features/step_definitions/%s_steps.rb", "features/steps/%s_steps.rb"],
\ },
\ "spec/factories/*s.rb": {
\ "command": "factory",
\ "affinity": "model",
\ "related": "app/models/%s.rb",
\ "template": "FactoryGirl.define do\n factory :%s do\n end\nend"
\ },
\ "spec/controllers/*_controller_spec.rb": {
\ "command": "speccontroller",
\ "affinity": "controller",
\ "related": "app/controllers/%s.rb",
\ "template": "require 'rails_helper'\n\nRSpec.describe %SController, type: :controller do\n\nend"
\ },
\ "spec/serializers/*_serializer_spec.rb": {
\ "command": "specserializer",
\ "affinity": "serializer",
\ "related": "app/serializers/%s.rb",
\ "template": "require 'rails_helper'\n\nRSpec.describe %SSerializer, type: :serializer do\n\nend"
\ },
\ "spec/models/*_spec.rb": {
\ "command": "spec",
\ "affinity": "model",
\ "related": "app/models/%s.rb",
\ "template": "require 'rails_helper'\n\nRSpec.describe %S, type: :model do\n\nend"
\ },
\ "spec/services/*_spec.rb": {
\ "command": "specservice",
\ "affinity": "service",
\ "related": "app/services/%s.rb",
\ "template": "require 'rails_helper'\n\nRSpec.describe %S do\n\nend"
\ },
\ "spec/workers/*_spec.rb": {
\ "command": "specworker",
\ "affinity": "worker",
\ "related": "app/workers/%s.rb",
\ "template": "require 'rails_helper'\n\nRSpec.describe %S, type: :worker do\n\nend"
\ },
\ "spec/features/*_spec.rb": {
\ "command": "specfeature",
\ "template": "require 'rails_helper'\n\nRSpec.feature '%S', type: :feature do\n\nend"
\ },
\ "spec/helpers/*_helper_spec.rb": {
\ "command": "spechelper",
\ "related": "app/helpers/%_helper.rb",
\ "affinity": "helper",
\ "template": "require 'rails_helper'\n\nRSpec.describe ApplicationHelper, type: :helper do\n\nend"
\ },
\ "lib/tasks/*.rake": {
\ "command": "rake",
\ "template": ["namespace :%s do\n desc '%s'\n task %s: :environment do\n\n end\nend"],
\ },
\ "config/*.rb": { "command": "config" },
\ "spec/support/*.rb": { "command": "support" },
\ }
let g:rails_gem_projections = {
\ "carrierwave": {
\ "app/uploaders/*_uploader.rb": {
\ "command": "uploader",
\ "template": "class %SUploader < CarrierWave::Uploader::Base\nend"
\ }
\ },
\ "resque": {
\ "app/workers/*_job.rb": {
\ "command": "worker",
\ "template": "class %SJob\n\n \n@queue = :main\ndef self.perform\n end\nend"
\ }
\ },
\ }
""" NOTES
" ARROW KEYS
" http://od-eon.com/blogs/liviu/macos-vim-controlarrow-functionality/
" arrow keys, up=A, down=B, right=C and left=D
" <C-Up> == <Esc>[A
""" DEPRECATED
" autocmd BufEnter *.png,*.jpg,*gif exec "! imgcat ".expand("%") | :bw " Display images in vim (does not work inside tmux)
" Ensures color scheme works for the gutter diff indicators
" NOTE: I think this isn't necessary if we stick with transparent background theme
"hi clear SignColumn "Show the gutter color the same as the number column color
" TODO: (2016-11-05) jonk => experiment with this more
" xmpfilter (need to: `gem install rcodetools` into each global gemset for each version of ruby that you want to use this with)
" map <F11> <Plug>(xmpfilter-mark)
" map <F12> <Plug>(xmpfilter-run)
"""" Testing with <leader-t>
" function! DetermineSpecRunString(focus, coverage)
" let test_kind = (&filetype == 'cucumber' ? 'bin/cucumber' : 'bin/rspec')
" let coverage = (a:coverage == 'coverage' ? 'COVERAGE=true bundle exec ' : ' ')
" let focus = (a:focus == 'focus' ? ':' . line('.') : '')
" return 'clear; ' . coverage . test_kind . " " . expand('%') . focus
" endfunction
" function! RunCurrentSpec(focus, coverage)
" let spec_run_string = DetermineSpecRunString(a:focus, a:coverage)
" call VimuxRunCommand(spec_run_string)
" endfunction
" let test#strategy = 'vimux'
" let test#javascript#jasmine#executable = 'node_modules/.bin/babel-node ./node_modules/.bin/jasmine'
" autocmd FileType jasmine.javascript nmap <silent> <leader>T :TestNearest<CR>
" autocmd FileType jasmine.javascript nmap <silent> <leader>t :TestFile<CR>
" " :autocmd FileType jasmine.javascript nmap <silent> <leader>a :TestSuite<CR>
" autocmd FileType jasmine.javascript nmap <silent> <leader>l :TestLast<CR>
" " :autocmd FileType jasmine.javascript nmap <silent> <leader>g :TestVisit<CR>
" map <Leader>t :call RunCurrentSpec('all', '')<CR>
" map <Leader>C :call RunCurrentSpec('all', 'coverage')<CR>
" map <Leader>T :call RunCurrentSpec('focus', '')<CR>
" map <leader>u :call VimuxRunCommand('clear; cucumber --profile syntastic --dry-run ' . expand('%'))<CR>
" map <leader>U :call VimuxRunCommand('clear; cucumber --profile syntastic --dry-run ' . expand('%') . ':' . line('.'))<CR>
""" VIMRC & TMUX CONF
" Load up the vimrc_main file (this file) in vim to edit it
nnoremap <Leader>ev :tabnew ~/.vim/vimrc_main<CR> :NERDTreeClose<CR>
" Load up the ~/.tmux.conf file in vim to edit it
nnoremap <Leader>et :tabnew ~/.tmux.conf<CR>
" Automatically source this file after it's saved
autocmd! BufWritePre vimrc_main :NERDTreeClose
autocmd! BufWritePost vimrc_main source %
autocmd! BufWritePost plugins.vim source %
" Prevent text from wrapping mid-word
set formatoptions=1
set linebreak
" set breakat=\ ^I!@*-+;:,./?\(\[\\{
set breakat=\ ^I!@*-+;:,./?
"" vim:fdm=expr:fdl=0
"" vim:fde=getline(v\:lnum)=~'^""'?'>'.(matchend(getline(v\:lnum),'""*')-2)\:'='
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment