在 NeoVim init.lua 中设置 Vim 插件选项

发布于 2025-01-18 16:26:26 字数 193 浏览 1 评论 0原文

我想设置具有vimscript格式的VIM插件选项,让我的neovim init.lua files in neovim File,我无法弄清楚如何设置这些选项的格式是新近尊重的。

我已经尝试使用vim.cmd(“让某些#选项=选项”),但这似乎不起作用。有建议吗?谢谢!

I want to set vim plugin options that have the vimscript format let some#option = option inside my NeoVim init.lua file, but I can't figure out how to set these options in a format that NeoVim respects.

I've tried using vim.cmd("let some#option = option") but this doesn't seem to work. Any advice? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

━╋う一瞬間旳綻放 2025-01-25 16:26:26

来自 nanotee/nvim-lua-guide,关于 管理vim内部变量显示各种API调用,包括

在实践中,设置全局变量看起来像

vim.api.nvim_set_var('some#var', 'value')

您也可以使用 元访问器,例如 vim.g

vim.g['some#var'] = 'value'

使用vmd.cmd 可以工作,尽管使用了 more建议使用上面所示的结构化 API。

请注意,在 vim.cmd("let some#option = option") 中,赋值运算符的右侧是一个表达式。这意味着普通令牌 option 将被评估为标识符。

根据您想要执行的操作,您可能需要添加其他引号来创建字符串。

vim.cmd("let some#var = 'value'")

From nanotee/nvim-lua-guide, the section on Managing vim internal variables shows various API calls, including

In practice, setting a global variable looks like

vim.api.nvim_set_var('some#var', 'value')

You can also use the meta-accessors, such as vim.g:

vim.g['some#var'] = 'value'

The method with vmd.cmd can work, although using the more structured API shown above is advised.

Note that in vim.cmd("let some#option = option") the right-hand side of the assignment operator is an expression. This means the plain token option would be evaluated as an identifier.

Depending on what you are trying to do, you may need to add additional quotes to create a string.

vim.cmd("let some#var = 'value'")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文