From 2f6ddcce43d25cdcf7fa8e9e9c4601c0c71af337 Mon Sep 17 00:00:00 2001 From: Matt Leong <mattleong91@gmail.com> Date: Tue, 28 Dec 2021 18:02:43 -0800 Subject: [PATCH] fix(lsp): readd eslint condition --- lua/cosmic/lsp/providers/null_ls.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/cosmic/lsp/providers/null_ls.lua b/lua/cosmic/lsp/providers/null_ls.lua index 1caa2f5..eaa4351 100644 --- a/lua/cosmic/lsp/providers/null_ls.lua +++ b/lua/cosmic/lsp/providers/null_ls.lua @@ -4,17 +4,28 @@ local config = require('cosmic.config') local null_ls = require('null-ls') local config_opts = config.lsp.servers.null_ls or {} +local has_eslint_config = function(u) + return u.root_has_file('.eslintrc') + or u.root_has_file('.eslintrc.json') + or u.root_has_file('.eslintrc.js') + or u.root_has_file('package.json') + or u.root_has_file('.eslintrc.cjs') + or u.root_has_file('.eslintrc.yaml') + or u.root_has_file('.eslintrc.yml') +end require('null-ls').setup(utils.merge({ - -- you must define at least one source for the plugin to work sources = { null_ls.builtins.code_actions.eslint_d.with({ + condition = has_eslint_config, prefer_local = 'node_modules/.bin', }), null_ls.builtins.diagnostics.eslint_d.with({ + condition = has_eslint_config, prefer_local = 'node_modules/.bin', }), null_ls.builtins.formatting.eslint_d.with({ + condition = has_eslint_config, prefer_local = 'node_modules/.bin', }), null_ls.builtins.formatting.prettier.with({