Comments (11)
regexes would be a great feature. 👍
Like it is now we have to
-
Rename a couple of files to match this naming convention to get nice icons
-
Stick with default icons and keep our own naming convention.
I suppose I will stick with our naming for now until we get regexes in this library.
Great pull-request from @luissimas 🥇 that matches all dots in the end of the string.
Keep up the good work @kyazdani42 💯 and thanks for bringing us this library.
from nvim-web-devicons.
I agree, ill see when I have some time to implement this
from nvim-web-devicons.
@kyazdani42 Is it possible to add a icon for a extension like .vimrc
or .zshrc
? Currently, they do not get applied icon/color of vim
or zsh
for some reason. Note: this is simpler than regex, it is hardcoded extension name.
from nvim-web-devicons.
Hi, I'm not sure if this is exactly what @Fenriuz means, but I was looking for a similar behaviour while using nvim-tree, and in the process of trying to implement it I may have found something that works.
I couldn't find a good way of implementing it in nvim-web-devicons itself, the way that the get_icon
function works seems fine, so I actually changed something in how nvim-tree handles the file extensions.
@kyazdani42, I see that nvim-tree uses the vim.fn.fnamemodify
function with the ":e"
modifier to get the file extension and then pass it to nvim-web-devicons, I think that this way of getting the file extension doesn't work very well when we have file extensions with multiple dots (like foo.test.js
).
What I did was change the vim.fn.fnamemodify
on nvim-tree with a lua pattern match that returns the full string after the first .
occurence: string.match(name, "%.(.*)")
. Now I can define the icons like this in nvim-web-devicons's setup function:
require("nvim-web-devicons").setup {
override = {
["test.js"] = {
icon = "ﭧ",
color = "#cbcb41",
name = "JavascriptTest"
}
},
default = true
}
The problem is that I don't know if this will break anything in nvim-tree, so I would like to ask @kyazdani42's opinion on this.
This is far from being the regex-like feature, but I think it covers some use cases that are very common.
If it's ok I can submit a PR to nvim-tree and then add some icons and doc regarding this behaviour to this repo later.
from nvim-web-devicons.
hi @luissimas, send a PR and i'll do a set of personnal test to ensure it's working as expected. It might break icon display for certain filenames but i'm not sure as i haven't seen your implementation yet :)
from nvim-web-devicons.
Hi, regexes are not supported at the moment, i think this could be added as a feature if it doesn't impact performance.
from nvim-web-devicons.
I get it, it would be great if that feature was added.
from nvim-web-devicons.
i'm not sure what's your question here @reportaman ? could you be a little bit more specific please ?
from nvim-web-devicons.
For test files you can do:
local devicons = require "nvim-web-devicons"
local function get_ext(name)
if name:find "^.+%.test%..+$" or name:find "^.+Test%..+$" or name:find "^.+_test%..+$" then
return "test"
end
if name:find "^.+%.spec%..+$" or name:find "^.+Spec%..+$" or name:find "^.+_spec%..+$" then
return "spec"
end
return name:match "^.*%.(.*)$" or ""
end
local get_icon = devicons.get_icon
devicons.get_icon = function(name, ext, opts)
return get_icon(name, ext or get_ext(name), opts)
end
local get_icon_colors = devicons.get_icon_colors
devicons.get_icon_colors = function(name, ext, opts)
return get_icon_colors(name, ext or get_ext(name), opts)
end
devicons.setup {
override = {
["test"] = { icon = "ﭧ", color = "#cbcb41", name = "TestFile" },
["spec"] = { icon = "ﭧ", color = "#cbcb41", name = "SpecFile" },
},
}
Example:
HelloTest.php
hello.test.js
hello_test.go
from nvim-web-devicons.
Can this also be done for files that contain "env" in their name? Or generally user defined regex filters?
Eg.
.env-sample
.env_example
.env.production
from nvim-web-devicons.
Unfortunately we don't have regex support.
You can add your own specific icons via API: https://github.com/nvim-tree/nvim-web-devicons#set-an-icon
from nvim-web-devicons.
Related Issues (20)
- 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
- set_icon not work HOT 3
- Cannot install nvim-web-devicons properly on Nvim 0.7.2 HOT 2
- feat: Allow overrides by patterns HOT 1
- Make files in `diagnostics` use `TroubleFileName` color HOT 2
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.