Merged
Conversation
Member
|
give it a test seems like works well thanks :) |
Member
Contributor
Author
|
I am unable to reproduce this. Can you share some code for me test on? |
Member
|
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) |
Contributor
Author
|
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 |
Contributor
Author
|
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. |
Member
|
now should work thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

issue #15