tree-sitter-angular icon indicating copy to clipboard operation
tree-sitter-angular copied to clipboard

Cant get indentation to work

Open Sitzdev opened this issue 1 year ago • 3 comments

Hi, I am currently trying to setup treesitter with Angular. But can`t get the indentation to work for the htmlangular filetype.

I am using nvim nightly as suggested (Version: NVIM v0.11.0-dev-1418+g557f2d9700)

here is my treesitter config:


return {
	"nvim-treesitter/nvim-treesitter",
	event = { "BufReadPre", "BufNewFile" },
	build = ":TSUpdate",
	dependencies = {
		"windwp/nvim-ts-autotag",
	},
	config = function()
		-- import nvim-treesitter plugin
		local treesitter = require("nvim-treesitter.configs")

		-- configure treesitter
		treesitter.setup({ -- enable syntax highlighting
			highlight = {
				enable = true,
			},
			sync_install = false,
			-- enable indentation
			indent = { enable = true },
			-- ensure these language parsers are installed
			ensure_installed = {
				"angular",
				"json",
				"javascript",
				"typescript",
				"tsx",
				"yaml",
				"html",
				"css",
				"prisma",
				"markdown",
				"markdown_inline",
				"svelte",
				"graphql",
				"bash",
				"lua",
				"vim",
				"dockerfile",
				"gitignore",
				"query",
				"vimdoc",
				"c",
				"rust",
				"astro",
			},
			incremental_selection = {
				enable = true,
				keymaps = {
					init_selection = "<C-space>",
					node_incremental = "<C-space>",
					scope_incremental = false,
					node_decremental = "<bs>",
				},
			},
		})
	end,
	{
		"windwp/nvim-ts-autotag",
		event = "InsertEnter",
		config = function()
			require("nvim-ts-autotag").setup({
				aliases = {
					["htmlangular"] = "html",
				},
			})
		end,
	},
}


when I try to move to a new line in a htmlangular file the indentation won`t work as expected

e.g.

<div>
<!-- div inserted after line break -->
<div>
</div>
</div>

I am not quite sure if I have misconfigured something. Any help is highly appreciated.

Thank you in advance!

Sitzdev avatar Dec 27 '24 17:12 Sitzdev

Did you solve it?, I'm struggling with the exact same issue :(

fcrios145 avatar Jan 21 '25 00:01 fcrios145

Hi @fcrios145,

sorry for the late answer. Unfortunately I have not found a solution to my problem. It still persists.

Sitzdev avatar Feb 08 '25 12:02 Sitzdev

This should be the minimal configuration for indentation:

require'nvim-treesitter.configs'.setup {
  indent = {
    enable = true
  }
}

Do you have something else configured in neovim regarding indentation? I also have this:

vim.o.autoindent      = true  -- Copy indent from current line
vim.o.smartindent     = true -- Make indenting smarter again

dlvandenberg avatar May 18 '25 06:05 dlvandenberg