Move conform and nvim-lint configuration

This commit is contained in:
Oliver Davies 2024-02-26 19:42:28 +00:00
parent 4efdebcb0e
commit 129a2dc990
3 changed files with 30 additions and 44 deletions

View file

@ -2,10 +2,17 @@ local conform = require "conform"
conform.setup {
formatters_by_ft = {
rst = { "rstfmt" },
bash = { "shellcheck" },
javascript = { { "prettierd", "prettier" } },
just = { "just" },
lua = { "stylua" },
nix = { { "alejandra", "nixfmt" } },
php = { { "php_cs_fixer", "phpcbf" } },
terraform = { "terraform_fmt" },
yaml = { "yamlfmt" },
},
}
conform.formatters.rstfmt = {
command = "rstfmt";
}
vim.keymap.set("n", "<leader>f", function()
conform.format { lsp_fallback = true, async = false, timeout_ms = 500 }
end)

19
after/plugin/lint.lua Normal file
View file

@ -0,0 +1,19 @@
local lint = require "lint"
lint.linters_by_ft = {
dockerfile = { "hadolint" },
javascript = { "eslint_d" },
json = { "jsonlint" },
lua = { "luacheck" },
markdown = { "markdownlint" },
nix = { "nix" },
php = { "php", "phpcs", "phpstan" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})

View file

@ -159,43 +159,3 @@ vim.diagnostic.config {
update_in_insert = false,
virtual_text = { spacing = 2 },
}
local conform = require "conform"
conform.setup {
formatters_by_ft = {
bash = { "shellcheck" },
javascript = { { "prettierd", "prettier" } },
just = { "just" },
lua = { "stylua" },
nix = { { "alejandra", "nixfmt" } },
php = { { "php_cs_fixer", "phpcbf" } },
terraform = { "terraform_fmt" },
yaml = { "yamlfmt" },
},
}
vim.keymap.set("n", "<leader>f", function()
conform.format { lsp_fallback = true, async = false, timeout_ms = 500 }
end)
local lint = require "lint"
lint.linters_by_ft = {
dockerfile = { "hadolint" },
javascript = { "eslint_d" },
json = { "jsonlint" },
lua = { "luacheck" },
markdown = { "markdownlint" },
nix = { "nix" },
php = { "php", "phpcs", "phpstan" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})