Skip to content

Commit 42cb142

Browse files
sebastianstudniczekjlonganecker
authored andcommitted
Add indentation fallback
1 parent cc82b77 commit 42cb142

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

init.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,8 +2102,12 @@ require('lazy').setup({
21022102
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
21032103
-- vim.wo.foldmethod = 'expr'
21042104

2105+
-- check if treesitter indentation is available for this language, and if so enable it
2106+
-- in case there is no indent query, the indentexpr will fallback to the vim's built in one
2107+
local has_indent_query = vim.treesitter.query.get(language, 'indent') ~= nil
2108+
21052109
-- enables treesitter based indentation
2106-
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
2110+
if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end
21072111
end
21082112

21092113
local available_parsers = require('nvim-treesitter').get_available()

0 commit comments

Comments
 (0)