Skip to content

Commit

Permalink
feat(lua): only enable selene linting if selene.toml exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Sep 20, 2024
1 parent b0ae1be commit 5b06dd4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/astrocommunity/pack/lua/init.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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,
},
{
Expand All @@ -55,6 +68,9 @@ return {
linters_by_ft = {
lua = { "selene" },
},
linters = {
selene = { condition = function(ctx) return selene_configured(ctx.filename) end },
},
},
},
}

0 comments on commit 5b06dd4

Please sign in to comment.