Comments (9)
I'd like to second an api to find by filetype. It would simplify things greatly.
from nvim-web-devicons.
i guess so, but a filetype is associated to a buffer, so you would need to load the buffer, assign it a file, then get the filetype. For a few files it would be ok, but for most use case it would be desatruously slow. Maybe providing a function geticonfromft would work
from nvim-web-devicons.
Yes that is exactly what I mean. I want to pass the filetype not the file.
from nvim-web-devicons.
well, you could add a PR i wouldn't be against it, but depending on your use case, wouldn't it be easier to just map filetypes to file extensions ? so you could only map those you would need (for instance, if your filetype is help
, you can map to .vim
, but otherwise it will load with the default extension)
from nvim-web-devicons.
I think icons should be classified by filetype, not by extensions. And there should be a map from file extension to filetype. The reason is that filetype is more primordial than extension, because different extensions can point to the same filetype (C++: cpp, cxx, cc). Entries in the current icon table are repeated rigth now and that's wasted memory. I''m also mentionning because I've been having trouble with the get_icon
function sometimes, I've seen a few stack overflows. I'm not sure where the icons memory lives, I would have expected on the heap, but anyway it's good to reduce memory usage. It will also be easier to maintain.
from nvim-web-devicons.
i agree it would be better if it were classified by filetype.
Although i've never experienced stack overflows (and i believe lua, as a high level garbage collected language, stores everything in the heap ? I'm not sure about that tough). Is a 100 entry table really that big in memory ?
Is there a way to get the filetype from a filename in the neovim api ? I'm not aware of such function, although i've looked up documentation as well as i could :)
Also some filename would not match any filetypes i believe, so that could also potentially be another issue and we would still need to add an extension based table.
from nvim-web-devicons.
The filetype doesn't necessarily depend on the name. Sometimes plugins will set the filetype on buffers just to get the syntax highlighting. Passing the filetype as an extra param or having a different function to get the icon by filetype would solve that issue. Separate function would be cleaner I think.
About memory, I would have expected lua to be fine but I have a lot of lua running currently (treesitter and a few plugins) and when I have lots of buffers open I often see a Lua: can't grow stack past 4002...
error messages when calling get_icon
. Can't say who is at fault but anyway less repetition is better.
:(
from nvim-web-devicons.
i believe your stack issue is related to vim <> lua code transfer. I can take a look to see if it happens on my machine with your barbar plugin, but i believe this is an issue for neovim.
Anyway make a Pr ill merge it :)
from nvim-web-devicons.
closed in #125
from nvim-web-devicons.
Related Issues (20)
- Missing icon for Java HOT 2
- :help HOT 1
- Some icons not show correctly HOT 2
- Incorrect NF symbol shown for Rust HOT 5
- Create a category for icons from desktop environments and window managers HOT 2
- Cannot override some icons by filename HOT 7
- TeX icon incorrect HOT 1
- [QUESTION]: how to add custom icon to laravel blade files HOT 4
- Invalid highlight name HOT 15
- change only icon color HOT 1
- W18 invalid character in a group name HOT 2
- Default icon is not working correctly HOT 12
- FR: differentiate `.d.ts` from `.ts` files (typescript) HOT 3
- Add known issue to README
- Custom icons not working on latest nvim nightly HOT 7
- Gulpfile and Gruntfile incorrect icon HOT 12
- Add issue template HOT 6
- Cannot override Lua icon color HOT 9
- Add gleam icon HOT 2
- Feature: Allow setup to be run multiple times
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-web-devicons.