diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index fc382f7..7996850 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -10,6 +10,7 @@ "dial.nvim": { "branch": "master", "commit": "27eb570085db2ef44bff4f620d3806039184651c" }, "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, "fidget.nvim": { "branch": "legacy", "commit": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6" }, + "formatter.nvim": { "branch": "master", "commit": "cb4778b8432f1ae86dae4634c0b611cb269a4c2f" }, "git-messenger.vim": { "branch": "master", "commit": "8a61bdfa351d4df9a9118ee1d3f45edbed617072" }, "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, diff --git a/config/nvim/lua/fschauen/plugins/formatter.lua b/config/nvim/lua/fschauen/plugins/formatter.lua new file mode 100644 index 0000000..a54e8ba --- /dev/null +++ b/config/nvim/lua/fschauen/plugins/formatter.lua @@ -0,0 +1,32 @@ +local M = { 'mhartington/formatter.nvim' } + +M.cmd = { + 'Format', + 'FormatLock', + 'FormatWrite', + 'FormatWriteLock', +} + +M.keys = { + { 'F', 'Format', desc = '󰉼 Format file' }, +} + +M.opts = function( --[[plugin]] _, opts) + local ft = require('formatter.filetypes') + return vim.tbl_deep_extend('force', opts or {}, { + filetype = { + c = { ft.c.clangformat }, + cmake = { ft.cmake.cmakeformat }, + cpp = { ft.cpp.clangformat }, + cs = { ft.cs.clangformat }, + json = { ft.cs.prettier }, + lua = { ft.lua.stylua }, + markdown = { ft.markdown.prettier }, + python = {}, -- TODO: pick one + sh = { ft.sh.shfmt }, + zsh = { ft.zsh.beautysh }, + } + }) +end + +return M