Skip to content

Commit

Permalink
use conform rather than ALE
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Dec 23, 2024
1 parent 7d97ef0 commit 80c7048
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 39 deletions.
39 changes: 0 additions & 39 deletions lua/plugins/ale.lua

This file was deleted.

57 changes: 57 additions & 0 deletions lua/plugins/conform.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable autoformat-on-save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save",
})

return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier", "eslint", },
typescript = { "prettier", "eslint" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
svelte = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
ruby = { 'rubocop' },
["*"] = { "trim_whitespace" },
},
format_after_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end

return {
lsp_fallback = true,
async = true,
}
end,
formatters = {
rubocop = {
args = { "--server", "--auto-correct-all", "--stderr", "--force-exclusion", "--stdin", "$FILENAME" }
}
}
})
end,
}

0 comments on commit 80c7048

Please sign in to comment.