Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Command mode prompt doesn't show until user types, when mapping opens command mode #553

Open
3 tasks done
dylan-chong opened this issue Dec 10, 2023 · 2 comments
Open
3 tasks done
Labels
bug Something isn't working

Comments

@dylan-chong
Copy link

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • I have searched the existing issues of which-key.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.4

Operating system/version

Ubuntu 22.04.3 LTS

Describe the bug

Command mode prompt is invisible until user types after triggering the mapping, e.g. the example below (which is in the repro lua)

{ ':echo "hello but not pressing enter"', 'example' }

Steps To Reproduce

  1. nvim -u repro.lua
  2. Type <space>%
  3. Nothing will happen.
  4. Type a

Expected Behavior

Command mode should show up at the end of step 2 with cursor at the end of the line

Repro

-- 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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/which-key.nvim", config = true, init = function()
	  require('which-key').register({
		  ['%'] = { ':echo "hello but not pressing enter"', 'example' }
	  }, { prefix = '<space>' })
  end},
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@dylan-chong dylan-chong added the bug Something isn't working label Dec 10, 2023
@dylan-chong
Copy link
Author

For now, i'm working around the issue by using the command mode buffer

function CopyPath(expand)
  local string = vim.fn.expand(expand)
  vim.fn.setreg('+', string)
  print('Copied: ' .. string)
end
lvim.builtin.which_key.mappings['%'] = {
  ":lua CopyPath('%:p')<Left><Left><Left><C-f>i", -- added <C-f>i
  "Copy file path"
}

dylan-chong added a commit to dylan-chong/dotfiles that referenced this issue Jan 21, 2024
dylan-chong added a commit to dylan-chong/dotfiles that referenced this issue Jan 21, 2024
@jonathf
Copy link

jonathf commented Feb 9, 2024

I have the same issue on MacOS. Workaround also work, but not with Noice unfortunatly. It forces traditional cmd mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants