echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.47k stars 175 forks source link

[mini.clue] mini.clue interferes with the complete mechanism of Julia language plugin #935

Closed ronisbr closed 1 month ago

ronisbr commented 1 month ago

Contributing guidelines

Module(s)

mini.clue

Description

First of all, thank you @echasnovski for these amazing set of packages!

When the mini.clue window opens, I see interference in the completion mechanism used by https://github.com/JuliaEditorSupport/julia-vim to replace LaTeX sequences with UTF-8 symbols. For example, in this case, you can type \alpha<C-x><C-u> and it is replaced by α. However, if the mini.clue window is opened, it does not work.

Neovim version

0.10

Steps to reproduce

  1. nvim -nu minimal.lua test.jl
  2. Type \alpha
  3. Hit <C-x><C-u> fast enough so that the mini.clue window does not open.
  4. In a new line, type \alpha again.
  5. Hit <C-x> wait for the mini.clue window and then type <C-x>.

minimal.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "JuliaEditorSupport/julia-vim",
    lazy = false,
    config = function()
      vim.g.latex_to_unicode_auto = false
    end
  },
  {
    "echasnovski/mini.clue",
    config = function()
      local miniclue = require("mini.clue")
      miniclue.setup({
        triggers = {
          -- Leader triggers
          { mode = "n", keys = "<Leader>" },
          { mode = "x", keys = "<Leader>" },
          { mode = "n", keys = "<localleader>" },
          { mode = "x", keys = "<localleader>" },
          { mode = "n", keys = "\\" },
          { mode = "x", keys = "\\" },
          { mode = "n", keys = "[" },
          { mode = "x", keys = "[" },
          { mode = "n", keys = "<cr>" },
          { mode = "x", keys = "<cr>" },
          { mode = "n", keys = "]" },
          { mode = "x", keys = "]" },

          -- Built-in completion
          { mode = "i", keys = "<C-x>" },

          -- `g` key
          { mode = "n", keys = "g" },
          { mode = "x", keys = "g" },

          -- Marks
          { mode = "n", keys = "'" },
          { mode = "n", keys = "`" },
          { mode = "x", keys = "'" },
          { mode = "x", keys = "`" },

          -- Registers
          { mode = "n", keys = '"' },
          { mode = "x", keys = '"' },
          { mode = "i", keys = "<C-r>" },
          { mode = "c", keys = "<C-r>" },

          -- Window commands
          { mode = "n", keys = "<C-w>" },

          -- `z` key
          { mode = "n", keys = "z" },
          { mode = "x", keys = "z" },
        },

        clues = {
          -- Enhance this by adding descriptions for <Leader> mapping groups
          miniclue.gen_clues.builtin_completion(),
          miniclue.gen_clues.g(),
          miniclue.gen_clues.marks(),
          miniclue.gen_clues.registers(),
          miniclue.gen_clues.windows(),
          miniclue.gen_clues.z(),
        },
        window = {
          delay = 500,
          config = {
            width = "auto",
          },
        },
      })
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

Expected behavior

After step 3 and 5, \alpha should be replaced by α.

Actual behavior

After step 3, \alpha is replaced by α. However, after step 5, the mini.clue window stays open and the text is not replaced.

echasnovski commented 1 month ago

Thanks for the issue!

This happens because <C-u> is by default a special key in key query process and is used to scroll clue window upwards. But only if the window is visible, as you experience.

This can be resolved with at least the following approaches:

Closing as it works as expected.

ronisbr commented 1 month ago

Hi @echasnovski !

Thank you very much for the quick and detailed answer! It is working perfectly now. Sorry for the noise.

echasnovski commented 1 month ago

No problem. It is kind of not obvious why this might happen. Searching 'mini.clue' help for '<C-x>' and '<C-u>' might have given a clue (pun intended).

The actual solutions are to somehow disable special treatment of '<C-u>', which this issue will now serve as reference. So it's good that you asked :)