mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
enable ctags if present
This commit is contained in:
parent
ae087287c7
commit
43413654bd
1 changed files with 10 additions and 6 deletions
|
@ -50,16 +50,18 @@ def fname_to_components(fname, with_colon):
|
||||||
class RepoMap:
|
class RepoMap:
|
||||||
ctags_cmd = ["ctags", "--fields=+S", "--extras=-F", "--output-format=json"]
|
ctags_cmd = ["ctags", "--fields=+S", "--extras=-F", "--output-format=json"]
|
||||||
|
|
||||||
def __init__(self, use_ctags=True, root=None, main_model="gpt-4"):
|
def __init__(self, use_ctags=None, root=None, main_model="gpt-4"):
|
||||||
if not self.check_for_ctags():
|
|
||||||
use_ctags = False
|
|
||||||
if not root:
|
if not root:
|
||||||
root = os.getcwd()
|
root = os.getcwd()
|
||||||
|
|
||||||
self.use_ctags = use_ctags
|
|
||||||
self.tokenizer = tiktoken.encoding_for_model(main_model)
|
|
||||||
self.root = root
|
self.root = root
|
||||||
|
|
||||||
|
if use_ctags is None:
|
||||||
|
self.use_ctags = self.check_for_ctags()
|
||||||
|
else:
|
||||||
|
self.use_ctags = use_ctags
|
||||||
|
|
||||||
|
self.tokenizer = tiktoken.encoding_for_model(main_model)
|
||||||
|
|
||||||
def get_repo_map(self, chat_files, other_files):
|
def get_repo_map(self, chat_files, other_files):
|
||||||
res = self.choose_files_listing(other_files)
|
res = self.choose_files_listing(other_files)
|
||||||
if not res:
|
if not res:
|
||||||
|
@ -164,6 +166,7 @@ class RepoMap:
|
||||||
|
|
||||||
# Update the cache
|
# Update the cache
|
||||||
TAGS_CACHE[cache_key] = {"mtime": file_mtime, "tags": tags}
|
TAGS_CACHE[cache_key] = {"mtime": file_mtime, "tags": tags}
|
||||||
|
return tags
|
||||||
|
|
||||||
def check_for_ctags(self):
|
def check_for_ctags(self):
|
||||||
try:
|
try:
|
||||||
|
@ -176,6 +179,7 @@ class RepoMap:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
rm = RepoMap()
|
rm = RepoMap()
|
||||||
res = rm.get_tags_map(sys.argv[1:])
|
res = rm.get_tags_map(sys.argv[1:])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue