Skip to content

Commit

Permalink
fix(nvim): only use prettier if there's a config for it
Browse files Browse the repository at this point in the history
  • Loading branch information
mscharley committed Oct 10, 2024
1 parent a12ec56 commit 29a72a5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xdg-config/nvim%lua%usermod/plugins/formatter.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
require('usermod.vimplug')('mhartington/formatter.nvim', {
config = function()
local formatters = {}
local prettierrc = vim.fs.find('.prettierrc', { path = "./", type = "file", upward = true })
if #prettierrc > 0 then
table.insert(formatters, require('formatter.defaults.prettier'))
end

require('formatter').setup({
logging = true,
log_level = vim.log.levels.WARN,
filetype = {
['*'] = {
require('formatter.defaults.prettier'),
},
['*'] = formatters,
},
})
vim.api.nvim_create_augroup("__formatter__", { clear = true })
Expand Down

0 comments on commit 29a72a5

Please sign in to comment.