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

vim.keymap.set not found #17023

Closed
alok opened this issue Jan 10, 2022 · 18 comments
Closed

vim.keymap.set not found #17023

alok opened this issue Jan 10, 2022 · 18 comments
Labels
build building and installing Neovim using the provided scripts distribution packaging and distributing Nvim to users platform:macos

Comments

@alok
Copy link

alok commented Jan 10, 2022

Neovim version (nvim -v)

NVIM v0.7.0-dev+2338-g8f27c4a04

Vim (not Nvim) behaves the same?

N/A

Operating system/version

Macos monterey

Terminal name/version

kitty

$TERM environment variable

xterm-kitty

Installation

built from source on homebrew

How to reproduce the issue

I tried switching over to vim.keymap.set and got this:

Error detected while processing /Users/alokbeniwal/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /Users/alokbeniwal/.config/nvim/init.lua:54: attempt to call field 'set' (a nil value)

Expected behavior

no error

Actual behavior

the error above

@alok alok added the bug issues reporting wrong behavior label Jan 10, 2022
@clason
Copy link
Member

clason commented Jan 10, 2022

I cannot reproduce this. Make sure the installation actually succeeded (if you've built from source yourself at some point, you may need to brew link neovim --overwrite).

@clason clason added build building and installing Neovim using the provided scripts distribution packaging and distributing Nvim to users platform:macos and removed bug issues reporting wrong behavior labels Jan 10, 2022
@alok
Copy link
Author

alok commented Jan 12, 2022

echo $VIMRUNTIME gives /usr/local/Cellar/neovim/HEAD-8f27c4a/share/nvim/runtime, which is commit 8f27c4a0417c001fa2dedb6346673da501ea78e5.

I ran brew link just in case and no change.

@lewis6991
Copy link
Member

Is this still an issue?

@orangestara
Copy link

orangestara commented Apr 6, 2022

I have the same problem:

处理 /Users/xxx/.config/nvim/init.lua 时发生错误:
E5113: Error while calling lua chunk: /Users/xxx/.config/nvim/lua/core/keybinds.lua:4: attempt to index field 'keymap' (a nil value)

actual code snippet:

vim.keymap.set("", "<Space>", "<Nop>", {noremap=true, silent=true})
vim.g.mapleader = " "

@dundargoc

This comment was marked as outdated.

@dundargoc

This comment was marked as outdated.

@muniter
Copy link
Member

muniter commented Apr 7, 2022

@orangestara can you confirm you actually have the runtime file. By running inside neovim !ls $VIMRUNTIME/lua/vim/keymap.lua and seeing the command is successful.

@juniway
Copy link

juniway commented Apr 18, 2022

@muniter
When I executed, I get this error

ls: /usr/local/Cellar/neovim/HEAD-bdfea9d_1/share/nvim/runtime/lua/vim/keymap.lua: No such file or directory

my nvim version is:

NVIM v0.7.0-dev+719-gbdfea9d9a
Build type: Release
LuaJIT 2.1.0-beta3

@juniway
Copy link

juniway commented Apr 18, 2022

image

If I call :lua vim.keymap.set() manually, I also get this:

CleanShot 2022-04-18 at 12 41 21@2x

@clason
Copy link
Member

clason commented Apr 18, 2022

This means your Neovim installation is broken. Remove Neovim (manually, if needed), then reinstall (with --overwrite --force, if needed).

@clason
Copy link
Member

clason commented Apr 18, 2022

Now that Neovim 0.7 is released, you should just brew install neovim (no need to build from source).

@clason clason closed this as completed Apr 18, 2022
@juniway
Copy link

juniway commented Apr 19, 2022

@clason I re-installed neovim, but the problems still exist when I do :lua vim.keymap.set()
CleanShot 2022-04-19 at 14 11 18@2x

NVIM v0.8.0-dev+10-ge73ef5c09
Build type: Release
LuaJIT 2.1.0-beta3

@zeertzjq
Copy link
Member

@clason I re-installed neovim, but the problems still exist when I do :lua vim.keymap.set() CleanShot 2022-04-19 at 14 11 18@2x

NVIM v0.8.0-dev+10-ge73ef5c09
Build type: Release
LuaJIT 2.1.0-beta3

It is working as intended.

@juniway
Copy link

juniway commented Apr 19, 2022

can you elaborate a little bit?

@zeertzjq
Copy link
Member

zeertzjq commented Apr 19, 2022

can you elaborate a little bit?

You must pass arguments to that function.

@juniway
Copy link

juniway commented Apr 19, 2022

@zeertzjq Thanks, suddenly Comment.nvim works, and I checked that /usr/local/Cellar/neovim/HEAD-e73ef5c/share/nvim/runtime/lua/vim/keymap.lua is actually there after reinstall neovim.

@davidc360
Copy link

Hope this helps the next person:
I kept getting keymap: no match, but manually running lua vim.keymap.set() works and I verified that keymap.lua exists.
Turns out changing the command from vim.keymap.set to lua vim.keymap.set makes it work.

@Lemanrp
Copy link

Lemanrp commented Sep 30, 2023

Can something in the instructions advise people to try adding "lua" in case of weird issues like this? I spend a few hours not figuring out why knap wasn't working on my nixos system. Same issue as Davidc360 had above and solution worked for me. thanks @davidc360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build building and installing Neovim using the provided scripts distribution packaging and distributing Nvim to users platform:macos
Projects
None yet
Development

No branches or pull requests

10 participants