(neovim) move coding related components to extra loaded configuration
This commit is contained in:
parent
1d969481df
commit
86cf2fa9d4
21 changed files with 185 additions and 156 deletions
101
config/common/nvim/lua/plugins/extra/linters.lua
Normal file
101
config/common/nvim/lua/plugins/extra/linters.lua
Normal file
|
@ -0,0 +1,101 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
cmd = "Mason",
|
||||
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
|
||||
build = ":MasonUpdate",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"ansible-language-server",
|
||||
"ansible-lint",
|
||||
"lua-language-server",
|
||||
"markdownlint-cli2",
|
||||
"marksman",
|
||||
"shfmt",
|
||||
"stylua",
|
||||
"terraform-ls",
|
||||
"tflint",
|
||||
"yaml-language-server",
|
||||
"yamlfix",
|
||||
"yamllint",
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("mason").setup(opts)
|
||||
local mr = require("mason-registry")
|
||||
local function ensure_installed()
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
if mr.has_package(tool) then
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
vim.notify("Mason: Installing " .. tool .. "...", vim.log.levels.INFO)
|
||||
p:install():once("closed", function()
|
||||
if p:is_installed() then
|
||||
vim.notify("Mason: Successfully installed " .. tool, vim.log.levels.INFO)
|
||||
else
|
||||
vim.notify("Mason: Failed to install " .. tool, vim.log.levels.ERROR)
|
||||
end
|
||||
end)
|
||||
end
|
||||
else
|
||||
vim.notify("Mason: Package '" .. tool .. "' not found", vim.log.levels.WARN)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if mr.refresh then
|
||||
mr.refresh(ensure_installed)
|
||||
else
|
||||
ensure_installed()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
require("lint").linters_by_ft = {
|
||||
markdown = { "markdownlint-cli2" },
|
||||
terraform = { "terraform_validate" },
|
||||
tf = { "terraform_validate" },
|
||||
yaml = { "yamllint" },
|
||||
}
|
||||
|
||||
local markdownlint = require("lint").linters["markdownlint-cli2"]
|
||||
markdownlint.args = {
|
||||
"--config",
|
||||
vim.fn.stdpath("config") .. "/lua/config/global.markdownlint-cli2.yaml",
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
callback = function()
|
||||
require("lint").try_lint()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = { "mason.nvim" },
|
||||
config = function()
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
["terraform-vars"] = { "terraform_fmt" },
|
||||
bash = { "shfmt" },
|
||||
lua = { "stylua" },
|
||||
markdown = { "markdownlint-cli2" },
|
||||
sh = { "shfmt" },
|
||||
terraform = { "terraform_fmt" },
|
||||
tf = { "terraform_fmt" },
|
||||
zsh = { "shfmt" },
|
||||
yaml = { "yamlfix" },
|
||||
},
|
||||
format_on_save = {
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue