diff --git a/lua/astrocommunity/pack/lua/init.lua b/lua/astrocommunity/pack/lua/init.lua index f4e621750..db9eee282 100644 --- a/lua/astrocommunity/pack/lua/init.lua +++ b/lua/astrocommunity/pack/lua/init.lua @@ -1,3 +1,7 @@ +local function selene_configured(path) + return #vim.fs.find("selene.toml", { path = path, upward = true, type = "file" }) > 0 +end + return { { "AstroNvim/astrolsp", @@ -29,6 +33,15 @@ return { optional = true, opts = function(_, opts) opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "stylua", "selene" }) + if not opts.handlers then opts.handlers = {} end + opts.handlers.selene = function(source_name, methods) + local null_ls = require "null-ls" + for _, method in ipairs(methods) do + null_ls.register(null_ls.builtins[method][source_name].with { + runtime_condition = function(params) return selene_configured(params.bufname) end, + }) + end + end end, }, { @@ -55,6 +68,9 @@ return { linters_by_ft = { lua = { "selene" }, }, + linters = { + selene = { condition = function(ctx) return selene_configured(ctx.filename) end }, + }, }, }, }