From f4778885e8d171cdbbabba69664de5c82859cce3 Mon Sep 17 00:00:00 2001 From: subcrip Date: Sat, 25 May 2024 15:21:58 +0800 Subject: [PATCH] backup --- src/bin/.nvim.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/bin/.nvim.lua b/src/bin/.nvim.lua index ab7fc86..3783e19 100644 --- a/src/bin/.nvim.lua +++ b/src/bin/.nvim.lua @@ -26,11 +26,13 @@ vim.keymap.set('n', 'l', '40vs std.in') local function add_timestamp() local bufnr = vim.api.nvim_get_current_buf() + if vim.fs.basename(vim.api.nvim_buf_get_name(bufnr)) == "template.cc" then + return + end local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) local current_time = os.time() local current_time_str = os.date("%Y-%m-%d %H:%M:%S", current_time) - local comment_string local create_time_str = "" local elapsed_minutes = 0 @@ -49,7 +51,7 @@ local function add_timestamp() create_time_str = current_time_str end - comment_string = { + local comment_string = { "/**", " * Author: subcrip", " * Created: " .. create_time_str, @@ -69,16 +71,10 @@ local function add_timestamp() end end + vim.cmd("undojoin") vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) end -vim.api.nvim_create_autocmd( - "BufWritePost", - { - pattern = "*.cc", - callback = add_timestamp, - } -) vim.api.nvim_create_autocmd( "BufWritePre", {