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: Noice doesn't trigger ModeChanged when exiting command-line mode. #390

Closed
3 tasks done
mawkler opened this issue Mar 10, 2023 · 4 comments · Fixed by #396 or #639
Closed
3 tasks done

bug: Noice doesn't trigger ModeChanged when exiting command-line mode. #390

mawkler opened this issue Mar 10, 2023 · 4 comments · Fixed by #396 or #639
Labels
bug Something isn't working upstream Issue is caused by a dependency (like Neovim) wontfix This will not be worked on

Comments

@mawkler
Copy link

mawkler commented Mar 10, 2023

Did you check docs and existing issues?

  • I have read all the noice.nvim docs
  • I have searched the existing issues of noice.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

v0.9.0-dev-1184+g0ecb4d725

Operating system/version

Arch Linux

Describe the bug

Noice doesn't trigger ModeChanged when exiting command-line mode.

Steps To Reproduce

  1. Enter command-line mode (:)
  2. Message: "mode changed: c"
  3. Leave command-line mode (<Esc>)
  4. No message

Expected Behavior

Message "mode changed: n" appears when leaving command-line mode.

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/noice.nvim',
    config = function()
      require('noice').setup({})
    end,
    dependencies = {
      'MunifTanjim/nui.nvim',
      'rcarriga/nvim-notify',
    }
  }
}

require('lazy').setup(plugins, {
  root = root .. '/plugins',
})

vim.cmd.colorscheme('tokyonight')

vim.api.nvim_create_augroup('NoiceTest', {})
vim.api.nvim_create_autocmd('ModeChanged', {
  callback = function()
    local mode = vim.api.nvim_get_mode().mode
    print('mode changed: ' .. mode)
  end,
  group = 'NoiceTest'
})
@folke
Copy link
Owner

folke commented Mar 12, 2023

I looked into this, and unfortunately this is not possible to fix.

When the cmdline is displayed, I need to make sure the cursor is always visible. I do this using vim.cmd([[noautocmd silent! normal! ze]]).

It seems that that sets the mode to normal internally, so when exiting the cmdline, the ModeChanged is not triggered.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2023
@folke folke added wontfix This will not be worked on upstream Issue is caused by a dependency (like Neovim) labels Mar 12, 2023
@mawkler
Copy link
Author

mawkler commented Mar 13, 2023

@folke Hmm ok. Is it possible to raise a custom event like NoiceCmdLineLeave when leaving command-line mode that I can subscribe to?

@folke folke reopened this Mar 14, 2023
@folke folke closed this as completed in fa7b6a1 Mar 14, 2023
@folke
Copy link
Owner

folke commented Mar 14, 2023

I was able to work-around this issue by not using a normal command to horizontally align the cursor. ModeChanged triggers as expected now

@mawkler
Copy link
Author

mawkler commented Mar 14, 2023

Thank you! Works great!

willothy pushed a commit to willothy/noice.nvim that referenced this issue Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Issue is caused by a dependency (like Neovim) wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants