nvim-tree / nvim-web-devicons Goto Github PK
View Code? Open in Web Editor NEWlua `fork` of vim-web-devicons for neovim
License: MIT License
lua `fork` of vim-web-devicons for neovim
License: MIT License
Hi, my favorite terminal emulator doesn't support true colors yet :'(
Would it be possible to use something like this snippet: https://gist.github.com/jasonbradley/4357406
to convert hex to rgb and provide xterm-256 colors?
https://soliditylang.org/
extension: ".sol"
By conventions, plugins usually use a prefix rather than a suffix for their hl group names:
JavascriptDevIcon => DevIconJavascript
The icons are classified by filename and/or extension. It would be nice to be able to get an icon by filetype.
Eg vim's help files have the help
filetype, but their extension is still .txt
.
This PR (#79) does allow a user to override icons but it won't allow any plugin to override the default_icon
because that can only be done in the setup
function as per the current implementation.
There are some file names that have special icons, different for the icon related to the file extension.
Example: the .gitlab-ci.yml
has its own icon, which is different from the icon for other .yml
files.
That's great! But the custom icon is only returned if I call the get_icon
function with the exact filename. If the special file is under another path, the default icon is returned:
If call :lua print(require('nvim-web-devicons').get_icon('.gitlab-ci.yml'))
I get the special gitlab icon. (Great!)
But if I call :lua print(require('nvim-web-devicons').get_icon('otherdir/.gitlab-ci.yml'))
I get default .yml
icon.
The same happens if I define some special icon by myself, like package.json
or .eslintrc.js
.
This can be resolved by using the function vim.fn.fnamemodify
with the flag ':t' to provide get_icon
only the tail of the file path.
I would like to know if this is the intended behavior. If it is, I think a tip could be added to the README instructing the user about using vim.fn.fnamemodify
to not miss the special icons.
I notice that using telescope.nvim. With the fuzzy finder, the special icons are rendered only if the file is in the vim current directory, otherwise the 'defaults' icons are displayed. I just want to check with you before submitting a PR to telescope about using vim.fn.fnamemodify
to avoid this inconsistency.
Thank you for creating a wonderful library!
I wanted to get the default icon with a get_icon()
, but I couldn't get it right, so I have a question for you.
It could not be obtained below.
local devicons = require'nvim-web-devicons'
print(devicons.get_icon('default_icon'))
But when I overruled it, I got it right.
local devicons = require'nvim-web-devicons'
devicons.setup({
default = true,
override = {
["default_icon"] = {
icon = "xx",
color = "#6d8086",
name = "Default",
}
}
})
print(devicons.get_icon('default_icon'))
-- xx DevIconDefault
Should this change be made?
diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua
index bb301cc..9b69048 100644
--- a/lua/nvim-web-devicons.lua
+++ b/lua/nvim-web-devicons.lua
@@ -851,7 +851,8 @@ local function setup(opts)
icons = vim.tbl_extend("force", icons, user_icons.override or {});
- table.insert(icons, default_icon)
+ -- table.insert(icons, default_icon)
+ icons["default_icon"] = default_icon
for _, icon_data in pairs(icons) do
if icon_data.color and icon_data.name then
local hl_group = get_highlight_name(icon_data)
my nerd font can't type the default directory icon
i want to change it to another one what is the directory extension
Im using telescope not nvim-tree
require'nvim-web-devicons'.setup {
-- your personnal icons can go here (to override)
-- DevIcon will be appended to `name`
override = {
lua = {icon = "", color = colors.nord15, name = "lua"},
.gitignore = {icon = "", color = colors.nord4, name = "GitIgnore"},
},
-- globally enable default icons (default to false)
-- will get overriden by `get_icons` option
default = true
}
This gives an error.
How do i properly override the .gitignore
icons? (And others that start with a dot)
The org icon is normally a unicorn. Have u ever come across it. If yes please add it. I have searched my pants of and I couldn't find it.
Will this plugin ever support other plugins like airline, nerdtree, ...?
Have you thought about running .setup()
automatically? What would you recommend for a plugin that depends on this? Do you have any reasons not to run .setup()
automatically? If I may argue, anyone that has the plugin in their config is very highly to want .setup()
to be called.
Reference: romgrk/barbar.nvim#11
Last update from 2 hours ago broke integration for telescope.
Related to this issue: nvim-telescope/telescope.nvim#211
here is a screenshot.
Reverting to previous commit aaffb87 solves the issue
Some file extensions allow several forms which differ only in letter cases: '.r' and '.R', '.Rmd' and '.rmd', etc. Currently to account for this, manual extra search should be done (like devicons.get_icon(file_name, file_ext) or devicons.get_icon(string.lower(file_name), string.lower(file_ext), { default = true })
).
Maybe it is a good idea to incorporate some form of case insensitiveness into plugin directly?
I'm trying to override both gitignore
and gitconfig
file icons. My current config looks like this:
git = {
icon = '<icon>',
color = '#e06c75',
name = 'gitignore'
},
This works fine, but when I do something like name = ['gitconfig', 'gitignore']
or name = {'gitconfig', 'gitignore'}
it doesn't work. Grateful for any tips on how to do this!
I don't know how to re-apply the highlights could someone give me a code snippet, i have a single init.vim file
Hi, Some times we want get an icon that even it doesn't match the ext or name, so use unknown
replace default
more better and remove opts? If we dosen't find an icon in icon_data we return unknown
icon. What do you think?
I would like to point out an issue which I encountered a few months ago and had raised in vim-dirvish
. A few weeks ago I added some updates which lead me to believe that this is indeed an issue of nvim-web-devicons
rather than vim-dirvish
.
Rather than duplicating everything, please refer to the last updates in this issue: justinmk/vim-dirvish#204
Hello,
Is it possible to override the icons from this plugin?
I'm the creator from the adelarsq/vim-emoji-icon-theme plugin, that extends ryanoasis/vim-devicons (and some others) to use emojis instead of overrided fonts. My idea is also to support this plugin.
Is it possible to change the colors of all icons somehow (without going through them one by one)?
Is there currently a way to disable the use of the predefined icons? I was thinking maybe it can be an option during the setup.
require('nvim-web-devicons').setup {
override = {}, -- we define all our icons here
predefined = false -- use none of the predefined icons
}
The reason for this is so that I can define a universal default icon for every single filetype. Can you suggest a better approach perhaps?
The previous API was defininig the highlight groups synchronously. Now that vim.schedule
is used, the function returns the HL group name but it's not defined yet because the scheduled function hasn't run yet.
Not sure why you've enabled that but I would tend to believe that this new behavior is incorrect.
Users of barbar.nvim who update their packages are all affected by this issue, LMK what's the ETA and resolution when you have more details.
Link: romgrk/barbar.nvim#98
add documentation for developers and users on how to use/setup this plugin.
Hi, Thank you for your work. I use lightline and vim-devicons to get icon in statusline. I want to know how to use nvim-web-devicons to get file icon and fileformat icon ,just look like this figure? I notice that nvim-web-devicons doesn't seem to provide such a approach.
The devicons for files like .vimrc
, .zshrc
is incorrect when file is opened from vim-startify screen. The icons are correct if these files are opened directly using commands like :e .vimrc<CR>
/ :e.zshrc<CR>
. The same problem does not occur for most of the other file types (including files that end in .vim
).
Steps to recreate:
.vimrc
file using usual command :e .vimrc<CR>
..vimrc
file by pressing <CR>
on .vimrc
file in the MRU buffer list of vim-startify's startup screen.Hey @kyazdani42 , thanks so much for this port.
I'd like to change default_icon
to something else
I tried
require'nvim-web-devicons'.setup {
override = {
default_icon = {
icon = " ",
color = "#6d8086",
name = "Default",
}
};
}
But didn't work for me
Thanks again
I can't get colors to work in nvim-tree or telescope. I have been troubleshooting this problem on and off for months. I am at my wits end, I give up. I'm dumping my config folder here in case you feel like figuring out what's breaking icon colors.
In short, my nvim-tree config looks like this:
require("nvim-web-devicons").setup{ default = true }
require("nvim-tree").setup {
hijack_cursor = true,
view = {
width = 40
}
}
Result:
Frustratingly, if I reload my plugin config (:so %
) and open nvim-tree again, it now has colored icons, but telescope doesn't:
I have spent more hours troubleshooting this than I care to admit, shuffling things around, disabling various plugins, configuring plugins in different orders etc. If you have any suggestions for what else I can try, I'd appreciate it a lot.
Here is my nvim config: nvim-config.zip
Some icons switch the active direction of text to RTL and affect the surrounding text. Specific examples are the latex icon (extension .tex) and the SVG icon. I know there are others as well, but #46 is a result of this issue specifically for the latex icon.
I don't have a PR yet (I could produce one if desired), but I was able to completely resolve these issues in my config by overriding the offending icons to add LTR Unicode direction isolates around the icon text. The Unicode consortium introduced these isolates to specifically help with issues like this. Text inside the isolate markers cannot affect the direction of the surrounding text, and as long as the terminal emulator properly supports the Unicode bidi algorithm, using the isolates fixes many of the rendering issues.
I've verified that if the icon text is surrounded with LTR isolate markers (LRI .. icon .. PDI
), then the icons will no longer mess up the rendering of surrounding text if the terminal emulator properly applies the bidi algorithm (modern terminal emulators do). Isolates specifically do not affect the direction of the surrounding text so this won't affect rendering if the icon appears in RTL text.
Maybe the icons that use codepoints that are designated as RTL (Tex, SVG, etc) should have LTR isolate markers around the unicode codepoint. This would involve something like:
["tex"] = {
icon = "<U+2066>ﭨ<U+2069>", -- actual utf-8 encoded codepoints instead, this is for demonstration
color = "#3D6117",
name = "Tex"
};
...
I have this override in my config and it corrected rendering issues with telescope.nvim and fzf-lua when they rendered the tex icon in their popup windows.
Another possibility is changing the get_icon()
function to wrap the icon text in the isolate markers before returning, possibly with a memoization.
Hi, how can I make it work with iterm2 on OSX?
I am using default iterm2 font - Monaco
.
Reference: romgrk/barbar.nvim#32
Can you provide an api to determine if the user has already run setup?
Hi! First of all, thanks for the nice plugin.
Some syntaxes could have multiple extensions associated, for example (yaml,yml), (clj,cljc,cljs,edn), (c, h), (markdown, md) and so on, while some files might also not have the extension but force a filetype by modeline, for example, so instead of having an entry for each extension, maybe it's better to rely on ft
. WDYT?
Hello, thank you for writing this Plugin!
For some reason, the default icon displayed for .svelte is a lying red glyph, that has very little to do with the logo of the language. I tried looking into this myself but I can't seem to get this to work, so perhaps you could update the icon in general?
I saw an Issue for an icon for "teal" so I thought perhaps you could help with this.
The correct icon for svelte would be:
This one, which was recently merged into devicons.
Thank you!
@kyazdani42 since #22 was merged and setup()
is now only allowed to be called once, if you try and source your init.vim during an editing setting the highlights are no longer re-applied. I was solving this issue in nvim-bufferline
by using an autocmd ColorScheme * lua.require'nvim-devicons'.setup()
to re-apply the highlights since most colorschemes will clear the existing highlights if you re source your init.vim
I think calling setup
is now not possible more than once so you can't re-apply the highlights.
I think a solution could be adding the autocommand to the plugin directly? What are your thoughts? if you agree I can test if it works and make a PR later today?
The solution in the latest commit (1a94ff0) does not seem to be good as that will not allow anyone to add/override an icon.
I have yamatsum/nvim-nonicons
installed which overrides some of the icons from nvim-web-devicons
, which is successful because it calls the setup
function first. Then, I also have my own setup which adds custom icons (which now fails) and then there's tamago324/lir.nvim
which adds its own folder icon (which also fails).
A solution would be to expose an override
function which would allow anyone to add/override an icon without doing the setup
call.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.