1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 12:48:01 +00:00

[neovim] Format hcl files on save

This commit is contained in:
Daniel Carrillo 2024-09-26 20:21:33 +02:00
parent 32417a0bce
commit 6c42fb1c09
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
2 changed files with 6 additions and 1 deletions

View File

@ -48,6 +48,10 @@ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
]]) ]])
end, end,
}) })
vim.api.nvim_create_autocmd("FileType", {
pattern = "hcl",
command = "setlocal shiftwidth=2 tabstop=2",
})
-- Disable some plugins on very large files -- Disable some plugins on very large files
vim.api.nvim_create_autocmd({ "BufEnter" }, { vim.api.nvim_create_autocmd({ "BufEnter" }, {

View File

@ -8,6 +8,7 @@ require("conform").setup({
python = { "isort", "black" }, python = { "isort", "black" },
typescript = { "prettier" }, typescript = { "prettier" },
yaml = { "prettier" }, yaml = { "prettier" },
hcl = { "terraform_fmt" },
}, },
formatters = { formatters = {
{ {
@ -16,7 +17,7 @@ require("conform").setup({
}, },
}, },
format_on_save = function(bufnr) format_on_save = function(bufnr)
local filetypes = { "go", "typescript", "lua" } local filetypes = { "go", "typescript", "lua", "hcl" }
if not vim.tbl_contains(filetypes, vim.bo[bufnr].filetype) then if not vim.tbl_contains(filetypes, vim.bo[bufnr].filetype) then
return return
end end