This commit is contained in:
Paul Gauthier 2023-10-18 15:18:12 -07:00
parent 2c98ea4448
commit 10b856e0af
3 changed files with 2 additions and 65 deletions

View file

@ -178,7 +178,7 @@ class Coder:
) )
if map_tokens > 0: if map_tokens > 0:
self.io.tool_output(f"Repo-map: universal-ctags using {map_tokens} tokens") self.io.tool_output(f"Repo-map: using {map_tokens} tokens")
else: else:
self.io.tool_output("Repo-map: disabled because map_tokens == 0") self.io.tool_output("Repo-map: disabled because map_tokens == 0")

View file

@ -1,58 +0,0 @@
import os
# Updated mapping of file extensions to parsers
PARSERS = {
".py": "python",
".js": "javascript",
".go": "go",
".bash": "bash",
".c": "c",
".cs": "c-sharp",
".cl": "commonlisp",
".cpp": "cpp",
".css": "css",
".dockerfile": "dockerfile",
".dot": "dot",
".el": "elisp",
".ex": "elixir",
".elm": "elm",
".et": "embedded-template",
".erl": "erlang",
".gomod": "go-mod",
".hack": "hack",
".hs": "haskell",
".hcl": "hcl",
".html": "html",
".java": "java",
".jsdoc": "jsdoc",
".json": "json",
".jl": "julia",
".kt": "kotlin",
".lua": "lua",
".mk": "make",
# ".md": "markdown",
".m": "objc",
".ml": "ocaml",
".pl": "perl",
".php": "php",
".ql": "ql",
".r": "r",
".regex": "regex",
".rst": "rst",
".rb": "ruby",
".rs": "rust",
".scala": "scala",
".sql": "sql",
".sqlite": "sqlite",
".toml": "toml",
".tsq": "tsq",
".tsx": "typescript",
".ts": "typescript",
".yaml": "yaml",
}
def filename_to_lang(filename):
file_extension = os.path.splitext(filename)[1]
lang = PARSERS.get(file_extension)
return lang

View file

@ -8,12 +8,11 @@ from pathlib import Path
import networkx as nx import networkx as nx
import pkg_resources import pkg_resources
from diskcache import Cache from diskcache import Cache
from grep_ast import TreeContext from grep_ast import TreeContext, filename_to_lang
from tqdm import tqdm from tqdm import tqdm
from tree_sitter_languages import get_language, get_parser from tree_sitter_languages import get_language, get_parser
from aider import models from aider import models
from aider.parsers import filename_to_lang
from .dump import dump # noqa: F402 from .dump import dump # noqa: F402
@ -183,8 +182,6 @@ class RepoMap:
scm_fname = pkg_resources.resource_filename( scm_fname = pkg_resources.resource_filename(
__name__, os.path.join("queries", f"tree-sitter-{lang}-tags.scm") __name__, os.path.join("queries", f"tree-sitter-{lang}-tags.scm")
) )
dump(fname)
dump(scm_fname)
query_scm = Path(scm_fname) query_scm = Path(scm_fname)
if not query_scm.exists(): if not query_scm.exists():
return return
@ -198,10 +195,8 @@ class RepoMap:
captures = query.captures(tree.root_node) captures = query.captures(tree.root_node)
captures = list(captures) captures = list(captures)
dump(captures)
for node, tag in captures: for node, tag in captures:
dump(node, tag)
if tag.startswith("name.definition."): if tag.startswith("name.definition."):
kind = "def" kind = "def"
elif tag.startswith("name.reference."): elif tag.startswith("name.reference."):