Spaces:
Sleeping
Sleeping
batonai-coding-assistant[bot] commited on
Add Go language support for syntax highlighting
Browse files- Extend `get_language_by_extension()` to recognize `.go` files, returning 'go' for Go language.
- Update `CodeParser` class to support Go:
- Add 'go' to `language_extension_map`.
- Modify `_install_parsers()` to clone and build the `tree-sitter-go` repository.
- Include relevant syntax nodes for Go in `_get_node_types_of_interest()`:
- import_declaration => 'Import'
- function_declaration => 'Function'
- Add more as needed.
- Update `_get_nodes_for_comments()` to recognize Go comments.
These changes are necessary to provide syntax highlighting capabilities for Go code in the application, improving usability for developers working with Go files.
Files changed (2)
- CodeParser.py+14-1
- app.py+2
18 unmodified lines19202122232425151 unmodified lines17717817918018118230 unmodified lines21321421521621721818 unmodified lines"ts": "typescript","tsx": "typescript","php": "php","rb": "ruby"}if file_extensions is None:self.language_names = []151 unmodified lines'module': 'Module','singleton_class': 'Singleton Class','begin': 'Begin Block',}}30 unmodified lines},'rb': {'comment': 'Comment',}}18 unmodified lines1920212223242526151 unmodified lines17817918018118218318418518618718818919019119230 unmodified lines22322422522622722822923023118 unmodified lines"ts": "typescript","tsx": "typescript","php": "php","rb": "ruby","go": "go"}if file_extensions is None:self.language_names = []151 unmodified lines'module': 'Module','singleton_class': 'Singleton Class','begin': 'Begin Block',},'go': {'import_declaration': 'Import','function_declaration': 'Function','method_declaration': 'Method','type_declaration': 'Type','struct_type': 'Struct','interface_type': 'Interface','package_clause': 'Package'}}30 unmodified lines},'rb': {'comment': 'Comment',},'go': {'comment': 'Comment',}}
55 unmodified lines56575859606155 unmodified linesreturn 'ruby'elif file_extension == 'php':return 'php'else:return None55 unmodified lines565758596061626355 unmodified linesreturn 'ruby'elif file_extension == 'php':return 'php'elif file_extension == 'go':return 'go'else:return None
CodeParser.py+14-1
app.py+2