provide a "language server protocol" (lsp) to be able to use zotero directly from editors

The language server protocol (lsp) standard is increasingly becoming the standard way to provide completion / linting / popup etc to advanced editors: https://en.wikipedia.org/wiki/Language_Server_Protocol .

Can / would it be possible to have a Zotero lsp that would for example provide completion, preview (show the bibtex entry over hoover as a documentation), linting, etc, of the citations available in Zotero?

I.e., as a user, I would like to be able to enable a Zotero lsp in visual studio code / vim / helix / other, so that when I type \cite{ or \citep{ or \citet{ or similar, I get autocompletion from the running Zotero app.

As a user, I would also like, if I hoover over a citation like \cite{some_bibtex_id} , to be able to "go to definition" or "show documentation" on the some_bibtex_id, which would display either the pdf of the bibtex entry.
  • Most of the work would have to be done in a vscode plugin. The Zotero side of things would be relatively simple.
  • Actually, I think it would be better to provide a LSP, rather than a VSC plugin - if you provide a LSP, then any editor that support the standard LSP API can use it (either it is VSC, Vim, Emacs, Helix, Sublime, etc ...). If you provide a VSC plugin, then it only works on VSC.
  • But the lsp plugin would also have to parse latex or markdown no?
  • edited August 12, 2024
    If it's just reacting to some lsp verbs I can give it a shot for stuff relating to latex. Someone will have to open an issue for it on the BBT github project and be willing to help hash it out and test.
  • edited August 12, 2024
    if you provide a LSP, then any editor that support the standard LSP API can use it
    My understanding is that that hasn't totally panned out, and most fully-featured LSPs require a dedicated editor plugin. But things could've improved since I last looked into it.

    How would this be different from BBT "Keep updated" + a BibTeX editor plugin?
  • > My understanding is that that hasn't totally panned out, and most fully-featured LSPs require a dedicated editor plugin. But things could've improved since I last looked into it.

    I may be wrong of course, but I think that this has evolved quite a bit and that dedicated plugins are a thing mostly of the past now :) . Some editors support LSPs out of the box in their core feature (see for example https://code.visualstudio.com/api/language-extensions/language-server-extension-guide

    https://s3.amazonaws.com/zotero.org/images/forums/u7216216/uso2co23kzv94q0islvs.png

    , https://docs.helix-editor.com/lang-support.html , https://zed.dev/docs/configuring-zed#lsp , https://neovim.io/doc/user/lsp.html , etc ), while some others require installing a general plugin to enable LSPs but this is just a single plugin to interact with any LSP from there (https://github.com/prabirshrestha/vim-lsp ).

    > But the lsp plugin would also have to parse latex or markdown no?

    and

    > If it's just reacting to some lsp verbs I can give it a shot for stuff relating to latex

    Agree that it could be made to simply react to \cite{ , \citep{ , \citet{ control sequences to open the LSP Zotero autocomplete functionality. Maybe providing a config in the form of a JSON file of admitted prefixes triggering Zotero LSP autocomplete would be good too, so this can be customized? :) . I do not think it is necessary to go all the way to a tree-sitter parsing or similar parsing to determine where to enable the LSP autocomplete.

    > Someone will have to open an issue for it on the BBT github project and be willing to help hash it out and test

    which GH project does BBT refer to? :) Would be happy to help with the testing, no experience developing LSPs on my side.
  • Agree that it could be made to simply react to \cite{ , \citep{ , \citet{ control sequences
    I don't know what "it" refers to here. I'm willing to try building the Zotero side of this, but someone will have to set up the vscode side of things. I don't know how a LSP server should signal that it is willing to play ball.
Sign In or Register to comment.