From a4853fcf344b8868cc4e4fa421a58c50cf5f5b24 Mon Sep 17 00:00:00 2001 From: goodbin Date: Wed, 7 Feb 2024 11:36:55 +0300 Subject: [PATCH] feat: Skip first filetype line (#49) Co-authored-by: GoodBin --- lua/template/init.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/template/init.lua b/lua/template/init.lua index b9e5847..17d99b1 100644 --- a/lua/template/init.lua +++ b/lua/template/init.lua @@ -201,13 +201,22 @@ function temp:generate_template(args) local tbl = vim.split(data, '\n') local _expand = expand_expr() + local skip_lines = 0 for i, v in ipairs(tbl) do + if i == 1 then + local line_data = vim.split(v, '%s') + if #line_data == 2 and ";;" == line_data[1] then + skip_lines = skip_lines + 1 + goto continue + end + end local line, cursor = _expand(v) lines[#lines + 1] = line if cursor then - cursor_pos = { i, 2 } + cursor_pos = { i - skip_lines, 2 } end + ::continue:: end local cur_line = api.nvim_win_get_cursor(0)[1]