From 79ff52b17ee01a602839d118ce6cf6b6493e5e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20V=C3=A1zquez-Otero?= Date: Sun, 11 Sep 2016 12:37:00 +0200 Subject: [PATCH 1/6] Adding java support --- plugin/header.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/header.vim b/plugin/header.vim index 7148634..8551af4 100644 --- a/plugin/header.vim +++ b/plugin/header.vim @@ -60,6 +60,9 @@ function s:filetype () elseif l:ft ==# 'javascript' let s:comment = "\/\/" let s:type = s:comment . " Javascript File" + elseif l:ft ==# 'java' + let s:comment = "\/\/" + let s:type = s:comment . " Java File" else let s:comment = "#" let s:type = s:comment . " Text File" From ca97649117441b1379208d72a888d8821d239129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20V=C3=A1zquez-Otero?= Date: Mon, 10 Oct 2016 09:55:25 +0200 Subject: [PATCH 2/6] adding function! to avoid loading twice when re-reading init.vim --- plugin/header.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/header.vim b/plugin/header.vim index 8551af4..0b7ad49 100644 --- a/plugin/header.vim +++ b/plugin/header.vim @@ -20,7 +20,7 @@ " when the file is not a script executable. -function s:filetype () +function! s:filetype () let s:file = expand(":t") let l:ft = &ft @@ -80,7 +80,7 @@ endfunction " created = Date of the file creation. " modified = Date of the last modification. -function s:insert () +function! s:insert () call s:filetype () @@ -113,7 +113,7 @@ endfunction " Update the date of last modification. " Check the line number 6 looking for the pattern. -function s:update () +function! s:update () call s:filetype () From d2eeccd9d8c1384d5a6be619c88d3996a967e1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20V=C3=A1zquez-Otero?= Date: Mon, 10 Oct 2016 10:17:54 +0200 Subject: [PATCH 3/6] merging some changes from s-gordon: dont insert header unless extension matches --- plugin/header.vim | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plugin/header.vim b/plugin/header.vim index 0b7ad49..87241e3 100644 --- a/plugin/header.vim +++ b/plugin/header.vim @@ -41,7 +41,8 @@ function! s:filetype () let s:type = s:comment . "!/usr/bin/env bash" elseif l:ft ==# 'python' let s:comment = "#" - let s:type = s:comment . "-*- coding:utf-8 -*-" + "let s:type = s:comment . "-*- coding:utf-8 -*-" + let s:type = s:comment . "!/usr/bin/env python" elseif l:ft ==# 'perl' let s:comment = "#" let s:type = s:comment . "!/usr/bin/env perl" @@ -63,12 +64,15 @@ function! s:filetype () elseif l:ft ==# 'java' let s:comment = "\/\/" let s:type = s:comment . " Java File" + elseif l:ft ==# 'markdown' + let s:comment = "#" + let s:type = s:comment . " TITLE" else let s:comment = "#" let s:type = s:comment . " Text File" endif unlet s:file - +" ['sh', 'py', 'vim', 'c', 'rst, 'h','php','javascript','java','md', 'markdown', 'pl'] endfunction @@ -133,5 +137,13 @@ function! s:update () endfunction -autocmd BufNewFile * call s:insert () +"autocmd BufNewFile * call s:insert () autocmd BufWritePre * call s:update () + + + + +" This might not be the best way to do it, but it works for now. +for g:ext in ['sh', 'py', 'vim', 'c', 'rst, 'h','php','javascript','java','md', 'markdown', 'pl'] + autocmd BufNewFile "*." . g:ext call s:insert () +endfor From f30485bc770a572527d80337a58fbe609cedfd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20V=C3=A1zquez-Otero?= Date: Mon, 10 Oct 2016 10:20:14 +0200 Subject: [PATCH 4/6] merging some changes from s-gordon: dont insert header unless extension matches --- plugin/header.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/header.vim b/plugin/header.vim index 87241e3..f6c1529 100644 --- a/plugin/header.vim +++ b/plugin/header.vim @@ -144,6 +144,6 @@ autocmd BufWritePre * call s:update () " This might not be the best way to do it, but it works for now. -for g:ext in ['sh', 'py', 'vim', 'c', 'rst, 'h','php','javascript','java','md', 'markdown', 'pl'] +for g:ext in ['sh', 'py', 'vim', 'c', 'rst, 'h', 'php', 'javascript', 'java', 'md', 'markdown', 'pl'] autocmd BufNewFile "*." . g:ext call s:insert () endfor From 68bab56c533d605d1b2ec36112369ecb66630c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20V=C3=A1zquez-Otero?= Date: Mon, 10 Oct 2016 10:22:53 +0200 Subject: [PATCH 5/6] merging some changes from s-gordon: dont insert header unless extension matches --- plugin/header.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/header.vim b/plugin/header.vim index f6c1529..4d7ee9b 100644 --- a/plugin/header.vim +++ b/plugin/header.vim @@ -72,8 +72,8 @@ function! s:filetype () let s:type = s:comment . " Text File" endif unlet s:file -" ['sh', 'py', 'vim', 'c', 'rst, 'h','php','javascript','java','md', 'markdown', 'pl'] endfunction +" ['sh', 'py', 'vim', 'c', 'rst, 'h','php','javascript','java','md', 'markdown', 'pl'] " FUNCTION: @@ -144,6 +144,6 @@ autocmd BufWritePre * call s:update () " This might not be the best way to do it, but it works for now. -for g:ext in ['sh', 'py', 'vim', 'c', 'rst, 'h', 'php', 'javascript', 'java', 'md', 'markdown', 'pl'] +for g:ext in ['sh', 'py', 'vim', 'c', 'rst', 'h', 'php', 'javascript', 'java', 'md', 'markdown', 'pl'] autocmd BufNewFile "*." . g:ext call s:insert () endfor From b420f0806446a5249ac30d3d58c4c6bd10135820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20V=C3=A1zquez-Otero?= Date: Mon, 10 Oct 2016 10:30:58 +0200 Subject: [PATCH 6/6] fixing comment function --- plugin/header.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/header.vim b/plugin/header.vim index 4d7ee9b..8fd7de7 100644 --- a/plugin/header.vim +++ b/plugin/header.vim @@ -137,7 +137,7 @@ function! s:update () endfunction -"autocmd BufNewFile * call s:insert () +autocmd BufNewFile * call s:insert () autocmd BufWritePre * call s:update ()