Giter Site home page Giter Site logo

jghauser / papis.nvim Goto Github PK

View Code? Open in Web Editor NEW
135.0 135.0 6.0 153 KB

Manage your bibliography from within your favourite editor

License: GNU General Public License v3.0

Lua 97.90% Nix 2.10%
academia bibliography citation lua neovim neovim-plugin papis references

papis.nvim's People

Contributors

davvil avatar jghauser avatar maxmahlke 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

papis.nvim's Issues

`get_ref_under_cursor` should fail gracefully if reference is not recognized

If the reference under the cursor when running :PapisOpenNote is not in the expected format given the filetype, the string.find function below fails with the following traceback.

local _, ref_start = string.find(word_under_cursor, cite_format_prefix)

Error executing Lua callback: .../packer/opt/papis.nvim/lua/papis/cursor-actions/init.lua:40: malformed pattern (
missing ']')                                                                                                     
stack traceback:                                                                                                 
        [C]: in function 'find'                                                                                  
        .../packer/opt/papis.nvim/lua/papis/cursor-actions/init.lua:40: in function 'get_ref_under_cursor'       
        .../packer/opt/papis.nvim/lua/papis/cursor-actions/init.lua:56: in function 'if_ref_valid_run_fun'       
        .../packer/opt/papis.nvim/lua/papis/cursor-actions/init.lua:109: in function <.../packer/opt/papis.nvim/l
ua/papis/cursor-actions/init.lua:108>     

The reference is not in the expected format as I had inserted it into another filetype and the copied it over into a different one.
Either way, I suggest that this function should perform three steps:

  1. Match reference under cursor against the expected pattern based on filetype, if not successful -> 2
  2. Match reference under cursor against all other possible patterns. If successful, notify user that it matched with an unexpected pattern. Else -> 3
  3. No match found, fail gracefully by notifying user that no match was found based on the reference pattern

Setup impossible

My config is here
https://gitlab.gnugen.ch/dorsch/nvim_config

Running
:Telescope papis
in nvim gives the following error

Error executing Lua callback: ...acker/opt/papis.nvim/lua/telescope/_ext
ensions/papis.lua:49: attempt to index field 'search' (a nil value)
stack traceback:
...acker/opt/papis.nvim/lua/telescope/_extensions/papis.lua:49:
in function 'entry_maker'
...scope.nvim/lua/telescope/finders/async_static_finder.lua:17:
in function 'new_table'
...acker/opt/papis.nvim/lua/telescope/_extensions/papis.lua:46:
in function <...acker/opt/papis.nvim/lua/telescope/_extensions/papis.lua
:38>
...ck/packer/start/telescope.nvim/lua/telescope/command.lua:199:
in function 'run_command'
...ck/packer/start/telescope.nvim/lua/telescope/command.lua:259:
in function 'load_command'
...te/pack/packer/start/telescope.nvim/plugin/telescope.lua:108:
in function <...te/pack/packer/start/telescope.nvim/plugin/telescope.lu
a:107>
Press ENTER or type command to continue

Entries are faulty

When papis.nvim initializes it gives me an error message like this for every entry in my database.

The entry at '/path/to/library/folder-name/info.yaml' is faulty and will not be added.

The info.yaml files all have the papis_id and ref fields, and papis doctor gives no errors, so I have no idea how the entries could be faulty.

Dependency libyaml-dev

I'm pretty sure libyaml-dev is a dependency in order to install lyaml.
When installing via packer, the installation of lyaml fails without giving any further information.
It would maybe be a good idea to mention it somewhere.

<c-p> in telescope works with huge delay (possible issue with <c-p>p).

Just for someone who can have same issue.
I use <c-p> key to navigate to previous item in telescope.
If papis enable_keymaps is true, I have very strange behaviour. Nvim insert some escape sequence (or something like this) and selecting previous item is processing with huge delay.

I have this issue in xtrem and kitty.

2023-06-12-04-46-09-.mp4

Add option to insert unformatted reference

Hi again! I'm finally getting back to writing a paper and using papis.nvim. You've done a lot of work on this plugin, that's great!
I have had some issue/ideas for this plugin, I will open a series (edit: only two ideas, I figured out the two issues I had while writing their bug reports) of issues to discuss them :-) For the feature requests, I have some working code on my side, so if you agree that they make sense, I'm happy to open a PR.

First up: I would like the option to insert unformatted references, rather than having them formatted according to filetype. I use snippets a lot (eg cp and ct for \citep{|} and \citet{|} in tex) and don't need the formatting.

opening references picker causes telescope error

Error executing vim.schedule lua callback: .../cal/share/nvim/rocks/rocks_rtp/lua/telescope/pickers.lua:1467: Cursor position outside buffer
stack traceback:
    [C]: in function 'nvim_win_set_cursor'
    ...cal/share/nvim/rocks/rocks_rtp/lua/telescope/pickers.lua:1467: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>

The telescope overlay opens and the error is repeated after every keypress. Telescope seems to be working fine for everything else other than papis.nvim. I tried the latest release of Telescope (0.1.6) and got the same error (although it pointed to line 1345 instead of 1467).

Improve Telescope picker

Currently, the Telescope picker is quite slow. The reason for this is probably the entry_display.create() function that is called for each line in the results window (that's the list of Author (Year) Title lines). The function is used to define which part of the string is to be highlighted with which highlight group (e.g. chars 1-5 with highlight group X, chars 6-10 with group Y, etc.). Because the length of the author and title string is different for each line, the function needs to be called for each line. Telescope's creators explicitly say in :h telescope.pickers.entry_display that this can slow things down.

An alternative is to have predefined lengths for each element in the results window (e.g. year -> 4 chars , author -> 20 chars, title -> remaining chars). It would look something like how citar does it:

citar

Advantages:

  • entry_display.create() only has to be called once when the picker is opened, which should speed things up

Disadvantages:

  • wastes space, which can be relevant especially when the picker window is small (applies to me as I usually have two documents open side-by-side

What do you think?

Invalid `jq` options `-oj` lead to Invalid YAML error

First, I'm really happy to see #19, the luarocks lyaml business often posed problems to me and to see it gone is great!

To the issue: I just set up my system from scratch and cloned papis.nvim. On PapisStart, I got an "The entry at xyz.yaml is faulty and will not be added" error for all yamls in my papis database. I ensured that the YAML in the files is correct using a linter. I then found the culprit to be

local handler = io.popen(yq_bin .. ' -oj "' .. filepath:absolute() .. '" 2>/dev/null')

In my version of jq, the -oj options are not valid filters, and the whole command with yq just echoed the yq --help text instead of the YAML converted to JSON. Replacing -oj with -j . worked for me, the JSON is now correctly echoed and the database is built.

My guess is that the jq options changed and are no longer valid. My jq and yq versions are

$ yq --version
yq 3.2.2
$ jq --version
jq-1.6

Attempt to concatenate upvalue 'tag_delimiter' (a nil value) in completion/source.lua

With a fresh setup of papis (only one article was added) and papis.nvim I get the following error when entering insert mode in any info.yaml file.

Error executing vim.schedule lua callback: ...ck/packer/opt/papis.nvim/lua/papis/completion/source.lua:66: attempt to concatenate upvalue 'tag_delimiter' (a nil value)                                                                                                       
stack traceback:                                                                                                                                                                                                                                                              
        ...ck/packer/opt/papis.nvim/lua/papis/completion/source.lua:66: in function 'is_available'                                                                                                                                                                            
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:99: in function 'get_sources'                                                                                                                                                                             
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:311: in function 'fn'                                                                                                                                                                                     
        .../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:57: in function <.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:55> 

The error goes away after adding some comma separated tags to an info.yaml file and running :PapisReInitData.

Setup not working correctly; database file apparently inaccessible

Hi. I've been trying to set up papis and papis.nvim on my Windows machine for a day or two now, and I'm running into issues. papis, by this point, works fine sans a single warning message which seems to not impede the actual use of the system. I've tested the serve webapp and it behaves as expected. However, when I try to use papis.nvim, I continually run into the following error when trying to initialize it (either manually or by opening a markdown file, for example). Any idea what's going on here?

Error executing lua callback: ...Data/Local/nvim-data/lazy/sqlite.lua/lua/sqlite /defs.lua:709: sqlite.lua: couldn't connect to sql database, ERR: unable to open database file stack traceback: [C]: in function 'error' ...Data/Local/nvim-data/lazy/sqlite.lua/lua/sqlite/defs.lua:709: in func tion 'connect' ...ppData/Local/nvim-data/lazy/sqlite.lua/lua/sqlite/db.lua:162: in func tion 'open' ...ppData/Local/nvim-data/lazy/sqlite.lua/lua/sqlite/db.lua:215: in func tion 'run' ...pData/Local/nvim-data/lazy/sqlite.lua/lua/sqlite/tbl.lua:63: in funct ion 'tbl' ...l/nvim-data/lazy/papis.nvim/lua/papis/sqlite-wrapper.lua:80: in main chunk [C]: in function 'require' ...pData/Local/nvim-data/lazy/papis.nvim/lua/papis/init.lua:64: in funct ion <...pData/Local/nvim-data/lazy/papis.nvim/lua/papis/init.lua:54>

Library directory not accessible

First, congrats on this nice plugin and the extensive documentation you provide! It gives a good impression of what the plugin provides and its extensive config options.

I'm having trouble getting started. I set the config as explained in the readme:

papis_python = {
  dir = "/home/max/astro/papers",
  info_name = "info.yaml",
  notes_name = [[notes.org]],
}

yet when I run :PapisStart I get the following output:

/home/max/~/astro/papers/ is not accessible by the current user!                                                 
/home/max/~/astro/papers/ is not accessible by the current user!                                                 
Press ENTER or type command to continue   

I tried different values for dir: ~/astro/papers/, astro/papers/, astro/papers, always the same message. The directory exists and is accessible to my user. Just to make sure it's the directory that the variable requires, it is the directory which contains my papers:

~ ❯ ls ~/astro/papers | head -3
0023fdcfceb1927113193f3bba1c3a80-marchi-s-and-lazzar
006e027d026931904dbe4c331f2a79b4-levison-harold-f.-a
0188fb24dfc019dd6986c965ef4dd07f-fedkin-a.-v.-and

NixVim documentation

I am currently rocking NixVim to manage my (neo)vim plugins, and I noted that Papis is missing from the list. It would be cool to include it in there. I am still a noob at Nix(OS), but if I get more experience, I would be willing to include it in there too.

I will try in the future also including it as an external plugin:

{pkgs, ...}: {
  programs.nixvim = {
    extraPlugins = [
      (pkgs.vimUtils.buildVimPlugin {
        name = "papis";
        src = builtins.fetchGit {
          url = "https://github.com/jghauser/papis.nvim";
          ref = "main";
        };
      })
    ];
  };
}

but further config need to be added at extraConfigLua then.

Move from lyaml luarock to yq

Because of the difficulties of managing luarocks in neovim (especially with lazy.nvim), I'm considering alternatives. One possibility I'm thinking about is to ditch the lyaml luarock (or make it optional) and instead depend on yq (or the python yq) to convert from yaml to json and then import the json with neovim's internal capabilities.

At the moment, I'm just putting this out there. We would still need something external to papis.nvim, but potentially it's easier to install for many people. If anyone has any thoughts about this, let me know here.

Opening files should respect papis config

Currently when I am hovering over a citation and hit <leader>po to open the associated PDF it opens up in Adobe (which is my system's default). However, I usually use rifle to open most things and I have a different PDF reader set as my default there. In my papis config I have opentool = rifle and when I run, e.g., papis open from the command line the PDF opens in my desired reader. I am thinking that papis.nvim should adhere to the configuration of papis itself (although maybe this can be debated).

BTW, I love this package!

Include nix output

Since you already seem to be using nix flakes to manage this, it might be a good idea to expose an output so that it's easier to use this plugin.

Enable multiple-selection in telescope picker

I would like to be able to select more than one paper and insert multiple references into my document. I got this to work on my side: <tab> is used to mark entries in the picker (default), and hitting enter inserts the references separated by comma into the buffer. It's quite neat.

More difficult could be the integration of multiple references into the filetype-specific formatter function.

As said, if you think it makes sense, I'll open a PR.

Having issues with read_yaml function in papis-storage.lua

I've been trying to install and config papis.nvim for a couple of days and am having issues when :PapisStart tries to add and convert yaml files. I know my install of yq is fine- I can run yq -oj info.yaml from the command line with no issue and it produces the correct json output. I know the function can find the yq executable, but it returns nil. I've saved the error from the yq golang code: panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x28 pc=0x1366b55] which makes me think that it can't find or read the yaml file. I don't know if this is an issue with the yq code or the papis-storage. Any suggestions?

cmp source for completing references

Thanks for making this plugin - it's awesome so far. When I'm in a markdown file, for example, it would be great to be able to do autocompletion of citation tags. Suppose I have a document in my papis library with the field ref: smith1992optimal, and I'm editing a markdown document in which I want to cite this reference. One option, which currently works is to type @| (the pipe character denotes the cursor position) and then enter Normal mode and hit Spacepp to open the papis.nvim telescope picker, begin typing smith19... and the fuzzy finder eventually matches and then hit enter, which puts smith1992optimal at the cursor position. My suggestion is to feed the refs as a source for cmp - that way, one need not exit Insert mode to search/match/input the desired citation.

Search depth in the library

Hi. Thank you for the amazing plugin.
Currently my papis library is structed like below

papis_library
├── author 1
│   └── paper 1
│       ├── info.yaml
│       └── author 1 - paper 1.pdf
├── author 2
│   ├── paper 1
│   │   ├── author 2 - paper 1.pdf
│   │   └── info.yaml
│   ├── paper 2
│   │   ├── author 2 - paper 2.pdf
│   │   └── info.yaml
│   └── paper 3
│       ├── author 2 - paper 3.pdf
│       └── info.yaml

When I set dir = papis_library this does not detect my info.yaml files. I got papis.nvim working if i set the dir to papis_library/author 2. But this gives me access to the articles by author 2. I guess this is because of the search depth implemented in the plugin.

Restructuring my library would resolve it. But I feel implementing a deeper search would be nice for folder structure arrangement.

vim.loop.os_uname().sysname returns "Windows_NT"

On Windows 10 (and other 64-bit Windows systems) the return value for vim.loop.os_uname().sysname is "Windows_NT".
In papis/utils.lua line 19, is_windows expects a return value from vim.loop.os_uname().sysname of "Windows" and will therefore return false even when the system is Windows.
FWIW, nvim-lspconfig addresses this issue by using version instead of sysname:
local is_windows = uv.os_uname().version:match("Windows")
(neovim/nvim-lspconfig@2c6f8db)

`read_yaml` should fail gracefully if yaml is malformatted

I got a rather ugly error message when my database was being built (did not save the traceback) which was due to a malformatted yaml file. I had to go through the traceback and add log.debug(filepath) to see which file was broken.

I suggest that in this function below

local function read_yaml(path)
log.trace("Reading path: " .. path)
local filepath = Path:new(path)
local entry = lyaml.load(filepath:read())
return entry
end

we add

  1. Catch the error: if read_yaml fails, just continue with the next one
  2. A notify and log.debug event: notify the user which file failed

Edit: Found the error traceback here

| Error detected while processing BufEnter Autocommands for "*.tex":
|| Error executing lua callback: 6:11: did not find expected key
|| stack traceback:
|| 	[C]: in function 'error'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:306: in function 'error'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:325: in function 'parse'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:443: in function 'load_node'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:340: in function 'load_node'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:393: in function 'load_node'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:378: in function 'load_node'
|| 	...acker_hererocks/2.1.0-beta3/share/lua/5.1/lyaml/init.lua:497: in function 'load'
|| 	...e/pack/packer/opt/papis.nvim/lua/papis/papis-storage.lua:90: in function 'read_yaml'
|| 	...e/pack/packer/opt/papis.nvim/lua/papis/papis-storage.lua:149: in function 'get_data_full'
|| 	.../nvim/site/pack/packer/opt/papis.nvim/lua/papis/data.lua:54: in function 'update_main_tbls'
|| 	.../nvim/site/pack/packer/opt/papis.nvim/lua/papis/data.lua:124: in function 'sync_storage_data'
|| 	.../nvim/site/pack/packer/opt/papis.nvim/lua/papis/data.lua:158: in function 'sync_db'
|| 	.../nvim/site/pack/packer/opt/papis.nvim/lua/papis/init.lua:103: in function <.../nvim/site/pack/packer/opt/papis.nvim/lua/papis/init.lua:49>

ps: illegal option -- q

I get this problem when starting papis using this plugin which supposedly originates from here:

cmd = "ps -q " .. pid

When I run ps -q I get an error saying ps: illegal option -- q. These are followed errors saying that my library files are faulty and will not be added to the database. As such, I see no files inside of neovim, even though the normal commands work fine.

I'm on Darwin version 13.5 Beta. I use Nix as my package manager, and even if I pull the ps command from Nix sources, I still get the same error.

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.