From: Nicolas Boisselier Date: Tue, 16 Aug 2016 10:25:12 +0000 (+0200) Subject: vim X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=bb00ea863f255de0a43d3b3d60c9877c326fa632;p=nb.git vim --- diff --git a/etc/vim/.vimplaterc b/etc/vim/.vimplaterc new file mode 100755 index 00000000..91c15bcd --- /dev/null +++ b/etc/vim/.vimplaterc @@ -0,0 +1,77 @@ +# This is an example configuration. +# please see: http://napali.ch/vimplate + +# you can use $Config::opt instead command options: +# -user= -dir= +#warn @ARGV; +use POSIX; +use File::Basename; + +sub filename { + my $f = $ENV{VIMFILE}; + $f = join(' ',@ARGV) if @ARGV and !$f; + #return join(' ',@ARGV) if @ARGV and !$f; + return $f unless $f; + + my $root; + + $f =~ s,^$root,\~izideal, if $root = $ENV{IZI_ROOT_DIR}; + $f =~ s,^$root/?,, if $root = $ENV{NB_ROOT}; + + $f =~ s,^$root/,, if $root = $ENV{HOME}; + + return $f; +} + +$file = filename() || '?'; + +$Config::var = { +#yourArray => [ 'Perl', 'C', 'C++' ], + time => sub{ time }, + programname => 'nico', + today => POSIX::strftime("%d.%m.%y", localtime), + year => POSIX::strftime("%Y", localtime), + filename => $file, + basename => basename($file), +}; + +$Config::opt = { + #dir => ($ENV{VIMHOME} || $ENV{HOME}).'/.vim/templates', + dir => $ENV{HOME}.'/.vim/templates', + user => 'nico', +}; + +$Config::opt{dir} = $ENV{VIMHOME} . '/templates' if $ENV{VIMHOME}; + + +# we need $Config::user with the option -user= +$Config::user = { + nico => { + me => 'NB', + firstname => 'Nicolas', + lastname => 'Boisselier', + mail => 'nicolas.boisselier@gmail.com', + }, +}; + +for (keys %$Config::user) { + my %h = %{$Config::user->{$_}}; + + $h{name} = $h{firstname}.' '.$h{lastname}; + $h{author} = $h{name}.' '.$h{mail}; + + $h{me_now} = $h{me}.' '.$Config::var->{today}; + + $h{copyright} = "(C) ".$Config::var->{year}." ".$h{name}; + + $h{copyright_laius} = "Copyright $h{copyright} + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +See ."; + + $Config::user->{$_} = \%h; +}; +1; diff --git a/etc/vim/source/functions.vim b/etc/vim/source/functions.vim index a0448956..9cc8547f 100644 --- a/etc/vim/source/functions.vim +++ b/etc/vim/source/functions.vim @@ -4,23 +4,17 @@ " See: http://learnvimscriptthehardway.stevelosh.com/chapters/27.html " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let $VIMHOME = $HOME.'/.vim' -if !isdirectory($VIMHOME) | let $VIMHOME = '/opt/nb/etc/vim' | endif -"let $VIMHOME = '/home/nico'.'/.vim' +" if !isdirectory($VIMHOME) | let $VIMHOME = '/opt/nb/etc/vim' | endif +" let cur = expend('%:p:h') -" let vimhome = '/home/nico/.vim' let $VIMPLATE_DIR = $VIMHOME . '/templates' -let $VIMPLATERC = $HOME.'/vimplaterc' -if !filereadable($VIMPLATERC) | let $VIMPLATERC = '/opt/nb/etc/vim/vimplaterc' | endif +" NB 16.08.16 let $VIMPLATERC = $HOME.'/.vimplaterc' +" NB 16.08.16 if !filereadable($VIMPLATERC) | let $VIMPLATERC = '/opt/nb/etc/vim/.vimplaterc' | endif +let $VIMPLATERC = '/opt/nb/etc/vim/.vimplaterc' -let $VIMPLATE = 'vimplate' - -" NB 18.01.15 let $VIMPLATE = $VIMPLATE . ' -user nico' - -let $VIMPLATE = $VIMPLATE . ' -config '.$VIMPLATERC - -let $VIMPLATE = $VIMPLATE . ' -dir '.$VIMPLATE_DIR +" We change HOME beacuse vimplate look for HOME/.vimplaterc +let $VIMPLATE = 'env HOME=' . $VIMHOME . ' vimplate' . ' -config '.$VIMPLATERC . ' -dir '.$VIMPLATE_DIR au VimLeave * if filereadable($VIMHOME."/.netrwhist")|call delete($VIMHOME."/.netrwhist")|endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -39,7 +33,9 @@ func! FileVimplate() if $VIMFILE =~ 'init\.d' let ftype = 'daemon' endif + let fname = ftype.'.tt' + let ffind = findfile(fname,$VIMPLATE_DIR) if ffind == '' " if ffind != $VIMPLATE_DIR . '/' . fname @@ -48,10 +44,12 @@ func! FileVimplate() endif let cmd = $VIMPLATE . ' -template '.ftype + let bashenv = $BASH_ENV let $BASH_ENV = "" execute "r!" . cmd let $BASH_ENV = bashenv + endfunc let $FileInit = '' @@ -199,7 +197,7 @@ func! FileCommentToggle() endfunc """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let Cmd = $HOME . '/.vim/vim-shortcurts' +let Cmd = $VIMHOME . '/vim-shortcurts' let FilePath = expand('%:p') let Debug = $VIMRC_DEBUG @@ -224,7 +222,7 @@ func! Debug(...) endfunc func! Stats() - let stats = expand("$HOME/.vim/stats") + let stats = expand("$VIMHOME/stats") if ! isdirectory(stats) call mkdir(stats) endif @@ -283,7 +281,6 @@ if !exists('*VimrcReload') call Debug("VimrcReload: Start") call Debug("VimrcReload: ".$MYVIMRC) - " source plugin/*.vim exec "source $MYVIMRC" call Debug("VimrcReload: End") diff --git a/etc/vim/source/map.vim b/etc/vim/source/map.vim index 43d38a38..7fcacc45 100644 --- a/etc/vim/source/map.vim +++ b/etc/vim/source/map.vim @@ -7,16 +7,6 @@ " set encoding=utf-8 " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" NB 22.07.12 " Remember last line -" NB 22.07.12 set viminfo='10,\"100,:20,%,n~/.viminfo -" NB 22.07.12 au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif -" NB 22.07.12 -" NB 22.07.12 " I know it's horrible for a vi master but useful for newbies. - NB 04.11.03 -" NB 22.07.12 imap I -" NB 22.07.12 imap A -" NB 22.07.12 map w -" NB 22.07.12 imap w -" NB 22.07.12 cmap """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " @@ -38,7 +28,6 @@ map :! """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " F2 - Script, formated text verification map :call FileCheck() -" map :!~/.vim/checkscript.sh % """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " F3 - Choose email signature @@ -70,21 +59,3 @@ map :call FileVimplate() " - Prog Create " map :call VimShortcurtsInteractive() " vmap :call VimShortcurtsInteractive() - - -" Start the find and replace command across the entire file -" vmap z :%s/=GetVisual()/ -" Interactif -" You can call this function with: :10,30call Count_words() -" map o=VimShortcurtsAuto('all_choose') -" NB 09.11.11 map :.!~/.vim/vim-shortcurts-stdin -" vmap !~/.vim/vim-shortcurts -" vmap .!~/.vim/vim-shortcurts all_choose -" map :s/^\(.*\)$/\=VimShortcurtsAuto('all_choose','\1')/ -" map :s/^/\=VimShortcurtsAuto('all_choose')/ -" vmap :s/^/\=VimShortcurtsAuto('all_choose')/ -" nmap :set opfunc=CountSpacesg@ -" vmap :call CountSpaces(visualmode(), 1) - - - diff --git a/etc/vim/vimplaterc b/etc/vim/vimplaterc deleted file mode 100755 index a11e53ec..00000000 --- a/etc/vim/vimplaterc +++ /dev/null @@ -1,74 +0,0 @@ -# This is an example configuration. -# please see: http://napali.ch/vimplate - -# you can use $Config::opt instead command options: -# -user= -dir= -#warn @ARGV; -use POSIX; -use File::Basename; - -sub filename { - my $f = $ENV{VIMFILE}; - $f = join(' ',@ARGV) if @ARGV and !$f; - #return join(' ',@ARGV) if @ARGV and !$f; - return $f unless $f; - - my $root; - - $f =~ s,^$root,\~izideal, if $root = $ENV{IZI_ROOT_DIR}; - $f =~ s,^$root/?,, if $root = $ENV{NB_ROOT}; - - $f =~ s,^$root/,, if $root = $ENV{HOME}; - - return $f; -} - -$file = filename(); - -$Config::var = { -#yourArray => [ 'Perl', 'C', 'C++' ], - time => sub{ time }, - programname => 'nico', - today => POSIX::strftime("%d.%m.%y", localtime), - year => POSIX::strftime("%Y", localtime), - filename => $file, - basename => basename($file), -}; - -$Config::opt = { - dir => $ENV{HOME}.'/.vim/templates', - user => 'nico', -}; - - -# we need $Config::user with the option -user= -$Config::user = { - nico => { - firstname => 'Nicolas', - lastname => 'Boisselier', - me => 'NB', - mail => 'nicolas.boisselier@gmail.com', - }, -}; - -for (keys %$Config::user) { - my %h = %{$Config::user->{$_}}; - - $h{name} = $h{firstname}.' '.$h{lastname}; - $h{author} = $h{name}.' '.$h{mail}; - - $h{me_now} = $h{me}.' '.$Config::var->{today}; - - $h{copyright} = "(C) ".$Config::var->{year}." ".$h{name}; - - $h{copyright_laius} = "Copyright $h{copyright} - -This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -See ."; - - $Config::user->{$_} = \%h; -}; -1; diff --git a/etc/vimrc b/etc/vimrc index c3835eeb..8bbc555b 100644 --- a/etc/vimrc +++ b/etc/vimrc @@ -1,2 +1,12 @@ " Require ln -s /opt/nb/etc/vim ~/.vim !!! -runtime! source/*.vim +" let $VIMHOME = $HOME.'/.vimZZ' +" if !isdirectory($VIMHOME) | let $VIMHOME = expand("%:p:h") | endif +" if !isdirectory($VIMHOME) | let $VIMHOME = '/opt/nb/etc/vim' | endif +let $VIMHOME = '/opt/nb/etc/vim' +" echo expand("%:p:h") +" runtime! expand("%:p:h") . '/vim/source/*.vim' +" runtime! $VIMHOME . '/source/*.vim' +" runtime! 'source/*.vim' +for file in split(globpath($VIMHOME . '/source/', '*.vim'), '\n') + execute 'source' fnameescape(file) +endfor