What is the default tab width for the templ formatter? #610
-
Templ version is:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Tab width is not something that templ could define, it will lie with your editor. |
Beta Was this translation helpful? Give feedback.
-
@joerdav I am experiencing some weird behavior that makes me think otherwise. I have quadruple checked on multiple different filetypes, including the go files within the server, and they all have 2 spaces as the tab width, as defined by my neovim config: vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.autoindent = true I only get the strange 8 char tab width in templ files, such as this: templ showcase(developments []models.Development) {
<div class="space-y-36 py-10">
for _, d := range developments {
<div
class={
"flex items-center justify-between",
"md:even:flex-row-reverse md:odd:flex-row flex-col",
}
>
<div
class={
"parallax md:w-[75%] w-full aspect-square rounded-lg bg-fixed",
bgImage(utils.GetPrimaryImage(d.Images)),
}
></div>
<div
class="p-8 rounded-lg shadow-lg relative z-10
prose w-full md:max-w-[35%]"
>
<a
href={ templ.SafeURL(fmt.Sprintf("/developments/%d", d.ID)) }
class="text-2xl link font-bold"
>
{ d.Name }
</a>
<p>{ d.Description }</p>
</div>
</div>
}
</div>
} For example, this is part of a html file that I have formatted via format on save: <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=5"
/> It has 2 spaces as tab indents, as expected. The only filetype I have an issue with is templ. |
Beta Was this translation helpful? Give feedback.
-
Also, if I run templ fmt from the terminal, and cat the file, I get the same issue, which is making me believe that it is in fact templ that is enforcing the tabs, and not my editor. I can set the tab width in neovim, which makes it look much better, but when I copy the code and paste (as above) I see that it is actually using tabs to format the file |
Beta Was this translation helpful? Give feedback.
-
@joerdav Sorry about this. Turns out it was the vim-sleuth plugin that was changing the tabstop to 8. |
Beta Was this translation helpful? Give feedback.
Tab width is not something that templ could define, it will lie with your editor.