jay-babu / mason-null-ls.nvim

GNU Affero General Public License v3.0
549 stars 22 forks source link

Automatic installation behavior contradicts documentation #97

Closed pwnalone closed 5 months ago

pwnalone commented 6 months ago

I'm currently using the first method (primary source of truth is mason-null-ls) for automatic setup, but it does not seem to work when using the order specified in the README.

-- Using lazy.nvim plugin manager
return {
    {
        "williamboman/mason-lspconfig.nvim",
        dependencies = { "neovim/nvim-lspconfig", "mason.nvim" },
        opts = {
            ensure_installed = { "lua_ls" },
            handlers = {
                function(lsp)
                    require("lspconfig")[lsp].setup({})
                end,
            },
        },
    },
    {
        "jay-babu/mason-null-ls.nvim",
        dependencies = { "nvimtools/none-ls.nvim", "mason.nvim" },
        opts = {
            ensure_installed = { "stylua" },
            handlers = {},
        },
        config = function(opts)
            require('mason-null-ls').setup(opts)
            require('null-ls').setup({
                sources = {
                    -- none
                }
            })
        end,
    },
    {
        "williamboman/mason.nvim",
        opts = {},
    },
}

Running :NullLsInfo shows that there is no attached language server. Getting rid of the config function entirely seems to fix the issue, but then the setup for null-ls is not executed, so I don't have access to the functions it exposes (e.g. :NullLsInfo). Requiring null-ls first inside the config function doesn't fix the issue, but, strangely enough, adding an opts = {} entry to the dependency specification for null-ls gets it to work.

    ...
    {
        "jay-babu/mason-null-ls.nvim",
        dependencies = { { "nvimtools/none-ls.nvim", opts = {} }, "mason.nvim" },
        opts = {
            ensure_installed = { "stylua" },
            handlers = {},
        },
    },
    ...

From my understanding of lazy.nvim, this means that null-ls will be setup before mason-null-ls, which is the opposite of what the README says is needed when using mason-null-ls as the source of truth. I'm confused though why this method worked, but swapping the order of the require-statements inside the config function did not.

I'm new to Lua, so I don't yet know how everything works, but I'm concerned that this could be a race condition between the setup of null-ls and mason-null-ls and that I'm only observing it when the setup routines for both modules are executed closely together in the config function.

Thank you for your time, and please let me know what is the correct way to enable automatic setup using mason-null-ls as the source of truth.

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

github-actions[bot] commented 5 months ago

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

jay-babu commented 4 months ago

you need to setup null-ls before mason-null-ls