184184include_regex = re .compile (r'#include\s*[<"]([^">]+)[">]' )
185185
186186# Ctags-based symbol index (optional)
187+ ctags_executable = None
187188ctags_available = False
188189ctags_header_to_qnames : dict [str , set [str ]] = {}
189190ctags_defs_by_qname : dict [str , set [str ]] = {}
@@ -204,11 +205,20 @@ def detect_universal_ctags() -> bool:
204205 """
205206 Return True if Universal Ctags is available on PATH.
206207 """
207- ctags_path = shutil .which ("ctags-universal" )
208+ exec_names = ["ctags-universal" , "ctags" ]
209+
210+ global ctags_executable
211+ for exec_name in exec_names :
212+ ctags_path = shutil .which (exec_name )
213+ if ctags_path :
214+ break
208215 if not ctags_path :
209216 return False
217+
218+ ctags_executable = ctags_path
219+
210220 try :
211- out = subprocess .run ([ctags_path , "--version" ], capture_output = True , text = True , check = False )
221+ out = subprocess .run ([ctags_executable , "--version" ], capture_output = True , text = True , check = False )
212222 return "Universal Ctags" in (out .stdout + out .stderr )
213223 except Exception :
214224 return False
@@ -241,7 +251,7 @@ def run_ctags_and_index(paths: list[str]) -> tuple[dict[str, set[str]], dict[str
241251 Paths in results are relative to project_root to match this script's expectations.
242252 """
243253 cmd = [
244- "ctags-universal" , "-R" , "-f" , "-" ,
254+ ctags_executable , "-R" , "-f" , "-" ,
245255 "--map-C++=+.ino" ,
246256 "--languages=C,C++" ,
247257 "--kinds-C=+p" ,
0 commit comments