Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language detection #21

Open
tmm1 opened this issue Jul 27, 2023 · 2 comments
Open

Language detection #21

tmm1 opened this issue Jul 27, 2023 · 2 comments

Comments

@tmm1
Copy link

tmm1 commented Jul 27, 2023

👋 first off, huge thanks for putting this package together!

i'm wondering, with all these languages available what is the recommended way to pick a parser/language for a given file?

i see that each language implementation has a package.json section for tree-sitter configuration:

https://github.com/tree-sitter/tree-sitter-python/blob/master/package.json#L28-L32
latex-lsp/tree-sitter-latex#19

perhaps the build process could pluck out these entries and make them available? so then a user could simply apply the file_types and content_regex rules to figure out what language to use.

@tmm1
Copy link
Author

tmm1 commented Jul 27, 2023

i'm wondering, with all these languages available what is the recommended way to pick a parser/language for a given file?

there's some logic in the tree-sitter cli that does this, but unfortunately its not part of the actual library

i guess most people are using linguist or integrating into editor environments where they already have textmate compatible language detection.

seems like it may be beneficial to port and bundle the detection code in this python package, so users don't have to reimplement it. wdyt?

here's the reference impl:

https://github.com/tree-sitter/tree-sitter/blob/b8f7645ae2a5e240e67f968c89328af280055c9f/cli/loader/src/lib.rs#L207-L223

cc @nathansobo do i have this right?

@grantjenks
Copy link
Owner

I’m open to a PR but unlikely to do it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants