Skip to content

Commit

Permalink
feat(nvim-formatter): disable formatter in filetypes
Browse files Browse the repository at this point in the history
Disable formatter in specific filetypes.
  • Loading branch information
twandylue committed Aug 12, 2023
1 parent b53b1a2 commit a828c4c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lua/plugin-config/nvim-formatter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ end

local util = require("formatter.util")

-- NOTE: Use the formatter in LSP: c, rust
formatter.setup({
logging = true,
log_level = vim.log.levels.WARN,
Expand Down Expand Up @@ -55,9 +54,15 @@ formatter.setup({
})

-- NOTE: format on save
vim.cmd([[
augroup FormatAutogroup
autocmd!
autocmd BufWritePost * FormatWrite
augroup END
]])
vim.api.nvim_create_augroup("FormatAutogroup", { clear = true })

vim.api.nvim_create_autocmd({ "BufWritePost" }, {
group = "FormatAutogroup",
callback = function()
local ft = vim.bo.filetype
-- NOTE: Use the formatter in LSP: c, cpp, rust and don't format in markdown, norg
if (ft ~= "c") and (ft ~= "cpp") and (ft ~= "rust") and (ft ~= "markdown") and (ft ~= "norg") then
vim.cmd("FormatWrite")
end
end,
})

0 comments on commit a828c4c

Please sign in to comment.