Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/astrocommunity/pack/lua/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ This plugin pack does the following:
- Adds `lua_ls` language server
- Adds `stylua` formatter
- Adds `selene` linter
- On `aarch64` machines this is skipped.
60 changes: 42 additions & 18 deletions lua/astrocommunity/pack/lua/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@ local function selene_configured(path)
return #vim.fs.find("selene.toml", { path = path, upward = true, type = "file" }) > 0
end

local is_aarch64 = vim.loop.os_uname().machine == "aarch64"

return {
{
"AstroNvim/astrolsp",
optional = true,
opts = {
config = {
lua_ls = { settings = { Lua = { hint = { enable = true, arrayIndex = "Disable" } } } },
lua_ls = {
settings = {
Lua = {
hint = {
enable = true,
arrayIndex = "Disable",
},
},
},
},
},
},
},
Expand All @@ -32,14 +43,21 @@ return {
"jay-babu/mason-null-ls.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "stylua", "selene" })
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, {
"stylua",
(not is_aarch64 and "selene") or nil,
})

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,
})

if not is_aarch64 then
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
end,
Expand All @@ -48,8 +66,11 @@ return {
"WhoIsSethDaniel/mason-tool-installer.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed =
require("astrocore").list_insert_unique(opts.ensure_installed, { "lua-language-server", "stylua", "selene" })
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, {
"lua-language-server",
"stylua",
(not is_aarch64 and "selene") or nil,
})
end,
},
{
Expand All @@ -64,13 +85,16 @@ return {
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
lua = { "selene" },
},
linters = {
selene = { condition = function(ctx) return selene_configured(ctx.filename) end },
},
},
opts = function(_, opts)
if not is_aarch64 then
opts.linters_by_ft = {
lua = { "selene" },
}
opts.linters = opts.linters or {}
opts.linters.selene = {
condition = function(ctx) return selene_configured(ctx.filename) end,
}
end
end,
},
}