-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Please install the necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirements" #94
Comments
Patch using Python to provide diff --git a/plugin/vim-markdown-preview.vim b/plugin/vim-markdown-preview.vim
index 082c69f..10f41d1 100644
--- a/plugin/vim-markdown-preview.vim
+++ b/plugin/vim-markdown-preview.vim
@@ -58,20 +58,42 @@ if !exists("g:vim_markdown_preview_hotkey")
let g:vim_markdown_preview_hotkey='<C-p>'
endif
+function! s:PyPopen(cmd)
+ let l:pinfo = { 'exitcode': 2, 'stdout': '', 'stderr': 'default err:' }
+py3 << EOPY
+import vim, subprocess
+cmd = vim.eval("a:cmd")
+pinfo = vim.eval("l:pinfo")
+proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, shell=True)
+exit_code = str(proc.wait()).replace("'", "'")
+stdout = proc.stdout.read().decode().replace("'", "'")
+stderr = proc.stderr.read().decode().replace("'", "'")
+vim.command(f"let pinfo.exitcode = '{exit_code}'")
+vim.command(f"let pinfo.stdout = '{stdout}'")
+vim.command(f"let pinfo.stderr = '{stderr}'")
+EOPY
+ return l:pinfo
+endfunction
+
function! Vim_Markdown_Preview()
let b:curr_file = expand('%:p')
-
+ let l:cmd = ''
if g:vim_markdown_preview_github == 1
- call system('grip "' . b:curr_file . '" --export /tmp/vim-markdown-preview.html --title vim-markdown-preview.html')
+ let l:cmd = 'grip "' . b:curr_file . '" --export /tmp/vim-markdown-preview.html --title vim-markdown-preview.html'
elseif g:vim_markdown_preview_perl == 1
- call system('Markdown.pl "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
+ let l:cmd = 'Markdown.pl "' . b:curr_file . '" > /tmp/vim-markdown-preview.html'
elseif g:vim_markdown_preview_pandoc == 1
- call system('pandoc --standalone "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
+
+ let l:cmd = 'pandoc --standalone "' . b:curr_file . '" > /tmp/vim-markdown-preview.html'
else
- call system('markdown "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
+ let l:cmd = 'markdown "' . b:curr_file . '" > /tmp/vim-markdown-preview.html'
endif
- if v:shell_error
- echo 'Please install the necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirements'
+ let l:pinfo = s:PyPopen(l:cmd)
+ if l:pinfo.exitcode != 0
+ echo 'Please install check necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirements'
+ echo 'EXITCODE,CMD: '.l:pinfo.exitcode.','.l:cmd
+ echo 'STDOUT: '.l:pinfo.stdout
+ echo 'STDERR: '.l:pinfo.stderr
endif
if g:vmp_osname == 'unix'
After applying the patch, if Please install check necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#require
ments
EXITCODE,CMD: 127,pandoc --standalone "/home/archie/README.md" > /tmp/vim-markdown-preview.html
STDOUT:
STDERR: pandoc: error while loading shared libraries: libHSQuickCheck-2.13.2-F1caelbelL24B6NyiafVp6-ghc8.8
.1.so: cannot open shared object file: No such file or directory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am packaging this plugin for nixos but the errors
Please install the necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirement
is too little. Seems like it fails to start grip even though I have it on PATH. Would be nice to display either/and:The text was updated successfully, but these errors were encountered: