File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ def src_paths(nvim):
120120 return {'src' , * nvim .vars .get ('acid_alt_paths' , [])}
121121
122122def get_stop_paths (nvim ):
123- return {'test' , 'src' }
123+ return {'test' , 'src' , * test_paths ( nvim ), * src_paths ( nvim ) }
124124
125125def find_file_in_path (nvim , msg ):
126126 fname = msg ['file' ]
Original file line number Diff line number Diff line change 11import os
2+ import re
23from acid .nvim .log import log_debug , log_warning
34
45
56def 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 :]
You can’t perform that action at this time.
0 commit comments