Skip to content

Allow configuring additional Lua globals for lua_ls #68

Description

@gamedevshrimp

Hi! I noticed that defold.nvim configures lua_ls with its own diagnostics.globals:

diagnostics = {
    globals = {
        "final",
        "fixed_update",
        "init",
        "on_input",
        "on_message",
        "on_reload",
        "update",
    },
},

This works well for Defold-specific globals, but it means that user-defined globals configured elsewhere are not available when editing Lua files inside a Defold project.

For example, I have the following in my regular lua_ls configuration:

diagnostics = {
    globals = {
        "vim",
        "spine",
        "firebase",
    },
},

This works correctly in regular Lua files, but once defold.nvim attaches its lua_ls configuration, these globals are no longer recognized and I get warnings such as:

Undefined global firebase

Suggested solution

Would it be possible to make the Defold LSP globals configurable, or provide a way to extend the default list?

For example, something along these lines:

opts = {
    lsp = {
        diagnostics = {
            globals = {
                "vim",
                "spine",
                "firebase",
            },
        },
    },
}

The plugin could then merge the user-provided globals with the built-in Defold globals rather than replacing them.

For example:

globals = vim.list_extend({
    "final",
    "fixed_update",
    "init",
    "on_input",
    "on_message",
    "on_reload",
    "update",
}, user_globals or {})

This would preserve the built-in Defold globals while allowing projects/users to define additional globals.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions