Skip to content

Commit

Permalink
setup pre-commit formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
WaylonWalker committed Feb 28, 2024
1 parent 9dcaf90 commit 407b428
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions nvim/.config/nvim/lua/waylonwalker/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ if settings.lazy_auto_sync then
})
end

M.pre_commit = function()
vim.api.nvim_command("PreCommit")
end

if settings.pre_commit then
-- source plugins.lua and run PackerSync on save
autocmd({ "BufWritePost" }, {
group = M.waylonwalker_augroup,
pattern = { "*.py" },
callback = M.pre_commit,
})
end

autocmd("BufWritePre", {
group = M.waylonwalker_augroup,
pattern = "*",
Expand Down
2 changes: 2 additions & 0 deletions nvim/.config/nvim/lua/waylonwalker/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,6 @@ set("n", "))", "<cmd>lua vim.diagnostic.goto_next()<CR>")

set("n", "<c-space>", "<cmd>x<cr>")

vim.api.nvim_create_user_command("PreCommit", "!pre-commit run --files %", {})

return M
4 changes: 2 additions & 2 deletions nvim/.config/nvim/lua/waylonwalker/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ local M = {}
M.packer_auto_sync = true
M.lazy_auto_sync = true
M.auto_format = true
M.pre_commit = false

function M.print()
print(vim.inspect(M))
print(vim.inspect(M))
end

-- M.auto_format = {
Expand All @@ -18,4 +19,3 @@ end
--

return M

0 comments on commit 407b428

Please sign in to comment.