jalvesaq / zotcite

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

mulitple citations (more than 3 or 4) on a single line slows down typing and motion movement #77

Open samtrek opened 4 months ago

samtrek commented 4 months ago

Including more than 3 citations on a single line greatly reduces the typing speed and motion movement in that line, but other lines without citations are not affected. Still use able but things become sluggish as typing continues, and their may even be a millisecond land between what is typed and and what is shown on the screen.

jalvesaq commented 4 months ago

Are you using Vim or Neovim? Is nvim-treesitter installed and is tree-sitter highlighting enabled?

samtrek commented 4 months ago

neovim and nvim-treesitter is installed, but I removed highlighting for markdown, can it still affect zotcite performance?

jalvesaq commented 4 months ago

Thanks for the feedback! I'll investigate this later. It seems to be possible to use treesitter for conceal...

jalvesaq commented 4 months ago

With four citations in a line, I can see a delay after pressing the space bar in Insert mode, but only if I have the following lines in my init.lua:

vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.keymap.set('',  '<Space>', '<Nop>')

There is no delay with the default mapleader and maplocalleader.

samtrek commented 4 months ago

vim.g.maplocalleader = ',' The above is my default maplocalleader, let me check and test the performance once again.

samtrek commented 4 months ago

I reverted back to the default keybinds for nvim, however, the same problem still persists, when in insert mode the slight delay is manageable (when calling on citations), however when writing normal sentences it can slow down work flow a little bit, especially when moving with the motion jklh vim-motion keys.

jalvesaq commented 4 months ago

I didn't see any slowness in Vim. But, in Neovim, the slowness persists even if I comment out line 652 of autoload/zotcite.vim:

        syn match zoteroKey  /@\S*[A-Z0-9]\{8}#/ conceal

So, my idea of using treesitter to conceal the Zotero key would probably make no difference.

jalvesaq commented 4 months ago

I just discovered that the delay that I was seeing was caused by a new feature that is being introduced in this pull request: https://github.com/R-nvim/R.nvim/pull/116

I changed the default configuration to insert a native R pipe from <LocalLeader>m (my <LocalLeader> is a <Space>) to ;; and now there is no delay. Of course, the cursor seems to be put when pressing h and l keys in Normal mode while moving from one character of the Zotero key to another because the characters are concealed and we can't see the cursor movement, but this is the expected behavior.

PMassicotte commented 4 months ago

<loacalLeader>m was not used for sending motion?

samtrek commented 4 months ago

Trying to see if the lag is CPU dependent, will check it out on a more modern CPU.

I just discovered that the delay that I was seeing was caused by a new feature that is being introduced in this pull request: R-nvim/R.nvim#116

I changed the default configuration to insert a native R pipe from <LocalLeader>m (my <LocalLeader> is a <Space>) to ;; and now there is no delay. Of course, the cursor seems to be put when pressing h and l keys in Normal mode while moving from one character of the Zotero key to another because the characters are concealed and we can't see the cursor movement, but this is the expected behavior.

the above is mainly in .r or .rmd documents, I am using it in *.md files and the lag is visible, when moving with the jkhl keys.

jalvesaq commented 1 month ago

I'll soon merge the branch nvim into the master branch. The nvim branch replaced VimScript with Lua, but I don't think it will make any difference for this issue. Anyway, could you try it?

samtrek commented 1 month ago

yes I will give it a try.

jalvesaq commented 1 month ago

The nvim branch is the master branch now.