Git Product home page Git Product logo

citation.vim's Introduction

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.

citation.vim's People

Contributors

dancingquanta avatar mcepl avatar rafaqz avatar sappo avatar tarrasch avatar termoshtt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

citation.vim's Issues

UTF8

Thank you for this wonderful plugin. I just have a problem. I write in French, so there are accented letters "é" /"è" for example.
When I insert a quotation note (citation/note)... it does not insert all accented characters. My text and my zotero are in UTF8. Can it come from the plugin?
Thanks in advance

Problem: encoding issues

With the better visibility on errors during operation, I found that in my case the python choke on encoding issues.

Citation.vim error:
Traceback (most recent call last):
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/python/citation_vim/citation.py", line 22,
in connect
    return Builder(Loader().context).build_source()
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 25, in build_source
    description = self.describe(item)
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 111, in describe
    return self.describe_with_source_field(description_values, item)
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 141, in describe_with_source_field
    return description_format.format(*description_values)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 3: ordinal not in range(128)
[unite.vim] function unite#helper#call_unite[33]..unite#start[1]..unite#start#standard[50]..unite#candidates#_recache[74].
.<SNR>100_recache_candidates_loop[42]..<SNR>100_get_source_candidates[40]..74, line 3
[unite.vim] Vim(return):E712: Argument of map() must be a List or Dictionary
[unite.vim] Error occurred in gather_candidates!

The above error was produced by the command Unite citation/key.

I read through the source code and found that in citation.vim\autoload\unite\sources\citation.vim some variables such as g:citation_vim_source_wrap, which was used to cover the key from front and back (why?), are using unicode characters.
These characters may be what my Python is choking on and using print in various places leads back to this.

Two questions are:

  • What are these variables and why do they use unicode characters
  • How to improve encoding/decoding unicode in python 2?

Question about generating bib files from Zotero in-line citations

I just installed this plugin along with a few others and it is an absolute game changer! I'm ridiculously impressed at how easy it is to directly reach into Zotero and search for/pull out/read my citations. I do have one question though. Let's say I create Manuscript.tex, and start citing a bunch of stuff from Zotero. I want to compile the document, but can't as the .bib file is not present, but I definitely didn't use my whole library or collection. Would there be a way to collect those in-line citations and tell Zotero to create a new bib file in the current directory so things will compile? If you have any ideas on what can point me in the right direction that I can mess around with, I would seriously appreciate it, and thank you for this awesome plugin!

Opening file from citation key sometimes oppens another paper

Hi and thanks for the plugin. I mainly use it to open papers from the reference key, using the "co" shortcut, which works well most of the time. However, it happens sometimes that the paper which is opened is not the one corresponding to the citation. It is, however, often another paper from the same author. I'm not sure what is the exact criterion to reproduce this. Should it be expected due to the "hacking" nature of the plugin, or is it a bug? Is there an implicit requirement on the citation keys to get this functionality to work properly (I use betterbibtex for the keys, but I also have order keys which follow a different rule, could it be the cause of the problem?)

Manipulate zotero data

This request is a challenge. I wonder if it is possible to extend citation.vim to directly manipulate zotero.sqlite to add or remove items, edit fields, add notes etc like you are using Zotero app itself.
The first problem is with this is that data corruption may result from writing to zotero.sqlite if Zotero is running.

Other is that I don't know if Unite.vim allows this kind of functionality.

What do you think?

Multibyte characters in title and journal name

Thanks for this great plugin!

citation.vim works seamlessly on English items, but failed to display titles or journal names if there are multibyte characters. Please below. Also note that the citation keys do not have this issue. BTW, I am using the Zotero source.

citation

Vim version info

``` VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 25 2018 18:34:30) MS-Windows 64-bit GUI version with OLE support Included patches: 1-327 Compiled by stop_@LAPTOP-E7OHISR4 Huge version with GUI. Features included (+) or not (-): +acl +byte_offset +conceal -dnd +float +keymap +menu +num64 +python/dyn +startuptime +terminal +vertsplit +windows +arabic +channel +cryptv -ebcdic +folding +lambda +mksession +ole +python3/dyn +statusline -tgetent +virtualedit +writebackup +autocmd +cindent +cscope +emacs_tags -footer +langmap +modify_fname +packages +quickfix -sun_workshop -termresponse +visual -xfontset +autochdir +clientserver +cursorbind +eval +gettext/dyn +libcall +mouse +path_extra +reltime +syntax +textobjects +visualextra -xim +autoservername +clipboard +cursorshape +ex_extra -hangul_input +linebreak +mouseshape +perl/dyn +rightleft +tag_binary +timers +viminfo +xpm_w32 +balloon_eval +cmdline_compl +dialog_con_gui +extra_search +iconv/dyn +lispindent +multi_byte_ime/dyn +persistent_undo +ruby/dyn +tag_old_static +title +vreplace -xterm_save -balloon_eval_term +cmdline_hist +diff +farsi +insert_expand +listcmds +multi_lang -postscript +scrollbind -tag_any_white +toolbar -vtp +browse +cmdline_info +digraphs +file_in_path +job +localmap +mzscheme/dyn +printer +signs +tcl/dyn +user_commands +wildignore ++builtin_terms +comments +directx +find_in_path +jumplist +lua/dyn +netbeans_intg +profile +smartindent -termguicolors +vartabs +wildmenu system vimrc file: "$VIM\vimrc" user vimrc file: "$HOME\_vimrc" 2nd user vimrc file: "$HOME\vimfiles\vimrc" 3rd user vimrc file: "$VIM\_vimrc" user exrc file: "$HOME\_exrc" 2nd user exrc file: "$VIM\_exrc" system gvimrc file: "$VIM\gvimrc" user gvimrc file: "$HOME\_gvimrc" 2nd user gvimrc file: "$HOME\vimfiles\gvimrc" 3rd user gvimrc file: "$VIM\_gvimrc" defaults file: "$VIMRUNTIME\defaults.vim" system menu file: "$VIMRUNTIME\menu.vim" Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL -DFEAT_XPM_W32 -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG /MD -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DGLOBAL_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python37.dll\" -DFEAT_MZSCHEME -I "..\..\libs\racket-6.12\include" -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracketxxxxxxx.dll\" -DDYNAMIC_MZGC_DLL=\"libmzgcxxxxxxx.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl528.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=25 -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby250.dll\" -DFEAT_HUGE /Fd.\ObjGXOULYHTRZAMD64/ /Zi Linking: link /nologo /subsystem:windows /opt:ref /LTCG:STATUS /HIGHENTROPYVA:NO oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib /machine:AMD64 msvcrt.lib oleaut32.lib user32.lib /nodefaultlib:lua53.lib /STACK:8388608 /nodefaultlib:python27.lib /nodefaultlib:python37.lib "C:\ActiveTcl\lib\tclstub86.lib" WSock32.lib .\xpm\x64\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug ```

My Zotero version: 5.0.58

Thanks!

clean() choking on integers

The clean() function in python/citation/zotero/parser is choking on integers found in issues, volumes and years. What is this function for and should there be a type cast inside the function before the regexes?

better bibtex citation keys not retrieved from zotero 4

Hello, I love this plugin, thanks for your effort.

After the fix to issue #16, I find that I do not get the right citation keys from my zotero 4 database.
I am still using version 4 because it is currently shipped with Debian Buster.

I can work around this, by pinning the plugin to the previous commit (715e647), but I thought to file the bug so that other users can find it as a reference.

With my plugin manager (Shougo/dein.vim) the workaround is:
call dein#add('rafaqz/citation.vim', {'rev': '715e64786a7'})

If fixing the issue for good is too difficult, at least the workaround (and similar for other plugin managers) should be added to the documentation.

PS: after the downgrade I had to modify the database through zotero to force updating the cache.

ddu.vim support

I know this is very much a long shot given that there was never time to get denite.vim support implemented, but could you make a quick assessment of how hard it would be to implement something like this for ddu.vim, the successor to denite.vim? (If it is going to take you a long time, then it's OK to decline and save your time of course). My coding background is pretty amateur, so it would probably be more than I could handle, but I might make the crazy decision to give it a shot. More likely, though, is that I will just use unite.vim and be very grateful for what I have.

Opening files and urls - not recognized key-words

I am using citation.vim with bibtex:

let g:citation_vim_bibtex_file='~/citation/out.bib'                                                                                      
let g:citation_vim_mode='bibtex'

out.bib is generated via pybtex-convert.
The following sources don't display the specified information:

-citation/notes
-citation/file
-citation/url

For some sources citation/url displays the url, for most not, but in any case using the action start on them does nothing.

Can you for a start provide an sample bibtex file, to check if mine is simply setup wrong.

Denite support

Add support for denite.nvim which supersedes unite.vim.

I am looking at how denite.nvim works and see if I can do a pull request.
However since citation.vim is a source for unite.vim it may need a rewrite for denite.nvim.
Should citation.vim-like source for denite.nvim be a separate plugin?

Open a reference's file with a custom program

Hi, I'm using a lot citation.vim to open the articles (the actual pdf files). Following the readme I'm using

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

It works well but the files are opened with the default pdf viewer. I do use 2 different pdf viewers depending on whether I want to read or annotate the articles, so how could I adapt the previous command to open the article with a custom program? The fact that it goes through unite makes it difficult for me to understand how the command above can be adapted… maybe it's actually more a question related to unite than this plugin, but I'm not sure.

Issue installing citation.vim on Mac OS X 10.11.4, Vim 7.4.1129

Hi

thanks for this awesome looking plugin. I followed the installation instructions on Mac OS X 10.11.4, Vim 7.4.1129, and Vundle 0.10.2. When I try the keyboard shortcut or command for citation insertion

 :<C-u>Unite -buffer-name=citation   -start-insert -default-action=append      bibtex

I only the see message

[unite.vim] Invalid source name "bibtex" is detected.                                                                                                              
[unite.vim] unite.vim: Invalid source
Press ENTER or type command to continue

Any pointers at how I could resolve this? Is there a good way to debug this and interact more directly w/ the plugin?

Best.

P.S.: I use the zotero standalone installation and set

let g:citation_vim_zotero_folder=["~/Library/Application Support/Zotero/Profiles/<random>.default/zotero"]

but I also tried a valid *.bib file with

let g:citation_vim_mode="bibtex"

Problem: citation crashes with zotero

Hi @rafaqz,

I still get an error when I try to use the latest version of citation.vim with zotero:

Citation.vim error:
Traceback (most recent call last):
  File "/home/sappo/.vim/bundle/citation.vim/python/citation_vim/citation.py", line 22, in connect
    return Builder(Loader().context).build_source()
  File "/home/sappo/.vim/bundle/citation.vim/autoload/unite/sources/../../../python/citation_vim/builder.py", line 25, in build_source
    description = self.describe(item)
  File "/home/sappo/.vim/bundle/citation.vim/autoload/unite/sources/../../../python/citation_vim/builder.py", line 111, in describe
    return self.describe_with_source_field(description_values, item)
  File "/home/sappo/.vim/bundle/citation.vim/autoload/unite/sources/../../../python/citation_vim/builder.py", line 141, in describe_with_source_field
    return description_format.format(*description_values)
KeyError: 'type'
[unite.vim] function unite#helper#call_unite[33]..unite#start[1]..unite#start#standard[50]..unite#candidates#_recache[74]..<SNR>294_recache_candidates_loop[42]..<SNR>294_get_source_candidates[40]..592, line 3
[unite.vim] Vim(return):E712: Argument of map() must be a List or Dictionary
[unite.vim] Error occurred in gather_candidates!
[unite.vim] Source name is citation/key

unite buffer "default" candidates are empty

I installed Unite and citation.vim, including most of the shortcuts that you list in the readme. I am successfully able to insert a citation using [unite]c, however I am not able to open a file from a citation under the cursor using [unite]co. When I enter the key combination [unite]co I get a message at the bottom of the vim window that reads: [unite.vim] unite buffer "default" candidates are empty. I am running gvim version 8.0.1453 and Zotero version 5.0.85. It would be great if you could point me in the right direction to get this fixed. Let me know if you need any more info.

Undefined variables

I have made some bad configuration and so leads to errors.
One of these errors results in

Citation.vim error: Cache could not be written
Citation.vim error:
Traceback (most recent call last):
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/python/citation_vim/citation.py", line 21,
in connect
    return Builder(Loader().context).build_source()
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 25, in build_source
    return self.get_sub_source()
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 29, in get_sub_source
    for item in self.get_items():
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 85, in get_items
    self.write_cache(items)
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/builder.py", line 120, in write_cache
    raiseError(u"Cache could not be written")
  File "/cygdrive/c/Users/andre/.vim/dein/repos/github.com/rafaqz/citation.vim/autoload/unite/sources/../../../python/cita
tion_vim/utils.py", line 37, in raiseError
    raise RuntimeError(plug_error, args)
NameError: global name 'plug_error' is not defined

There is a variable in citation.vim/python/citation_vim/utils.py called plug_error which is undefined.
There really a need to create a new function called raiseError while just passing a string to RunTimeError is enough? I am doing a pull request on this.

Insert Zotero citation issue on Windows

Hi

Many thanks for this awesome plugin which can integrate powerful features of both unite and Zotero.

I followed the installation instructions on the README on my Windows 10 machine with Vim 7.4.2202 and Zotero 4.0.29.10 (with extension Better BibTex 1.6.72).

When I try to activate the unite citation source in the command line:
:Unite citation/title, some errors popped out:

[unite.vim] function <SNR>85_call_unite[33]..unite#start[1]..unite#start#standard[50]..unite#candidates#_recache[74]..<SNR>197_recache_candidates_loop[42]..<SNR>197_get_source_cand
idates[40]..209[1]..<SNR>194_map_entries[1]..<SNR>194_get_source, line 9
[unite.vim] Vim(let):Traceback (most recent call last):
[unite.vim] Error occurred in gather_candidates!

And every other sources of citation will give similar error messages.

Here below is the citation part of my _vimrc:

" Citation configuration {{{
" To use Zotero database.
let g:citation_vim_zotero_folder=["c:/Users/jiaho/OneDrive\ -\ PersonalOnedrive/3-Literatures/Zotero/"]
let g:citation_vim_mode="zotero"
let g:citation_vim_cache_path='~/vimfiles/Citation'
" Set citation suffix and prefix. Pandoc markdown style is the default.
let g:citation_vim_outer_prefix="["
let g:citation_vim_inner_prefix="@"
let g:citation_vim_suffix="]"
" 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/title<cr>
" To immediately open a file or url 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>
" }}}

Any insights of what is going on and how to solve this problem? Thanks!

Unite throws errors when I call `:Unite citation`(i.e. without specifying sub-menu)

Perhaps this is unintended usage? But when I call :Unite <args> citation instead of (e.g.) :Unite <args> citation/key, so as to choose one option from the menu, I observe some odd behavior:

If I do this for the first time after opening a new Vim session, I get no error.

If I do this after the first time, I get the following error message:

[Citation] citation sources
[unite.vim] function unite#helper#call_unite[33]..unite#start[1]..unite#start#standard[50]..unite#candidates#_recache[74]..<SNR>174_recache_candidates_l
oop[42]..<SNR>174_get_source_candidates[40]..385, line 4
[unite.vim] Vim(return):E731: using Dictionary as a String
[unite.vim] Error occurred in gather_candidates!

If I choose an option from the sub-menu directly via my :Unite call (i.e., via :Unite citation/key), the plugin works fine.

Btw thanks for writing this thing, it is in general awesome.

Folder Not Found

I continue to have similar problems to #1 #2 perhaps due to #4. I get a message stating:

[unite.vim] function unite#action#do[70]..244[1]..unite#start_t
emporary[1]..unite#start#temporary[59]..unite#start#standard[50
]..unite#candidates#_recache[74]..<SNR>131_recache_candidates_l
oop[42]..<SNR>131_get_source_candidates[40]..177[1]..<SNR>128_m
ap_entries[1]..<SNR>128_get_source, line 9
[unite.vim] Vim(let):Traceback (most recent call last):
[unite.vim] Error occurred in gather_candidates!
[unite.vim] Source name is citation/author

Running test.py yields

Traceback (most recent call last):
  File "test.py", line 22, in <module>
    items = builder.build_list()
  File "/home/nabeel/.vim/plugged/citation.vim/python/citation_vim/../citation_vim/citation.py", line 71, in build_list
    for item in self.get_items():
  File "/home/nabeel/.vim/plugged/citation.vim/python/citation_vim/../citation_vim/citation.py", line 92, in get_items
    parser = self.get_parser()
  File "/home/nabeel/.vim/plugged/citation.vim/python/citation_vim/../citation_vim/citation.py", line 113, in get_parser
    parser = bibtexParser(self.context)
  File "/home/nabeel/.vim/plugged/citation.vim/python/citation_vim/../citation_vim/bibtex/parser.py", line 13, in __init__
    self.et_al_limit = context.et_al_limit
AttributeError: 'Context' object has no attribute 'et_al_limit'

The following are the relevant sections of my vimrc:

let g:citation_vim_mode="bibtex"
let g:citation_vim_bibtex_file="/home/nabeel/Dropbox/Miscellaneous/Zotero/library.bib"
let g:citation_vim_cache_path="/home/nabeel/.vim/citations/"
let g:citation_vim_outer_prefix="["
let g:citation_vim_inner_prefix="@"
let g:citation_vim_suffix="]"
let g:citation_vim_et_al_limit=2

I run :Unite citation/key and get traceback

When running :Unite citation/key on neovim (from HEAD of the git repo, currently at neovim/neovim@dadcfe22c ) I get this backtrace:

Citation.vim error:                                                                        
Traceback (most recent call last):                                                         
  File "/home/matej/.vim/pack/minpac/start/citation.vim/python/citation_vim/citation.py", l
ine 24, in connect                                                                         
    return Builder(ContextLoader().context).build_source()                                 
  File "/home/matej/.vim/pack/minpac/start/citation.vim/autoload/unite/sources/../../../pyt
hon/citation_vim/context_loader.py", line 21, in __init__                                  
    context = self.get_shared_context(context)                                             
  File "/home/matej/.vim/pack/minpac/start/citation.vim/autoload/unite/sources/../../../pyt
hon/citation_vim/context_loader.py", line 59, in get_shared_context                        
    context['cache_path']   = self.get_cache_path()                                        
  File "/home/matej/.vim/pack/minpac/start/citation.vim/autoload/unite/sources/../../../pyt
hon/citation_vim/context_loader.py", line 75, in get_cache_path                            
    return os.path.expanduser(vim.eval("g:citation_vim_cache_path"))                       
  File "/usr/lib/python3.6/site-packages/neovim/plugin/script_host.py", line 204, in eval  
    obj = self.request("vim_eval", expr)                                                   
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 170, in request         
    res = self._session.request(name, *args, **kwargs)                                     
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/session.py", line 100, in reque
st                                                                                         
    raise self.error_wrapper(err)                                                          
neovim.api.nvim.NvimError: b'Vim:E121: Undefined variable: g:citation_vim_cache_path'      
[unite.vim] function unite#helper#call_unite[33]..unite#start[1]..unite#start#standard[50].
.unite#candidates#_recache[74]..<SNR>166_recache_candidates_loop[42]..<SNR>166_get_source_c
andidates[40]..84, line 3                                                                  
[unite.vim] Vim(return):E712: Argument of map() must be a List or Dictionary               
[unite.vim] Error occurred in gather_candidates!                                           
                                                                                           
Press ENTER or type command to continue

Problem: error when using latest version with zotero

I get the following error when I call the unite source:

Citation.vim error:
Traceback (most recent call last):
  File "/home/sappo/.vim/bundle/citation.vim/python/citation_vim/citation.py", line 22, in connect
    return Builder(Loader().context).build_source()
  File "/home/sappo/.vim/bundle/citation.vim/autoload/unite/sources/../../../python/citation_vim/builder.py", line 25, in build_source
    description = self.describe(item)
File "/home/sappo/.vim/bundle/citation.vim/autoload/unite/sources/../../../python/citation_vim/builder.py", line 111, in describe
    return self.describe_with_source_field(description_values, item)
  File "/home/sappo/.vim/bundle/citation.vim/autoload/unite/sources/../../../python/citation_vim/builder.py", line 138, in describe_with_source_field
    return description_format.format(*description_values)
KeyError: 'type'
[unite.vim] function unite#helper#call_unite[33]..unite#start[1]..unite#start#standard[50]..unite#candidates#_recache[74]..<SNR>168_recache_candidates_loop[42]..<SNR>168_get_source_candidates[40]..141, line 3
[unite.vim] Vim(return):E712: Argument of map() must be a List or Dictionary
[unite.vim] Error occurred in gather_candidates!
[unite.vim] Source name is citation/key

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.