" NB 12.12.22: Functions to comment texts
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if exists("_loaded_comment")
+ finish
+endif
+let _loaded_comment = 1
+
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Global
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+let $USER_INITIALS = system('printf "%s" ${USER_INITIALS:-`whoami`}')
func! CommentMeNow()
return $USER_INITIALS . ' ' . strftime('%d.%m.%y')
endfunc
endfor
endfunc
- " NB 12.12.22 let g:File['path'] = expand('%:p')
- " NB 12.12.22 let g:File['ext'] = expand('%:e')
- " NB 12.12.22 let g:File['type'] = &filetype
func! CommentNewLine()
" NB 12.12.22: Create a new line of comment
- if ( g:mimeComment->get(&filetype) == '0')
+ if ( g:mimeComment->get(FileType()) == '0')
let comment = '#'
- " NB 12.12.22 return Err('No comment defined for filetype '.&filetype)
+ " NB 12.12.22 return Err('No comment defined for filetype '.FileType())
else
- let comment = g:mimeComment->get(&filetype)
+ let comment = g:mimeComment->get(FileType())
endif
let comment = split(comment,'\s\+')
call CommentSubSpecialChar(comment)
func! CommentToggle()
" NB 12.12.22: Toggle current line between commented / not commented
- if ( g:mimeComment->get(&filetype) == '0')
+ if ( g:mimeComment->get(FileType()) == '0')
let comment = '#'
- " NB 12.12.22 return Err('No comment defined for filetype '.&filetype)
+ " NB 12.12.22 return Err('No comment defined for filetype '.FileType())
else
- let comment = g:mimeComment->get(&filetype)
+ let comment = g:mimeComment->get(FileType())
endif
let comment = split(comment,'\s\+')
" See: http://learnvimscriptthehardway.stevelosh.com/chapters/27.html
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if exists("_loaded_file")
+ finish
+endif
+let _loaded_file = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" File...()
+" NB 14.12.22: Return filetype
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-let File = { 'type' : '' }
-let $USER_INITIALS = system('printf "%s" ${USER_INITIALS:-`whoami`}')
+func! FileType()
+
+ " From aliases
+ if (g:aliasFileType->has_key(&filetype))
+ return g:aliasFileType[&filetype]
+ endif
+
+ " Trust vim
+ if (!&filetype->empty())
+ return &filetype
+ endif
+
+ " From ext
+ let ext = expand('%:e')
+ if (g:extFileType->has_key(ext))
+ return g:extFileType->get(ext])
+ endif
+endfunc
func! FileCheckSyntaxe()
- if ( g:mimeCheck->get(&filetype) == '0')
+ if ( g:mimeCheck->get(FileType()) == '0')
let cmd = 'xargs -IZ sh -c "ls -ahl Z" <<<'
else
- let cmd = g:mimeCheck->get(&filetype)
+ let cmd = g:mimeCheck->get(FileType())
endif
let cmd = cmd . ' "' .expand('%:p') . '"'
echo cmd
endfunc
-function Err(txt)
- echo 'ERROR: '.a:txt
- return
-endfunc
-