-
Notifications
You must be signed in to change notification settings - Fork 18
support for tab indentation #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
give it a test seems like works well thanks :) |
|
I am unable to reproduce this. Can you share some code for me test on? |
|
because of modeline . eg vim source code when i develop the feature of vim i notice that. just in C file the header is set tabstop to 8 shiftwidth to 4 noexpandtab (modeline) |
|
this somewhat fixes it: @@ -96,6 +96,7 @@ local function on_line(_, _, bufnr, row)
local bot_indent = bot_row >= 0 and find_in_snapshot(bot_row + 1) or 0
indent = math.max(top_indent, bot_indent)
end
+ if not vim.o.expandtab then cache.shiftwidth = vim.o.tabstop end
for i = 1, indent - 1, cache.shiftwidth do
local col = i - 1
local level = math.floor(col / cache.shiftwidth) + 1for doing this properly instead of saving |
|
this should be correct solution I think: @@ -72,7 +72,7 @@ local function find_row(row, curindent, direction, render)
return INVALID
end
-local function current_line_range(winid, shiftw)
+local function current_line_range(winid, step)
local row = api.nvim_win_get_cursor(winid)[1] - 1
local indent, _ = find_in_snapshot(row + 1)
if indent == 0 then
@@ -80,7 +80,7 @@ local function current_line_range(winid, shiftw)
end
local top_row = find_row(row, indent, UP, false)
local bot_row = find_row(row, indent, DOWN, false)
- return top_row, bot_row, math.floor(indent / shiftw)
+ return top_row, bot_row, math.floor(indent / step)
end
local function on_line(_, _, bufnr, row)
@@ -96,9 +96,9 @@ local function on_line(_, _, bufnr, row)
local bot_indent = bot_row >= 0 and find_in_snapshot(bot_row + 1) or 0
indent = math.max(top_indent, bot_indent)
end
- for i = 1, indent - 1, cache.shiftwidth do
+ for i = 1, indent - 1, cache.step do
local col = i - 1
- local level = math.floor(col / cache.shiftwidth) + 1
+ local level = math.floor(col / cache.step) + 1
local higroup = 'IndentLine'
if row > cache.reg_srow and row < cache.reg_erow and level == cache.cur_inlevel then
higroup = 'IndentLineCurrent'
@@ -126,9 +126,10 @@ local function on_win(_, winid, bufnr, toprow, botrow)
end
api.nvim_win_set_hl_ns(winid, ns)
cache.leftcol = vim.fn.winsaveview().leftcol
- cache.shiftwidth = get_shiftw_value(bufnr)
+ cache.step = get_shiftw_value(bufnr)
+ if not vim.o.expandtab then cache.step = vim.o.tabstop end
cache.count = api.nvim_buf_line_count(bufnr)
- cache.reg_srow, cache.reg_erow, cache.cur_inlevel = current_line_range(winid, cache.shiftwidth)
+ cache.reg_srow, cache.reg_erow, cache.cur_inlevel = current_line_range(winid, cache.step)
for i = toprow, botrow do
cache.snapshot[i + 1] = { get_indent_lnum(i + 1), line_is_empty(i + 1) }
endyou would need the C function to get tabstop value. |
|
now should work thanks |

issue #15