Skip to content

Adding java support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions plugin/header.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
" when the file is not a script executable.


function s:filetype ()
function! s:filetype ()

let s:file = expand("<afile>:t")
let l:ft = &ft
Expand All @@ -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"
Expand All @@ -60,13 +61,19 @@ 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"
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

endfunction
" ['sh', 'py', 'vim', 'c', 'rst, 'h','php','javascript','java','md', 'markdown', 'pl']


" FUNCTION:
Expand All @@ -77,7 +84,7 @@ endfunction
" created = Date of the file creation.
" modified = Date of the last modification.

function s:insert ()
function! s:insert ()

call s:filetype ()

Expand Down Expand Up @@ -110,7 +117,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 ()

Expand All @@ -132,3 +139,11 @@ endfunction

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