Find file Copy path
91ea869 Dec 11, 2018
1 contributor

Users who have contributed to this file

547 lines (373 sloc) 10.4 KB
" .vimrc
" phajas
" Originally written Feb 1, 2014
" vim:fdm=marker
" Tabs, spaces and indenting {{{
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" }}}
" Key remapping {{{
" Make leader the , key
let mapleader = ","
" I don't use ;, I don't even know what it does! Let's just use :
nnoremap ; :
" Use jk and kj to escape
inoremap jk <Esc>
inoremap kj <Esc>
" Y to yank to the end of the line, to match C and D
nnoremap Y y$
" Leader-. to reload .vimrc
nmap <silent> <leader>. :so $MYVIMRC<CR>
" Remap <BS> to % to easily jump to matching identifier (bracket, paren, tag)
nmap <BS> %
" }}}
" Searching / Moving {{{
set ignorecase
set gdefault
set incsearch
set showmatch
" Highlight all the matches for the current search query
set hlsearch
" Clear the current query when hitting leader-<space>
nnoremap <silent> <leader><space> :noh<cr>
" When searching for things, keep the current match in the middle of the
" window and pulse the line when moving to them
nnoremap n nzzzv
nnoremap N Nzzzv
" Move up and down visually. I'm not totally sold on this...
nnoremap j gj
nnoremap k gk
" }}}
" Split windows {{{
" leader-w makes a new split and moves to it
nnoremap <leader>w <C-w>v<C-w>l
" leader-W makes a new horizontal split and moves to it
nnoremap <leader>W <C-w>s<C-w>j
" Remap ctrl-movement keys to move to adjacent splits
nnoremap <C-h> <C-\><C-N><C-w>h
nnoremap <C-j> <C-\><C-N><C-w>j
nnoremap <C-k> <C-\><C-N><C-w>k
nnoremap <C-l> <C-\><C-N><C-w>l
" Map arrow keys to move to adjacent splits also
nnoremap <silent><left> <C-\><C-N><C-w>h
nnoremap <silent><down> <C-\><C-N><C-w>j
nnoremap <silent><up> <C-\><C-N><C-w>k
nnoremap <silent><right> <C-\><C-N><C-w>l
" Resize splits when resizing vim
au VimResized * :wincmd =
" }}}
" Tabs {{{
" Remap leader-t to make a new tab
nmap <silent> <leader>t :tabnew <CR>
" Remap ]w to next tab
nmap <silent> ]w :tabnext <CR>
nmap <silent> [w :tabprevious <CR>
" }}}
" Line handling {{{
set formatoptions=qrn1
" Split lines (opposite of [J]oining lines)
nnoremap S i<cr><esc><right>
" }}}
" Filetypes {{{
filetype plugin indent on
" }}}
" Visual styling {{{
let g:LightModeActive = exists('w:LightModeActive') ? w:LightModeActive : 0
function ResetTheme()
let g:LightModeActive = 0
hi Normal ctermbg=NONE
hi Normal ctermfg=NONE
hi EndOfBuffer ctermbg=NONE
hi EndOfBuffer ctermfg=NONE
" Highlight selected text to be more visible
hi Visual ctermbg=white
hi Visual ctermfg=black
" Highlight folds to be the same as the background
hi Folded ctermbg=black
function LightTheme()
let g:LightModeActive = 1
" This inverts all the settings above
hi Normal ctermbg=white
hi Normal ctermfg=black
hi EndOfBuffer ctermbg=white
hi EndOfBuffer ctermfg=black
hi Visual ctermbg=black
hi Visual ctermfg=white
hi Folded ctermbg=white
function ToggleTheme()
if g:LightModeActive
call ResetTheme()
call LightTheme()
" Get into the default theme (dark)
call ResetTheme()
" Leader-s to toggle themes
" (I guess the hint here is "s for style"?)
nmap <silent> <leader>s :call ToggleTheme() <CR>
" Font
if has('gui_running')
set guifont=Menlo\ Regular:h11
" Turn on syntax highlighting
syntax on
" Advertise that our terminal supports 256 colors
set t_Co=256
" Disable everything in the GUI by passing empty guioptions
set guioptions=
" }}}
" Status Line {{{
" Divided into two sides:
" Left:
" Branch
" Notice that this doesn't start with a +=. This resets the statusline in the
" event that the .vimrc is reloaded
set statusline=%{fugitive#head()}
" Path
set statusline+=\ %F
" Modified state
set statusline+=\ %m
" Right:
" Delimeter character
set statusline+=%=
" Line
set statusline+=\ %l
set statusline+=\/
" Total lines
set statusline+=\%L
" Always hide the status line. This can always be re-enabled.
set laststatus=0
" }}}
" Line numbers {{{
let g:NumbersShowing = exists('w:NumbersShowing') ? w:NumbersShowing : 0
function ShowLineNumbers()
let g:NumbersShowing = 1
set number
set relativenumber
function HideLineNumbers()
let g:NumbersShowing = 0
set nonumber
set norelativenumber
function ToggleNumbers()
if g:NumbersShowing
call HideLineNumbers()
call ShowLineNumbers()
nmap <silent> <leader>n :call ToggleNumbers() <CR>
" }}}
" Mouse Support {{{
" Turn on mouse support
set mouse=a
" }}}
" Folding {{{
" On insertion entering / leaving (or window leaving), disable folding
" This causes significant speed increases when using folds
autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif
" Toggle folds with Space
nnoremap <Space> za
vnoremap <Space> za
" }}}
" ALE {{{
" According to ALE docs, some / all of these need to be enabled *before* ALE
" has been loaded
" Turn on ALE completion
let g:ale_completion_enabled = 1
" Have ALE populate the quickfix
let g:ale_set_quickfix = 1
" Show ALE messages when near a line with errors / warnings
let g:ale_virtualtext_cursor = 1
" }}}
" NeoBundle Setup {{{
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
" }}}
" List of Plugins {{{
" Editing:
NeoBundle 'keith/swift.vim'
NeoBundle 'dag/vim-fish'
NeoBundle 'plasticboy/vim-markdown'
NeoBundle 'tpope/vim-afterimage'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-obsession'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-unimpaired'
NeoBundle 'tpope/vim-vinegar'
NeoBundle 'tpope/vim-speeddating'
" Syntax:
NeoBundle 'ervandew/supertab'
NeoBundle 'godlygeek/tabular'
NeoBundle 'jpalardy/vim-slime'
NeoBundle 'w0rp/ale'
" Colors:
" Misc:
NeoBundle 'ctrlpvim/ctrlp.vim'
NeoBundle 'mbbill/undotree'
NeoBundle 'junegunn/vim-peekaboo'
" Prose:
NeoBundle 'junegunn/goyo.vim'
NeoBundle 'reedes/vim-pencil'
NeoBundle 'reedes/vim-lexical'
NeoBundle 'reedes/vim-wordy'
call neobundle#end()
" Enable matchit, which has smarter matching support (HTML tags, etc.)
runtime macros/matchit.vim
" }}}
" Plugin Settings {{{
" Commentary
nmap <leader>/ :Commentary <CR>
vmap <leader>/ :Commentary <CR>
" Ctrl-P
set runtimepath^=~/.vim/bundle/ctrlp.vim
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
let g:ctrlp_map = '<leader>,'
let g:ctrlp_switch_buffer = 0
" Fugitive
" Map leader-b to blame
nmap <silent> <leader>b :Gblame <CR>
" undotree
" Map control-u to toggle undotree
nmap <silent> <C-u> :UndotreeToggle<CR>
" vim-slime
" Activate tmux, my multiplexer of choice
let g:slime_target = "tmux"
" Default to a tmux configuration with a REPL on the right and editor on the
" left
let g:slime_default_config = {"socket_name": "default", "target_pane": ":.1"}
" }}}
" Prose mode configuration {{{
let g:ProseModeActive = exists('w:ProseModeActive') ? w:ProseModeActive : 0
function EnterProseMode()
let g:ProseModeActive = 1
call lexical#init()
set nocursorline
function ExitProseMode()
let g:ProseModeActive = 0
set cursorline
function ToggleProseMode()
if g:ProseModeActive
call ExitProseMode()
call EnterProseMode()
nmap <silent> <leader>e :call ToggleProseMode() <CR>
" }}}
" Marked Integration {{{
function OpenInMarked2()
!open -a Marked\ %
nmap <silent> <leader>m :call OpenInMarked2() <CR> <CR>
" }}}
" Scratchpad {{{
function EditScratchPad()
if strlen(expand('%:p')) == 0
e ~/.scratch
autocmd VimEnter * call EditScratchPad()
" }}}
" Terminal Setup {{{
if has('terminal')
" Remap ctrl-movement keys to move to adjacent splits
tnoremap <C-h> <C-\><C-N><C-w>h
tnoremap <C-j> <C-\><C-N><C-w>j
tnoremap <C-k> <C-\><C-N><C-w>k
tnoremap <C-l> <C-\><C-N><C-w>l
" Map arrow keys to move to adjacent splits also
tnoremap <silent><left> <C-\><C-N><C-w>h
tnoremap <silent><down> <C-\><C-N><C-w>j
tnoremap <silent><up> <C-\><C-N><C-w>k
tnoremap <silent><right> <C-\><C-N><C-w>l
" Leader-a to launch a terminal into a fish shell
nmap <leader>a :term fish<CR>
" }}}
" Misc. {{{
" Change the default shell vim uses to avoid a warning from Syntastic
set shell=bash
" Change vim's character encoding to UTF-8
set encoding=utf-8
" Never let there be less than 15 spaces above/below the insertion point
set scrolloff=15
" Automatically indent
set autoindent
" Show the current mode
set showmode
" Enable wildcard matching for commands. Complete until the longest common
" string
set wildmenu
set wildmode=list:longest
" Instead of beeping, use the visual bell
set visualbell
" Not sure.
set backspace=indent,eol,start
" Only show the tab line if there are >1 tabs
set showtabline=1
" Keep an undo file. TODO: Do we need this? Seems annoying...
set undofile
" Don't keep a backup file or swap file
set nobackup
set noswapfile
" Save all the time, automatically. It's 2015, computers should do this.
set autowrite
set autowriteall
" If a file has changed outside of vim, reload it (it seems MacVim may do this
" automatically, but terminal vim does not)
set autoread
" Sets up the clipboard to interface with the system clipboard
set clipboard=unnamed
" Turn on ttyfast and lazyredraw for speed in the Terminal
set ttyfast
set lazyredraw
" Disable non-text characters by coloring them like the background
highlight EndOfBuffer ctermfg=black ctermbg=black
" Don't show text control characters
set nolist
" Let filetype plugins do indents
if has('autocmd')
filetype plugin indent on
" Turn on syntax highlighting if possible
if has('syntax') && !exists('g:syntax_on')
syntax enable
" Turn on "smarttab" for tab insertion / deletion
set smarttab
" For combos, give me 100 units of time (ms?) to hit a combo
set ttimeout
set ttimeoutlen=100
" Delete comment character when joining commented lines
set formatoptions+=j
" Have a command history of 1000
set history=1000
" Not sure
if !empty(&viminfo)
set viminfo^=!
" Turn on hidden buffers
set hidden
" }}}