Giter Club home page Giter Club logo

Comments (9)

BerkeleyTrue avatar BerkeleyTrue commented on July 20, 2024 6

I'd like to second an api to find by filetype. It would simplify things greatly.

from nvim-web-devicons.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

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.

romgrk avatar romgrk commented on July 20, 2024

Yes that is exactly what I mean. I want to pass the filetype not the file.

from nvim-web-devicons.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

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.

romgrk avatar romgrk commented on July 20, 2024

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.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

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.

romgrk avatar romgrk commented on July 20, 2024

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.

:(

Screenshot from 2020-10-31 20-07-28

from nvim-web-devicons.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

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.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

closed in #125

from nvim-web-devicons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.