Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Fix python module path in git-bash && Add sync in browser opening #72

Merged
merged 2 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions autoload/mkdp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ let g:mkdp_cwd = ''
"python/python3 import init
exec s:py_cmd . 'import vim'
exec s:py_cmd . 'import sys'
exec s:py_cmd . 'import os'
exec s:py_cmd . 'import re'
exec s:py_cmd . 'cwd = vim.eval("expand(\"<sfile>:p:h\")")'
exec s:py_cmd . "cwd = re.sub(r'(?<=^.)', r':', os.sep.join(cwd.split('/')[1:])) if os.name == 'nt' and cwd.startswith('/') else cwd"
exec s:py_cmd . 'sys.path.insert(0,cwd)'
exec s:py_cmd . 'from server import send'
exec s:py_cmd . 'import base64'
Expand Down
35 changes: 23 additions & 12 deletions plugin/mkdp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,29 @@ if !exists('g:mkdp_command_for_global')
endif

function! MKDP_browserfunc_default(url)
if has("win32") || has("win64")
" windows
execute "silent !cmd /c start " . a:url . '.html'
elseif has("unix")
silent! let s:uname=system("uname")
if s:uname=="Darwin\n"
" mac
let dummy = system('open "' . a:url . '"')
else
" unix
let dummy = system('xdg-open "' . a:url . '"')
endif
" windows, including mingw
if has('win32') || has('win64') || has('win32unix')
let l:cmd = "start " . a:url . '.html'
" mac os
elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin'
let l:cmd = 'open ' . a:url
" linux
elseif executable('xdg-open')
let l:cmd = 'xdg-open ' . a:url
" can not find the browser
else
echoerr "Browser not found."
return
endif

" Async open the url in browser
if exists('*jobstart')
call jobstart(l:cmd)
elseif exists('*job_start')
call job_start(l:cmd)
else
" if async is not supported, use `system` command
call system(l:cmd)
endif
endfunction
if !exists('g:mkdp_browserfunc')
Expand Down