return { "nvimtools/none-ls.nvim", dependencies = { "nvimtools/none-ls-extras.nvim", }, config = function() local null_ls = require("null-ls") local utils = require("dnsc.utils") local string_starts_with = function(str, start) return string.sub(str, 1, #start) == start end local create_runtime_condition = function(config_names) local bufnr_cache = {} local config_path_cache = {} return function(params) if bufnr_cache[params.bufnr] ~= nil then return bufnr_cache[params.bufnr] else for _, cached_config_path in ipairs(config_path_cache) do if string_starts_with(params.bufname, cached_config_path) then bufnr_cache[params.bufnr] = true return true end end end local config_path = utils.root_pattern(config_names)(params.bufname) local has_config = config_path ~= nil if has_config then table.insert(config_path_cache, config_path) end bufnr_cache[params.bufnr] = has_config return has_config end end local eslint_runtime_condition = create_runtime_condition({ ".eslintrc.cjs", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yaml", ".eslintrc.yml", "eslint.config.mjs", "eslint.config.js", "eslint.config.ts", "eslint.config.mts", }) null_ls.setup({ sources = { require("none-ls.code_actions.eslint_d"), require("none-ls.diagnostics.eslint_d").with({ runtime_condition = eslint_runtime_condition, }), }, }) end, }