mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-10 15:30:01 -04:00
Fix indent size
Indent size should equal shiftwidth, unless shiftwidth is 0 in which case tabstop should be used.
This commit is contained in:
parent
445d16ccae
commit
bdbae28b24
1 changed files with 1 additions and 5 deletions
|
|
@ -39,10 +39,6 @@ local get_indents = utils.memoize_by_buf_tick(function(bufnr)
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function get_indent_size()
|
|
||||||
return vim.bo.softtabstop > 0 and vim.bo.shiftwidth or vim.bo.tabstop
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.get_indent(lnum)
|
function M.get_indent(lnum)
|
||||||
local parser = parsers.get_parser()
|
local parser = parsers.get_parser()
|
||||||
if not parser or not lnum then return -1 end
|
if not parser or not lnum then return -1 end
|
||||||
|
|
@ -52,7 +48,7 @@ function M.get_indent(lnum)
|
||||||
local node = get_node_at_line(root, lnum-1)
|
local node = get_node_at_line(root, lnum-1)
|
||||||
|
|
||||||
local indent = 0
|
local indent = 0
|
||||||
local indent_size = get_indent_size()
|
local indent_size = vim.fn.shiftwidth()
|
||||||
|
|
||||||
-- to get corret indetation when we land on an empty line (for instance by typing `o`), we try
|
-- to get corret indetation when we land on an empty line (for instance by typing `o`), we try
|
||||||
-- to use indentation of previous nonblank line, this solves the issue also for languages that
|
-- to use indentation of previous nonblank line, this solves the issue also for languages that
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue