use conform instead of formatter

This commit is contained in:
Christian Nieves
2024-01-06 07:35:12 -06:00
parent 7c53740379
commit cbb6f0cb51
3 changed files with 69 additions and 148 deletions

View File

@ -0,0 +1,36 @@
return {
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
-- Conform will run multiple formatters sequentially
-- go = { "goimports", "gofmt" },
-- Use a sub-list to run only the first available formatter
-- javascript = { { "prettierd", "prettier" } },
lua = { "stylua" },
-- Conform will run multiple formatters sequentially
python = { "isort", "black" },
-- Use a sub-list to run only the first available formatter
javascript = { { "prettierd", "prettier" } },
gdscript = { "gdformat" },
dashboard = {},
-- Use the "*" filetype to run formatters on all filetypes.
["*"] = { "codespell" },
-- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured.
["_"] = { "trim_whitespace" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_fallback = true,
},
formatters = {
my_formatter = {
command = "gdformat",
args = { "-l 100" },
},
},
},
},
}

View File

@ -1,115 +0,0 @@
return {
"mhartington/formatter.nvim",
config = function()
-- Utilities for creating configurations
local util = require("formatter.util")
vim.cmd([[
augroup FormatAutogroup
autocmd!
autocmd BufWritePost * FormatWrite
augroup END
]])
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
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
lua = {
-- "formatter.filetypes.lua" defines default configurations for the
-- "lua" filetype
-- require("formatter.filetypes.lua").stylua,
-- You can also define your own configuration
function()
-- Supports conditional formatting
if util.get_current_buffer_file_name() == "special.lua" then
return nil
end
-- Full specification of configurations is down below and in Vim help
-- files
return {
exe = "stylua",
args = {
"--search-parent-directories",
"--stdin-filepath",
util.escape_path(util.get_current_buffer_file_path()),
"--",
"-",
},
stdin = true,
}
end,
},
html = {
require("formatter.defaults").prettier,
},
cs = {
-- require("formatter.filetypes.cs").astyle,
-- require("formatter.filetypes.cs").uncrustify,
require("formatter.filetypes.cs").clangformat,
-- require("formatter.filetypes.cs").dotnetformat,
},
gdscript = {
function()
return {
exe = "gdformat",
args = {
"-l 100",
},
}
end,
},
xml = {
function()
return {
exe = "tidy",
args = {
"-xml",
"-quiet",
"-wrap",
"--tidy-mark",
"no",
"--indent",
"yes",
"--indent-spaces",
"2",
"--indent-attributes",
"yes",
"--sort-attributes",
"alpha",
"--wrap-attributes",
"yes",
"--vertical-space",
"yes",
"-",
},
stdin = true,
}
end,
},
-- java = {
-- function()
-- return {
-- exe = "google-java-format",
-- }
-- end,
-- },
-- 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,
},
},
})
end,
}