Add this to your .vimrc:
fun! s:parse_pivotal_story(entry)
let l:stories = pivotaltracker#stories('', '')
let l:filtered = filter(l:stories, {idx, val -> val.menu == a:entry[0]})
return l:filtered[0].word
endfun
inoremap <expr> <c-x><c-s> fzf#complete(
\ {
\ 'source': map(pivotaltracker#stories('', ''), {_key, val -> val.menu}),
\ 'reducer': function('<sid>parse_pivotal_story'),
\ 'options': '-m',
\ 'down': '20%'
\ })
Add these plugins to vim with your favorite plugin manager. I use Plug:
" fzf (fuzzy finding)
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
" Complete pivotal tracker story ids
Plug 'hauleth/pivotaltracker.vim'
In INSERT MODE press <c-x><c-s>
search for a story title and press <CR>
when done.
To enable this you would need to set environment variables in your system:
PIVOTAL_TOKEN
- Where to get it: https://www.pivotaltracker.com/profile (see bottom of page)
- Where to set it: Either .zshrc.local (so it does not get accidentally committed), or direnv - see below.
PIVOTAL_ID
- Where to get it: It will be in the URL of your project in pivotal e.g. https://www.pivotaltracker.com/n/projects/[this number]
- Where to set it: Either .zshrc.local (if you only ever work on one project); or use direnv to set it automatically when you cd into the directory of your project)
- I am using FZF to fuzzy search story titles so it is a pre-req, but you don't have to use FZF for anything else unless you want to.
- I've only tested this with NeoVim. Though I think it should work for Vim too.