From 3c06476e732ea91538d2ddde9caf9df2bbfbfb55 Mon Sep 17 00:00:00 2001 From: Mattias <1116150+Mattias1@users.noreply.github.com> Date: Sun, 21 Oct 2018 17:05:45 +0200 Subject: [PATCH] #253 Fix formatterpath seperator char on windows --- plugin/autoformat.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/autoformat.vim b/plugin/autoformat.vim index 142713c..6df7751 100644 --- a/plugin/autoformat.vim +++ b/plugin/autoformat.vim @@ -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)