Merge pull request #254 from Mattias1/fix-formatterpath-on-windows-253
#253 Fix formatterpath seperator char on windows
This commit is contained in:
commit
9ecbae7220
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user