Skip to content

Commit e11ce83

Browse files
authored
chore(#3271): add new format-check, rename style-fix to format-fix (#3273)
* chore(#3271): add new format-check, rename style-fix to format-fix * chore(#3271): CI install CodeFormat from luarocks * chore(#3271): CI install CodeFormat from luarocks * chore(#3271): CI install CodeFormat from luarocks * chore(#3271): remove bad printf after format-check failure * chore(#3271): install CodeFormat from binary as luarocks is too slow * chore(#3271): no broken windows - all formatting fixed
1 parent 5dd95ea commit e11ce83

File tree

6 files changed

+46
-18
lines changed

6 files changed

+46
-18
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ jobs:
4343
runs-on: ubuntu-latest
4444

4545
concurrency:
46-
group: ${{ github.workflow }}-${{ matrix.nvim_version }}-${{ matrix.luals_version }}-${{ github.head_ref || github.ref_name }}
46+
group: ${{ github.workflow }}-${{ matrix.nvim_version }}-${{ matrix.luals_version }}-${{ matrix.emmyluacodestyle_version }}-${{ github.head_ref || github.ref_name }}
4747
cancel-in-progress: true
4848

4949
strategy:
5050
matrix:
5151
nvim_version: [ stable, nightly ]
5252
luals_version: [ 3.15.0 ]
53+
emmyluacodestyle_version: [ 1.6.0 ]
5354

5455
env:
5556
VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime
@@ -71,12 +72,20 @@ jobs:
7172
curl -L "https://github.com/LuaLS/lua-language-server/releases/download/${{ matrix.luals_version }}/lua-language-server-${{ matrix.luals_version }}-linux-x64.tar.gz" | tar zx --directory luals
7273
echo "luals/bin" >> "$GITHUB_PATH"
7374
75+
- name: install EmmyLuaCodeStyle ${{ matrix.emmyluacodestyle_version }}
76+
run: |
77+
mkdir -p EmmyLuaCodeStyle
78+
curl -L "https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/${{ matrix.emmyluacodestyle_version }}/linux-x64.tar.gz" | tar zx --directory EmmyLuaCodeStyle
79+
echo "EmmyLuaCodeStyle/linux-x64/bin" >> "$GITHUB_PATH"
80+
7481
- run: make check
7582

7683
- run: make style
7784

7885
- run: make style-doc
7986

87+
- run: make format-check
88+
8089
- name: build Nvim from source
8190
run: |
8291
mkdir -p "${DIR_NVIM_SRC}"

CONTRIBUTING.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ markdown-toc --maxdepth=2 -i CONTRIBUTING.md
1515
- [Quality](#quality)
1616
* [lint](#lint)
1717
* [style](#style)
18+
* [format-fix](#format-fix)
1819
* [check](#check)
20+
* [format-check](#format-check)
1921
- [Diagnostics](#diagnostics)
2022
- [Backwards Compatibility](#backwards-compatibility)
2123
- [:help Documentation](#help-documentation)
@@ -36,10 +38,10 @@ Language server: [luals](https://luals.github.io)
3638

3739
Lint: [luacheck](https://github.com/lunarmodules/luacheck/)
3840

39-
Style Fixing: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeCheck`
40-
4141
nvim-tree.lua migrated from stylua to EmmyLuaCodeStyle ~2024/10. `vim.lsp.buf.format()` may be used as it is the default formatter for luals, using an embedded [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle)
4242

43+
Formatting: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeFormat` executable
44+
4345
You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks`
4446

4547
# Quality
@@ -67,10 +69,12 @@ make lint
6769
make style
6870
```
6971

70-
You can automatically fix style issues using `CodeCheck`:
72+
## format-fix
73+
74+
You can automatically fix most style issues using `CodeFormat`:
7175

7276
```sh
73-
make style-fix
77+
make format-fix
7478
```
7579

7680
## check
@@ -96,6 +100,17 @@ curl -L "https://github.com/LuaLS/lua-language-server/releases/download/3.15.0/l
96100
PATH="luals/bin:${PATH}" make check
97101
```
98102

103+
## format-check
104+
105+
This is run in CI. Commit or stage your changes and run:
106+
107+
```sh
108+
make format-check
109+
```
110+
111+
- Re-runs `make format-fix`
112+
- Checks that `git diff` is empty, to ensure that all content has been generated. This is why a stage or commit is necessary.
113+
99114
# Diagnostics
100115

101116
Diagnostics issues may not be suppressed. See [luals](https://luals.github.io) documentation for details on how to structure the code and comments.

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ luals:
2525
scripts/luals-check.sh
2626

2727
#
28-
# fixes
28+
# format
2929
#
30-
style-fix:
30+
format-fix:
3131
CodeFormat format --config .editorconfig --workspace lua
3232

33+
format-check:
34+
CodeFormat format --config .editorconfig --workspace lua
35+
git diff --exit-code lua
36+
3337
#
3438
# utility
3539
#
@@ -46,5 +50,5 @@ help-check: help-update
4650
git diff --ignore-blank-lines --exit-code doc/nvim-tree-lua.txt
4751

4852

49-
.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check
53+
.PHONY: all lint style check luacheck style-check style-doc luals format-fix format-check help-update help-check
5054

lua/nvim-tree/_meta/api/decorator.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ local Class = require("nvim-tree.classic")
4141
---
4242
---@class nvim_tree.api.highlighted_string
4343
---
44-
---One or many glyphs/characters.
44+
---One or many glyphs/characters.
4545
---@field str string
4646
---
4747
---Highlight group names to apply in order. Empty table for no highlighting.

lua/nvim-tree/_meta/api/decorator_example.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error("Cannot require a meta file")
1414
---```lua
1515
---
1616
--- local MyDecorator = require("my-decorator")
17-
---
17+
---
1818
--- require("nvim-tree").setup({
1919
--- renderer = {
2020
--- decorators = {
@@ -40,25 +40,25 @@ error("Cannot require a meta file")
4040
--- ---@field private my_icon_node nvim_tree.api.highlighted_string
4141
--- ---@field private my_highlight_group string
4242
--- local MyDecorator = require("nvim-tree.api").Decorator:extend()
43-
---
43+
---
4444
--- ---Mandatory constructor :new() will be called once per tree render, with no arguments.
4545
--- function MyDecorator:new()
4646
--- self.enabled = true
4747
--- self.highlight_range = "name"
4848
--- self.icon_placement = "after"
49-
---
49+
---
5050
--- -- create your icons and highlights once, applied to every node
5151
--- self.my_icon1 = { str = "1", hl = { "DiffAdd" } }
5252
--- self.my_icon2 = { str = "2", hl = { "DiffText" } }
5353
--- self.my_icon_node = { str = "N", hl = { "Error" } }
5454
--- self.my_highlight_group = "IncSearch"
55-
---
55+
---
5656
--- -- Define the icon signs only once
5757
--- -- Only needed if you are using icon_placement = "signcolumn"
5858
--- -- self:define_sign(self.my_icon1)
5959
--- -- self:define_sign(self.my_icon2)
6060
--- end
61-
---
61+
---
6262
--- ---Override node icon
6363
--- ---@param node nvim_tree.api.Node
6464
--- ---@return nvim_tree.api.highlighted_string? icon_node
@@ -69,7 +69,7 @@ error("Cannot require a meta file")
6969
--- return nil
7070
--- end
7171
--- end
72-
---
72+
---
7373
--- ---Return two icons for DecoratorIconPlacement "after"
7474
--- ---@param node nvim_tree.api.Node
7575
--- ---@return nvim_tree.api.highlighted_string[]? icons
@@ -80,7 +80,7 @@ error("Cannot require a meta file")
8080
--- return nil
8181
--- end
8282
--- end
83-
---
83+
---
8484
--- ---Exactly one highlight group for DecoratorHighlightRange "name"
8585
--- ---@param node nvim_tree.api.Node
8686
--- ---@return string? highlight_group
@@ -91,6 +91,6 @@ error("Cannot require a meta file")
9191
--- return nil
9292
--- end
9393
--- end
94-
---
94+
---
9595
--- return MyDecorator
9696
---```

lua/nvim-tree/_meta/config/renderer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ error("Cannot require a meta file")
364364
--- for reason, count in pairs(hidden_stats) do
365365
--- total_count = total_count + count
366366
--- end
367-
---
367+
---
368368
--- if total_count > 0 then
369369
--- return "(" .. tostring(total_count) .. " hidden)"
370370
--- end

0 commit comments

Comments
 (0)