From d3c5d1edca0cef8eff99709027e3f74ad769ac98 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Tue, 27 Aug 2024 13:58:31 +0930 Subject: [PATCH] feat: convert vimscript autocmd to lua --- .config/nvim/.stylelua.toml | 7 +++++++ .config/nvim/lua/core/autocmd.lua | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/.stylelua.toml diff --git a/.config/nvim/.stylelua.toml b/.config/nvim/.stylelua.toml new file mode 100644 index 0000000..6ce0431 --- /dev/null +++ b/.config/nvim/.stylelua.toml @@ -0,0 +1,7 @@ +column_width = 160 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "ForceDouble" +no_call_parentheses = false +collapse_simple_statement = 'Always' diff --git a/.config/nvim/lua/core/autocmd.lua b/.config/nvim/lua/core/autocmd.lua index 4b5fddd..8e6348f 100644 --- a/.config/nvim/lua/core/autocmd.lua +++ b/.config/nvim/lua/core/autocmd.lua @@ -27,7 +27,11 @@ local aucmd_dict = { BufRead = { { -- Return cursor to where it was previously when re-opening a file - command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]] + callback = function() + if vim.fn.expand('%:p') ~= '.git/COMMIT_EDITMSG' and vim.fn.line("'\"") > 1 and vim.fn.line("'\"") <= vim.fn.line("$") then + vim.cmd("normal! g`\"") + end + end }, {