#253 Fix formatterpath seperator char on windows

This commit is contained in:
Mattias 2018-10-21 17:05:45 +02:00
parent 3c09aec853
commit 3c06476e73

View File

@ -185,7 +185,7 @@ function! s:TryFormatterPython()
let verbose = &verbose || g:autoformat_verbosemode == 1
python << EOF
import vim, subprocess, os
import vim, subprocess, os, platform
from subprocess import Popen, PIPE
text = os.linesep.join(vim.current.buffer[:]) + os.linesep
formatprg = vim.eval('b:formatprg')
@ -194,7 +194,8 @@ verbose = bool(int(vim.eval('verbose')))
env = os.environ.copy()
if int(vim.eval('exists("g:formatterpath")')):
extra_path = vim.eval('g:formatterpath')
env['PATH'] = ':'.join(extra_path) + ':' + env['PATH']
pathsep = ';' if platform.system() == 'Windows' else ':'
env['PATH'] = pathsep.join(extra_path) + pathsep + env['PATH']
# When an entry is unicode, Popen can't deal with it in Python 2.
# As a pragmatic fix, we'll omit that entry.
@ -241,7 +242,7 @@ function! s:TryFormatterPython3()
let verbose = &verbose || g:autoformat_verbosemode == 1
python3 << EOF
import vim, subprocess, os
import vim, subprocess, os, platform
from subprocess import Popen, PIPE
# The return code is `failure`, unless otherwise specified
@ -253,7 +254,8 @@ verbose = bool(int(vim.eval('verbose')))
env = os.environ.copy()
if int(vim.eval('exists("g:formatterpath")')):
extra_path = vim.eval('g:formatterpath')
env['PATH'] = ':'.join(extra_path) + ':' + env['PATH']
pathsep = ';' if platform.system() == 'Windows' else ':'
env['PATH'] = pathsep.join(extra_path) + pathsep + env['PATH']
try:
p = subprocess.Popen(formatprg, env=env, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)