]> git.nbdom.net Git - nb.git/commitdiff
vim
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 16 Aug 2016 10:25:12 +0000 (12:25 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 16 Aug 2016 10:25:12 +0000 (12:25 +0200)
etc/vim/.vimplaterc [new file with mode: 0755]
etc/vim/source/functions.vim
etc/vim/source/map.vim
etc/vim/vimplaterc [deleted file]
etc/vimrc

diff --git a/etc/vim/.vimplaterc b/etc/vim/.vimplaterc
new file mode 100755 (executable)
index 0000000..91c15bc
--- /dev/null
@@ -0,0 +1,77 @@
+# This is an example configuration.
+# please see: http://napali.ch/vimplate
+
+# you can use $Config::opt instead command options:
+#   -user=<user> -dir=<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=<name>
+$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 <http://www.gnu.org/licenses/>.";
+
+       $Config::user->{$_} = \%h;
+};
+1;
index a044895677ace1ad50820b738f89cc6cdb4e786e..9cc8547f38ab058be7bcca306fc9989e3fe5da1e 100644 (file)
@@ -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")
index 43d38a3829618ef8072adf0997e6f0f6f0256b47..7fcacc45454011fe8ff3ae4be261676774c911ea 100644 (file)
@@ -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 <C-a> <Esc>I
-" NB 22.07.12 imap <C-e> <ESC>A
-" NB 22.07.12 map <C-Tab> <C-W>w
-" NB 22.07.12 imap <C-Tab> <C-O><C-W>w
-" NB 22.07.12 cmap <C-Tab> <C-C><C-Tab>
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 "
@@ -38,7 +28,6 @@ map <F1> :!<C-UP><C-M>
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " F2 - Script, formated text verification
 map <F2> :call FileCheck()<CR>
-" map <F2> :!~/.vim/checkscript.sh %<CR>
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " F3 - Choose email signature
@@ -70,21 +59,3 @@ map <F7> :call FileVimplate()<CR>
 " - Prog Create
 " map <F8> :call VimShortcurtsInteractive()<CR>
 " vmap <F8> :call VimShortcurtsInteractive()<CR>
-
-
-" Start the find and replace command across the entire file
-" vmap <leader>z <Esc>:%s/<c-r>=GetVisual()<cr>/
-" Interactif
-" You can call this function with: :10,30call Count_words()
-" map <F7> o<C-R>=VimShortcurtsAuto('all_choose')<CR>
-" NB 09.11.11 map <F8> :.!~/.vim/vim-shortcurts-stdin<CR>
-" vmap <F8> !~/.vim/vim-shortcurts<CR>
-" vmap <F8> .!~/.vim/vim-shortcurts all_choose<CR>
-" map <F8> :s/^\(.*\)$/\=VimShortcurtsAuto('all_choose','\1')/<CR>
-" map <F8> :s/^/\=VimShortcurtsAuto('all_choose')/<CR>
-" vmap <F8> :s/^/\=VimShortcurtsAuto('all_choose')/<CR>
-" nmap <silent> <F8> :set opfunc=CountSpaces<CR>g@
-" vmap <silent> <F8> :<C-U>call CountSpaces(visualmode(), 1)<CR>
-
-
-
diff --git a/etc/vim/vimplaterc b/etc/vim/vimplaterc
deleted file mode 100755 (executable)
index a11e53e..0000000
+++ /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=<user> -dir=<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=<name>
-$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 <http://www.gnu.org/licenses/>.";
-
-       $Config::user->{$_} = \%h;
-};
-1;
index c3835eeb2c167b836be7b6581541d585db29e15e..8bbc555b46d66884521a0c1bb245b708057b3b33 100644 (file)
--- 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