Skip to content

Commit

Permalink
refactor: conform
Browse files Browse the repository at this point in the history
  • Loading branch information
outragedline committed Jan 18, 2025
1 parent 0704971 commit 87ad87e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
36 changes: 36 additions & 0 deletions lua/fastvim/configs/conform.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>f",
function()
require("conform").format { async = true, lsp_format = "fallback" }
end,
mode = "",
desc = "[F]ormat buffer",
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
local disable_filetypes = { c = true, cpp = true }
local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = "never"
else
lsp_format_opt = "fallback"
end
return {
timeout_ms = 500,
lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = {
lua = { "stylua" },
python = { "isort", "black" },
javascript = { "prettierd", "prettier", stop_after_first = true },
},
},
}
36 changes: 0 additions & 36 deletions lua/fastvim/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,6 @@ return {
require "fastvim.configs.neokinds",
require "fastvim.configs.treesitter",

{
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>f",
function()
require("conform").format({ async = true, lsp_format = "fallback" })
end,
mode = "",
desc = "[F]ormat buffer",
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
local disable_filetypes = { c = true, cpp = true }
local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = "never"
else
lsp_format_opt = "fallback"
end
return {
timeout_ms = 500,
lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = {
lua = { "stylua" },
python = { "isort", "black" },
javascript = { "prettierd", "prettier", stop_after_first = true },
},
},
},
{
"folke/todo-comments.nvim",
event = "VimEnter",
Expand Down

0 comments on commit 87ad87e

Please sign in to comment.