Skip to content

Commit

Permalink
better behavior on blank line
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Apr 28, 2024
1 parent ca11ddf commit 61e4707
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ local function indentline(opt)
return
end
local line_is_empty = #lines[1] == 0
local shiftw = vim.fn.shiftwidth()
if indent == 0 and line_is_empty then
local prev_row = row - 1
while true do
Expand All @@ -42,15 +43,14 @@ local function indentline(opt)
local prev_indent = indent_fn(prev_row + 1)
if prev_indent == 0 and #lines[1] ~= 0 then
break
else
indent = prev_indent
elseif #lines[1] ~= 0 and prev_indent > 0 then
indent = prev_indent + shiftw
break
end
prev_row = prev_row - 1
end
end

local shiftw = vim.fn.shiftwidth()
local last_defined_level = 0
for i = 1, indent - 1, shiftw do
local col = i - 1
Expand Down
9 changes: 9 additions & 0 deletions test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local function test_tab()
if true then
if true then
if true then
print('hello')
end
end
end
end

0 comments on commit 61e4707

Please sign in to comment.