Hey Ben,
Would it be possible to include a language field in the /code API response?
Right now (in searchcode-sdk), I’m manually guessing the language using the whats-that-code library, like this:
language = guess_language_all_methods(code=code_data)
syntax = Syntax(code=code_data, lexer=language, line_numbers=True)
That’s from lines 176–177 in searchcode-sdk/searchcode/cli.py.
However, when using the /search endpoint, each result includes a language key, which makes it easy to apply syntax highlighting directly in the CLI.
For example:
for item in data:
filename = item.get("filename", "Unknown")
repo = item.get("repo", "Unknown")
language = item.get("language", "text")
lines_count = item.get("linescount", "??")
code_string = extract_code_string_with_linenumbers(
lines_dict=item.get("lines", {})
)
syntax = Syntax(
code=code_string, lexer=language, word_wrap=False, indent_guides=True
)
It’d be super helpful to have that same language field available in the /code response, just to avoid the guesswork. Totally understand if there’s a reason it’s currently excluded. I just thought I’d ask if it might be feasible to include.
Hey Ben,
Would it be possible to include a
languagefield in the/codeAPI response?Right now (in searchcode-sdk), I’m manually guessing the language using the whats-that-code library, like this:
That’s from lines 176–177 in searchcode-sdk/searchcode/cli.py.
However, when using the
/searchendpoint, each result includes alanguagekey, which makes it easy to apply syntax highlighting directly in the CLI.For example:
It’d be super helpful to have that same
languagefield available in the/coderesponse, just to avoid the guesswork. Totally understand if there’s a reason it’s currently excluded. I just thought I’d ask if it might be feasible to include.