Skip to content

Commit fb6af69

Browse files
sebastianstudniczekhideyosh1
authored andcommitted
Add indentation fallback
1 parent 8f791f9 commit fb6af69

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
@@ -1129,8 +1129,12 @@ require('lazy').setup {
11291129
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
11301130
vim.wo.foldmethod = 'expr'
11311131

1132+
-- check if treesitter indentation is available for this language, and if so enable it
1133+
-- in case there is no indent query, the indentexpr will fallback to the vim's built in one
1134+
local has_indent_query = vim.treesitter.query.get(language, 'indent') ~= nil
1135+
11321136
-- enables treesitter based indentation
1133-
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
1137+
if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end
11341138
end
11351139

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

0 commit comments

Comments
 (0)