From 24c00a28122f2facfcc98d86851224c135ae75f9 Mon Sep 17 00:00:00 2001 From: tower_town Date: Thu, 3 Aug 2023 21:59:50 +0800 Subject: [PATCH 01/10] chore: add vim9script support. --- plugin/copyright.vim | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 689c5e4..4b169a8 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2021-02-09 10:41 +" Last Modified : 2023-08-03 21:57 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -209,7 +209,12 @@ endfunction " ##### 不同文件添加不同头总调用函数 function! AddTitle() let file_copyright_head_hase = 0 - "如果文件类型为.sh文件 + "如果文件类型为.vim文件 + if &filetype == 'vim' + call Title_vim() + let file_copyright_head_hase = 1 + endif + if &filetype == 'sh' call Title_sh() let file_copyright_head_hase = 1 @@ -287,6 +292,15 @@ function! AddTitle() endfunc " ##### 具体实现函数 +func! Title_vim() + if getline(1) == 'vim9script' + let g:file_copyright_comment_prefix = '\#' + call SetComment(1) + else + call SetComment(0) + endif +endfunc + func! Title_sh() call setline(1, "\#!/bin/bash") call SetComment(1) From 77f46fbc09fdef70d19c5399949395678d3b791a Mon Sep 17 00:00:00 2001 From: tower_town Date: Fri, 4 Aug 2023 02:49:48 +0800 Subject: [PATCH 02/10] fix: missing set gloal variable. add comment map for vim9script. --- plugin/copyright.vim | 46 ++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 4b169a8..ea962c0 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-03 21:57 +" Last Modified : 2023-08-04 02:22 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -55,28 +55,30 @@ let g:file_copyright_comment_prefix_map_default = { \"python": "\#", "py":"\#", \"cpp":"/*", "c":"/*", "h":"/*", "hpp":"/*", \"go":"/*", - \"vim":"\"", + \"vim":"\"", "vim9script": "\#", \"sh":"\#", "shell":"\#", \"ruby":"\#", "rb":"\#", "rake":"\#", \"uml":"/'", "plantuml":"/'", \} if !exists('g:file_copyright_comment_prefix_map') - let g:file_copyright_comment_prefix_map = {} + let _comment = getline(1) == "vim9script" ? "\#": "\"" + let g:file_copyright_comment_prefix_map = {"vim": _comment} endif let g:file_copyright_comment_mid_prefix_map_default = { \"python": "\#", "py":"\#", \"cpp":"\#", "c":"\#", "h":"\#", "hpp":"\#", \"go":"\#", - \"vim":"\"", + \"vim":"\"", "vim9script": "\#", \"sh":"\#", "shell":"\#", \"ruby":"\#", "rb":"\#", "rake":"\#", \"uml":"'", "plantuml":"'", \} if !exists('g:file_copyright_comment_mid_prefix_map') - let g:file_copyright_comment_mid_prefix_map = {} + let _comment = getline(1) == "vim9script" ? "\#": "\"" + let g:file_copyright_comment_mid_prefix_map = {"vim": _comment} endif let g:file_copyright_comment_end_map_default = { @@ -151,9 +153,12 @@ endfunction function! SetComment(begin) call SetCommentFlag() let l = -1 - if &filetype == 'sh' || &filetype == "perl" || &filetype == "python" || &filetype == 'ruby' || &filetype == 'rb' || &filetype == 'rake' + for ftype in ['sh', 'perl', 'python', 'ruby', 'rb', 'rake', 'vim'] + if &filetype == ftype let l = 0 - endif + endif + endfor + if &filetype == 'python' if a:begin isnot 0 let l = 2 @@ -180,15 +185,14 @@ function! UpdateFileHead(add) call SetCommentFlag() let n = 1 let regline = '^'.g:file_copyright_comment_mid_prefix.'\s*\S*Last\sModified\s*:\s*\S*.*$' - while n < 15 - let line = getline(n) - if line =~ regline - call UpdateTitle() - call cursor(curline, curcol) - return - endif - let n = n + 1 - endwhile + for n in range(1,14) + let line = getline(n) + if line =~ regline + call UpdateTitle() + call cursor(curline, curcol) + return + endif + endfor if a:add isnot 0 call SetComment(0) @@ -293,16 +297,20 @@ endfunc " ##### 具体实现函数 func! Title_vim() - if getline(1) == 'vim9script' - let g:file_copyright_comment_prefix = '\#' + let choice = confirm("create a vim9script script?", "&y\n&n\n") + if choice == 1 + cal setline(1, "vim9script") + let g:file_copyright_comment_prefix = "\#" + let g:file_copyright_comment_mid_prefix = "\#" call SetComment(1) + else call SetComment(0) endif endfunc func! Title_sh() - call setline(1, "\#!/bin/bash") + call setline(1, "\#!/usr/bin/env bash") call SetComment(1) endfunc From 31d16e7f8214508e439b9f391d91d9b5840fe8e9 Mon Sep 17 00:00:00 2001 From: tower_town Date: Fri, 4 Aug 2023 10:28:12 +0800 Subject: [PATCH 03/10] fix: add break in check filetype loop --- plugin/copyright.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index ea962c0..1434c46 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-04 02:22 +" Last Modified : 2023-08-04 10:26 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -156,6 +156,7 @@ function! SetComment(begin) for ftype in ['sh', 'perl', 'python', 'ruby', 'rb', 'rake', 'vim'] if &filetype == ftype let l = 0 + break endif endfor From 75a43c75a2d0a24a577675b2ff75542ce07f370d Mon Sep 17 00:00:00 2001 From: tower_town Date: Fri, 4 Aug 2023 11:01:40 +0800 Subject: [PATCH 04/10] fix(vim9script): fix vim9script file head RegEx. --- plugin/copyright.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 1434c46..62b3d27 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-04 10:26 +" Last Modified : 2023-08-04 10:59 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -62,8 +62,8 @@ let g:file_copyright_comment_prefix_map_default = { \} if !exists('g:file_copyright_comment_prefix_map') - let _comment = getline(1) == "vim9script" ? "\#": "\"" - let g:file_copyright_comment_prefix_map = {"vim": _comment} + let __comment = getline(1) =~# "^vim9script" ? "\#": "\"" + let g:file_copyright_comment_prefix_map = {"vim": __comment} endif let g:file_copyright_comment_mid_prefix_map_default = { @@ -77,8 +77,8 @@ let g:file_copyright_comment_mid_prefix_map_default = { \} if !exists('g:file_copyright_comment_mid_prefix_map') - let _comment = getline(1) == "vim9script" ? "\#": "\"" - let g:file_copyright_comment_mid_prefix_map = {"vim": _comment} + let __comment = getline(1) =~# "^vim9script" ? "\#": "\"" + let g:file_copyright_comment_mid_prefix_map = {"vim": __comment} endif let g:file_copyright_comment_end_map_default = { From f6ad1a6cd5e86dec9d795f807612cb6791dcea09 Mon Sep 17 00:00:00 2001 From: tower_town Date: Fri, 4 Aug 2023 19:41:51 +0800 Subject: [PATCH 05/10] fix: add tranform filetype function, that mean one filetype to many format. --- plugin/copyright.vim | 48 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 62b3d27..8e9a930 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-04 10:59 +" Last Modified : 2023-08-04 17:54 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -41,7 +41,7 @@ if !exists('g:file_copyright_auto_filetypes') \ 'h', 'hpp', 'c', 'cpp', 'java', \ 'ruby', 'rb', 'rake', \ 'uml', 'plantuml', - \ 'go', + \ 'go', 'vim', \] " let g:file_copyright_auto_filetypes = [ ] endif @@ -62,8 +62,7 @@ let g:file_copyright_comment_prefix_map_default = { \} if !exists('g:file_copyright_comment_prefix_map') - let __comment = getline(1) =~# "^vim9script" ? "\#": "\"" - let g:file_copyright_comment_prefix_map = {"vim": __comment} + let g:file_copyright_comment_prefix_map = {} endif let g:file_copyright_comment_mid_prefix_map_default = { @@ -77,8 +76,7 @@ let g:file_copyright_comment_mid_prefix_map_default = { \} if !exists('g:file_copyright_comment_mid_prefix_map') - let __comment = getline(1) =~# "^vim9script" ? "\#": "\"" - let g:file_copyright_comment_mid_prefix_map = {"vim": __comment} + let g:file_copyright_comment_mid_prefix_map = {} endif let g:file_copyright_comment_end_map_default = { @@ -106,17 +104,31 @@ endfunction autocmd BufNewFile * if MatchFileType() | exec ":call AddTitle()" | endif +" this function transform filetype: one filetype to many format. +" parm: &filetype +" return a string which key in file_copyright_comment_xxxx_map or other string + +function TransformFileType(ftype) + if a:ftype == "vim" + " return a key in file_copyright_comment_prefix_map_default + return getline(1) =~# "^vim9script" ? "vim9script": "vim" + else + return a:ftype + endif +endfunction + function SetCommentFlag() + let tftype =TransformFileType(&filetype) if !exists('g:file_copyright_comment_prefix') let g:file_copyright_comment_prefix = "\#" for item in keys(g:file_copyright_comment_prefix_map_default) - if item == &filetype - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default[&filetype] + if item == tftype + let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default[tftype] endif endfor for item in keys(g:file_copyright_comment_prefix_map) - if item == &filetype - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map[&filetype] + if item == tftype + let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map[tftype] endif endfor endif @@ -124,13 +136,13 @@ function SetCommentFlag() if !exists('g:file_copyright_comment_mid_prefix') let g:file_copyright_comment_mid_prefix = "\#" for item in keys(g:file_copyright_comment_mid_prefix_map_default) - if item == &filetype - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default[&filetype] + if item == tftype + let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default[tftype] endif endfor for item in keys(g:file_copyright_comment_mid_prefix_map) - if item == &filetype - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map[&filetype] + if item == tftype + let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map[tftype] endif endfor endif @@ -138,13 +150,13 @@ function SetCommentFlag() if !exists('g:file_copyright_comment_end') let g:file_copyright_comment_end = "" for item in keys(g:file_copyright_comment_end_map_default) - if item == &filetype - let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default[&filetype] + if item == tftype + let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default[tftype] endif endfor for item in keys(g:file_copyright_comment_end_map) - if item == &filetype - let g:file_copyright_comment_end = g:file_copyright_comment_end_map[&filetype] + if item == tftype + let g:file_copyright_comment_end = g:file_copyright_comment_end_map[tftype] endif endfor endif From 8529f60d0f22d353c666a9eae64801a07b11ac94 Mon Sep 17 00:00:00 2001 From: tower_town Date: Fri, 4 Aug 2023 19:58:02 +0800 Subject: [PATCH 06/10] docs: update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc8d72d..6fd72ed 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ let g:file_copyright_comment_prefix_map = { \"python": "\#", "py":"\#", \"cpp":"/*", "c":"/*", "h":"/*", "hpp":"/*", \"go":"/*", - \"vim":"\"", + \"vim":"\"", "vim9script": "\#", \"sh":"\#", "shell":"\#", \} @@ -69,7 +69,7 @@ let g:file_copyright_comment_mid_prefix_map = { \"python": "\#", "py":"\#", \"cpp":"\#", "c":"\#", "h":"\#", "hpp":"\#", \"go":"\#", - \"vim":"\"", + \"vim":"\"", "vim9script": "\#", \"sh":"\#", "shell":"\#", \} From f4905156f27f9e81e4da504938ac10ca2a5d957e Mon Sep 17 00:00:00 2001 From: tower_town Date: Sat, 5 Aug 2023 00:54:21 +0800 Subject: [PATCH 07/10] refactor: rewrite for-loop with lambda expression. --- plugin/copyright.vim | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 8e9a930..a492aac 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-04 17:54 +" Last Modified : 2023-08-05 00:46 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -120,45 +120,18 @@ endfunction function SetCommentFlag() let tftype =TransformFileType(&filetype) if !exists('g:file_copyright_comment_prefix') - let g:file_copyright_comment_prefix = "\#" - for item in keys(g:file_copyright_comment_prefix_map_default) - if item == tftype - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default[tftype] - endif - endfor - for item in keys(g:file_copyright_comment_prefix_map) - if item == tftype - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map[tftype] - endif - endfor + let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default->get(tftype) ?? "\#" + let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map->get(tftype) ?? g:file_copyright_comment_prefix endif if !exists('g:file_copyright_comment_mid_prefix') - let g:file_copyright_comment_mid_prefix = "\#" - for item in keys(g:file_copyright_comment_mid_prefix_map_default) - if item == tftype - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default[tftype] - endif - endfor - for item in keys(g:file_copyright_comment_mid_prefix_map) - if item == tftype - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map[tftype] - endif - endfor + let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default->get(tftype) ?? "\#" + let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map->get(tftype) ?? g:file_copyright_comment_mid_prefix endif if !exists('g:file_copyright_comment_end') - let g:file_copyright_comment_end = "" - for item in keys(g:file_copyright_comment_end_map_default) - if item == tftype - let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default[tftype] - endif - endfor - for item in keys(g:file_copyright_comment_end_map) - if item == tftype - let g:file_copyright_comment_end = g:file_copyright_comment_end_map[tftype] - endif - endfor + let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default->get(tftype) ?? "" + let g:file_copyright_comment_end = g:file_copyright_comment_end_map->get(tftype) ?? g:file_copyright_comment_end endif endfunction From 56213feb240c41c6794d88e92ad01eee6c63e134 Mon Sep 17 00:00:00 2001 From: tower_town Date: Sat, 5 Aug 2023 00:57:17 +0800 Subject: [PATCH 08/10] refactor: rewrite for-loop with falsy operator and method call. --- plugin/copyright.vim | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 8e9a930..a492aac 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-04 17:54 +" Last Modified : 2023-08-05 00:46 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -120,45 +120,18 @@ endfunction function SetCommentFlag() let tftype =TransformFileType(&filetype) if !exists('g:file_copyright_comment_prefix') - let g:file_copyright_comment_prefix = "\#" - for item in keys(g:file_copyright_comment_prefix_map_default) - if item == tftype - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default[tftype] - endif - endfor - for item in keys(g:file_copyright_comment_prefix_map) - if item == tftype - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map[tftype] - endif - endfor + let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default->get(tftype) ?? "\#" + let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map->get(tftype) ?? g:file_copyright_comment_prefix endif if !exists('g:file_copyright_comment_mid_prefix') - let g:file_copyright_comment_mid_prefix = "\#" - for item in keys(g:file_copyright_comment_mid_prefix_map_default) - if item == tftype - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default[tftype] - endif - endfor - for item in keys(g:file_copyright_comment_mid_prefix_map) - if item == tftype - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map[tftype] - endif - endfor + let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default->get(tftype) ?? "\#" + let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map->get(tftype) ?? g:file_copyright_comment_mid_prefix endif if !exists('g:file_copyright_comment_end') - let g:file_copyright_comment_end = "" - for item in keys(g:file_copyright_comment_end_map_default) - if item == tftype - let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default[tftype] - endif - endfor - for item in keys(g:file_copyright_comment_end_map) - if item == tftype - let g:file_copyright_comment_end = g:file_copyright_comment_end_map[tftype] - endif - endfor + let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default->get(tftype) ?? "" + let g:file_copyright_comment_end = g:file_copyright_comment_end_map->get(tftype) ?? g:file_copyright_comment_end endif endfunction From cc728afd4c2cbbeadff6a2005dbf280dfa77ba92 Mon Sep 17 00:00:00 2001 From: tower_town Date: Sat, 5 Aug 2023 18:42:35 +0800 Subject: [PATCH 09/10] chore: fix variable scope and compatible vim8 --- plugin/copyright.vim | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index a492aac..0820135 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-05 00:46 +" Last Modified : 2023-08-05 17:26 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -118,20 +118,28 @@ function TransformFileType(ftype) endfunction function SetCommentFlag() - let tftype =TransformFileType(&filetype) + let l:tftype = TransformFileType(&filetype) + + let l:prefix_default = g:file_copyright_comment_prefix_map_default + let l:prefix = g:file_copyright_comment_prefix_map + let l:mid_prefix_default = g:file_copyright_comment_mid_prefix_map_default + let l:mid_prefix = g:file_copyright_comment_mid_prefix_map + let l:end_prefix_default = g:file_copyright_comment_end_map_default + let l:end_prefix = g:file_copyright_comment_end_map + if !exists('g:file_copyright_comment_prefix') - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map_default->get(tftype) ?? "\#" - let g:file_copyright_comment_prefix = g:file_copyright_comment_prefix_map->get(tftype) ?? g:file_copyright_comment_prefix + let g:file_copyright_comment_prefix = l:prefix_default->get(l:tftype) == 0 ? l:prefix_default->get(l:tftype) : "\#" + let g:file_copyright_comment_prefix = l:prefix->get(l:tftype) == 0 ? l:prefix->get(l:tftype) : g:file_copyright_comment_prefix endif if !exists('g:file_copyright_comment_mid_prefix') - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map_default->get(tftype) ?? "\#" - let g:file_copyright_comment_mid_prefix = g:file_copyright_comment_mid_prefix_map->get(tftype) ?? g:file_copyright_comment_mid_prefix + let g:file_copyright_comment_mid_prefix = l:mid_prefix_default->get(l:tftype) == 0 ? l:mid_prefix_default->get(l:tftype) : "\#" + let g:file_copyright_comment_mid_prefix = l:mid_prefix->get(l:tftype) == 0 ? l:mid_prefix->get(l:tftype) : g:file_copyright_comment_mid_prefix endif if !exists('g:file_copyright_comment_end') - let g:file_copyright_comment_end = g:file_copyright_comment_end_map_default->get(tftype) ?? "" - let g:file_copyright_comment_end = g:file_copyright_comment_end_map->get(tftype) ?? g:file_copyright_comment_end + let g:file_copyright_comment_end = l:end_prefix_default->get(l:tftype) == 0 ? l:end_prefix_default->get(l:tftype) : "" + let g:file_copyright_comment_end = l:end_prefix->get(l:tftype) == 0 ? l:end_prefix->get(l:tftype) : g:file_copyright_comment_end endif endfunction From 875efc4bf5a66ce3a0004ee2a5107ba215578b6e Mon Sep 17 00:00:00 2001 From: tower_town Date: Sat, 5 Aug 2023 19:23:02 +0800 Subject: [PATCH 10/10] chore: fix number condition --- plugin/copyright.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin/copyright.vim b/plugin/copyright.vim index 0820135..eb4ed92 100644 --- a/plugin/copyright.vim +++ b/plugin/copyright.vim @@ -4,7 +4,7 @@ " Author : bbxytl " Email : bbxytl@gmail.com " File Name : copyright.vim -" Last Modified : 2023-08-05 17:26 +" Last Modified : 2023-08-05 19:21 " Describe : Released under the MIT licence. " Add and update Copyright messag, eg. file name, last modified " @@ -128,18 +128,18 @@ function SetCommentFlag() let l:end_prefix = g:file_copyright_comment_end_map if !exists('g:file_copyright_comment_prefix') - let g:file_copyright_comment_prefix = l:prefix_default->get(l:tftype) == 0 ? l:prefix_default->get(l:tftype) : "\#" - let g:file_copyright_comment_prefix = l:prefix->get(l:tftype) == 0 ? l:prefix->get(l:tftype) : g:file_copyright_comment_prefix + let g:file_copyright_comment_prefix = l:prefix_default->get(l:tftype) isnot 0 ? l:prefix_default->get(l:tftype) : "\#" + let g:file_copyright_comment_prefix = l:prefix->get(l:tftype) isnot 0 ? l:prefix->get(l:tftype) : g:file_copyright_comment_prefix endif if !exists('g:file_copyright_comment_mid_prefix') - let g:file_copyright_comment_mid_prefix = l:mid_prefix_default->get(l:tftype) == 0 ? l:mid_prefix_default->get(l:tftype) : "\#" - let g:file_copyright_comment_mid_prefix = l:mid_prefix->get(l:tftype) == 0 ? l:mid_prefix->get(l:tftype) : g:file_copyright_comment_mid_prefix + let g:file_copyright_comment_mid_prefix = l:mid_prefix_default->get(l:tftype) isnot 0 ? l:mid_prefix_default->get(l:tftype) : "\#" + let g:file_copyright_comment_mid_prefix = l:mid_prefix->get(l:tftype) isnot 0 ? l:mid_prefix->get(l:tftype) : g:file_copyright_comment_mid_prefix endif if !exists('g:file_copyright_comment_end') - let g:file_copyright_comment_end = l:end_prefix_default->get(l:tftype) == 0 ? l:end_prefix_default->get(l:tftype) : "" - let g:file_copyright_comment_end = l:end_prefix->get(l:tftype) == 0 ? l:end_prefix->get(l:tftype) : g:file_copyright_comment_end + let g:file_copyright_comment_end = l:end_prefix_default->get(l:tftype) isnot 0 ? l:end_prefix_default->get(l:tftype) : "" + let g:file_copyright_comment_end = l:end_prefix->get(l:tftype) isnot 0 ? l:end_prefix->get(l:tftype) : g:file_copyright_comment_end endif endfunction