How to use vim.g

A lot of great changes have occurred over the past few updates. Given these changes, what is the recommended way to set vim.g field values? I ask because I’m no longer sure if plugin writers are using it, and whether I should as I have in the past for setting plugin-specific settings.

In context of neovim 0.10 and using the lazy plugin manager, should I be relying on vim.g to set plugin specific settings?

If so, what is the recommended way to get the lua lsp to consider the diagnostic error:

Lua Diagnostics.: Fields cannot be injected into the reference of 
`vim.var_accessor` for `diminactive_enable_focus`. To do so, 
use `---@class` for `vim.g`. [inject-field]

I could set g as a class that would include setting the table to {} prior to my writing, but that raises the question about how plugin authors use it (as I would be clearing those values in the process).

Thank you to anyone with some advice here.

1 Like