-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
customizable file type mapping #3273
customizable file type mapping #3273
Conversation
Meybe this should be under the |
Right now that's the case, but it doesn't have to be (see disc). |
This key name is confusing: looking just at the toml I would think this makes helix think any |
The key name is derived from the default strings ("rust", "typescript", "javascript", etc.) returned from (or are you talking about the Some possibilities: |
I mean the |
I kept it plural ( Note that the statusline refers to |
Just in case anyone wants to try this with nerdfonts, here's a quick file I put together that has all the filetypes I and Helix know about: https://gist.github.com/sbromberger/20ba8b7174ecacad43a10a402446d6fa These probably won't show up in your browser but if you have nerdfonts and download the file, you should see the glyphs. You should be able to append this file to your |
Here's a version that falls back to use the scope identifier if no LSP is provided.
Not overly testet but what I did test seemed to work. Nice feature BTW 👍 |
I think this is ready for review. The bug in language identification is unrelated to this PR but fixing it will definitely make this feature more accurate. |
@@ -330,6 +330,12 @@ where | |||
F: Fn(&mut RenderContext, String, Option<Style>) + Copy, | |||
{ | |||
let file_type = context.doc.language_id().unwrap_or("text"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat unrelated to this change, I think this might be better off as the scope
field from languages.toml
which is context.doc.language().unwrap_or("text")
. That way Rust is "source.rust", toml is "source.toml", html is "text.html.basic", etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest any changes to this PR? My opinion is that we should have a function whose sole purpose is to return the language. Right now there are several possible ways to do it, each with their own issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have a function whose sole purpose is to return the language
The trouble is: what is the language? We could say it's the scope
or we could say it's the name
(language_id but not language_id()
, see also #3338). It depends on what we want the public API of language names to be: is the LanguageConfiguration.language_id
an implementation detail or is it ok for configurations to use them?
I'd be hesitant to merge this PR until we figure that out since this PR introduces a way for configurations to depend on language names/ids/scopes.
@archseer what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR merely provides a mapping from the current language reporting functionality so that we can use custom strings that don't take up 1/4 of the status line. I'd be really disappointed if this PR was held up as a result of a feature that is still unimplemented.
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
ref: #3164
This PR introduces a new
[editor.file-types]
config section that will allow custom mappings between the default file type strings and user-defined custom strings. An example:will remap the "rust" file type string to "rs" (currently used by the statusline). Glyphs/icons should be supported, if available in the user's font definition.
cc @Etienne-K