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

feat: show filetype and filetype icon and lsp name in statusline #2211

Closed

Conversation

ttys3
Copy link
Contributor

@ttys3 ttys3 commented Apr 21, 2022

I'd like to show filetype and filetype icon and lsp name in statusline

is there better way to do this?

maybe more flexiable way, using a language like starlark ?

currently the code is rather tricky and dirty and not ready for merge, and just for discussion.

ft_icons.toml is auto generated via a lua script (lua gen.lua > ft_icons.toml) which mainly get the icons via https://github.com/kyazdani42/nvim-web-devicons/blob/master/lua/nvim-web-devicons.lua

gen.lua

#!/usr/bin/env lua

local icons = require "nvim-web-devicons"

for key, value in pairs(icons.get_icons()) do
    print(string.format('"%s"="%s"', key, value.icon))
end

here's the demo:

image

image

image

@ttys3 ttys3 marked this pull request as draft April 21, 2022 07:58
@ttys3 ttys3 force-pushed the statusline-ft-icon-lsp-name-for-pr branch from 1fc35ca to 78c3f02 Compare April 21, 2022 08:04
@David-Else
Copy link
Contributor

What about if there are multiple LSPs active (in possible future updates)?

@ttys3
Copy link
Contributor Author

ttys3 commented Apr 21, 2022

What about if there are multiple LSPs active (in possible future updates)?

yes, multiple LSPs currrently not supported, but I think it could be supported with minor updates.

future updates currently not supported. actully I did not take much time to investigate the code about how the statusline is rendered and updated.

@CptPotato
Copy link
Contributor

Is the statusline currently configurable? I think using the langauge icons might cause issues for people who don't use fonts that include them.

@ttys3
Copy link
Contributor Author

ttys3 commented Apr 21, 2022

yes, unicode emoji will be a problem for user who don't have an emoji font.

so I think it is better if the statusline is configurable.

a simple config will be a boolean item, which allow user to enable this feature. but this config maybe not flexiable

but I think maybe we can use something like starlark, so the user can define his own func to return the icon

@EpocSquadron
Copy link
Contributor

Beyond devicons there is also nerd fonts , which is a superset. I think it's relatively common to have support for it via a toggle. I think it would be a good approach here to include the info on the status line and check a global toggle for nerd fonts. Then we can show icons not just here but in various other places as well.

@David-Else
Copy link
Contributor

David-Else commented Apr 21, 2022

I never got nerd fonts to work, I really don't like them! I instead use:

https://github.com/microsoft/vscode-codicons
https://microsoft.github.io/vscode-codicons/dist/codicon.html

and they work out great, no need to patch anything. They look like this in Neovim:

68747470733a2f2f656c7365776562646576656c6f706d656e742e636f6d2f77702d636f6e74656e742f75706c6f6164732f6e76696d2d636d702d6461726b2d706c75732e706e67

@the-mikedavis
Copy link
Member

I would prefer to only show the language name/scope - the icons seem unnecessary to me and that they need a patched font doesn't help. Plus https://github.com/kyazdani42/nvim-web-devicons is not licensed so I don't know where it stands on distributing the ft_icons.toml.

@ttys3
Copy link
Contributor Author

ttys3 commented Apr 22, 2022

as for the license issue, I do not think this could be a problem. we could create ft_icons.toml by our own, which we only use unicode emoji, which is absolutely has no license issue. and also, we may allow user to override ft_icons.toml by their own.
(yes, just like languages.toml override)

yes, need a patched font, this is something not perfect, but for most users, this should not be a big problem.

@archseer
Copy link
Member

Requiring patched or custom fonts to properly display in an editor is an automatic ❌ for something built in or available out of the box.

Similar to #649 (comment) I'd like to see this be a part of statusline config so users can add it in if they want but it's off by default since a language name + icon are redundant most of the time. It's going to be hard to add this with just the toml config though.

@CptPotato
Copy link
Contributor

fwiw, I really like the icons, but I agree that it should be opt-in.

@the-mikedavis
Copy link
Member

Should we close this in favor of #2434?

@the-mikedavis the-mikedavis added the S-needs-discussion Status: Needs discussion or design. label May 18, 2022
@ttys3
Copy link
Contributor Author

ttys3 commented May 19, 2022

@the-mikedavis I'll close this PR now.

but I still do not like the implementation of static config fields like #2434

I think if we could use some script, like lua or starlark to config the statusline.

the idea is expose statusline related api to the script lang, and then let the script to config and build the final statusline.

in that way, user can have their own filetype emoji or do anything we can not do now, as it does not depend on the helix Rust code anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-discussion Status: Needs discussion or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants