nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.39k stars 69 forks source link

on_attach doesn't get run if one of the configs throws an error #87

Closed qoobes closed 5 months ago

qoobes commented 5 months ago

FAQ

Issues

Neovim Version

v0.9.5

Dev Version?

Operating System

OSX

Minimal Config

-- this template is borrowed from nvim-lspconfig
local on_windows = vim.loop.os_uname().version:match("Windows")
local function join_paths(...)
    local path_sep = on_windows and "\\" or "/"
    local result = table.concat({ ... }, path_sep)
    return result
end

vim.g.loaded_remote_plugins = ""
vim.cmd([[set runtimepath=$VIMRUNTIME]])

local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))

local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")

local null_ls_config = function()
    local null_ls = require("null-ls")
    -- add only what you need to reproduce your issue
    null_ls.setup({
        sources = {
            null_ls.builtins.diagnostics.eslint_d,
            null_ls.builtins.formatting.gofmt,
        },
        debug = true,
    })
end

local function load_plugins()
    -- only add other plugins if they are necessary to reproduce the issue
    require("packer").startup({
        {
            "wbthomason/packer.nvim",
            {
                "nvimtools/none-ls.nvim",
                requires = { "nvim-lua/plenary.nvim" },
                config = null_ls_config,
            },
        },
        config = {
            package_root = package_root,
            compile_path = compile_path,
        },
    })
end

if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
    load_plugins()
    require("packer").sync()
else
    load_plugins()
    require("packer").sync()
end

Steps to Reproduce

  1. Open a .go file

That's it. The on_attach won't get run, and more importantly doing :NullLsInfo will yield no sources attached, even though gofmt should be attached.

Now, you can try deleting the eslint_d source, and then it'll work fine.

Reproducibility Check

Expected Behavior

Gofmt should work in go files and on_attach should be run, regardless of whether one of the sources throws an error.

Actual Behavior

I get the following error in the console: [null-ls] failed to load builtin eslint_d for method diagnostics; please check your config And no sources are loaded

Debug Log

[WARN  Tue Mar  5 16:51:14 2024] /Users/ahmed/.local/share/nvim/site/pack/packer/start/none-ls.nvim/lua/null-ls/builtins/init.lua:17: failed to load builtin eslint_d for method diagnostics; please check your config

Help

No

Implementation Help

No response

Requirements

qoobes commented 5 months ago

Ok a small update, after this kept not working, I've just noticed that eslint_d and a few other sources have been completely removed. Does anyone know why this happened?

mochaaP commented 5 months ago

Search for eslint_d in #81. You should migrate to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#eslint or use https://github.com/nvimtools/none-ls-extras.nvim