@@ -43,6 +43,13 @@ function M.add_headers(header)
4343
4444 -- prepare headers (inline version)
4545 local function prepare (cb )
46+ if header .config .author_from_git then
47+ local gitname = vim .fn .systemlist (" git config user.name" )
48+ if vim .v .shell_error == 0 and # gitname > 0 then
49+ header .config .author = gitname [1 ]
50+ end
51+ end
52+
4653 if header .config .license_from_file then
4754 local files = license .scan_license_files ()
4855 if # files == 0 then
@@ -65,12 +72,6 @@ function M.add_headers(header)
6572
6673 local file = vim .fn .expand (" %:t" )
6774 local created = os.date (header .config .date_created_fmt , vim .fn .getftime (vim .fn .expand (" %" )))
68- if header .config .author_from_git then
69- local gitname = vim .fn .systemlist (" git config user.name" )
70- if vim .v .shell_error == 0 and # gitname > 0 then
71- header .config .author = gitname [1 ]
72- end
73- end
7475
7576 local hdrs = {}
7677 if header .config .file_name then
@@ -105,8 +106,14 @@ function M.add_headers(header)
105106 if not hdrs then
106107 return
107108 end
109+
110+ local new_hrds = {}
111+ for i , line in ipairs (hdrs ) do
112+ new_hrds [i ] = util .replace_all_tokens (line , header )
113+ end
114+
108115 remove_old_headers (comments_table )
109- local commented = comments .comment_headers (hdrs , comments_table , header .config .use_block_header )
116+ local commented = comments .comment_headers (new_hrds , comments_table , header .config .use_block_header )
110117 vim .api .nvim_buf_set_lines (0 , 0 , 0 , false , commented )
111118 end )
112119end
@@ -119,9 +126,7 @@ function M.add_license_header(header, opts)
119126 end
120127
121128 local license_text = require (" header.licenses." .. string.lower (opts ))
122- license_text = util .replace_token (license_text , " project" , header .config .project )
123- license_text = util .replace_token (license_text , " organization" , header .config .author )
124- license_text = util .replace_token (license_text , " year" , os.date (" %Y" ))
129+ license_text = util .replace_all_tokens (license_text , header )
125130
126131 local license_table = util .string_to_table (license_text )
127132 local comments_table = comments_fn ()
0 commit comments