jalvesaq / zotcite

Neovim plugin for integration with Zotero
GNU General Public License v3.0
170 stars 14 forks source link

Inconsistent user interface (vim.ui.select vs custom Telescope dialog) #88

Closed jalvesaq closed 2 months ago

jalvesaq commented 2 months ago

The :Zannotations (and other commands) call vim.ui.select. My result for :Zannotations neuroscience is:

Select one of:
1: Greene (2019) The believing brain: evolution, neuroscience, and the spiritual instinct
2: Callard, Fitzgerald (2015) Rethinking Interdisciplinarity across the Social Sciences and Neurosciences
3: Jost, Nam, Amodio, Van Bavel (2014) Political neuroscience: the beginning of a beautiful friendship
4: Haas, Warren, Lauf (2020) Political neuroscience: understanding how the brain makes political decisions
Type number and <Enter> or click with the mouse (q or empty cancels):

If I use the Telescope ui-select extension the result is:

╭─────────────────────────────── Select one of ────────────────────────────────╮
│>                                                                        4 / 4│
├──────────────────────────────────────────────────────────────────────────────┤
│> Greene (2019) The believing brain: evolution, neuroscience, and the spiritua│
│  Callard, Fitzgerald (2015) Rethinking Interdisciplinarity across the Social │
│  Jost, Nam, Amodio, Van Bavel (2014) Political neuroscience: the beginning of│
│  Haas, Warren, Lauf (2020) Political neuroscience: understanding how the brai│
│                                                                              │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

And :Zseek is the only one to use a custom Telescope dialog:

image

Perhaps we should use the custom Telescope dialog for everything. We can even create an Insert mode key binding for inserting citation keys (as an alternative, not replacement, for cmp-zotcite). Or we may have a global option allowing users to choose between vim.ui.select and the custom Telescope dialog. More options are good for users but mean more work for us. What do you think, @adam-coates ?

jalvesaq commented 2 months ago

Note: I deleted a spam message.

Reason to keep only the custom Telescope dialog: we can open it with an empty search string and populate the list with all Zotcite references. With the Insert mode key binding, this would implement what @acorreya requested on #46.

adam-coates commented 2 months ago

This I agree with and I've already tested out telescope for the Zselectannotations command. But the issue is that the telescope picker list cannot refresh the list. This is document here https://github.com/nvim-telescope/telescope.nvim/issues/2016#issue-1276097274

For instance, once an annotation selection has been made, it should be removed from the list of available annotations (ideally). As far as I can tell we can implement telescope in the annotations selection menu but that this means it might not remove an annotation that's been selected.

I tried a few things for this problem and I can't get the telescope list to change the options once the menu is open, neither does opening a new picker list work.

jalvesaq commented 2 months ago

:Zselectannotations works in two steps. First, it selects the reference. Then it selects the annotations.

We don't need to change anything in the second step; your implementation is good. But we can use the custom Telescope dialog for the first step. I can make a pull request for this tomorrow to make more clear what I mean.

adam-coates commented 2 months ago

Ahh yeah it would be okay to implement it to select which reference the annotation comes from.

In ways this should be straightforward as Zseek now already does this.

Perhaps instead of displaying the abstract we display the reference info (journal, year etc)

We can add a config option to allow users to choose what is displayed in the telescope preview window.

But I'm definitely for having telescope in the commands 😀

jalvesaq commented 2 months ago

The main inconsistency I reported is fixed, but we could still improve the Telescope dialog.

I'm suggesting a new way of calculating the width of the author field on the branch improve_seeker.

jalvesaq commented 2 months ago

News on the improve_seeker branch: accept calling seek.refs with an empty string and use Telescope to insert citation key (<C-X><C-C>). This effectively allows us to close issue #46.

jalvesaq commented 2 months ago

We can add a config option to allow users to choose what is displayed in the telescope preview window.

When we resize the terminal, Telescope automatically updates itself and shows the preview window if the terminal is large enough or hides it if the terminal doesn't have enough columns. In my opinion, we don't need further customization, unless there is demand for it.

jalvesaq commented 2 months ago

Perhaps instead of displaying the abstract we display the reference info (journal, year etc)

The branch improve_seeker now formats the reference. It can still be improved but it's already more informative than before because it includes the book title or journal name. The message "No abstract" is displayed only for journal articles.

jalvesaq commented 2 months ago

Now, a custom syntax highlighting for the previewer:

image