6

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!

1 Answer 1

10

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'")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.