Closed v3natio closed 1 week ago
In the meantime, I've found this configuration by folke, here's a snippet:
{
"mfussenegger/nvim-lint",
opts = {
linters_by_ft = {
lua = { "selene", "luacheck" },
},
linters = {
selene = {
condition = function(ctx)
local root = LazyVim.root.get({ normalize = true })
if root ~= vim.uv.cwd() then
return false
end
return vim.fs.find({ "selene.toml" }, { path = root, upward = true })[1]
end,
},
luacheck = {
condition = function(ctx)
local root = LazyVim.root.get({ normalize = true })
if root ~= vim.uv.cwd() then
return false
end
return vim.fs.find({ ".luacheckrc" }, { path = root, upward = true })[1]
end,
},
},
},
},
With the idea from the solution above I realized I could leverage lsp
's functionality to get the root directory of a project, and pass that onto the cwd
argument of nvim-lint
.
So instead of:
callback = function()
lint.try_lint()
end,
we replace it with:
callback = function()
local client = vim.lsp.get_clients({ bufnr = 0 })[1] or {}
lint.try_lint(nil, { cwd = client.root_dir })
end,
This either takes the cwd
from lsp
, or won't set one at all, making it usable in all cases.
Hi, I've installed
selene
throughMason
. This is my current configuration:Now, my issue is that I'm not sure how to properly set up
selene
. The thing is, I've got aselene.toml
file in the./nvim/
folder, and here are it's contents:If I
cd
into the./nvim/
directory from my terminal, and then open a.lua
file, then selene works as expected. Otherwise, if I don't open it from that directory, then the configuration won't be loaded.selene
itself does work, but the configuration to ignore the vim globals won't.