mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-21 12:50:09 -04:00
feat(indent): use proper shiftwidth for injected languages
This commit is contained in:
parent
ee8e149a4f
commit
7d973dafdb
1 changed files with 4 additions and 0 deletions
|
|
@ -189,6 +189,10 @@ function M.get_indent(lnum)
|
|||
if root_start ~= 0 then
|
||||
-- injected tree
|
||||
indent = vim.fn.indent(root:start() + 1)
|
||||
-- With an injected tree, we have a different language than the filetype of the current buffer,
|
||||
-- so it doesn't make sense to use the value of 'shiftwidth' for the current buffer. Instead, we
|
||||
-- get the default 'shiftwidth' for this filetype!
|
||||
indent_size = vim.api.nvim_get_option_value("shiftwidth", { filetype = lang_tree:lang() })
|
||||
end
|
||||
|
||||
-- tracks to ensure multiple indent levels are not applied for same line
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue