Comments (20)
It's fixed! Thx!
from mapx.nvim.
Please open an issue for it and I will work on it when I have time. I do like the idea!
Also, if you'd prefer, you can pin Mapx to an earlier version using your plugin manager until then so you don't need to change your config. With Packer this would look like:
use {
'b0o/mapx.nvim'
commit = 'xxxxxx' -- Use the last working commit hash
}
I'm not sure exactly what commit changed this behavior, do let me know if you figure it out though.
from mapx.nvim.
Please open an issue for it and I will work on it when I have time. I do like the idea!
Also, if you'd prefer, you can pin Mapx to an earlier version using your plugin manager until then so you don't need to change your config. With Packer this would look like:
use { 'b0o/mapx.nvim' commit = 'xxxxxx' -- Use the last working commit hash }I'm not sure exactly what commit changed this behavior, do let me know if you figure it out though.
commit '5ef5da3' "fixed it" , will make a new issue later today!
from mapx.nvim.
Did you set the whichkey
option to true
in mapx.setup
?
local mapx = require'mapx'.setup{ whichkey = true }
If you did this and it's still not working, could you elaborate on how it's not working? Is there an error message, does the mapping work but just not show up in the WhichKey popup, ...?
from mapx.nvim.
require("mapx").setup { global = false, whichkey = true }
This is my mapx
setup.
There is no error message as seems the mapping is ignored.
In my configuration, it is mapped to tpope/unimpaired <Plug>(unimpaired-tnext)
The expected behavior is to override that config.
The first one works in this case but the second one fails.
from mapx.nvim.
Thanks for that information. Unfortunately I'm still unable to reproduce the issue.
I tried this mapping and it works as expected:
mapx.nmap("]t", '<cmd>lua require("trouble").next({skip_groups = true, jump = true})<CR>', "Next Trouble")
I tried this and it works as well:
mapx.nmap("<leader>nt", "<Plug>(unimpaired-tnext)", "Unimpaired tnext")
Here are some steps you can take to help me debug this further:
-
Share the following:
- The full output of
:version
- Your OS/distro name and version.
- If on Windows, are you using neovim through WSL? If so, share those details.
- Your terminal emulator or neovim frontend name and version
- The full output of
:checkhealth nvim which_key
- Your full neovim configuration including the mapx mappings that have issues. Please note which mappings have issues and what issues they have (error message/not having any effect/etc)
- The full output of
-
Gather debug logs:
- Enable debug mode with
require("mapx").setup { whichkey = true, debug = true }
- Restart nvim
- Try to trigger the mapping that isn't working
- Share the debug output here
- Enable debug mode with
If you want to go further, a minimal reproducible configuration would help the most:
- Try to isolate the minimum configuration file needed to cause the bug to occur.
- Share this configuration and list all steps necessary to reproduce the bug.
from mapx.nvim.
I found the issue.
I use the packer.nvim
to manage my plugins and set up mapx
using its config
function.
However, when I use mapx's functions, the config
function is not called.
It's a bit strange and I don't understand why now.
However, we may improve in the following ways:
- Currently, we use
self.whichkey
to judge whether to usewhichkey
. However, if use setwhich_key=true
in setup, it should be an error instead of just ignore it without warning. - We should issue an warning if
mapx.{n}map
is called before setup.
from mapx.nvim.
Oh okay, this makes sense now.
I use the packer.nvim to manage my plugins and set up mapx using its config function.
However, when I use mapx's functions, the config function is not called.
If I understand correctly, the issue is that the packer config function is being executed after your mappings have already been processed. You can fix this in one of a few ways:
Option A: Put your mappings into a separate Lua file and require that file from within the packer config function:
-- File: init.lua, or wherever you configure Packer
use {
'b0o/mapx.nvim',
config = function()
require'my-mappings'
end,
-- Or you could use:
-- config = [[ require'my-mappings' ]],
}
-- File: lua/my-mappings.lua
-- Don't require this file from anywhere other than Packer's config function
local mapx = require'mapx'.setup { whichkey = true }
mapx.nmap("]t", '<cmd>lua require("trouble").next({skip_groups = true, jump = true})<CR>', "Next Trouble")
mapx.nmap("[t", '<cmd>lua require("trouble").previous({skip_groups = true, jump = true})<CR>', "Previous Trouble")
mapx.nmap("<leader>nt", "<Plug>(unimpaired-tnext)", "Unimpaired tnext")
-- ... The rest of your mappings
Option B: Don't use the packer config
function, just call mapx.setup { ... }
directly in your configuration. This is what I do. The downside is that you will get errors if mapx isn't installed yet.
Currently, we use self.whichkey to judge whether to use whichkey. However, if use set which_key=true in setup, it should be an error instead of just ignore it without warning.
There is a bug here, thank you. The intended behavior if whichkey = false
is to ignore the label but to still create the mapping. I will push a fix momentarily.
We should issue an warning if mapx.{n}map is called before setup.
The current behavior is intentional - calling mapx.setup()
is optional. However, I will update the documentation to make this more clear.
from mapx.nvim.
Yeah, currently I use the second way with pcall
.
from mapx.nvim.
That sounds good.
I pushed the fix I mentioned: ae8db6c. Would you mind trying it out and seeing if your issues are all resolved?
from mapx.nvim.
The new commit solves the ]t
& [t
mappings.
However, the following doesn't work
local escape = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
-- HACK
function _G.enhance_align()
if not packer_plugins["vim-easy-align"].loaded then
vim.cmd [[packadd vim-easy-align]]
end
return escape "<Plug>(EasyAlign)"
end
local label = "EasyAlign"
mapx.nmap("ga", enhance_align, mapx.expr, label)
mapx.xmap("ga", enhance_align, mapx.expr, label)
The behavior is different. I can see it is registered in which_key
. But the mappings don't take effect.
If I remove the label and use the following, it works.
mapx.nmap("ga", enhance_align, mapx.expr)
mapx.xmap("ga", enhance_align, mapx.expr)
from mapx.nvim.
What's the output of :nmap ga
with the broken example?
from mapx.nvim.
:nmap ga
for broken examples
n ga * luaeval("require'mapx'.mapper:func(1, vim.v.count)")
n g * <Cmd>lua require("which-key").show("g", {mode = "n", auto = true})<CR>
:nmap ga
for working examples
n g * <Cmd>lua require("which-key").show("g", {mode = "n", auto = true})<CR>
n ga luaeval("require'mapx'.mapper:func(1, vim.v.count)")
from mapx.nvim.
That's another bug, thanks. WhichKey defaults noremap
to true
if it's not explicitly set, which is different from Neovim's default behavior. <Plug>
mappings don't work with noremap = true
, which was causing your issue. Please try the latest commit and see if that fixes the issue.
from mapx.nvim.
Cool, thanks for your patience debugging all of this for me!
from mapx.nvim.
After updating i still get an error
Error detected while processing VimEnter Autocommands for "*":
E5108: Error executing lua .../pack/packer/start/which-key.nvim/lua/which-key/keys.lua:209: Invalid key mapping:
{ ":Telescope ", "telescope",
noremap = true,
prefix = "<leader>t"
}
stack traceback:
[C]: in function 'error'
.../pack/packer/start/which-key.nvim/lua/which-key/keys.lua:209: in function 'parse_mappings'
.../pack/packer/start/which-key.nvim/lua/which-key/keys.lua:177: in function 'parse_mappings'
.../pack/packer/start/which-key.nvim/lua/which-key/keys.lua:275: in function 'register'
.../pack/packer/start/which-key.nvim/lua/which-key/init.lua:96: in function 'load'
[string ":lua"]:1: in main chunk
my conf init.lua
NVIM v0.6.0-dev+575-g2ef9d2a66
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,
-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protect
ion -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g
-Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconver
sion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -f
diagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT
32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/inferno/.cache/paru/clone/neovim-git/sr
c/build/config -I/home/inferno/.cache/paru/clone/neovim-git/src/neovim-git/src -I/usr/include
-I/home/inferno/.cache/paru/clone/neovim-git/src/build/src/nvim/auto -I/home/inferno/.cache/pa
ru/clone/neovim-git/src/build/include
Compiled by inferno
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
my whichkey.nvim
should be on the latest version
from mapx.nvim.
@LamprosPitsillos That's a different issue, but this use of prefix
on a group:
M.group({
prefix = "<leader>t"
}, function()
-- ...
end)
is not currently supported usage of Mapx. It's a good idea though! Feel free to open another issue requesting that as a feature.
from mapx.nvim.
@LamprosPitsillos That's a different issue, but this use of
prefix
on a group:M.group({ prefix = "<leader>t" }, function() -- ... end)is not currently supported usage of Mapx. It's a good idea though! Feel free to open another issue requesting that as a feature.
That's really funny , because I've been using this in my config for months now 😆
And was working perfectly fine might i add, really strange to see the "feature" was never there in the first place...
from mapx.nvim.
It's technically possible because options are forwarded to WhichKey, but Mapx has no special logic to account for it.
from mapx.nvim.
It's technically possible because options are forwarded to WhichKey, but Mapx has no special logic to account for it.
Ok so I'll just manually de-group them all ( i had a lot of groups it was amazing! ) Until the feature is officially added, thanks!
from mapx.nvim.
Related Issues (11)
- This should be default in nvim HOT 1
- Proposal: map with multiple modes
- Support metatables with `__call` metamethod as rhs
- Use the new builtin `nvim_set_keymap()` `callback` option for Lua mappings
- Use the new builtin `nvim_set_keymap()` `desc` option for WhichKey integration HOT 2
- `v:count` parameter passed to Lua functions causing conflicts HOT 7
- Execute multiple commands using a dictionary HOT 4
- Packer.nvim recompile error HOT 2
- `v:lua` string doesn't work HOT 4
- Announcements
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapx.nvim.