All Projects → rafaqz → citation.vim

rafaqz / citation.vim

Licence: MIT License
Zotero and bibtex citations for Vim

Programming Languages

python
139335 projects - #7 most used programming language
Vim Script
2826 projects

Projects that are alternatives of or similar to citation.vim

pandoc alfred
Pandoc-Suite for Academic Writing in Markdown
Stars: ✭ 68 (-12.82%)
Mutual labels:  bibtex, pandoc, zotero
citeproc-el
A CSL 1.0.2 Citation Processor for Emacs.
Stars: ✭ 75 (-3.85%)
Mutual labels:  bibtex, citation
my-writing-workflow
Tutorial for converting markdown files in to APA-formatted docs, based on my workflow.
Stars: ✭ 35 (-55.13%)
Mutual labels:  bibtex, pandoc
Zotero Better Bibtex
Make Zotero effective for us LaTeX holdouts
Stars: ✭ 2,336 (+2894.87%)
Mutual labels:  bibtex, zotero
LaTeX-Templates
Document templates composed using LaTeX for my college assignments and projects (Applicable for any other university or college) ✨
Stars: ✭ 18 (-76.92%)
Mutual labels:  bibtex, citation
papis-zotero
Zotero compatiblity scripts for papis
Stars: ✭ 29 (-62.82%)
Mutual labels:  bibtex, zotero
bookends-tools
Alfred Workflow to Integrate with Bookends, an academic reference manager/bibliography tool for macOS
Stars: ✭ 78 (+0%)
Mutual labels:  pandoc, citation
AASTeX60
Version 6 of the LaTeX style files and documentation for authoring AAS Journal (AJ/ApJ) articles.
Stars: ✭ 40 (-48.72%)
Mutual labels:  bibtex, citation
tufte-markdown
Use markdown to write your handouts and books in Tufte style.
Stars: ✭ 82 (+5.13%)
Mutual labels:  pandoc
elasticsearch-ingest-attachment-plugin-example
Example of how to use ElasticSearch ingest-attachment plugin using JavaScript
Stars: ✭ 19 (-75.64%)
Mutual labels:  attachment
OmniOutliner-Plug-Ins
Omni Automation plug-ins for OmniOutliner, including a basic reference manager based on BibTeX
Stars: ✭ 15 (-80.77%)
Mutual labels:  bibtex
emanote
Spiritual successor to neuron, based on Ema.
Stars: ✭ 301 (+285.9%)
Mutual labels:  pandoc
citesphere
Citation management app that sits on top of Zotero
Stars: ✭ 17 (-78.21%)
Mutual labels:  zotero
bibtex-js
Library for parsing .bib files, used in Bibliography.js 📚
Stars: ✭ 55 (-29.49%)
Mutual labels:  bibtex
ex elasticlunr
Elasticlunr is a small, full-text search library for use in the Elixir environment. It indexes JSON documents and provides a friendly search interface to retrieve documents.
Stars: ✭ 125 (+60.26%)
Mutual labels:  fulltext-search
kerkoapp
A web application that provides a faceted search interface for bibliographies managed with Zotero.
Stars: ✭ 30 (-61.54%)
Mutual labels:  zotero
markdown-css
Stylesheets for Markdown to HTML conversion
Stars: ✭ 91 (+16.67%)
Mutual labels:  pandoc
ESP-Mail-Client
⚡️Arduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.
Stars: ✭ 78 (+0%)
Mutual labels:  attachment
videlibri
📚 Cross-platform library client to automate any OPAC and library catalog from your local device, e.g. for renewing of borrowed books or searching for books available in the library in automated scripts.
Stars: ✭ 18 (-76.92%)
Mutual labels:  bibtex
bcs thesis
My bachelor's thesis on the Entity-Component-System pattern and ECST
Stars: ✭ 36 (-53.85%)
Mutual labels:  pandoc

citation.vim

A citation source for unite.vim

(https://github.com/rafaqz/citation.vim)

Citation.vim imports Zotero databases or exported bibtex/biblatex files. It can insert keys and many other fields, open attached pdfs and urls.

Citation.vim allows you to create a workflow from within your documents. You can open referenced pdfs or url directly from citations, and view all citation details, notes and abstracts within vim or nvim. You can also use Zoteros full-text search to pre-filter items based on attachment text.

Citation.vim screenshot

Many thanks to termoshtt for unite-bibtex and smathot for gnotero and LibZotero code.

Warning: the concept of this plugin is fundamentally a hack. It uses Zotero databases in ways they are not intended to be used (in the name of brute speed and unmatched utility, of course), and bibtex/biblatex files that are problematic in terms of their structural consistency. This plugin should work for Zotero 5 or biblatex files in vim with python 2 or 3 on Linux, in English. I test the hell out that setup and use it most days. Other setups may work fine, or they may break.

If you have problems, please open an issue on github and include the error output from vim.

Sources

This plugin provides a lot of unite sources. Some important ones are:

citation/key

  • returns citation key string like [@smith2004] to be used as a reference.
  • customise the prefix and suffix to produce latex/pandoc etc. citation styles.

citation/file

  • Returns the file attached to a citation, great for opening pdfs from vim directly, using the 'start' action.
  • If there are multiple files it returns the first one.

citation/combined

  • Preview all available citation data on one page.

The full list:

Source Output
citation list sources
citation/abstract absract
citation/author all authors, combined with rules set in g:citation_vim_et_al_limit
citation/combined all fields combined in an info page
citation/date year of publication
citation/doi doi
citation/duplicate_keys key from filter items that have duplicate keys
citation/file the first listed attachment that is a pdf, epub or ps file
citation/isbn isbn
citation/publication name of journal, magazine etc
citation/key key from bibtex, generated, of from zotero. default format is [@key]
citation/key_inner inner key, default format is @key
citation/language language
citation/issue issue
citation/notes all attached notes, joined
citation/pages pages
citation/publisher publisher
citation/tags all tags, comma separated
citation/title title
citation/type type of item
citation/url url
citation/volume volume
citation/zotero_key the raw key used by zotero
citation_collection (yes underscore not slash) list Zotero collection to filter results.

Whichever source is selected, execute/edit and preview commands will always echo combined information for the citation, and file will always use the attached pdf/epub file path. This is useful for setting open/show info key commands to use within unite - see the example mappings for how to do this.

Installation

  1. Install unite.vim

  2. Install this plugin in vim however you like to do that.

  3. Choose your source

    If you're using bibtex

    • install pybtex

      easy_install pybtex
    • Set variables:

      let g:citation_vim_bibtex_file="/path/to/your/bib/file/library.bib"
      let g:citation_vim_mode="bibtex"
      

    To use zotero

    • Set variables:

      let g:citation_vim_mode="zotero" (default)
      let g:citation_vim_zotero_path="/path/to/your/zotero/7XX8XX72/zotero_folder/" ("~/Zotero" is default)
      let g:citation_vim_zotero_version=5 (5 is the Default, zotero 4 is no longer supported)
      

      The zotero path is quite variable accross different systems, just make sure it contains the file zotero.sqlite

    • If you have set a "Linked Attachment Base Directory" in zotero (in Preferences\Files and Folders) you will need to set:

      let g:citation_vim_zotero_attachment_path="/your/linked/attachment/base/directory" ("default ~/Zotero/library")
      
    • If you don't have the better bibtex plugin and you want readable keys (like smith2010Sometitle), set a key formatter. This will not produce fixed keys like the better-bibtex plugin, so make sure to manage your duplicates (use Unite citation/duplicate_keys to check) and watch for key changes after editing author, date or title in zotero. Author and Title can be in lower case or sentence case.

      let g:citation_vim_key_format="{author}{date}{title}"
      

      Key cleanup is set ot match zoteros default Bibtex.js/Biblatex.js translator files. If you need to change these, you can also set:

      let g:citation_vim_key_title_banned_regex = "\\b(a|an|the|some|from|on|in|to|of|do|with|der|die|das|ein|eine|einer|eines|einem|einen|un|une|la|le|l|el|las|los|al|uno|una|unos|unas|de|des|del|d)\\W")
      let g:citation_vim_key_clean_regex = "[^A-Za-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+")
      
    • And optionally:

      let g:citation_vim_collection" = 'your_zotero_collection'
      

      Although this can be set on the fly with :Unite citation_collection

  4. Set a cache path:

let g:citation_vim_cache_path='~/.vim/your_cache_path'
  1. Set your citation suffix and prefix. This pandoc markdown style is the default:
let g:citation_vim_outer_prefix="["
let g:citation_vim_inner_prefix="@"
let g:citation_vim_suffix="]"
  1. Set the et al. limit. If the number of authors is greater than the limit only the first author with et al. appended is shown or printed in case of citation/author. (Default: 5)
let g:citation_vim_et_al_limit=2
  1. The default order results are displayed in was recently reversed so your recent additions are allways at the top. If you want to keep the old behaviour, set:
let g:citation_vim_reverse_order=0 
  1. Set some mappings. Copy and paste the following examples into your vimrc to get started.

Key mappings:

Set a unite leader:

nmap <leader>u [unite]
nnoremap [unite] <nop>

To insert a citation:

nnoremap <silent>[unite]c       :<C-u>Unite -buffer-name=citation-start-insert -default-action=append      citation/key<cr>

To immediately open a file from a citation under the cursor:

nnoremap <silent>[unite]co :<C-u>Unite -input=<C-R><C-W> -default-action=start -force-immediately citation/file<cr>

Or open a url from a citation under the cursor:

nnoremap <silent><leader>cu :<C-u>Unite -input=<C-R><C-W> -default-action=start -force-immediately citation/url<cr>

To browse the file folder from a citation under the cursor:

nnoremap <silent>[unite]cf :<C-u>Unite -input=<C-R><C-W> -default-action=file -force-immediately citation/file<cr>

To view all citation information from a citation under the cursor:

nnoremap <silent>[unite]ci :<C-u>Unite -input=<C-R><C-W> -default-action=preview -force-immediately citation/combined<cr>

To preview, append, yank any other citation data you want from unite:

nnoremap <silent>[unite]cp :<C-u>Unite -default-action=yank citation/your_source_here<cr>

To integrate with zotcli for note editing (assuming you have zotcli installed):

nnoremap <silent><leader>cn :<C-u>UniteWithCursorWord -default-action=yank -force-immediately citation/title<cr><cr>:!zotcli add-note "<C-R>0"<cr>

Search fulltext

Search for word by appending them after the command and a colon:

Search for the word under the cursor:

nnoremap <silent>[unite]cs :<C-u>Unite  -default-action=yank  citation/key:<C-R><C-W><cr>

Search for selected words in visual mode (notice that spaces have to be escaped) :

vnoremap <silent>[unite]cs :<C-u>exec "Unite  -default-action=start citation/key:" . escape(@*,' ') <cr>

Type search terms in the prompt:

nnoremap <silent>[unite]cx :<C-u>exec "Unite  -default-action=start citation/key:" . escape(input('Search Key : '),' ') <cr>

:Unite citation for a full list of sources...

Open files or show info from any source

This autocomand sets Control-o to open files and Control-i to show info

autocmd FileType unite call s:unite_my_settings()
function! s:unite_my_settings()
  nnoremap <silent><buffer><expr> <C-o> unite#do_action('start')
  imap     <silent><buffer><expr> <C-o> unite#do_action('start')
  nnoremap <silent><buffer><expr> <C-i> unite#do_action('preview')
  imap     <silent><buffer><expr> <C-i> unite#do_action('preview')
endfunction

Tweaks

Customise the unite display, using the names of citation sources and a python format string (the {} braces will be replaced by the sources):

let g:citation_vim_description_format = "{}∶ {} \˝{}\˝ ₋{}₋ ₍{}₎"
let g:citation_vim_description_fields = ["key", "author", "doi", "journal", "whateveryouwant"]

You might have noticed the weird characters in the description format string. They are used for highlighting sections, to avoid confusion with normal characters that might be in the citation.

To change description highlighting characters, copy and paste characters from this list:

  • Quotes ″‴‶‷

  • Brackets ⊂〔₍⁽ ⊃〕₎⁾

  • Arrows ◁<‹ ▷>›

  • Blobs ♯♡◆◇◊○◎●◐◑∗∙⊙⊚⌂★■□▢▣▤▥▦▧▨▩

  • Tiny 、。‸₊⁺∘♢☆☜☞♢☼

  • Bars ‖│┃┆∥┇┊┋

  • Dashes ‾⁻−₋‐⋯┄–—―∼┈─▭▬┉━┅₌⁼‗

  • And use these like a colon after words (notice that's not a normal colon) ∶∷→⇒≫

Long lines will occasionally break the display colors. It's a quirk of how unite shortens lines.

Troubleshooting

You can correct your .bib file with pybtex-convert:

pybtex-convert /path/to/your.bib out.bib

If you have other problems, open an issue on github and include the error output from vim. Please pull the latest changes first, and include your vim/nvim version and zotero versions in the issue. Attaching your bib(la)tex file may also be helpful if using the bibtex/biblatex backend.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].