Giter Club home page Giter Club logo

Comments (8)

sbromberger avatar sbromberger commented on July 20, 2024 2

Sorry for resurrecting this, but I'm running into what may be the same question: is there an equivalent to vim-devicons WebDevIconsGetFileTypeSymbol() and WebDevIconsGetFileFormatSymbol() functions?

Thanks!

from nvim-web-devicons.

brankojay avatar brankojay commented on July 20, 2024 2

For anyone who comes across this - here's how i got the nvim-web-devicons working with lightline:

In Lua, define a function to provide the icon by filetype with get_icon_by_filetype :

function getfiletypeicon( filetype )
    local icon = require('nvim-web-devicons').get_icon_by_filetype( filetype )
    return icon
end

The component_function from lightline expects a vimscript function (in my case, defined directly in Lua):

vim.cmd([[
function! CustomFilename()
    let filetype = winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : '-') : ''
    let filename = expand('%:t') !=# '' ? expand('%:t') : '[no name]'
    let filetypeicon = v:lua.getfiletypeicon(filetype)

    return filetypeicon . ' ' . filename
endfunction
]])

Use CustomFilename in your lightline setup:

vim.g['lightline'] = {
    active = {
        left = {{'mode', 'paste'}, {'gitbranch', 'readonly', 'filename', 'modified'}}
    },
    component_function = {
        filename = 'CustomFilename',
        gitbranch = 'FugitiveHead'
    }
}

from nvim-web-devicons.

kyazdani42 avatar kyazdani42 commented on July 20, 2024 1

Hello, there is not getFileFormatSymbol function actually but there could be one (now i understand what this issue means). get file type symbol is the main function this plugins provides through require'nvim-web-devicons'.get_icon(filename, extension, { default = true })
to get the file format it would be quite easy to do, maybe just make a PR ?

from nvim-web-devicons.

atanasj avatar atanasj commented on July 20, 2024 1

I'm keen for this too as I would like to get rid of the vim-devicons dependency for lightline, but would not know where to start!

from nvim-web-devicons.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

Hi, i'm not sure what you mean by that, did you read the README ?

from nvim-web-devicons.

krisfans avatar krisfans commented on July 20, 2024

Where file format I mean the newline character- CR and LF , which has a different form in DOS, UNIX, and Mac, and in vimrc,I cat set like this set fileformats=unix,dos,mac

from nvim-web-devicons.

kyazdani42 avatar kyazdani42 commented on July 20, 2024

i get what fileformats are, but i'm not sure about how it relates to getting an icon ? the icon returned is just a string

from nvim-web-devicons.

escasinas avatar escasinas commented on July 20, 2024

Do you have a patched font installed?

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.