Skip to content

Commit

Permalink
Merge branch 'nvim-tree:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Apr 7, 2023
2 parents 240ea8a + 0568104 commit 735ec4a
Show file tree
Hide file tree
Showing 16 changed files with 2,473 additions and 287 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
insert_final_newline = true
end_of_line = lf

[*.lua]
indent_style = space
indent_size = 2
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- run: pip install pre-commit
- run: pre-commit run --all-files
33 changes: 33 additions & 0 deletions .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- 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.
15 changes: 15 additions & 0 deletions .github/workflows/semantic-pr-subject.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.lua
.luarocks
7 changes: 7 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
max_line_length = 120

globals = {
"vim",
"jit",
"bit",
}
12 changes: 12 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}

21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
6 changes: 6 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
92 changes: 92 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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"
}
};
}
```

Expand All @@ -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 = <boolean>`. If the default key is set to true this function will return a default
if there is no matching icon
`default = <boolean>` and `strict = <boolean>`. 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
Expand Down Expand Up @@ -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)
Loading

0 comments on commit 735ec4a

Please sign in to comment.