Porting a markdown-live-preview-in-vim plugin from

2019-05-16 18:38发布

问题:

I need your help. Because I've no idea what I'm doing.

There is this nice plugin vim-instant-markdown I recently stumbled onto. Basically, it's a live preview in a browser, running in the background, while you're writing your text in markdown plugin, and I like the concept.

So, I've tried to get it to work on Windows,

  • installed Ruby (rubyinstaller-1.9.3-p125)
  • installed Ruby-DevKit (DevKit-tdm-32-4.5.2-20111229-1559-sfx)
  • followed instructions on https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
  • gem install redcarpet pygments.rb
  • installed node (node-v0.6.10)
  • npm -g install instant-markdown-d

So far so good,

I open a markdown file in Vim, and it opens (pause button works here) a command line window with my text inside. Browser not seen anywhere.

In the plugin there is an /dev/null "thing" (I'm not an unix guy, more than I needed to be, which wasn't very much - just an ordinary user for most part). /dev doesn't exist on Windows.

To put long story short, my question is - can this be made to work on Windows, the way it should work, or is it a waste of effort even to try it to get it to work?

I'm welcoming all constructive ideas and suggestions.

回答1:

glad you found this useful enough to want a Windows port! I think it definitely can be done, you just might need more dependencies and hackage.

First of all, understand that there's a server component that is used apart from the actual .vim file to make this work, which is started and stopped on demand. You will definitely need to look at its code, which can be found here.

The server uses open on OSX and xdg-open on Linux to open a browser window, neither of which exist on Windows. On Windows, you can use start (more here). Try to find a way to make the browser window open in the background, and not steal focus, otherwise it will be very annoying.

Also, curl is used to send commands to the server, and curl doesn't exist for Windows. Indeed, I don't think anything similar exists. There is a curl Windows port, though IMO it kinda sucks to add such a thing as a requirement for the plugin...

It seems that you've taken this on at least partially as a learning experience, so I hope you can make it work and send back a pull request! (Of course feel free to keep asking questions if you're stuck) But in the (hopefully unlikely) event that you lose interest or give up, create an issue in github requesting Windows compatibility, and I'll see if I have time to implement it. Also, keep in mind that some questions/comments will be better suited to the project's issues area than here.

Good luck!



标签: vim markdown