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: Breaks built in mappings #609

Closed
3 tasks done
mehalter opened this issue Jun 6, 2024 · 17 comments · Fixed by #608
Closed
3 tasks done

bug: Breaks built in mappings #609

mehalter opened this issue Jun 6, 2024 · 17 comments · Fixed by #608
Labels
bug Something isn't working

Comments

@mehalter
Copy link
Contributor

mehalter commented Jun 6, 2024

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)

NVIM v0.10.0 (github release)

Operating system/version

Arch Linux

Describe the bug

It looks like something changed in the processing of mappings in the v2 release that breaks built in mappings such as << to de-indent.

E5108: Error executing lua ...bug/.repro/plugins/which-key.nvim/lua/which-key/util.lua:44: Invalid 'str': Expected Lua string     
stack traceback:                                                                                                                  
        [C]: in function 'nvim_replace_termcodes'                                                                                 
        ...bug/.repro/plugins/which-key.nvim/lua/which-key/util.lua:44: in function 't'                                           
        ...bug/.repro/plugins/which-key.nvim/lua/which-key/keys.lua:136: in function 'get_mappings'                               
        ...bug/.repro/plugins/which-key.nvim/lua/which-key/view.lua:278: in function 'on_keys'                                    
        ...bug/.repro/plugins/which-key.nvim/lua/which-key/view.lua:246: in function 'open'                                       
        ...bug/.repro/plugins/which-key.nvim/lua/which-key/init.lua:44: in function 'show'                                        
        [string ":lua"]:1: in main chunk

Steps To Reproduce

  1. nvim -u repro.lua , use the minimal reproducing config below
  2. <<, binding for decreasing indentation
  3. See error.

Expected Behavior

No error and all default mappings should still work.

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 },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@mehalter mehalter added the bug Something isn't working label Jun 6, 2024
@folke
Copy link
Owner

folke commented Jun 6, 2024

Can't reproduce with the repro. Are you 100% you're on the latest version?

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

Please try again, the minimal repro.lua above reproduces the bug perfectly. Here is a recording showing me doing a fresh installation given the code above and walking through:

https://asciinema.org/a/eDq77UjzMbI7GCzwSs8TnraHT

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Here are the full version details of the neovim version I am using

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

NVIM v0.11.0-dev-189+g78d3f4742
Build type: RelWithDebInfo
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info

I have verified that I can also reproduce with the latest nightly

@folke
Copy link
Owner

folke commented Jun 6, 2024

I you run that repro, make sure to update the plugins in the repro as well

@folke
Copy link
Owner

folke commented Jun 6, 2024

nm, you deleted the files

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

2024-06-06_10:44:43_screenshot

I have verified that I am on the latest.

@folke
Copy link
Owner

folke commented Jun 6, 2024

so weird, it all works fine for me

@folke
Copy link
Owner

folke commented Jun 6, 2024

2024-06-06_16-47-16.mp4

@folke
Copy link
Owner

folke commented Jun 6, 2024

ok, can reproduce now. First >> then << triggers the error

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

Do the other way...

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

I also agree that >> works as shown in my recording

@folke
Copy link
Owner

folke commented Jun 6, 2024

bisected it to #600

Will check or revert

@folke
Copy link
Owner

folke commented Jun 6, 2024

reverted for now. had a quick look at that code and it's wrong for sure.
will implement it myself

@mehalter
Copy link
Contributor Author

mehalter commented Jun 6, 2024

Thanks! Definitely strange you have to indent first, on my end if I just do the exact steps I put in the issue and run << even as the first thing in the editor I get the problem

@folke folke closed this as completed in 25d5b9e Jun 6, 2024
@folke
Copy link
Owner

folke commented Jun 6, 2024

I reverted the PR and just did a proper fix for those nested operators.

@folke
Copy link
Owner

folke commented Jun 6, 2024

Thank you for reporting!

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

Successfully merging a pull request may close this issue.

2 participants