commit 471e93d2945b0cdbe1998eb51842bb5e89bc9150
Author: Michal Hoftich <michal.h21@gmail.com>
Date:   Thu Aug 16 23:09:04 2018 +0200

    Initial commit

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7e6b964
--- /dev/null
+++ b/README.md
@@ -0,0 +1,23 @@
+# The `papis-vim` package
+
+This package provides Vim support for [Papis](https://papis.readthedocs.io/en/latest/), command-line based bibliography manager.
+
+[Screencast](https://asciinema.org/a/VkKJJYA3RRO4bHnw7Sgkoy2ZB)
+
+## Install 
+
+This package depends on [fzf.vim](https://github.com/junegunn/fzf.vim).
+
+### Using Vundle
+
+Add these lines to the `.vimrc`:
+
+
+    Plugin 'junegunn/fzf'
+    Plugin 'git@github.com:papis/papis-vim.git'
+
+## Usage
+
+The `:Papis` command will open a search window for your bibliographic database. `Enter` command will insert citation for the selected record in the current buffer.
+
+## Configuration
diff --git a/plugin/papis.vim b/plugin/papis.vim
new file mode 100644
index 0000000..436f2a7
--- /dev/null
+++ b/plugin/papis.vim
@@ -0,0 +1,42 @@
+function! s:yank_to_register(data)
+  let @" = a:data
+  silent! let @* = a:data
+  silent! let @+ = a:data
+endfunction
+
+
+function! s:handler(a)
+  let lines = a:a
+  if lines == [] || lines == ['','','']
+    return
+  endif
+  " Expect at least 2 elements, `query` and `keypress`, which may be empty
+  " strings.
+  let query    = lines[0]
+  let keypress = lines[1]
+  let cmd = "normal a"
+  let pat = '@\v(.{-})$'
+  " it is possible to yank the doc id using the ctrl-y keypress
+  if keypress ==? "ctrl-y"
+    let hashes = join(filter(map(lines[2:], 'matchlist(v:val, pat)[1]'), 'len(v:val)'), "\n")
+    return s:yank_to_register(hashes)
+    " this will insert \cite{id} command for all selected citations
+  else
+    let citations = lines[2:]
+    let candidates = []
+    for line in citations
+      let id = matchlist(line, pat)[1]
+      call add(candidates, "\\cite{". id . "}")
+    endfor
+  endif
+
+  for candidate in candidates
+    execute join([cmd, candidate])
+  endfor
+
+endfunction
+
+
+command! -bang -nargs=* Papis
+      \ call fzf#run(fzf#wrap({'source': 'papis list <args> --format "{doc[author]}: {doc[title]} @{doc[ref]}"', 'sink*': function('<sid>handler'), 'options': '--multi --expect=ctrl-y --print-query'}))
+