beloglazov / vim-online-thesaurus

A Vim plugin for looking up words in an online thesaurus
Apache License 2.0
247 stars 21 forks source link

Windows support #28

Closed v-yadli closed 9 years ago

beloglazov commented 9 years ago

Thanks for the PR! At the moment, I'm not able to test it - I'll try to get to it next week.

v-yadli commented 9 years ago

Tested working on OSX, so I guess I didn't break the *NIX side. :)

annagrram commented 9 years ago

Not breaking the *NIX side is great :+1:

Just stating a couple of assumptions you made:

  1. Git is installed
  2. 64-bit Windows

I guess that Git is quite a resonable assumption as most people use some kind of plugin manager for Vim which uses Git. But, should it also support 32-bit Windows?

beloglazov commented 9 years ago

Looks like there is a problem with line breaks (that's why all the line are shown as modified in the diff). I've just tried it on OS X and got:

Error detected while processing ~/.vim/plugged/vim-online-thesaurus/plugin/online-thesaurus.vim:
line    5:
E492: Not an editor command: ^M
line    6:
E15: Invalid expression: exists("g:loaded_online_thesaurus")^M
line   72:
E171: Missing :endif
Press ENTER or type command to continue
v-yadli commented 9 years ago

@beloglazov I've embedded a ^V^M into the script.. maybe it's why it breaks. I'll look into that.

v-yadli commented 9 years ago

@av3r4ge Fixed :) The newest script works for 32bit Windows too.

beloglazov commented 9 years ago

I still get exactly the same error, as I showed above. I think the reason is that you've probably edited the file in Windows, which inserted it's own line breaks. Your last commit has the following git diff:

diff --git a/plugin/online-thesaurus.vim b/plugin/online-thesaurus.vim
index 32f56a4..93c6d37 100644
--- a/plugin/online-thesaurus.vim
+++ b/plugin/online-thesaurus.vim
@@ -12,9 +12,17 @@ let s:save_cpo = &cpo
 set cpo&vim
 let s:save_shell = &shell
 if has("win32")
-    let &shell        = 'C:\\Program Files (x86)\\Git\\bin\\bash.exe'
+    let cpu_arch      = system('echo %PROCESSOR_ARCHITECTURE%')^M
     let s:script_name = "\\thesaurus-lookup.sh"
-    let s:sort        = "C:\\Program Files (x86)\\Git\\bin\\sort.exe"
+    if isdirectory('C:\\Program Files (x86)\\Git')^M
+        let &shell        = 'C:\\Program Files (x86)\\Git\\bin\\bash.exe'^M
+        let s:sort        = "C:\\Program Files (x86)\\Git\\bin\\sort.exe"^M
+    elseif isdirectory('C:\\Program Files\\Git')^M
+        let &shell        = 'C:\\Program Files\\Git\\bin\\bash.exe'^M
+        let s:sort        = "C:\\Program Files\\Git\\bin\\sort.exe"^M
+    else^M
+        echoerr 'vim-thesaurus: Cannot find git installation.'^M
+    endif^M
 else
     let &shell        = '/bin/sh'
     let s:script_name = "/thesaurus-lookup.sh"
@@ -43,7 +51,7 @@ function! s:Lookup(word)
     exec ":silent 0r !" . s:path . " " . shellescape(l:word)
     exec ":silent! g/\\vrelevant-\\d+/,/^$/!" . s:sort . " -t ' ' -k 1,1r -k 2,2"
     if has("win32")
-        silent! %s/^M//g
+        silent! %s/\r//g^M
         silent! normal! gg5dd
     endif
     silent g/\vrelevant-\d+ /s///

These ^M line breaks cause problems. You can try to fix it as described here: http://stackoverflow.com/questions/64749/m-character-at-end-of-lines

v-yadli commented 9 years ago

I got you. Maybe I just turned off "check in \n, check out \r\n".

v-yadli commented 9 years ago

btw, @beloglazov what's the font used in your screenshot? it looks cool.

beloglazov commented 9 years ago

It looks good now, thanks! The font is Terminus - my favorite, I still use it :)