From 3f365fd9a8c387376f5ad070ffe73c148b728336 Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Thu, 18 Feb 2021 10:00:12 -0800 Subject: [PATCH] Add --clean to avoid loading ftplugins This uses vim's '--clean' switch to avoid loading ftplugins, since this can affect behavior during vroom tests. This switch seems to avoid the issue in my local testing, whereas other things ('-i NONE', '--noplugin', etc.) don't seem to have the same effect. This falls back to trying without the '--clean' switch if vim fails to start up. I can't get vroom running in '--neovim' mode (nvim 0.4.4), so this doesn't attempt to address the issue in the neovim code path. neovim appears to define '--clean' differently from vim, so it's possible neovim may require a different fix. I verified this still respects vroom's '--vimrc' switch while having the desired behavior of avoiding plugins. Fixes #105 --- vroom/vim.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vroom/vim.py b/vroom/vim.py index f295f65..4fc4684 100644 --- a/vroom/vim.py +++ b/vroom/vim.py @@ -92,8 +92,12 @@ class Communicator(object): def __init__(self, args, env, writer): self.writer = writer.commands self.args = args + # The order of switches matters. '--clean' will prevent vim from loading any + # plugins from ~/.vim/, but it also sets '-u DEFAULTS'. We supply '-u' after + # to force vim to take our '-u' value (while still avoiding plugins). self.start_command = [ 'vim', + '--clean', '-u', args.vimrc, '--servername', args.servername, '-c', 'set shell=' + args.shell, @@ -120,6 +124,13 @@ def Start(self): # still has a _vim attribute it can query for details. self.process = subprocess.Popen(self.start_command, env=self.env) time.sleep(self.args.startuptime) + if self.process.poll() is not None and self.process.poll() != 0: + # If vim exited this quickly, it probably means we passed a switch it + # doesn't recognize. Try again without the '--clean' switch since this is + # new in 8.0.1554+. + self.start_command.remove('--clean') + self.process = subprocess.Popen(self.start_command, env=self.env) + time.sleep(self.args.startuptime) def _IsCurrentDisplayUsable(self): """Check whether vim fails using the current configured display."""