-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
Add an option to map an extension to a language #67
Comments
In order to check if a language exists, I thought about |
I have thought about this feature for a few months. I don't think it should be through flags. Then you'd always have to remember to have the set the correct flags every time. Instead I think it should be like |
I agree that a rc file would be really nice but being able to use this feature on the cli can be useful when you want something quick.
What do you think? |
@xpayn Well I think this should be implemented on the road to to rc. As I don't want to make an implementation that will have to be rewritten soon. As rc is the next feature I want to implement. |
ok, seems fair to me. |
@xpayn Please do. And of course if there are any other problems or feature requests please do make an issue for them too! |
@Aaronepower Maybe you can have a look at what @BurntSushi did for managing extensions an file types in ripgrep: https://github.com/BurntSushi/ripgrep/blob/master/src/types.rs |
FYI, I'm working on splitting out the ignore/gitignore/filetype logic from ripgrep into a separate crate. It should be done in the next couple weeks. |
A heads-up for contributors, looks like the https://crates.io/crates/ignore |
@remexre Tokei has already integrated the |
Forgive my ignorance, but what exactly is the problem that needs to be solved? ignore's types module vs tokei's? Or is there something else? |
@remexre Having the same functionality as .gitignore, but as it relates to mapping extensions against languages. |
Doesn't |
@remexre ignores's types aren't 1 to 1 with tokei's. Those are for ignoring file types, where tokei wants to map them to a different language. |
Note that you don't need to use the built in file types.
…On Dec 11, 2016 5:17 AM, "Aaron Power" ***@***.***> wrote:
@remexre <https://github.com/remexre> ignores's types aren't 1 to 1 with
tokei's. Those are for ignoring file types, where tokei wants to map them
to a different language.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#67 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAb34kZeRBHqbmq-LyqKLWgoOE9U6x-vks5rG823gaJpZM4KCntQ>
.
|
A modeline (vim) or file-local-vars (emacs) at the beginning or end of a file are also often used to enable a certain language mode and can be used for better accuracy. There's also the problem that languages have conventions for certain files which are not merely the extension but the whole filename. For example, in Erlang you have |
@Tuncer I'm not really familiar with modeline, or file-local-vars, could you provide a few examples? |
The relevance for tokei is that it's common to select a filetype (vim) or mode (emacs) via a file local var and modeline in files that do not have a uniquely mappable file extension ( |
Would it be an option to apply heuristics on the files with ambiguous extensions to try and guess the language? |
I'm going to close this issue, moving everything to #195 as I don't think I'm going to implement a solution that isn't a configuration file. |
This comment has been minimized.
This comment has been minimized.
What about files with no extension? tokei completely ignores those currently. For example my zsh configuration is made out of modular files with no extension (example: Would it be possible to specify a "fallback" language used if the language can't be determined, or be able to map full glob patterns or similar to languages, rather than only extensions? |
It doesn't, tokei just currently requires a well-known file name before it will count them, you can see this for dockerfiles for example. Line 351 in 5f755db
|
It would be very convenient to have such an option when an extension is unknown for a given language or when an extension is ambiguous (e.g. .cgi, .inc).
It could be used to override a default mapping, or even discard a mapping, for instance I have a file .pro which is a QT Creator project and not a Prolog file. But maybe in the later case, it would be cleaner to have a dedicated option to ignore a given extension.
I'll try to submit a PR, but any guidance would be greatly appreciated :)
The text was updated successfully, but these errors were encountered: