diff --git a/lua/guard-collection/linter/init.lua b/lua/guard-collection/linter/init.lua index 0cb5697..744f9a3 100644 --- a/lua/guard-collection/linter/init.lua +++ b/lua/guard-collection/linter/init.lua @@ -1,11 +1,14 @@ -return { - ['clang-tidy'] = require('guard-collection.linter.clang-tidy'), - codespell = require('guard-collection.linter.codespell'), - flake8 = require('guard-collection.linter.flake8'), - hadolint = require('guard-collection.linter.hadolint'), - luacheck = require('guard-collection.linter.luacheck'), - pylint = require('guard-collection.linter.pylint'), - rubocop = require('guard-collection.linter.rubocop'), - selene = require('guard-collection.linter.selene'), - shellcheck = require('guard-collection.linter.shellcheck'), -} +local linter_dir = vim.fn.fnamemodify(debug.getinfo(1).source:sub(2), ':h') +local linter_files = vim.fn.readdir(linter_dir) + +local linters = {} + +for _, linter_file in ipairs(linter_files) do + if linter_file ~= 'init.lua' then + local linter_name = vim.fn.fnamemodify(linter_file, ':t:r') + + linters[linter_name] = require('guard-collection.linter.' .. linter_name) + end +end + +return linters