Skip to content

Commit dfeecfc

Browse files
committed
Revise path_to_ns
1 parent 2080a81 commit dfeecfc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

rplugin/python3/acid/nvim/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def src_paths(nvim):
120120
return {'src', *nvim.vars.get('acid_alt_paths', [])}
121121

122122
def get_stop_paths(nvim):
123-
return {'test', 'src'}
123+
return {'test', 'src', *test_paths(nvim), *src_paths(nvim)}
124124

125125
def find_file_in_path(nvim, msg):
126126
fname = msg['file']

rplugin/python3/acid/pure/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import os
2+
import re
23
from acid.nvim.log import log_debug, log_warning
34

45

56
def path_to_ns(path, stop_paths=None):
67
if stop_paths is None:
78
stop_paths = ['src', 'test']
89

9-
path = path.replace("_", "-").split('/')[1:]
10-
path[-1] = path[-1].split('.')[0]
10+
stop_paths = sorted(stop_paths, key=lambda x: x.count('/'))
11+
1112
raw_path_list = None
1213

13-
for ix, node in enumerate(reversed(path)):
14-
if node in stop_paths:
15-
raw_path_list = path[ix * -1:]
14+
for stop_path in reversed(stop_paths):
15+
m = re.search(stop_path, path)
16+
if m:
17+
raw_path_list = path[m.start():].replace("_", "-").split('/')[stop_path.count('/') + 1:]
18+
raw_path_list[-1] = raw_path_list[-1].split('.')[0]
1619
break
1720

1821
if raw_path_list is None:
1922
log_debug("Previous check did not work. Attempting project.clj")
2023

2124
# Look for project.clj
25+
path = path.replace("_", "-").split('/')[1:]
26+
path[-1] = path[-1].split('.')[0]
2227
for ix, _ in enumerate(path):
2328
if os.path.exists(os.path.join(*["/", *path[:ix], "project.clj"])):
2429
raw_path_list = path[ix+1:]

0 commit comments

Comments
 (0)