Skip to content

Commit e800c64

Browse files
blueyedjustinmk
authored andcommitted
refactor: discover_runtime_directories (#287)
1 parent 936110a commit e800c64

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

neovim/plugin/script_host.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
if sys.version_info >= (3, 4):
2525
from importlib.machinery import PathFinder
2626

27+
PYTHON_SUBDIR = 'python3'
28+
else:
29+
PYTHON_SUBDIR = 'python2'
30+
2731

2832
@plugin
2933
class ScriptHost(object):
@@ -236,16 +240,11 @@ def hook(path):
236240

237241
def discover_runtime_directories(nvim):
238242
rv = []
239-
for path in nvim.list_runtime_paths():
240-
if not os.path.exists(path):
243+
for rtp in nvim.list_runtime_paths():
244+
if not os.path.exists(rtp):
241245
continue
242-
path1 = os.path.join(path, 'pythonx')
243-
if IS_PYTHON3:
244-
path2 = os.path.join(path, 'python3')
245-
else:
246-
path2 = os.path.join(path, 'python2')
247-
if os.path.exists(path1):
248-
rv.append(path1)
249-
if os.path.exists(path2):
250-
rv.append(path2)
246+
for subdir in ['pythonx', PYTHON_SUBDIR]:
247+
path = os.path.join(rtp, subdir)
248+
if os.path.exists(path):
249+
rv.append(path)
251250
return rv

0 commit comments

Comments
 (0)