Skip to content

Commit

Permalink
formatter update
Browse files Browse the repository at this point in the history
  • Loading branch information
bangalcat committed Sep 11, 2024
1 parent 2fae87c commit 663954f
Showing 1 changed file with 1 addition and 68 deletions.
69 changes: 1 addition & 68 deletions lua/plugins/formatter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,8 @@ return {
"stevearc/conform.nvim",
opts = {
formatters = {
shfmt = {
prepend_args = { "-i", "2", "-ci" },
},
shfmt = {},
},
},
},
{
"mhartington/formatter.nvim",
enabled = false,
cmd = { "FormatWrite" },
event = { "BufReadPre", "BufNewFile" },
keys = {
{ "<leader>bf", "<cmd>Format<CR>", mode = "n", silent = true },
},
config = function()
local util = require("formatter.util")

local L = {}
function L.rubocop()
return {
exe = "./bin/rubocop",
args = {
"--fix-layout",
"--stdin",
util.escape_path(util.get_current_buffer_file_name()),
"--format",
"files",
},
stdin = true,
transform = function(text)
table.remove(text, 1)
table.remove(text, 1)
return text
end,
}
end

require("formatter").setup({
-- Enable or disable logging
logging = true,
-- Set the log level
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
-- Formatter configurations for filetype "lua" go here
-- and will be executed in order
-- elixir = { require("formatter.filetypes.elixir").mixformat },
-- lua = { require("formatter.filetypes.lua").stylua },
-- markdown = { markdown_format },
-- telekasten = { markdown_format },
ruby = { L.rubocop },

-- Use the special "*" filetype for defining formatter configurations on
-- any filetype
["*"] = {
-- "formatter.filetypes.any" defines default configurations for any
-- filetype
-- require("formatter.filetypes.any").remove_trailing_whitespace,
},
},
})

-- formatter setup
vim.api.nvim_create_augroup("FormatAutogroup", { clear = true })
vim.api.nvim_create_autocmd("BufWritePost", {
-- pattern = ".md",
group = "FormatAutogroup",
command = "FormatWrite",
})
end,
},
}

0 comments on commit 663954f

Please sign in to comment.