diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e32aefbaf3c..b827c6fb423 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,13 +43,14 @@ jobs: runs-on: ubuntu-latest concurrency: - group: ${{ github.workflow }}-${{ matrix.nvim_version }}-${{ matrix.luals_version }}-${{ github.head_ref || github.ref_name }} + group: ${{ github.workflow }}-${{ matrix.nvim_version }}-${{ matrix.luals_version }}-${{ matrix.emmyluacodestyle_version }}-${{ github.head_ref || github.ref_name }} cancel-in-progress: true strategy: matrix: nvim_version: [ stable, nightly ] luals_version: [ 3.15.0 ] + emmyluacodestyle_version: [ 1.6.0 ] env: VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime @@ -71,12 +72,20 @@ jobs: 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 echo "luals/bin" >> "$GITHUB_PATH" + - name: install EmmyLuaCodeStyle ${{ matrix.emmyluacodestyle_version }} + run: | + mkdir -p EmmyLuaCodeStyle + curl -L "https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/${{ matrix.emmyluacodestyle_version }}/linux-x64.tar.gz" | tar zx --directory EmmyLuaCodeStyle + echo "EmmyLuaCodeStyle/linux-x64/bin" >> "$GITHUB_PATH" + - run: make check - run: make style - run: make style-doc + - run: make format-check + - name: build Nvim from source run: | mkdir -p "${DIR_NVIM_SRC}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bfa75ade13c..6d7451d198e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,9 @@ markdown-toc --maxdepth=2 -i CONTRIBUTING.md - [Quality](#quality) * [lint](#lint) * [style](#style) + * [format-fix](#format-fix) * [check](#check) + * [format-check](#format-check) - [Diagnostics](#diagnostics) - [Backwards Compatibility](#backwards-compatibility) - [:help Documentation](#help-documentation) @@ -36,10 +38,10 @@ Language server: [luals](https://luals.github.io) Lint: [luacheck](https://github.com/lunarmodules/luacheck/) -Style Fixing: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeCheck` - 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) +Formatting: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeFormat` executable + You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks` # Quality @@ -67,10 +69,12 @@ make lint make style ``` -You can automatically fix style issues using `CodeCheck`: +## format-fix + +You can automatically fix most style issues using `CodeFormat`: ```sh -make style-fix +make format-fix ``` ## check @@ -96,6 +100,17 @@ curl -L "https://github.com/LuaLS/lua-language-server/releases/download/3.15.0/l PATH="luals/bin:${PATH}" make check ``` +## format-check + +This is run in CI. Commit or stage your changes and run: + +```sh +make format-check +``` + +- Re-runs `make format-fix` +- Checks that `git diff` is empty, to ensure that all content has been generated. This is why a stage or commit is necessary. + # Diagnostics Diagnostics issues may not be suppressed. See [luals](https://luals.github.io) documentation for details on how to structure the code and comments. diff --git a/Makefile b/Makefile index c6c837f5ab2..6d668cf2b6a 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,15 @@ luals: scripts/luals-check.sh # -# fixes +# format # -style-fix: +format-fix: CodeFormat format --config .editorconfig --workspace lua +format-check: + CodeFormat format --config .editorconfig --workspace lua + git diff --exit-code lua + # # utility # @@ -46,5 +50,5 @@ help-check: help-update git diff --ignore-blank-lines --exit-code doc/nvim-tree-lua.txt -.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check +.PHONY: all lint style check luacheck style-check style-doc luals format-fix format-check help-update help-check diff --git a/lua/nvim-tree/_meta/api/decorator.lua b/lua/nvim-tree/_meta/api/decorator.lua index c4ef939765b..1d1b9dbb723 100644 --- a/lua/nvim-tree/_meta/api/decorator.lua +++ b/lua/nvim-tree/_meta/api/decorator.lua @@ -41,7 +41,7 @@ local Class = require("nvim-tree.classic") --- ---@class nvim_tree.api.highlighted_string --- ----One or many glyphs/characters. +---One or many glyphs/characters. ---@field str string --- ---Highlight group names to apply in order. Empty table for no highlighting. diff --git a/lua/nvim-tree/_meta/api/decorator_example.lua b/lua/nvim-tree/_meta/api/decorator_example.lua index 32ccc4fd991..c4d42c5cb24 100644 --- a/lua/nvim-tree/_meta/api/decorator_example.lua +++ b/lua/nvim-tree/_meta/api/decorator_example.lua @@ -14,7 +14,7 @@ error("Cannot require a meta file") ---```lua --- --- local MyDecorator = require("my-decorator") ---- +--- --- require("nvim-tree").setup({ --- renderer = { --- decorators = { @@ -40,25 +40,25 @@ error("Cannot require a meta file") --- ---@field private my_icon_node nvim_tree.api.highlighted_string --- ---@field private my_highlight_group string --- local MyDecorator = require("nvim-tree.api").Decorator:extend() ---- +--- --- ---Mandatory constructor :new() will be called once per tree render, with no arguments. --- function MyDecorator:new() --- self.enabled = true --- self.highlight_range = "name" --- self.icon_placement = "after" ---- +--- --- -- create your icons and highlights once, applied to every node --- self.my_icon1 = { str = "1", hl = { "DiffAdd" } } --- self.my_icon2 = { str = "2", hl = { "DiffText" } } --- self.my_icon_node = { str = "N", hl = { "Error" } } --- self.my_highlight_group = "IncSearch" ---- +--- --- -- Define the icon signs only once --- -- Only needed if you are using icon_placement = "signcolumn" --- -- self:define_sign(self.my_icon1) --- -- self:define_sign(self.my_icon2) --- end ---- +--- --- ---Override node icon --- ---@param node nvim_tree.api.Node --- ---@return nvim_tree.api.highlighted_string? icon_node @@ -69,7 +69,7 @@ error("Cannot require a meta file") --- return nil --- end --- end ---- +--- --- ---Return two icons for DecoratorIconPlacement "after" --- ---@param node nvim_tree.api.Node --- ---@return nvim_tree.api.highlighted_string[]? icons @@ -80,7 +80,7 @@ error("Cannot require a meta file") --- return nil --- end --- end ---- +--- --- ---Exactly one highlight group for DecoratorHighlightRange "name" --- ---@param node nvim_tree.api.Node --- ---@return string? highlight_group @@ -91,6 +91,6 @@ error("Cannot require a meta file") --- return nil --- end --- end ---- +--- --- return MyDecorator ---``` diff --git a/lua/nvim-tree/_meta/config/renderer.lua b/lua/nvim-tree/_meta/config/renderer.lua index 4e7d419f101..6f61d864efe 100644 --- a/lua/nvim-tree/_meta/config/renderer.lua +++ b/lua/nvim-tree/_meta/config/renderer.lua @@ -364,7 +364,7 @@ error("Cannot require a meta file") --- for reason, count in pairs(hidden_stats) do --- total_count = total_count + count --- end ---- +--- --- if total_count > 0 then --- return "(" .. tostring(total_count) .. " hidden)" --- end