forked from foxora/nix
added formatter and format on save!!!
This commit is contained in:
parent
a8a297d142
commit
35bab88ce9
14 changed files with 620 additions and 494 deletions
33
homes/modules/programs/neovim/lua/plugins/format.lua
Normal file
33
homes/modules/programs/neovim/lua/plugins/format.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- docs -> https://github.com/stevearc/conform.nvim
|
||||
return {
|
||||
{
|
||||
"conform.nvim",
|
||||
enabled = nixCats("format") or false,
|
||||
keys = {
|
||||
{ "<leader>p", desc = "Format File (pretty :3)" },
|
||||
},
|
||||
after = function(plugin)
|
||||
local conform = require("conform")
|
||||
|
||||
conform.setup({
|
||||
formatters_by_ft = {
|
||||
lua = nixCats("lang.lua.format") and { "stylua" } or nil,
|
||||
nix = nixCats("lang.nix.format") and { "nixfmt" } or nil,
|
||||
rust = nixCats("lang.rust.format") and { "rustfmt", lsp_format = "fallback" } or nil,
|
||||
haskell = nixCats("lang.haskell.format") and { "ormolu" } or nil,
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<leader>p", function()
|
||||
conform.format({
|
||||
lsp_fallback = false,
|
||||
async = false,
|
||||
timeout_ms = 1000,
|
||||
})
|
||||
end, { desc = "Format File (pretty :3)" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue