Skip to content

Instantly share code, notes, and snippets.

@SevereOverfl0w
Created July 9, 2018 16:51
Show Gist options
  • Save SevereOverfl0w/121b163cedada964e6a04eea61ff973d to your computer and use it in GitHub Desktop.
Save SevereOverfl0w/121b163cedada964e6a04eea61ff973d to your computer and use it in GitHub Desktop.
My init.vim based on a fork of vim-plug
" vim:fdm=marker:tw=59
source ~/src/github.com/junegunn/vim-plug/plug.vim
let g:config_base_dir = '~/.config/nvim'
call plug#begin(g:config_base_dir.'/pluggedtest')
" Enable true colour (16 million instead of 256) support
set termguicolors
" Set the clipboard to be the same as the system's
" clipboard, not vim's internal one:
set clipboard+=unnamedplus
" Reduce updatetime, the most visible effect is making
" gitgutter more responsive. But also controls swap file
" write frequency.
set updatetime=100
" Configure replacements (e.g. :s) to show a preview of
" what's changing
set inccommand=split
" Leader keys are important, because you bang on them all day
let mapleader=" "
let maplocalleader=","
" This colour scheme is light looks good respite that
Plug 'sonph/onehalf', {'rtp': 'vim/'}
colorscheme onehalflight
" Vim-Sneak (in-buffer navigation) {{{
" vim-sneak provides alternatives to f,F which:
" - Work across lines
" - Provides an awesome label mode which prompts for a
" character
" - Very fast (compared to alternatives I've tried)
Plug 'justinmk/vim-sneak'
" Enable labels for jumping around
let g:sneak#label = 1
" By default vim-sneak uses z for operator-pending mode to
" avoid colliding with vim-surround. I would prefer to have
" consistency, and change vim-surround (or whatever
" surround plugin I use)
" By default, vim-sneak uses z for operator-pending mode,
" and s for normal mode. Unfortunately s collides with
" vim-sandwich (sandwich). I really want consistency for
" my choice of mappings though. vim-sneak is really
" important, I use it more often than vim-sandwich.
omap s <Plug>Sneak_s
omap S <Plug>Sneak_S
" vim-sneak doesn't rebind f,F,t,T by default to it's
" slightly improved versions by default. NOTE: vim-sneak
" doesn't use label mode for these by default, see
" |sneak-functions| for how to change that.
map f <Plug>Sneak_f
map F <Plug>Sneak_F
map t <Plug>Sneak_t
map T <Plug>Sneak_T
" sindresorhus found the best prompt character in unicode,
" use it for vim-sneak's prompt
let g:sneak#prompt = '❯'
" }}}
" A few plugins require this plugin in order to make their
" own operators. More than just those in operators.
Plug 'kana/vim-operator-user'
" This is both a utility and dependency of a few plugins
" (fugitive, rhubarb, jack-in)
Plug 'tpope/vim-dispatch'
" This provides dispatch with a neovim :terminal based
" interface. This means that `:Start` will open a terminal
" in a tab.
Plug 'radenling/vim-dispatch-neovim'
" This plugin extends the functionality of `.`. This is
" originally tpope's plugin, kana perceived some weaknesses
" in it and attempted to improve it. I'm not sure I can
" personally see any difference.
" I added it initially for support with >) from vim-sexp,
" but vim-sneak and many others also use it.
Plug 'kana/vim-repeat'
" Some plugins require this in order to figure out the
" contextual filetype (e.g. in a [source] block in
" asciidoc, or in ```clojure in markdown) Plug
" Used by:
" - deoplete
Plug 'Shougo/context_filetype.vim'
" Commenting {{{
" tcomment is pretty solid, works well with motions and
" "gcc" does what I mean. Unfortunately it doesn't support
" context filetypes very well, so I'm looking at how I can
" change that, caw.vim does, but doesn't work well with
" motions.
Plug 'tomtom/tcomment_vim'
" I really don't like the insert-mode mappings it creates:
let g:tcomment_mapleader1 = ''
let g:tcomment_mapleader2 = ''
" }}}
" Surround things {{{
" vim-sandwich looks at vim-surround and says "ha, that is
" no true operator", and fixes that.
Plug 'machakann/vim-sandwich'
" Sandwich has this cute highlighting trick where it shows
" the thing it's deleting/surrounding in a special
" highlight. The only duration that enables you to see this
" is 200ms. For deletes this makes them feel slow, and you
" can barely see it, so disable highlighting for delete.
call operator#sandwich#set('delete', 'all', 'highlight', 0)
" The default key mappings collide with s from vim-sneak,
" so bind them behind leader. I don't use them too often,
" so I don't think it's a massive loss having them be 3
" keypresses away instead of 2.
let g:sandwich_no_default_key_mappings = 1
silent! nmap <unique><silent> <leader>sd <Plug>(operator-sandwich-delete)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-query-a)
silent! nmap <unique><silent> <leader>sr <Plug>(operator-sandwich-replace)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-query-a)
silent! nmap <unique><silent> <leader>sdb <Plug>(operator-sandwich-delete)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-auto-a)
silent! nmap <unique><silent> <leader>srb <Plug>(operator-sandwich-replace)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-auto-a)
" Recipe list:
" - In vim files, `pg` will surround the snippet as `Plug '%s'` for
" integration with vim-plug
let s:local_recipes = [{'__filetype__': 'vim', 'buns': ["Plug '", "'"], 'input': [ 'pg' ], 'filetype': ['vim']}]
" Adding custom recipes involves copying the default
" recipes and adding.
let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
let g:sandwich#recipes += s:local_recipes
" }}}
" Clojure {{{
" Update the static files for clojure from it's upstream,
" this includes fixes like indenting #() properly.
Plug 'guns/vim-clojure-static'
" This plugin allows you to manipulate sexp (clojure
" parens) in magical ways.
Plug 'guns/vim-sexp'
" By default == has a maximum number of lines to prevent
" hanging. Disable that, because I'm happy to wait when I
" want this.
let g:clojure_maxlines = 0
" Unfortunately the default mappings for vim-sexp are hard
" to press (lots of ctrl & alt), but tpope has us covered:
Plug 'tpope/vim-sexp-mappings-for-regular-people'
" FiREPLace is a plugin for integrating with a Clojure
" nREPL.
Plug 'tpope/vim-fireplace'
" REPLant is a plugin for enhancing your REPL experience
" with vim I develop this, so I've selected my src dir.
Plug '~/src/github.com/SevereOverfl0w/replant'
" A plugin for managing nREPL middleware and starting the
" nREPL.
Plug '~/src/github.com/clojure-vim/vim-jack-in'
" }}}
" Terraform {{{
" vim-terraform "fixes" syntax detection for *.tf to be
" terraform files
Plug 'hashivim/vim-terraform'
" Integrate tcomment with terraform
call tcomment#type#Define('terraform', '# %s')
call tcomment#type#Define('terraform_block', '/* %s */' )
call tcomment#type#Define('terraform_inline', '/* %s */' )
" Provides:
" - Contextual completions with deoplete support
" - Automatic linting via syntastic or neomake
" - Tagbar integration
" - Keybindings for docs
" For now I am mostly using the completion though.
Plug 'juliosueiras/vim-terraform-completion'
" }}}
" Operators {{{
" Operators allow you to perform actions (operations) on text objects and
" motions.
" I collect additional generic ones to make my life easier.
" A lot of them depend on vim-operator-user
" I'm trying to use the <Leader>o prefix (for operator).
" The replace operator allows you to replace an object with the value in the
" register (clipboard).
Plug 'kana/vim-operator-replace'
map <Leader>or <Plug>(operator-replace)
" }}}
" Text Objects / Motions {{{
" These plugins enhance the kind of things you can refer to. e.g. sentences,
" words, lines, indentation level. vim-sneak could fit into this category,
" but it shines on it's own.
" This is a dependency of many textobjs for defining themselves.
Plug 'kana/vim-textobj-user'
" This adds a text object which refers to the whole buffer. Pairs well with
" fireplace's `cp` motion, in place of doing `%:Eval`, and also with `=`.
"
" Defaults to binding `ae` and `ie`. This is incompatible
" with vim-sexp though, so remap to aE and Ie. I don't
" expected to use this mapping too much.
"
Plug 'kana/vim-textobj-entire'
let g:textobj_entire_no_default_key_mappings = 1
xmap aE <Plug>(textobj-entire-a)
omap aE <Plug>(textobj-entire-a)
xmap iE <Plug>(textobj-entire-i)
omap iE <Plug>(textobj-entire-i)
" Adds a text object which refers to the current line.
" Binds to `al` and `il` by default.
Plug 'kana/vim-textobj-line'
" Wordmotion creates word definitions which surpass the default ones in
" utility. The readme does a better job of explaining than I could.
Plug 'chaoren/vim-wordmotion'
" }}}
" Git {{{
" Gitgutter {{{
" Gitgutter provides a few functions:
" - Show where files have changed via gutter icons
" - Text object for hunks
" - Staging / unstaging hunks
Plug 'airblade/vim-gitgutter'
" Disable gitgutter mappings, I can take care of that, thank you!
let g:gitgutter_map_keys = 0
" Apparently I can integrate with ripgrep really easily, and ripgrep is
" awesome.
if executable('rg')
let g:gitgutter_grep = 'grep'
endif
" Mapping for jumping between hunks
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
" Stage the hunk under the cursor
nmap <Leader>ghs <Plug>GitGutterStageHunk
" Show the diff of the hunk at cursor. I'm not convinced this is actually
" useful yet, but time will tell.
nmap <Leader>ghp <Plug>GitGutterPreviewHunk
" Discard the hunk under the cursor. Useful for getting rid of println code.
nmap <Leader>ghu <Plug>GitGutterUndoHunk
" This is a text object referring to the current hunk
omap ih <Plug>GitGutterTextObjectInnerPending
omap ah <Plug>GitGutterTextObjectOuterPending
xmap ih <Plug>GitGutterTextObjectInnerVisual
xmap ah <Plug>GitGutterTextObjectOuterVisual
" }}}
" Fugitive {{{
" FuGITive is a git wrapper for vim. The interactive staging features are
" amazing.
Plug 'tpope/vim-fugitive'
" The official integration between fugitive and github
Plug 'tpope/vim-rhubarb'
" This list is butched from:
" https://www.reddit.com/r/vim/comments/21f4gm/best_workflow_when_using_fugitive/cgciltz/
" Stage file
nnoremap <Leader>ga :Git add %:p<CR><CR>
" Open status buffer
nnoremap <Leader>gs :Gstatus<CR>
" Commit normally
nnoremap <Leader>gc :Gcommit -v -q<CR>
" Commit and stage current file (if you commit only)
nnoremap <Leader>gt :Gcommit -v -q %:p<CR>
" Open current file in diff mode
nnoremap <Leader>gd :Gdiff<CR>
" Open current file on the index
nnoremap <Leader>ge :Gedit<CR>
" Like `:edit` but against the index
nnoremap <Leader>gr :Gread<CR>
" Like `:write` but against the index (stage file,
" basically)
nnoremap <Leader>gw :Gwrite<CR><CR>
" Open log for current file
nnoremap <Leader>gl :silent! Glog<CR>:bot copen<CR>
" git-grep version of :grep
nnoremap <Leader>gp :Ggrep<Space>
" Rename current buffer and do `git mv`
nnoremap <Leader>gm :Gmove<Space>
" Pass through to git
nnoremap <Leader>gb :Git branch<Space>
nnoremap <Leader>go :Git checkout<Space>
" Pull & push
nnoremap <Leader>gps :Dispatch! git push<CR>
nnoremap <Leader>gpl :Dispatch! git pull<CR>
" }}}
" }}}
" vimrc {{{
" Since reading learn vimscript the hard way, I always keep these mappings
" available in some form:
" let $MYVIMRC = '~/plug.vim' " temporary until is actually
" the vimrc
noremap <Leader>ve :topleft 60vsplit $MYVIMRC<CR>
noremap <Leader>vs :source $MYVIMRC<CR>
" }}}
" Completion {{{
" Deoplete provides asyncronous as-you-type completions
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" It isn't enabled by default, so start it up
let g:deoplete#enable_at_startup = 1
" I set some deoplete patterns later on for filetypes
let g:deoplete#keyword_patterns = {}
let g:deoplete#omni_patterns = {}
" Clojure {{{
Plug 'clojure-vim/async-clj-omni'
let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*'
" }}}
" Terraform {{{
" TODO: This doesn't seem to cover all possible cases where
" terraform can do completions.
call deoplete#custom#var('omni', 'input_patterns', {
\ 'terraform': '[^ *\t"{=$]\w*',
\})
" }}}
" }}}
" Grepping {{{
" vim-grepper helps you win at grep, integrated with the
" quickfix
Plug 'mhinz/vim-grepper'
let g:grepper = {}
" Change the preferred ordering of tools, ripgrep is too
" fast to say no
let g:grepper.tools = ['rg', 'ag', 'git', 'grep']
" I took the default value for this and added `-L` to follow
" symlinks.
let g:grepper.rg = get(g:grepper, 'rg', {})
let g:grepper.rg.grepprg = 'rg -H -L --no-heading --vimgrep'
" An operator for grepping. Allows me to do `gsiW` or
" `gsie`, etc. to grep for a text object.
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
noremap <leader>/ :<C-u>Grepper<CR>
" }}}
" Quickfix {{{
" The quickfix is so important, especially with vim-grepper.
" vim-qf is romainl's collection of hacks for the quickfix.
Plug 'romainl/vim-qf'
" Wrapping version of :cnext and :cprev, for qf and location
" list.
nmap ]q <Plug>(qf_qf_next)
nmap [q <Plug>(qf_qf_previous)
nmap ]l <Plug>(qf_loc_next)
nmap [l <Plug>(qf_loc_previous)
" Add some reasonable convenience mappings:
" - s horizontal split, v vertical split
" - p open in preview
" - o open entry and return
let g:qf_mapping_ack_style = 1
" }}}
" Formatting {{{
Plug 'tpope/vim-sleuth'
" }}}
" File jumping {{{
Plug 'lotabout/skim'
" Remove git ls-tree, it doesn't include untracked files.
let $SKIM_DEFAULT_COMMAND = "rg --files || ag -l -g \"\" || find ."
" jf = jump file
nnoremap <Leader>jf :<C-U>SK<CR>
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment