diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..0514a27e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +insert_final_newline = true +end_of_line = lf + +[*.lua] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..332a3227 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: Lint +on: pull_request +permissions: + contents: read +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: leafo/gh-actions-lua@v9 + with: + luaVersion: "5.1" + - uses: leafo/gh-actions-luarocks@v4 + - name: Install luacheck + run: luarocks install luacheck + - uses: rhysd/action-setup-vim@v1 + with: + neovim: true + - uses: actions/setup-python@v4.5.0 + - run: pip install pre-commit + - run: pre-commit run --all-files diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml new file mode 100644 index 00000000..fc6739f0 --- /dev/null +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -0,0 +1,33 @@ +name: Pre-commit autoupdate +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: +permissions: + contents: write + pull-requests: write +jobs: + auto-update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: leafo/gh-actions-lua@v9 + with: + luaVersion: "5.1" + - uses: leafo/gh-actions-luarocks@v4 + - name: Install luacheck + run: luarocks install luacheck + - uses: rhysd/action-setup-vim@v1 + with: + neovim: true + - uses: actions/setup-python@v4.5.0 + - run: pip install pre-commit + - run: pre-commit autoupdate + - run: pre-commit run --all-files + - uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: update/pre-commit-hooks + title: "chore: update pre-commit hooks" + commit-message: "chore: update pre-commit hooks" + body: Update versions of pre-commit hooks to latest version. diff --git a/.github/workflows/semantic-pr-subject.yml b/.github/workflows/semantic-pr-subject.yml new file mode 100644 index 00000000..5b9554f5 --- /dev/null +++ b/.github/workflows/semantic-pr-subject.yml @@ -0,0 +1,15 @@ +name: Semantic Pull Request Subject +on: + pull_request: + types: + - opened + - reopened + - edited + - synchronize +jobs: + semantic-pr-subject: + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v4.5.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0dfa452a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.lua +.luarocks diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 00000000..eeebf4a8 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,7 @@ +max_line_length = 120 + +globals = { + "vim", + "jit", + "bit", +} diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 00000000..bcb6b47a --- /dev/null +++ b/.luarc.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "runtime.version" : "Lua 5.1", + "diagnostics": { + "globals": [ + "vim", + "jit", + "bit" + ] + } +} + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..45d90100 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/johnnymorganz/stylua + rev: v0.17.1 + hooks: + - id: stylua-github + - repo: local + hooks: + - id: luacheck + name: Luacheck + description: Lints Lua files using Luacheck. + entry: luacheck -- + language: system + types: [lua] + - repo: local + hooks: + - id: lighttheme + name: Light Color Scheme Generator + description: Ensures Light Color Scheme version has been generated. + entry: nvim --headless -c 'source scripts/generate_colors.lua' -c 'qall' + language: system + types: [lua] diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 00000000..ecb6dca5 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "None" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..b6c4b0fa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,92 @@ +# Contributing to `nvim-web-devicons` + +Thank you for your contribution! + +## Name + +Please name your commits and the PR simply e.g. + + add .tex + update makefile icon + update .kt colors + +## Prerequisites + +Add [vim-colortemplate](https://github.com/lifepillar/vim-colortemplate) to &runtimepath. The easiest way to do this is via your package manager. + +Code is formatted using stylua and linted using luacheck. + +You can install these with: +```sh +cargo install stylua +luarocks install luacheck +``` + +or via your OS package manager e.g. Arch linux: +```sh +pacman -S stylua +pacman -S luacheck +``` + +## Building + +Following your changes, please run: + +```sh +make +``` + +This will: +1. Generate cterm colors +2. Generate light color variants +3. Check style +4. Lint + +You can automatically fix any style issues via: +```sh +make style-fix +``` + +## Generate Colors + +Add or update icons in `scripts/nvim-web-devicons.lua`. + +There are two tables where icons can be added: +1. icons_by_filename +2. icons_by_file_extension + +Add the icon in table 1. if the icon is for a file that is always named that +way, for example `.gitconfig`. Add to table 2. if the icon is for all files +with an extension. + +Each icon must have the following (this is an example): +```lua +[".gitconfig"] = { + icon = "", + color = "#41535b", + cterm_color = "0", + name = "GitConfig", +}, +``` +___Key/value pairs must appear in the same exact order!___ + +- `color` must contain a color in the html notation +- `cterm_color` must be below `color`, and it must contain a number (any number) +- the correct value for `cterm_color` will be generated by the script + +Ensure your current working directory is the repo root. +Run `make`. This will: +- Update `cterm_color` based on `color` +- Generate `nvim-web-devicons-light.lua` + +Please commit both `nvim-web-devicons.lua` and `nvim-web-devicons-light.lua` + +## Pull Request + +Please reference any issues in the description e.g. "resolves #1234". + +Please check "allow edits by maintainers" to allow nvim-web-devicons maintainers to make small changes such as documentation tweaks. + +## Documentation + +When modifying or adding API, please update [Usage](README.md#Usage) diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bdfcc998 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +all: colors style-check lint + +colors: + nvim --headless -c 'source scripts/generate_colors.lua' -c 'qall' + +style-check: + stylua . --check + +style-fix: + stylua . + +lint: + luacheck . + +.PHONY: all colors style-check style-fix lint diff --git a/README.md b/README.md index 3f8a8175..56762d41 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Nvim-web-devicons -A `lua` fork of [vim-devicons](https://github.com/ryanoasis/vim-devicons). This plugin provides the same icons _as well as_ -colors for each icon. +A `lua` fork of [vim-devicons](https://github.com/ryanoasis/vim-devicons). This plugin provides the same icons _as well as_ colors for each icon. + +Light and dark color variants are provided. ## Requirements @@ -24,6 +25,12 @@ use 'nvim-tree/nvim-web-devicons' ## Usage +### Variants + +Light or dark color variants of the icons depend on `&background`. + +These will be updated following `OptionSet` `background` however be advised that the plugin using nvim-web-devicons may have cached the icons. + ### Setup This adds all the highlight groups for the devicons @@ -50,6 +57,29 @@ require'nvim-web-devicons'.setup { -- globally enable default icons (default to false) -- will get overriden by `get_icons` option default = true; + -- globally enable "strict" selection of icons - icon will be looked up in + -- different tables, first by filename, and if not found by extension; this + -- prevents cases when file doesn't have any extension but still gets some icon + -- because its name happened to match some extension (default to false) + strict = true; + -- same as `override` but specifically for overrides by filename + -- takes effect when `strict` is true + override_by_filename = { + [".gitignore"] = { + icon = "", + color = "#f1502f", + name = "Gitignore" + } + }; + -- same as `override` but specifically for overrides by extension + -- takes effect when `strict` is true + override_by_extension = { + ["log"] = { + icon = "", + color = "#81e043", + name = "Log" + } + }; } ``` @@ -64,8 +94,10 @@ require'nvim-web-devicons'.get_icon(filename, extension, options) ``` The optional `options` argument can used to change how the plugin works the keys include -`default = `. If the default key is set to true this function will return a default -if there is no matching icon +`default = ` and `strict = `. If the default key is set to true this +function will return a default if there is no matching icon. If the strict key is set +to true this function will lookup icon specifically by filename, and if not found then +specifically by extension, and fallback to default icon if default key is set to true. e.g. ```lua @@ -135,3 +167,7 @@ require("nvim-web-devicons").get_icon_cterm_color_by_filetype(filetype, opts) These functions are the same as their counterparts without the `_by_filetype` suffix, but they take a filetype instead of a name/extension. You can also use `get_icon_name_by_filetype(filetype)` to get the icon name associated with the filetype. + +## Contributing + +PRs are always welcome! Please see [CONTRIBUTING](CONTRIBUTING.md) diff --git a/lua/nvim-web-devicons-light.lua b/lua/nvim-web-devicons-light.lua new file mode 100644 index 00000000..0daa4d4e --- /dev/null +++ b/lua/nvim-web-devicons-light.lua @@ -0,0 +1,1554 @@ +local icons_by_filename = { + [".babelrc"] = { + icon = "ﬥ", + color = "#666620", + cterm_color = "58", + name = "Babelrc", + }, + [".bash_profile"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "BashProfile", + }, + [".bashrc"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Bashrc", + }, + [".ds_store"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "DsStore", + }, + [".eslintrc"] = { + icon = "", + color = "#4b32c3", + cterm_color = "56", + name = "Eslintrc", + }, + [".gitattributes"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitAttributes", + }, + [".gitconfig"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitConfig", + }, + [".gitignore"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitIgnore", + }, + [".gitlab-ci.yml"] = { + icon = "", + color = "#aa321f", + cterm_color = "124", + name = "GitlabCI", + }, + [".gitmodules"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitModules", + }, + [".gvimrc"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Gvimrc", + }, + [".npmignore"] = { + icon = "", + color = "#ae1d38", + cterm_color = "161", + name = "NPMIgnore", + }, + [".npmrc"] = { + icon = "", + color = "#ae1d38", + cterm_color = "161", + name = "NPMrc", + }, + [".settings.json"] = { + icon = "", + color = "#643995", + cterm_color = "91", + name = "SettingsJson", + }, + [".vimrc"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Vimrc", + }, + [".zprofile"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Zshprofile", + }, + [".zshenv"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Zshenv", + }, + [".zshrc"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Zshrc", + }, + ["brewfile"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Brewfile", + }, + ["cmakelists.txt"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "CMakeLists", + }, + ["commit_editmsg"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitCommit", + }, + ["containerfile"] = { + icon = "󰡨", + color = "#2e5f99", + cterm_color = "25", + name = "Dockerfile", + }, + ["copying"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "License", + }, + ["copying.lesser"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "License", + }, + ["docker-compose.yml"] = { + icon = "󰡨", + color = "#2e5f99", + cterm_color = "25", + name = "Dockerfile", + }, + ["docker-compose.yaml"] = { + icon = "󰡨", + color = "#2e5f99", + cterm_color = "25", + name = "Dockerfile", + }, + [".dockerignore"] = { + icon = "󰡨", + color = "#2e5f99", + cterm_color = "25", + name = "Dockerfile", + }, + ["gemfile$"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Gemfile", + }, + ["license"] = { + icon = "", + color = "#686020", + cterm_color = "58", + name = "License", + }, + ["r"] = { + icon = "ﳒ", + color = "#286844", + cterm_color = "29", + name = "R", + }, + ["rmd"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Rmd", + }, + ["vagrantfile$"] = { + icon = "", + color = "#104abf", + cterm_color = "26", + name = "Vagrantfile", + }, + ["_gvimrc"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Gvimrc", + }, + ["_vimrc"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Vimrc", + }, + ["package.json"] = { + icon = "", + color = "#ae1d38", + name = "PackageJson", + }, + ["package-lock.json"] = { + icon = "", + color = "#7a0d21", + name = "PackageLockJson", + }, + ["node_modules"] = { + icon = "", + color = "#ae1d38", + cterm_color = "161", + name = "NodeModules", + }, + ["favicon.ico"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Favicon", + }, + ["gnumakefile"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Makefile", + }, + ["makefile"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Makefile", + }, + ["mix.lock"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "MixLock", + }, + [".env"] = { + icon = "", + color = "#32310d", + cterm_color = "236", + name = "Env", + }, + ["gruntfile"] = { + icon = "", + color = "#975122", + cterm_color = "130", + name = "Gruntfile", + }, + ["gulpfile"] = { + icon = "", + color = "#992e33", + cterm_color = "88", + name = "Gulpfile", + }, + ["webpack"] = { + icon = "ﰩ", + color = "#36677c", + cterm_color = "24", + name = "Webpack", + }, + ["rakefile"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Rakefile", + }, + ["procfile"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Procfile", + }, + ["dockerfile"] = { + icon = "󰡨", + color = "#2e5f99", + cterm_color = "25", + name = "Dockerfile", + }, +} + +local icons_by_file_extension = { + ["ai"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Ai", + }, + ["awk"] = { + icon = "", + color = "#3a4446", + cterm_color = "238", + name = "Awk", + }, + ["bash"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Bash", + }, + ["bat"] = { + icon = "", + color = "#40500f", + cterm_color = "58", + name = "Bat", + }, + ["bmp"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Bmp", + }, + ["c"] = { + icon = "", + color = "#3b69aa", + cterm_color = "25", + name = "C", + }, + ["c++"] = { + icon = "", + color = "#a23253", + cterm_color = "125", + name = "CPlusPlus", + }, + ["cbl"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["cc"] = { + icon = "", + color = "#a23253", + cterm_color = "125", + name = "CPlusPlus", + }, + ["cfg"] = { + icon = "", + color = "#2f2f2f", + cterm_color = "236", + name = "Configuration", + }, + ["clj"] = { + icon = "", + color = "#466024", + cterm_color = "22", + name = "Clojure", + }, + ["cljc"] = { + icon = "", + color = "#466024", + cterm_color = "22", + name = "ClojureC", + }, + ["cljs"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "ClojureJS", + }, + ["cljd"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "ClojureDart", + }, + ["cmake"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "CMake", + }, + ["cob"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["cobol"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["coffee"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Coffee", + }, + ["conf"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Conf", + }, + ["config.ru"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "ConfigRu", + }, + ["cp"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Cp", + }, + ["cpp"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Cpp", + }, + ["cpy"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["cr"] = { + icon = "", + color = "#434343", + cterm_color = "238", + name = "Crystal", + }, + ["cs"] = { + icon = "", + color = "#434d04", + cterm_color = "58", + name = "Cs", + }, + ["csh"] = { + icon = "", + color = "#3a4446", + cterm_color = "238", + name = "Csh", + }, + ["cson"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Cson", + }, + ["css"] = { + icon = "", + color = "#2c6ea3", + cterm_color = "24", + name = "Css", + }, + ["csv"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Csv", + }, + ["cxx"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Cxx", + }, + ["d"] = { + icon = "", + color = "#325a13", + cterm_color = "22", + name = "D", + }, + ["dart"] = { + icon = "", + color = "#03589C", + cterm_color = "25", + name = "Dart", + }, + ["db"] = { + icon = "", + color = "#494848", + cterm_color = "238", + name = "Db", + }, + ["desktop"] = { + icon = "", + color = "#563d7c", + cterm_color = "54", + name = "DesktopEntry", + }, + ["diff"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "Diff", + }, + ["doc"] = { + icon = "", + color = "#185abd", + cterm_color = "26", + name = "Doc", + }, + ["docx"] = { + icon = "", + color = "#185abd", + cterm_color = "26", + name = "Docx", + }, + ["drl"] = { + icon = "", + color = "#553a3a", + cterm_color = "238", + name = "Drools", + }, + ["dropbox"] = { + icon = "", + color = "#0049be", + cterm_color = "26", + name = "Dropbox", + }, + ["dump"] = { + icon = "", + color = "#494848", + cterm_color = "238", + name = "Dump", + }, + ["edn"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Edn", + }, + ["eex"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Eex", + }, + ["ejs"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Ejs", + }, + ["elm"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Elm", + }, + ["epp"] = { + icon = "", + color = "#80530d", + name = "Epp", + }, + ["erb"] = { + icon = "", + color = "#701516", + cterm_color = "94", + name = "Erb", + }, + ["erl"] = { + icon = "", + color = "#8a2b72", + cterm_color = "89", + name = "Erl", + }, + ["ex"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Ex", + }, + ["exs"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Exs", + }, + ["f#"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Fsharp", + }, + ["f90"] = { + icon = "󱈚", + color = "#563b70", + cterm_color = "53", + name = "Fortran", + }, + ["fnl"] = { + color = "#33312b", + icon = "🌜", + cterm_color = "236", + name = "Fennel", + }, + ["fish"] = { + icon = "", + color = "#3a4446", + cterm_color = "238", + name = "Fish", + }, + ["fs"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Fs", + }, + ["fsi"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Fsi", + }, + ["fsscript"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Fsscript", + }, + ["fsx"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Fsx", + }, + ["gd"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "GDScript", + }, + ["gemspec"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Gemspec", + }, + ["gif"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Gif", + }, + ["git"] = { + icon = "", + color = "#b5391e", + cterm_color = "160", + name = "GitLogo", + }, + ["glb"] = { + icon = "", + color = "#80581e", + cterm_color = "94", + name = "BinaryGLTF", + }, + ["go"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Go", + }, + ["godot"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "GodotProject", + }, + ["graphql"] = { + icon = "", + color = "#ac2880", + cterm_color = "126", + name = "GraphQL", + }, + ["gql"] = { + icon = "", + color = "#ac2880", + cterm_color = "126", + name = "GraphQL", + }, + ["h"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "H", + }, + ["haml"] = { + icon = "", + color = "#2f2f2d", + cterm_color = "236", + name = "Haml", + }, + ["hbs"] = { + icon = "", + color = "#a04f1d", + cterm_color = "130", + name = "Hbs", + }, + ["heex"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Heex", + }, + ["hh"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Hh", + }, + ["hpp"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Hpp", + }, + ["hrl"] = { + icon = "", + color = "#8a2b72", + cterm_color = "89", + name = "Hrl", + }, + ["hs"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Hs", + }, + ["htm"] = { + icon = "", + color = "#aa391c", + cterm_color = "124", + name = "Htm", + }, + ["html"] = { + icon = "", + color = "#ab3a1c", + cterm_color = "124", + name = "Html", + }, + ["hxx"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Hxx", + }, + ["ico"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Ico", + }, + ["import"] = { + icon = "", + color = "#2f2f2f", + cterm_color = "236", + name = "ImportConfiguration", + }, + ["ini"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Ini", + }, + ["java"] = { + icon = "", + color = "#992e33", + cterm_color = "88", + name = "Java", + }, + ["jl"] = { + icon = "", + color = "#6c4b7c", + cterm_color = "96", + name = "Jl", + }, + ["jpeg"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Jpeg", + }, + ["jpg"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Jpg", + }, + ["js"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Js", + }, + ["test.js"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "TestJs", + }, + ["spec.js"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "SpecJs", + }, + ["json"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "Json", + }, + ["json5"] = { + icon = "ﬥ", + color = "#666620", + cterm_color = "58", + name = "Json5", + }, + ["jsx"] = { + icon = "", + color = "#158197", + cterm_color = "31", + name = "Jsx", + }, + ["test.jsx"] = { + icon = "", + color = "#158197", + cterm_color = "31", + name = "JavaScriptReactTest", + }, + ["spec.jsx"] = { + icon = "", + color = "#158197", + cterm_color = "31", + name = "JavaScriptReactSpec", + }, + ["ksh"] = { + icon = "", + color = "#3a4446", + cterm_color = "238", + name = "Ksh", + }, + ["kt"] = { + icon = "", + color = "#5f3ebf", + cterm_color = "92", + name = "Kotlin", + }, + ["kts"] = { + icon = "", + color = "#5f3ebf", + cterm_color = "92", + name = "KotlinScript", + }, + ["leex"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Leex", + }, + ["less"] = { + icon = "", + color = "#563d7c", + cterm_color = "54", + name = "Less", + }, + ["lhs"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Lhs", + }, + ["license"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "License", + }, + ["lua"] = { + icon = "", + color = "#366b8a", + cterm_color = "24", + name = "Lua", + }, + ["luau"] = { + icon = "", + color = "#366b8a", + cterm_color = "24", + name = "Luau", + }, + ["gnumakefile"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Makefile", + }, + ["makefile"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Makefile", + }, + ["mk"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Makefile", + }, + ["markdown"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Markdown", + }, + ["material"] = { + icon = "", + color = "#8a2b72", + cterm_color = "89", + name = "Material", + }, + ["md"] = { + icon = "", + color = "#333333", + cterm_color = "236", + name = "Md", + }, + ["mdx"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Mdx", + }, + ["mint"] = { + icon = "", + color = "#44604a", + cterm_color = "23", + name = "Mint", + }, + ["mjs"] = { + icon = "", + color = "#504b1e", + cterm_color = "58", + name = "Mjs", + }, + ["ml"] = { + icon = "λ", + color = "#975122", + cterm_color = "130", + name = "Ml", + }, + ["mli"] = { + icon = "λ", + color = "#975122", + cterm_color = "130", + name = "Mli", + }, + ["mo"] = { + icon = "∞", + color = "#654ca7", + cterm_color = "61", + name = "Motoko", + }, + ["mustache"] = { + icon = "", + color = "#975122", + cterm_color = "130", + name = "Mustache", + }, + ["nim"] = { + icon = "", + color = "#514700", + cterm_color = "58", + name = "Nim", + }, + ["nix"] = { + icon = "", + color = "#3f5d72", + cterm_color = "24", + name = "Nix", + }, + ["opus"] = { + icon = "", + color = "#a55c01", + cterm_color = "130", + name = "OPUS", + }, + ["org"] = { + icon = "", + color = "#4f7166", + cterm_color = "66", + name = "OrgMode", + }, + ["otf"] = { + icon = "", + color = "#2f2f2f", + cterm_color = "236", + name = "OpenTypeFont", + }, + ["pck"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "PackedResource", + }, + ["pdf"] = { + icon = "", + color = "#b30b00", + cterm_color = "124", + name = "Pdf", + }, + ["php"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Php", + }, + ["pl"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Pl", + }, + ["pm"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Pm", + }, + ["png"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Png", + }, + ["pp"] = { + icon = "", + color = "#80530d", + name = "Pp", + }, + ["ppt"] = { + icon = "", + color = "#983826", + cterm_color = "94", + name = "Ppt", + }, + ["pro"] = { + icon = "", + color = "#725c2a", + cterm_color = "94", + name = "Prolog", + }, + ["ps1"] = { + icon = "󰨊", + color = "#325698", + cterm_color = "25", + name = "PsScriptfile", + }, + ["psd1"] = { + icon = "󰨊", + color = "#4f5893", + cterm_color = "60", + name = "PsManifestfile", + }, + ["psm1"] = { + icon = "󰨊", + color = "#4f5893", + cterm_color = "60", + name = "PsScriptModulefile", + }, + ["psb"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Psb", + }, + ["psd"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Psd", + }, + ["py"] = { + icon = "", + color = "#805e02", + cterm_color = "94", + name = "Py", + }, + ["pyc"] = { + icon = "", + color = "#332d1d", + cterm_color = "236", + name = "Pyc", + }, + ["pyd"] = { + icon = "", + color = "#332d1d", + cterm_color = "236", + name = "Pyd", + }, + ["pyo"] = { + icon = "", + color = "#332d1d", + cterm_color = "236", + name = "Pyo", + }, + ["query"] = { + icon = "", + color = "#607035", + cterm_color = "58", + name = "Query", + }, + ["r"] = { + icon = "ﳒ", + color = "#286844", + cterm_color = "29", + name = "R", + }, + ["rake"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Rake", + }, + ["rb"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Rb", + }, + ["rlib"] = { + icon = "", + color = "#6f5242", + cterm_color = "95", + name = "Rlib", + }, + ["rmd"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Rmd", + }, + ["rproj"] = { + icon = "鉶", + color = "#286844", + cterm_color = "29", + name = "Rproj", + }, + ["rs"] = { + icon = "", + color = "#6f5242", + cterm_color = "95", + name = "Rs", + }, + ["rss"] = { + icon = "", + color = "#7e4e1e", + cterm_color = "94", + name = "Rss", + }, + ["sass"] = { + icon = "", + color = "#a33759", + cterm_color = "125", + name = "Sass", + }, + ["sbt"] = { + icon = "", + color = "#992e33", + cterm_color = "88", + name = "sbt", + }, + ["scala"] = { + icon = "", + color = "#992e33", + cterm_color = "88", + name = "Scala", + }, + ["scm"] = { + icon = "ﬦ", + color = "#000000", + cterm_color = "16", + name = "Scheme", + }, + ["scss"] = { + icon = "", + color = "#a33759", + cterm_color = "125", + name = "Scss", + }, + ["sh"] = { + icon = "", + color = "#3a4446", + cterm_color = "238", + name = "Sh", + }, + ["sig"] = { + icon = "λ", + color = "#975122", + cterm_color = "130", + name = "Sig", + }, + ["slim"] = { + icon = "", + color = "#aa391c", + cterm_color = "124", + name = "Slim", + }, + ["sln"] = { + icon = "", + color = "#643995", + cterm_color = "91", + name = "Sln", + }, + ["sml"] = { + icon = "λ", + color = "#975122", + cterm_color = "130", + name = "Sml", + }, + ["sql"] = { + icon = "", + color = "#494848", + cterm_color = "238", + name = "Sql", + }, + ["sqlite"] = { + icon = "", + color = "#494848", + cterm_color = "238", + name = "Sql", + }, + ["sqlite3"] = { + icon = "", + color = "#494848", + cterm_color = "238", + name = "Sql", + }, + ["styl"] = { + icon = "", + color = "#466024", + cterm_color = "22", + name = "Styl", + }, + ["sublime"] = { + icon = "", + color = "#975122", + cterm_color = "130", + name = "Suo", + }, + ["suo"] = { + icon = "", + color = "#643995", + cterm_color = "91", + name = "Suo", + }, + ["sv"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "SystemVerilog", + }, + ["svelte"] = { + icon = "", + color = "#bf2e00", + cterm_color = "160", + name = "Svelte", + }, + ["svh"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "SystemVerilog", + }, + ["svg"] = { + icon = "ﰟ", + color = "#80581e", + cterm_color = "94", + name = "Svg", + }, + ["swift"] = { + icon = "", + color = "#975122", + cterm_color = "130", + name = "Swift", + }, + ["t"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Tor", + }, + ["tbc"] = { + icon = "﯑", + color = "#1e5cb3", + cterm_color = "25", + name = "Tcl", + }, + ["tcl"] = { + icon = "﯑", + color = "#1e5cb3", + cterm_color = "25", + name = "Tcl", + }, + ["terminal"] = { + icon = "", + color = "#217929", + cterm_color = "28", + name = "Terminal", + }, + ["tex"] = { + icon = "ﭨ", + color = "#3D6117", + cterm_color = "22", + name = "Tex", + }, + ["tf"] = { + icon = "", + color = "#4732af", + cterm_color = "55", + name = "Terraform", + }, + ["tfvars"] = { + icon = "", + color = "#4732af", + cterm_color = "55", + name = "TFVars", + }, + ["toml"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Toml", + }, + ["tres"] = { + icon = "", + color = "#666620", + cterm_color = "58", + name = "TextResource", + }, + ["ts"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "Ts", + }, + ["test.ts"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "TestTs", + }, + ["spec.ts"] = { + icon = "", + color = "#36677c", + cterm_color = "24", + name = "SpecTs", + }, + ["tscn"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "TextScene", + }, + ["tsx"] = { + icon = "", + color = "#1354bf", + cterm_color = "26", + name = "Tsx", + }, + ["test.tsx"] = { + icon = "", + color = "#1354bf", + cterm_color = "26", + name = "TypeScriptReactTest", + }, + ["spec.tsx"] = { + icon = "", + color = "#1354bf", + cterm_color = "26", + name = "TypeScriptReactSpec", + }, + ["twig"] = { + icon = "", + color = "#466024", + cterm_color = "22", + name = "Twig", + }, + ["txt"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Txt", + }, + ["v"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Verilog", + }, + ["vala"] = { + icon = "", + color = "#562b86", + cterm_color = "54", + name = "Vala", + }, + ["vh"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Verilog", + }, + ["vhd"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "VHDL", + }, + ["vhdl"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "VHDL", + }, + ["vim"] = { + icon = "", + color = "#017226", + cterm_color = "22", + name = "Vim", + }, + ["vue"] = { + icon = "﵂", + color = "#466024", + cterm_color = "22", + name = "Vue", + }, + ["webmanifest"] = { + icon = "", + color = "#504b1e", + cterm_color = "58", + name = "Webmanifest", + }, + ["webp"] = { + icon = "", + color = "#6b4d83", + cterm_color = "96", + name = "Webp", + }, + ["webpack"] = { + icon = "ﰩ", + color = "#36677c", + cterm_color = "24", + name = "Webpack", + }, + ["xcplayground"] = { + icon = "", + color = "#975122", + cterm_color = "130", + name = "XcPlayground", + }, + ["xls"] = { + icon = "", + color = "#207245", + cterm_color = "29", + name = "Xls", + }, + ["xlsx"] = { + icon = "", + color = "#207245", + cterm_color = "29", + name = "Xlsx", + }, + ["xml"] = { + icon = "謹", + color = "#975122", + cterm_color = "130", + name = "Xml", + }, + ["xul"] = { + icon = "", + color = "#975122", + cterm_color = "130", + name = "Xul", + }, + ["yaml"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Yaml", + }, + ["yml"] = { + icon = "", + color = "#526064", + cterm_color = "59", + name = "Yml", + }, + ["zig"] = { + icon = "", + color = "#7b4d0e", + cterm_color = "94", + name = "Zig", + }, + ["zsh"] = { + icon = "", + color = "#447028", + cterm_color = "22", + name = "Zsh", + }, + ["sol"] = { + icon = "ﲹ", + color = "#36677c", + cterm_color = "24", + name = "Solidity", + }, + ["prisma"] = { + icon = "卑", + color = "#333333", + cterm_color = "236", + name = "Prisma", + }, + ["lock"] = { + icon = "", + color = "#5e5e5e", + cterm_color = "59", + name = "Lock", + }, + ["log"] = { + icon = "", + color = "#333333", + cterm_color = "236", + name = "Log", + }, + ["wasm"] = { + icon = "", + color = "#4539a4", + cterm_color = "55", + name = "Wasm", + }, + ["liquid"] = { + icon = "", + color = "#4a6024", + cterm_color = "58", + name = "Liquid", + }, +} + +return { + icons_by_filename = icons_by_filename, + icons_by_file_extension = icons_by_file_extension, +} diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua index 522f4060..3c20eab2 100644 --- a/lua/nvim-web-devicons.lua +++ b/lua/nvim-web-devicons.lua @@ -1,38 +1,5 @@ --- references: --- 1. Linguist: https://github.com/github/linguist --- 2. coc-explorer: https://github.com/weirongxu/coc-explorer/blob/59bd41f8fffdc871fbd77ac443548426bd31d2c3/src/icons.nerdfont.json#L2 --- 3. chad-tree: https://github.com/ms-jpq/chadtree/blob/f9f333c062/artifacts/icons.json --- jquery = { --- icon = "", --- color = "#1B75BB" --- }, --- angular = { --- icon = "", --- color = "#E23237" --- }, --- backbone = { --- icon = "", --- color = "#0071B5" --- }, --- requirejs = { --- icon = "", --- color = "#F44A41" --- }, --- materialize = { --- icon = "", --- color = "#EE6E73" --- }, --- mootools = { --- icon = "", --- color = "#ECECEC" --- }, --- puppet = { --- icon = "", --- color = "#ffa61a" --- }, - --- When adding new icons, remember to add an entry to the `filetypes` table, if applicable. -local icons = { +-- exact match by file name +local icons_by_filename = { [".babelrc"] = { icon = "ﬥ", color = "#cbcb41", @@ -51,58 +18,64 @@ local icons = { cterm_color = "113", name = "Bashrc", }, - [".DS_Store"] = { + [".ds_store"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "DsStore", }, + [".eslintrc"] = { + icon = "", + color = "#4b32c3", + cterm_color = "56", + name = "Eslintrc", + }, [".gitattributes"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "GitAttributes", }, [".gitconfig"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "GitConfig", }, [".gitignore"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "GitIgnore", }, [".gitlab-ci.yml"] = { icon = "", color = "#e24329", - cterm_color = "166", + cterm_color = "196", name = "GitlabCI", }, [".gitmodules"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "GitModules", }, [".gvimrc"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Gvimrc", }, [".npmignore"] = { icon = "", color = "#E8274B", - cterm_color = "161", + cterm_color = "197", name = "NPMIgnore", }, [".npmrc"] = { icon = "", color = "#E8274B", - cterm_color = "161", + cterm_color = "197", name = "NPMrc", }, [".settings.json"] = { @@ -114,7 +87,7 @@ local icons = { [".vimrc"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Vimrc", }, [".zprofile"] = { @@ -135,73 +108,85 @@ local icons = { cterm_color = "113", name = "Zshrc", }, - ["Brewfile"] = { + ["brewfile"] = { icon = "", color = "#701516", cterm_color = "52", name = "Brewfile", }, - ["CMakeLists.txt"] = { + ["cmakelists.txt"] = { icon = "", color = "#6d8086", cterm_color = "66", name = "CMakeLists", }, - ["COMMIT_EDITMSG"] = { + ["commit_editmsg"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "GitCommit", }, - ["Containerfile"] = { - icon = "", - color = "#384d54", - cterm_color = "59", + ["containerfile"] = { + icon = "󰡨", + color = "#458ee6", + cterm_color = "68", name = "Dockerfile", }, - ["COPYING"] = { + ["copying"] = { icon = "", color = "#cbcb41", cterm_color = "185", name = "License", }, - ["COPYING.LESSER"] = { + ["copying.lesser"] = { icon = "", color = "#cbcb41", cterm_color = "185", name = "License", }, - ["Dockerfile"] = { - icon = "", - color = "#384d54", - cterm_color = "59", + ["docker-compose.yml"] = { + icon = "󰡨", + color = "#458ee6", + cterm_color = "68", + name = "Dockerfile", + }, + ["docker-compose.yaml"] = { + icon = "󰡨", + color = "#458ee6", + cterm_color = "68", + name = "Dockerfile", + }, + [".dockerignore"] = { + icon = "󰡨", + color = "#458ee6", + cterm_color = "68", name = "Dockerfile", }, - ["Gemfile$"] = { + ["gemfile$"] = { icon = "", color = "#701516", cterm_color = "52", name = "Gemfile", }, - ["LICENSE"] = { + ["license"] = { icon = "", color = "#d0bf41", - cterm_color = "179", + cterm_color = "185", name = "License", }, - ["R"] = { + ["r"] = { icon = "ﳒ", color = "#358a5b", - cterm_color = "65", + cterm_color = "29", name = "R", }, - ["Rmd"] = { + ["rmd"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Rmd", }, - ["Vagrantfile$"] = { + ["vagrantfile$"] = { icon = "", color = "#1563FF", cterm_color = "27", @@ -210,15 +195,101 @@ local icons = { ["_gvimrc"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Gvimrc", }, ["_vimrc"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Vimrc", }, + ["package.json"] = { + icon = "", + color = "#e8274b", + name = "PackageJson", + }, + ["package-lock.json"] = { + icon = "", + color = "#7a0d21", + name = "PackageLockJson", + }, + ["node_modules"] = { + icon = "", + color = "#E8274B", + cterm_color = "197", + name = "NodeModules", + }, + ["favicon.ico"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Favicon", + }, + ["gnumakefile"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Makefile", + }, + ["makefile"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Makefile", + }, + ["mix.lock"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "MixLock", + }, + [".env"] = { + icon = "", + color = "#faf743", + cterm_color = "227", + name = "Env", + }, + ["gruntfile"] = { + icon = "", + color = "#e37933", + cterm_color = "166", + name = "Gruntfile", + }, + ["gulpfile"] = { + icon = "", + color = "#cc3e44", + cterm_color = "167", + name = "Gulpfile", + }, + ["webpack"] = { + icon = "ﰩ", + color = "#519aba", + cterm_color = "74", + name = "Webpack", + }, + ["rakefile"] = { + icon = "", + color = "#701516", + cterm_color = "52", + name = "Rakefile", + }, + ["procfile"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Procfile", + }, + ["dockerfile"] = { + icon = "󰡨", + color = "#458ee6", + cterm_color = "68", + name = "Dockerfile", + }, +} + +-- fuzzy match by extension +local icons_by_file_extension = { ["ai"] = { icon = "", color = "#cbcb41", @@ -228,7 +299,7 @@ local icons = { ["awk"] = { icon = "", color = "#4d5a5e", - cterm_color = "59", + cterm_color = "240", name = "Awk", }, ["bash"] = { @@ -240,7 +311,7 @@ local icons = { ["bat"] = { icon = "", color = "#C1F12E", - cterm_color = "154", + cterm_color = "191", name = "Bat", }, ["bmp"] = { @@ -252,7 +323,7 @@ local icons = { ["c"] = { icon = "", color = "#599eff", - cterm_color = "75", + cterm_color = "111", name = "C", }, ["c++"] = { @@ -276,31 +347,31 @@ local icons = { ["cfg"] = { icon = "", color = "#ECECEC", - cterm_color = "231", + cterm_color = "255", name = "Configuration", }, ["clj"] = { icon = "", color = "#8dc149", - cterm_color = "107", + cterm_color = "113", name = "Clojure", }, ["cljc"] = { icon = "", color = "#8dc149", - cterm_color = "107", + cterm_color = "113", name = "ClojureC", }, ["cljs"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "ClojureJS", }, ["cljd"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "ClojureDart", }, ["cmake"] = { @@ -342,13 +413,13 @@ local icons = { ["cp"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Cp", }, ["cpp"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Cpp", }, ["cpy"] = { @@ -358,9 +429,9 @@ local icons = { name = "Cobol", }, ["cr"] = { - icon = "", - color = "#000000", - cterm_color = "16", + icon = "", + color = "#c8c8c8", + cterm_color = "251", name = "Crystal", }, ["cs"] = { @@ -372,7 +443,7 @@ local icons = { ["csh"] = { icon = "", color = "#4d5a5e", - cterm_color = "59", + cterm_color = "240", name = "Csh", }, ["cson"] = { @@ -384,7 +455,7 @@ local icons = { ["css"] = { icon = "", color = "#42a5f5", - cterm_color = "39", + cterm_color = "75", name = "Css", }, ["csv"] = { @@ -396,13 +467,13 @@ local icons = { ["cxx"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Cxx", }, ["d"] = { icon = "", color = "#427819", - cterm_color = "64", + cterm_color = "28", name = "D", }, ["dart"] = { @@ -420,26 +491,26 @@ local icons = { ["desktop"] = { icon = "", color = "#563d7c", - cterm_color = "60", + cterm_color = "54", name = "DesktopEntry", }, ["diff"] = { icon = "", color = "#41535b", - cterm_color = "59", + cterm_color = "239", name = "Diff", }, ["doc"] = { icon = "", color = "#185abd", - cterm_color = "25", + cterm_color = "26", name = "Doc", }, - ["dockerfile"] = { - icon = "", - color = "#384d54", - cterm_color = "59", - name = "Dockerfile", + ["docx"] = { + icon = "", + color = "#185abd", + cterm_color = "26", + name = "Docx", }, ["drl"] = { icon = "", @@ -462,7 +533,7 @@ local icons = { ["edn"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Edn", }, ["eex"] = { @@ -480,7 +551,7 @@ local icons = { ["elm"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Elm", }, ["epp"] = { @@ -491,13 +562,13 @@ local icons = { ["erb"] = { icon = "", color = "#701516", - cterm_color = "52", + cterm_color = "214", name = "Erb", }, ["erl"] = { icon = "", color = "#B83998", - cterm_color = "132", + cterm_color = "163", name = "Erl", }, ["ex"] = { @@ -515,49 +586,49 @@ local icons = { ["f#"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Fsharp", }, - ["favicon.ico"] = { - icon = "", - color = "#cbcb41", - cterm_color = "185", - name = "Favicon", + ["f90"] = { + icon = "󱈚", + color = "#734f96", + cterm_color = "97", + name = "Fortran", }, ["fnl"] = { color = "#fff3d7", icon = "🌜", cterm_color = "230", - name = "Fennel" + name = "Fennel", }, ["fish"] = { icon = "", color = "#4d5a5e", - cterm_color = "59", + cterm_color = "240", name = "Fish", }, ["fs"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Fs", }, ["fsi"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Fsi", }, ["fsscript"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Fsscript", }, ["fsx"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Fsx", }, ["gd"] = { @@ -581,19 +652,19 @@ local icons = { ["git"] = { icon = "", color = "#F14C28", - cterm_color = "202", + cterm_color = "196", name = "GitLogo", }, ["glb"] = { icon = "", color = "#FFB13B", - cterm_color = "215", + cterm_color = "214", name = "BinaryGLTF", }, ["go"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Go", }, ["godot"] = { @@ -606,25 +677,13 @@ local icons = { icon = "", color = "#e535ab", cterm_color = "199", - name = "GraphQL" + name = "GraphQL", }, ["gql"] = { icon = "", color = "#e535ab", cterm_color = "199", - name = "GraphQL" - }, - ["gruntfile"] = { - icon = "", - color = "#e37933", - cterm_color = "173", - name = "Gruntfile", - }, - ["gulpfile"] = { - icon = "", - color = "#cc3e44", - cterm_color = "167", - name = "Gulpfile", + name = "GraphQL", }, ["h"] = { icon = "", @@ -635,13 +694,13 @@ local icons = { ["haml"] = { icon = "", color = "#eaeae1", - cterm_color = "188", + cterm_color = "255", name = "Haml", }, ["hbs"] = { icon = "", color = "#f0772b", - cterm_color = "208", + cterm_color = "202", name = "Hbs", }, ["heex"] = { @@ -665,7 +724,7 @@ local icons = { ["hrl"] = { icon = "", color = "#B83998", - cterm_color = "132", + cterm_color = "163", name = "Hrl", }, ["hs"] = { @@ -677,13 +736,13 @@ local icons = { ["htm"] = { icon = "", color = "#e34c26", - cterm_color = "166", + cterm_color = "196", name = "Htm", }, ["html"] = { icon = "", color = "#e44d26", - cterm_color = "202", + cterm_color = "196", name = "Html", }, ["hxx"] = { @@ -701,7 +760,7 @@ local icons = { ["import"] = { icon = "", color = "#ECECEC", - cterm_color = "231", + cterm_color = "255", name = "ImportConfiguration", }, ["ini"] = { @@ -741,11 +800,17 @@ local icons = { name = "Js", }, ["test.js"] = { - icon = "", - color = "#e37933", - cterm_color = "173", + icon = "", + color = "#cbcb41", + cterm_color = "185", name = "TestJs", }, + ["spec.js"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "SpecJs", + }, ["json"] = { icon = "", color = "#cbcb41", @@ -760,14 +825,26 @@ local icons = { }, ["jsx"] = { icon = "", - color = "#519aba", - cterm_color = "67", + color = "#20c2e3", + cterm_color = "45", name = "Jsx", }, + ["test.jsx"] = { + icon = "", + color = "#20c2e3", + cterm_color = "45", + name = "JavaScriptReactTest", + }, + ["spec.jsx"] = { + icon = "", + color = "#20c2e3", + cterm_color = "45", + name = "JavaScriptReactSpec", + }, ["ksh"] = { icon = "", color = "#4d5a5e", - cterm_color = "59", + cterm_color = "240", name = "Ksh", }, ["kt"] = { @@ -791,7 +868,7 @@ local icons = { ["less"] = { icon = "", color = "#563d7c", - cterm_color = "60", + cterm_color = "54", name = "Less", }, ["lhs"] = { @@ -818,8 +895,20 @@ local icons = { cterm_color = "74", name = "Luau", }, + ["gnumakefile"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Makefile", + }, ["makefile"] = { - icon = "", + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Makefile", + }, + ["mk"] = { + icon = "", color = "#6d8086", cterm_color = "66", name = "Makefile", @@ -827,25 +916,25 @@ local icons = { ["markdown"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Markdown", }, ["material"] = { icon = "", color = "#B83998", - cterm_color = "132", + cterm_color = "163", name = "Material", }, ["md"] = { icon = "", color = "#ffffff", - cterm_color = "white", + cterm_color = "231", name = "Md", }, ["mdx"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Mdx", }, ["mint"] = { @@ -854,44 +943,38 @@ local icons = { cterm_color = "108", name = "Mint", }, - ["mix.lock"] = { - icon = "", - color = "#a074c4", - cterm_color = "140", - name = "MixLock", - }, ["mjs"] = { icon = "", color = "#f1e05a", - cterm_color = "221", + cterm_color = "185", name = "Mjs", }, ["ml"] = { icon = "λ", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Ml", }, ["mli"] = { icon = "λ", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Mli", }, ["mo"] = { icon = "∞", color = "#9772FB", - cterm_color = "99", + cterm_color = "135", name = "Motoko", }, ["mustache"] = { icon = "", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Mustache", }, ["nim"] = { - icon = "👑", + icon = "", color = "#f3d400", cterm_color = "220", name = "Nim", @@ -902,34 +985,24 @@ local icons = { cterm_color = "110", name = "Nix", }, - ["node_modules"] = { - icon = "", - color = "#E8274B", - cterm_color = "161", - name = "NodeModules", - }, ["opus"] = { icon = "", color = "#F88A02", cterm_color = "208", name = "OPUS", }, + ["org"] = { + icon = "", + color = "#77AA99", + cterm_color = "73", + name = "OrgMode", + }, ["otf"] = { icon = "", color = "#ECECEC", - cterm_color = "231", + cterm_color = "255", name = "OpenTypeFont", }, - ['package.json'] = { - icon = "", - color = "#e8274b", - name = "PackageJson" - }, - ['package-lock.json'] = { - icon = "", - color = "#7a0d21", - name = "PackageLockJson" - }, ["pck"] = { icon = "", color = "#6d8086", @@ -951,13 +1024,13 @@ local icons = { ["pl"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Pl", }, ["pm"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Pm", }, ["png"] = { @@ -974,7 +1047,7 @@ local icons = { ["ppt"] = { icon = "", color = "#cb4a32", - cterm_color = "167", + cterm_color = "214", name = "Ppt", }, ["pro"] = { @@ -983,76 +1056,70 @@ local icons = { cterm_color = "179", name = "Prolog", }, - ["Procfile"] = { - icon = "", - color = "#a074c4", - cterm_color = "140", - name = "Procfile", - }, ["ps1"] = { icon = "󰨊", color = "#4273ca", - cterm_color = "69", + cterm_color = "68", name = "PsScriptfile", }, ["psd1"] = { icon = "󰨊", color = "#6975c4", - cterm_color = "105", + cterm_color = "68", name = "PsManifestfile", }, ["psm1"] = { icon = "󰨊", color = "#6975c4", - cterm_color = "105", + cterm_color = "68", name = "PsScriptModulefile", }, ["psb"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Psb", }, ["psd"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Psd", }, ["py"] = { icon = "", color = "#ffbc03", - cterm_color = "61", + cterm_color = "214", name = "Py", }, ["pyc"] = { icon = "", color = "#ffe291", - cterm_color = "67", + cterm_color = "222", name = "Pyc", }, ["pyd"] = { icon = "", color = "#ffe291", - cterm_color = "67", + cterm_color = "222", name = "Pyd", }, ["pyo"] = { icon = "", color = "#ffe291", - cterm_color = "67", + cterm_color = "222", name = "Pyo", }, ["query"] = { icon = "", color = "#90a850", - cterm_color = "154", + cterm_color = "107", name = "Query", }, ["r"] = { icon = "ﳒ", color = "#358a5b", - cterm_color = "65", + cterm_color = "29", name = "R", }, ["rake"] = { @@ -1061,12 +1128,6 @@ local icons = { cterm_color = "52", name = "Rake", }, - ["rakefile"] = { - icon = "", - color = "#701516", - cterm_color = "52", - name = "Rakefile", - }, ["rb"] = { icon = "", color = "#701516", @@ -1076,25 +1137,25 @@ local icons = { ["rlib"] = { icon = "", color = "#dea584", - cterm_color = "180", + cterm_color = "216", name = "Rlib", }, ["rmd"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Rmd", }, ["rproj"] = { icon = "鉶", color = "#358a5b", - cterm_color = "65", + cterm_color = "29", name = "Rproj", }, ["rs"] = { icon = "", color = "#dea584", - cterm_color = "180", + cterm_color = "216", name = "Rs", }, ["rss"] = { @@ -1136,19 +1197,19 @@ local icons = { ["sh"] = { icon = "", color = "#4d5a5e", - cterm_color = "59", + cterm_color = "240", name = "Sh", }, ["sig"] = { icon = "λ", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Sig", }, ["slim"] = { icon = "", color = "#e34c26", - cterm_color = "166", + cterm_color = "196", name = "Slim", }, ["sln"] = { @@ -1160,7 +1221,7 @@ local icons = { ["sml"] = { icon = "λ", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Sml", }, ["sql"] = { @@ -1184,13 +1245,13 @@ local icons = { ["styl"] = { icon = "", color = "#8dc149", - cterm_color = "107", + cterm_color = "113", name = "Styl", }, ["sublime"] = { icon = "", color = "#e37933", - cterm_color = "98", + cterm_color = "166", name = "Suo", }, ["suo"] = { @@ -1202,73 +1263,73 @@ local icons = { ["sv"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "SystemVerilog", }, ["svelte"] = { - icon = "", + icon = "", color = "#ff3e00", - cterm_color = "202", + cterm_color = "196", name = "Svelte", }, ["svh"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "SystemVerilog", }, ["svg"] = { icon = "ﰟ", color = "#FFB13B", - cterm_color = "215", + cterm_color = "214", name = "Svg", }, ["swift"] = { icon = "", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Swift", }, ["t"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Tor", }, ["tbc"] = { icon = "﯑", color = "#1e5cb3", - cterm_color = "67", + cterm_color = "25", name = "Tcl", }, ["tcl"] = { icon = "﯑", color = "#1e5cb3", - cterm_color = "67", + cterm_color = "25", name = "Tcl", }, ["terminal"] = { icon = "", color = "#31B53E", - cterm_color = "71", + cterm_color = "34", name = "Terminal", }, ["tex"] = { icon = "ﭨ", color = "#3D6117", - cterm_color = "58", + cterm_color = "22", name = "Tex", }, ["tf"] = { icon = "", color = "#5F43E9", - cterm_color = "57", + cterm_color = "93", name = "Terraform", }, ["tfvars"] = { icon = "", color = "#5F43E9", - cterm_color = "57", + cterm_color = "93", name = "TFVars", }, ["toml"] = { @@ -1286,9 +1347,21 @@ local icons = { ["ts"] = { icon = "", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Ts", }, + ["test.ts"] = { + icon = "", + color = "#519aba", + cterm_color = "74", + name = "TestTs", + }, + ["spec.ts"] = { + icon = "", + color = "#519aba", + cterm_color = "74", + name = "SpecTs", + }, ["tscn"] = { icon = "", color = "#a074c4", @@ -1297,14 +1370,26 @@ local icons = { }, ["tsx"] = { icon = "", - color = "#519aba", - cterm_color = "67", + color = "#1354bf", + cterm_color = "26", name = "Tsx", }, + ["test.tsx"] = { + icon = "", + color = "#1354bf", + cterm_color = "26", + name = "TypeScriptReactTest", + }, + ["spec.tsx"] = { + icon = "", + color = "#1354bf", + cterm_color = "26", + name = "TypeScriptReactSpec", + }, ["twig"] = { icon = "", color = "#8dc149", - cterm_color = "107", + cterm_color = "113", name = "Twig", }, ["txt"] = { @@ -1316,43 +1401,49 @@ local icons = { ["v"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Verilog", }, + ["vala"] = { + icon = "", + color = "#7239b3", + cterm_color = "91", + name = "Vala", + }, ["vh"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Verilog", }, ["vhd"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "VHDL", }, ["vhdl"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "VHDL", }, ["vim"] = { icon = "", color = "#019833", - cterm_color = "29", + cterm_color = "28", name = "Vim", }, ["vue"] = { - icon = "", + icon = "﵂", color = "#8dc149", - cterm_color = "107", + cterm_color = "113", name = "Vue", }, ["webmanifest"] = { icon = "", color = "#f1e05a", - cterm_color = "221", + cterm_color = "185", name = "Webmanifest", }, ["webp"] = { @@ -1364,31 +1455,37 @@ local icons = { ["webpack"] = { icon = "ﰩ", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Webpack", }, ["xcplayground"] = { icon = "", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "XcPlayground", }, ["xls"] = { icon = "", color = "#207245", - cterm_color = "23", + cterm_color = "29", name = "Xls", }, + ["xlsx"] = { + icon = "", + color = "#207245", + cterm_color = "29", + name = "Xlsx", + }, ["xml"] = { icon = "謹", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Xml", }, ["xul"] = { icon = "", color = "#e37933", - cterm_color = "173", + cterm_color = "166", name = "Xul", }, ["yaml"] = { @@ -1406,7 +1503,7 @@ local icons = { ["zig"] = { icon = "", color = "#f69a1b", - cterm_color = "208", + cterm_color = "172", name = "Zig", }, ["zsh"] = { @@ -1418,19 +1515,13 @@ local icons = { ["sol"] = { icon = "ﲹ", color = "#519aba", - cterm_color = "67", + cterm_color = "74", name = "Solidity", }, - [".env"] = { - icon = "", - color = "#faf743", - cterm_color = "226", - name = "Env", - }, ["prisma"] = { icon = "卑", color = "#ffffff", - cterm_color = "white", + cterm_color = "231", name = "Prisma", }, ["lock"] = { @@ -1442,20 +1533,47 @@ local icons = { ["log"] = { icon = "", color = "#ffffff", - cterm_color = "white", + cterm_color = "231", name = "Log", }, + ["wasm"] = { + icon = "", + color = "#5c4cdb", + cterm_color = "62", + name = "Wasm", + }, + ["liquid"] = { + icon = "", + color = "#95BF47", + cterm_color = "106", + name = "Liquid", + }, } +-- When adding new icons, remember to add an entry to the `filetypes` table, if applicable. +local icons + +-- Set the current icons tables, depending on the 'background' option. +local function refresh_icons() + local by_filename, by_file_extension + if vim.o.background == "light" then + by_filename = require("nvim-web-devicons-light").icons_by_filename + by_file_extension = require("nvim-web-devicons-light").icons_by_file_extension + else + by_filename = icons_by_filename + by_file_extension = icons_by_file_extension + end + icons = vim.tbl_extend("keep", {}, by_filename, by_file_extension) +end + -- Map of filetypes -> icon names local filetypes = { - ["Brewfile"] = "Brewfile", - ["COMMIT"] = "COMMIT_EDITMSG", - ["COPYING"] = "COPYING", - ["Gemfile"] = "Gemfile$", - ["LESSER"] = "COPYING.LESSER", - ["LICENSE"] = "LICENSE", - ["Vagrantfile"] = "Vagrantfile$", + ["brewfile"] = "brewfile", + ["commit"] = "commit_editmsg", + ["copying"] = "copying", + ["gemfile"] = "gemfile$", + ["lesser"] = "copying.lesser", + ["vagrantfile"] = "vagrantfile$", ["awk"] = "awk", ["bmp"] = "bmp", ["c"] = "c", @@ -1478,6 +1596,7 @@ local filetypes = { ["desktop"] = "desktop", ["diff"] = "diff", ["doc"] = "doc", + ["docx"] = "docx", ["dockerfile"] = "dockerfile", ["dosbatch"] = "bat", ["dosini"] = "ini", @@ -1494,7 +1613,8 @@ local filetypes = { ["fennel"] = "fnl", ["fish"] = "fish", ["forth"] = "fs", - ["fortran"] = "f#", + ["fortran"] = "f90", + ["fsharp"] = "f#", ["fsi"] = "fsi", ["fsscript"] = "fsscript", ["fsx"] = "fsx", @@ -1502,6 +1622,9 @@ local filetypes = { ["gif"] = "gif", ["git"] = "git", ["gitconfig"] = ".gitconfig", + ["gitcommit"] = "commit_editmsg", + ["gitignore"] = ".gitignore", + ["gitattributes"] = ".gitattributes", ["glb"] = "glb", ["go"] = "go", ["godot"] = "godot", @@ -1529,6 +1652,7 @@ local filetypes = { ["kotlin"] = "kt", ["leex"] = "leex", ["less"] = "less", + ["liquid"] = "liquid", ["lhaskell"] = "lhs", ["license"] = "license", ["log"] = "log", @@ -1557,7 +1681,7 @@ local filetypes = { ["postscr"] = "ai", ["ppt"] = "ppt", ["prisma"] = "prisma", - ["procfile"] = "Procfile", + ["procfile"] = "procfile", ["prolog"] = "pro", ["ps1"] = "ps1", ["psd1"] = "psd1", @@ -1607,14 +1731,17 @@ local filetypes = { ["txt"] = "txt", ["typescript"] = "ts", ["typescriptreact"] = "tsx", + ["vala"] = "vala", ["verilog"] = "v", ["vhdl"] = "vhd", ["vim"] = "vim", ["vue"] = "vue", + ["wasm"] = "wasm", ["webp"] = "webp", ["webpack"] = "webpack", ["xcplayground"] = "xcplayground", ["xls"] = "xls", + ["xlsx"] = "xlsx", ["xml"] = "xml", ["yaml"] = "yaml", ["zig"] = "zig", @@ -1630,13 +1757,14 @@ local default_icon = { local global_opts = { override = {}, + strict = false, default = false, color_icons = true, } local function get_highlight_name(data) if not global_opts.color_icons then - data = default_icon + data = default_icon end return data.name and "DevIcon" .. data.name @@ -1645,21 +1773,23 @@ end local nvim_set_hl = vim.api.nvim_set_hl local function set_up_highlight(icon_data) if not global_opts.color_icons then - icon_data = default_icon + icon_data = default_icon end local hl_group = get_highlight_name(icon_data) if hl_group and (icon_data.color or icon_data.cterm_color) then - nvim_set_hl(0, get_highlight_name(icon_data), { - fg = icon_data.color, - ctermfg = tonumber(icon_data.cterm_color), - }) + nvim_set_hl(0, get_highlight_name(icon_data), { + fg = icon_data.color, + ctermfg = tonumber(icon_data.cterm_color), + }) end end local nvim_get_hl_by_name = vim.api.nvim_get_hl_by_name local function highlight_exists(group) - if not group then return end + if not group then + return + end local ok, hl = pcall(nvim_get_hl_by_name, group, true) return ok and not (hl or {})[true] @@ -1682,7 +1812,7 @@ end local function get_highlight_foreground(icon_data) if not global_opts.color_icons then - icon_data = default_icon + icon_data = default_icon end return string.format("#%06x", nvim_get_hl_by_name(get_highlight_name(icon_data), true).foreground) @@ -1690,7 +1820,7 @@ end local function get_highlight_ctermfg(icon_data) if not global_opts.color_icons then - icon_data = default_icon + icon_data = default_icon end return nvim_get_hl_by_name(get_highlight_name(icon_data), false).foreground @@ -1712,22 +1842,37 @@ local function setup(opts) global_opts.default = true end + if user_icons.strict then + global_opts.strict = true + end + global_opts.color_icons = if_nil(user_icons.color_icons, global_opts.color_icons) if user_icons.override and user_icons.override.default_icon then default_icon = user_icons.override.default_icon end - icons = vim.tbl_extend("force", icons, user_icons.override or {}) + local user_filename_icons = user_icons.override_by_filename + local user_file_ext_icons = user_icons.override_by_extension + + icons = + vim.tbl_extend("force", icons, user_icons.override or {}, user_filename_icons or {}, user_file_ext_icons or {}) + + if user_filename_icons then + icons_by_filename = vim.tbl_extend("force", icons_by_filename, user_filename_icons) + end + if user_file_ext_icons then + icons_by_file_extension = vim.tbl_extend("force", icons_by_file_extension, user_file_ext_icons) + end table.insert(icons, default_icon) set_up_highlights() vim.api.nvim_create_autocmd("ColorScheme", { - desc = "Re-apply icon colors after changing colorschemes", - group = vim.api.nvim_create_augroup("NvimWebDevicons", { clear = true }), - callback = set_up_highlights, + desc = "Re-apply icon colors after changing colorschemes", + group = vim.api.nvim_create_augroup("NvimWebDevicons", { clear = true }), + callback = set_up_highlights, }) end @@ -1735,14 +1880,49 @@ local function get_default_icon() return default_icon end +-- recursively iterate over each segment separated by '.' to parse extension with multiple dots in filename +local function iterate_multi_dotted_extension(name, icon_table) + if name == nil then + return nil + end + + local compound_ext = name:match "%.(.*)" + local icon = icon_table[compound_ext] + if icon then + return icon + end + + return iterate_multi_dotted_extension(compound_ext, icon_table) +end + +local function get_icon_by_extension(name, ext, opts) + local is_strict = if_nil(opts and opts.strict, global_opts.strict) + local icon_table = is_strict and icons_by_file_extension or icons + + if ext ~= nil then + return icon_table[ext] + end + + return iterate_multi_dotted_extension(name, icon_table) +end + local function get_icon(name, ext, opts) - ext = ext or name:match("^.*%.(.*)$") or "" + if type(name) == "string" then + name = name:lower() + end + if not loaded then setup() end local has_default = if_nil(opts and opts.default, global_opts.default) - local icon_data = icons[name] or icons[ext] or (has_default and default_icon) + local is_strict = if_nil(opts and opts.strict, global_opts.strict) + local icon_data + if is_strict then + icon_data = icons_by_filename[name] or get_icon_by_extension(name, ext, opts) or (has_default and default_icon) + else + icon_data = icons[name] or get_icon_by_extension(name, ext, opts) or (has_default and default_icon) + end if icon_data then return icon_data.icon, get_highlight_name(icon_data) @@ -1755,17 +1935,24 @@ end local function get_icon_by_filetype(ft, opts) local name = get_icon_name_by_filetype(ft) - return get_icon(name or '', nil, opts) + opts = opts or {} + opts.strict = false + return get_icon(name or "", nil, opts) end local function get_icon_colors(name, ext, opts) - ext = ext or name:match("^.*%.(.*)$") or "" if not loaded then setup() end local has_default = if_nil(opts and opts.default, global_opts.default) - local icon_data = icons[name] or icons[ext] or (has_default and default_icon) + local is_strict = if_nil(opts and opts.strict, global_opts.strict) + local icon_data + if is_strict then + icon_data = icons_by_filename[name] or get_icon_by_extension(name, ext, opts) or (has_default and default_icon) + else + icon_data = icons[name] or get_icon_by_extension(name, ext, opts) or (has_default and default_icon) + end if icon_data then local color = icon_data.color @@ -1780,7 +1967,7 @@ end local function get_icon_colors_by_filetype(ft, opts) local name = get_icon_name_by_filetype(ft) - return get_icon_colors(name or '', nil, opts) + return get_icon_colors(name or "", nil, opts) end local function get_icon_color(name, ext, opts) @@ -1790,7 +1977,9 @@ end local function get_icon_color_by_filetype(ft, opts) local name = get_icon_name_by_filetype(ft) - return get_icon_color(name or '', nil, opts) + opts = opts or {} + opts.strict = false + return get_icon_color(name or "", nil, opts) end local function get_icon_cterm_color(name, ext, opts) @@ -1800,13 +1989,13 @@ end local function get_icon_cterm_color_by_filetype(ft, opts) local name = get_icon_name_by_filetype(ft) - return get_icon_cterm_color(name or '', nil, opts) + return get_icon_cterm_color(name or "", nil, opts) end local function set_icon(user_icons) icons = vim.tbl_extend("force", icons, user_icons or {}) if not global_opts.color_icons then - return + return end for _, icon_data in pairs(user_icons) do @@ -1821,6 +2010,12 @@ local function set_default_icon(icon, color, cterm_color) set_up_highlight(default_icon) end +-- Load the icons already, the loaded tables depend on the 'background' setting. +refresh_icons() + +-- Change icon set on background change +vim.api.nvim_create_autocmd("OptionSet", { pattern = "background", callback = refresh_icons }) + return { get_icon = get_icon, get_icon_colors = get_icon_colors, diff --git a/scripts/filetype-generator.sh b/scripts/filetype-generator.sh index 4b003647..902c6ef4 100755 --- a/scripts/filetype-generator.sh +++ b/scripts/filetype-generator.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh ## Credit: @B0o (Maddison Hellstrom) diff --git a/scripts/generate_colors.lua b/scripts/generate_colors.lua new file mode 100644 index 00000000..2cf7fb82 --- /dev/null +++ b/scripts/generate_colors.lua @@ -0,0 +1,168 @@ +-- Plugin lifepillar/vim-colortemplate must be available on &runtimepath +-- +-- The current working directory must be set to the repo root + +-- IMPORTANT: the `cterm_color` key must always be below the `color` key of the +-- same icon. Currently they are. + +-- This file should be run from the shell with `make colors` + +local fn = vim.fn + +if not jit then + error "Neovim must be LuaJIT-enabled to source this script" +end + +if fn.filereadable "lua/nvim-web-devicons.lua" == 0 then + error "lua/nvim-web-devicons.lua not found" +end + +local rc, err = pcall(vim.fn["colortemplate#colorspace#approx"], "#000000") +if not rc then + error(err .. "\nPlease ensure lifepillar/vim-colortemplate is present in the runtimepath.") +end + +-------------------------------------------------------------------------------- +-- Local functions +-------------------------------------------------------------------------------- + +local light78 = 255 * 7 / 8 +local light68 = 255 * 6 / 8 +local light58 = 255 * 5 / 8 +local light12 = 255 / 2 +local light13 = 255 / 3 + +local function darken_color(rrggbb) + local r, g, b = rrggbb:match "%#(%x%x)(%x%x)(%x%x)" + r, g, b = tonumber("0x" .. r), tonumber("0x" .. g), tonumber("0x" .. b) + -- luminance formula: see https://stackoverflow.com/a/596243 + local lum = 0.299 * r + 0.587 * g + 0.114 * b + if lum < light13 then -------------------- darkest tertile + return rrggbb + elseif lum < light12 then ---------------- second darkest quartile + r = bit.tohex(r / 4 * 3):sub(-2) + g = bit.tohex(g / 4 * 3):sub(-2) + b = bit.tohex(b / 4 * 3):sub(-2) + elseif lum < light58 then ---------------- lightest octiles: first + r = bit.tohex(r / 3 * 2):sub(-2) + g = bit.tohex(g / 3 * 2):sub(-2) + b = bit.tohex(b / 3 * 2):sub(-2) + elseif lum < light68 then ---------------- lightest octiles: second + r = bit.tohex(r / 2):sub(-2) + g = bit.tohex(g / 2):sub(-2) + b = bit.tohex(b / 2):sub(-2) + elseif lum < light78 then ---------------- lightest octiles: third + r = bit.tohex(r / 3):sub(-2) + g = bit.tohex(g / 3):sub(-2) + b = bit.tohex(b / 3):sub(-2) + else ------------------------------------- lightest octile + r = bit.tohex(r / 5):sub(-2) + g = bit.tohex(g / 5):sub(-2) + b = bit.tohex(b / 5):sub(-2) + end + return string.format("#%s%s%s", r, g, b) +end + +local function update_cterm_colors() + -- move to first line + vim.cmd ":1" + local last = 0 + + while true do + local cur = fn.search "^\\s*color =" + if cur < last then + break + end + last = cur + local color = fn.getline("."):match "%#......" + if fn.search "^\\s*cterm_color" < cur then + break + end + if fn.getline("."):find "%d" then + fn.setline( + ".", + fn.substitute(fn.getline ".", "\\d\\+", function() + return tostring(vim.fn["colortemplate#colorspace#approx"](color).index) + end, "") + ) + end + end +end + +local function generate_lines() + local start = fn.line "." - 1 + fn.search "^}" + local finish = fn.line "." + local lines = vim.api.nvim_buf_get_lines(fn.bufnr(), start, finish, true) + for i = 1, #lines do + if lines[i]:find "^%s*color =" then + lines[i] = lines[i]:gsub("%#%x+", function(m) + return darken_color(m) + end) + end + end + table.insert(lines, "") + return lines +end + +-------------------------------------------------------------------------------- +-- Generate file with icons for light backgrounds +-------------------------------------------------------------------------------- + +vim.cmd "noswapfile drop lua/nvim-web-devicons.lua" + +print "Generating file with icons for light backgrounds..." + +-- move to first line +vim.cmd ":1" + +-- first table +if fn.search "^local icons_by_filename" == 0 then + error "Table not found!" +end +local lines = generate_lines() + +-- second table +if fn.search "^local icons_by_file_extension" == 0 then + error "Table not found!" +end +local lines2 = generate_lines() +table.insert(lines2, "return {") +table.insert(lines2, " icons_by_filename = icons_by_filename,") +table.insert(lines2, " icons_by_file_extension = icons_by_file_extension,") +table.insert(lines2, "}") + +-- write both tables to file +fn.writefile(lines, "lua/nvim-web-devicons-light.lua") +fn.writefile(lines2, "lua/nvim-web-devicons-light.lua", "a") + +print "Finished creating new file!" + +-------------------------------------------------------------------------------- +-- Update cterm colors for dark background +-------------------------------------------------------------------------------- + +print "Generating cterm colors for dark background...\n" + +update_cterm_colors() + +vim.cmd "wall!" +print "Finished!" + +-------------------------------------------------------------------------------- +-- Generate cterm colors for light background +-------------------------------------------------------------------------------- + +if fn.filereadable "lua/nvim-web-devicons-light.lua" == 0 then + error "lua/nvim-web-devicons-light.lua not found!" +end + +vim.cmd "noswapfile drop lua/nvim-web-devicons-light.lua" + +print "Generating cterm colors for light background...\n" + +update_cterm_colors() + +vim.cmd ":1" +vim.cmd "wall!" +print "Finished!\n"