Skip to content
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

feat(itero): don't start newline on empty line #911

Merged
merged 1 commit into from
May 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lua/neorg/modules/core/itero/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,21 @@ module.on_event = function(event)

local _, column = current:start()

local is_on_nonempty_line = vim.api.nvim_buf_get_lines(event.buffer, cursor_pos, cursor_pos+1, true)[1]:match("%S")
if is_on_nonempty_line then
cursor_pos = cursor_pos + 1
end

vim.api.nvim_buf_set_lines(
event.buffer,
cursor_pos + 1,
cursor_pos + 1,
cursor_pos,
cursor_pos + (is_on_nonempty_line and 0 or 1),
true,
{ string.rep(" ", column) .. text_to_repeat .. (should_append_extension and "( ) " or "") }
)
vim.api.nvim_win_set_cursor(
event.window,
{ cursor_pos + 2, column + text_to_repeat:len() + (should_append_extension and ("( ) "):len() or 0) }
{ cursor_pos + 1, column + text_to_repeat:len() + (should_append_extension and ("( ) "):len() or 0) }
)
end
end
Expand Down