Skip to content

Commit a36c494

Browse files
author
Ali Shahid
committed
[configs.lua] use autocmd in neovim way
1 parent 31d4246 commit a36c494

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lua/configs.lua

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ vim.api.nvim_create_autocmd(
123123
}
124124
)
125125

126-
-- jump to the last position when reopening a file
127-
vim.cmd([[
128-
if has("autocmd")
129-
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
130-
endif
131-
]])
126+
vim.api.nvim_create_autocmd(
127+
"BufEnter",
128+
{
129+
desc = "jump to the last position when reopening a file",
130+
pattern = "*",
131+
group = group,
132+
command = [[ if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif ]]
133+
}
134+
)
132135

133136
vim.api.nvim_create_autocmd(
134137
"BufWritePre",

0 commit comments

Comments
 (0)