【发布时间】:2022-08-04 07:56:03
【问题描述】:
如何在 lua nvim 配置中映射 shell 命令?
maps.n[\"<F4>\"] = { function() io.popen(\"python3 \" + vim.fn.expand(\"%\")) end, desc = \"Run current Python file\"}
错误:
E5108: Error executing lua: /home/kobe/.config/nvim/lua/core/mappings.lua:19: attempt to perform arithmetic on a string value
stack traceback:
/home/kobe/.config/nvim/lua/core/mappings.lua:19: in function </home/kobe/.config/nvim/lua/core/mappings.lua:19>
-
当它说“请不要对字符串进行算术运算”时,也许你可以猜到在 Lua 中没有使用“str1 + str2”?毕竟,Lua 是一种不同的语言,它没有义务像那些“pythonistas”那样做所有事情。想先阅读lua.org/manual/5.1/manual.html#2.5 吗?
-
这看起来不像您在 lua 中映射键的方式。你在使用插件吗?可能是
which-key.nvim?