Browse files

add windows supports.

i think it's a great news for windows-vim users.
Signed-off-by: sunus <sunuslee@gmail.com>
  • Loading branch information...
1 parent 20a2942 commit 9110f5e8dafd3b27f1da81f323f622f8bbb6c00a @sunuslee committed Dec 12, 2012
Showing with 84 additions and 24 deletions.
  1. +26 −8 README.md
  2. +58 −16 randomColorPicker.vim
View
34 README.md
@@ -2,23 +2,27 @@
Power VIM Users like us have already wasted tons of time to choose
-our favorite colorschemes, and may still not be satisfied with the
+our favorite colorschemes, and may still not be satisfied with the
-current colorschemes. So I wrote this plugin to help us out, to
+current colorschemes. So I wrote this plugin to help us out, to
-meet the perfect colorsheme that we are __DESTINED__ to be with.
+meet the perfect colorsheme that we are __DESTINED__ to be with.
just like your lovely girlfriends/wifves:)
Written by sunus Lee
sunus.the.dev[at]gmail.com
-Thu Nov 22 00:03:59 CST 2012
+Wed Dec 12 11:50:55 CST 2012
+
+Added Windows Support, great news for windows vim users, right? :)
### Installation ###
Just copy randomColorPicker.vim to your VIM runtime plugin path:
+##### Linux #####
+
You may need to create ~/.vim/plugin directory if it doesn't exist:
`mkdir -p ~/.vim/plugin`
@@ -27,6 +31,20 @@ then:
`cp randomColorPicker.vim ~/.vim/plugin`
+##### Windows #####
+
+1. create a directory at:
+
+ `C:\Users\YourUsername\vimfiles\plugin`
+
+ or enter directory:
+
+ `C:\Program Files\vim\vim73\plugin`
+
+ vim73 might be vim72 or whatever.. as long as it's where ur vim is installed, it's vaild.
+
+2. copy randomColorPicker.vim to that directory.
+
### Usage ###
When you use vim open a file, I will randomly pick up a colorscheme
for you.
@@ -52,8 +70,8 @@ for you.
randomly pick a new coloscheme.
* if you somehow regret what you did and want to get the hated colorscheme back,
-
- Enter(In Normal Mode)
+
+ Enter(In Normal Mode)
`:Back`
@@ -69,7 +87,7 @@ for you.
### Tips ###
Use this plugin with a large colorsheme pool
-
+
will increase the possibility of meeting the right ColorScheme for you.
So, I recommand you also use the ColorScheme Pack at:
@@ -78,5 +96,5 @@ for you.
Big Thanks to __Robert Melton__ for his awesome work!
-### Any Feedback any Suggestions is welcomed ###
+### Any Feedback and Suggestions is welcomed ###
mail me: sunus.the.dev[at]gmail.com
View
74 randomColorPicker.vim
@@ -6,18 +6,45 @@
"
" ==ABOUT==
" Power VIM Users like us have already wasted tons of time to choose
-" our favorite colorschemes, and may still not be satisfied with the
-" current colorschemes. So I wrote this plugin to help us out, to
-" meet the perfect colorsheme that we are `DESTINED` to be with.
+" our favorite colorschemes, and may still not be satisfied with the
+" current colorschemes. So I wrote this plugin to help us out, to
+" meet the perfect colorsheme that we are `DESTINED` to be with.
" just like your lovely girlfriends/wifves:)
" Written by sunus Lee
" sunus.the.dev@gmail.com
-let g:plugin_path=$HOME.'/.vim/plugin/'
-let g:love_path=g:plugin_path.'.love'
-let g:hate_path=g:plugin_path.'.hate'
+function! GetOS()
+ if has('unix')
+ return 'linux'
+ elseif has('win16') || has('win32') || has('win64')
+ return 'win'
+ endif
+endfunction
+
+function! GetRAND()
+ if g:os == 'linux'
+ return system("echo $RANDOM")
+ elseif g:os == 'win'
+ return system("echo %RANDOM%")
+ endif
+endfunction
+
+let g:os=GetOS()
+let plugin_path = expand('%:p:h')
+
+if g:os == 'linux'
+ let g:slash='/'
+ let g:love_path=g:plugin_path.'/.love'
+ let g:hate_path=g:plugin_path.'/.hate'
+elseif g:os == 'win'
+ let g:slash='\'
+ let g:love_path=g:plugin_path.'\love.txt'
+ let g:hate_path=g:plugin_path.'\hate.txt'
+endif
+
let g:colorscheme_file_path=''
let g:colorscheme_file=''
+let g:totla_colorschemes = 0
function! Picker()
let r=findfile(g:love_path)
@@ -29,19 +56,24 @@ function! Picker()
return
endif
endif
- let colorscheme_dirs=[$VIMRUNTIME.'/colors', '~/.vim/colors']
+ if g:os == 'linux'
+ let colorscheme_dirs=[$VIMRUNTIME.'/colors', '~/.vim/colors']
+ elseif g:os == 'win'
+ let colorscheme_dirs=[$VIMRUNTIME.'/colors', $HOME.'/vimfiles/colors']
+ endif
let arr=[]
for colorsheme_dir in colorscheme_dirs
let colorschemes=glob(colorsheme_dir.'/*.vim')
- let arr+=split(colorschemes)
+ let arr+=split(colorschemes, '\n')
endfor
+ let g:total_colorschemes = len(arr)
let hates=[]
let r=findfile(g:hate_path)
if r != ''
let hates=readfile(g:hate_path)
endif
while 1
- let rand=system("echo $RANDOM")
+ let rand=GetRAND()
let rand=rand%len(arr)
let g:colorscheme_file_path=arr[rand]
if index(hates, g:colorscheme_file_path) == -1
@@ -50,7 +82,7 @@ function! Picker()
endwhile
" colorscheme is /path/to/colorscheme_file.vim
" convert to colorscheme_file
- let g:colorscheme_file=split(g:colorscheme_file_path, '/')[-1][:-5]
+ let g:colorscheme_file=split(g:colorscheme_file_path, g:slash)[-1][:-5]
call ApplyCS()
endfunction
@@ -65,12 +97,22 @@ endfunction
function! HateCS()
call delete(g:love_path)
- let hates=readfile(g:hate_path)
- call add(hates, g:colorscheme_file_path)
- call writefile(hates, g:hate_path)
- call Picker()
- redrawstatus
- call ShowCS()
+ let r=findfile(g:hate_path)
+ if r != ''
+ let hates=readfile(g:hate_path)
+ else
+ let hates=[]
+ endif
+ if len(hates) + 1 == g:total_colorschemes
+ redrawstatus
+ echo "She is the last one you got, Can't hate it anymore, or :Back first."
+ else
+ call add(hates, g:colorscheme_file_path)
+ call writefile(hates, g:hate_path)
+ call Picker()
+ redrawstatus
+ call ShowCS()
+ endif
endfunction
function! BackCS()

0 comments on commit 9110f5e

Please sign in to comment.