Skip to content

Commit 1ae1c33

Browse files
authored
chore(#2931): stylua -> EmmyLuaCodeStyle (#2932)
* stylua -> EmmyLuaCodeStyle: config and doc * stylua -> EmmyLuaCodeStyle: CI * stylua -> EmmyLuaCodeStyle: CI * stylua -> EmmyLuaCodeStyle: CI * stylua -> EmmyLuaCodeStyle: CI * stylua -> EmmyLuaCodeStyle: CI * stylua -> EmmyLuaCodeStyle * stylua -> EmmyLuaCodeStyle: call_arg_parentheses = always * stylua -> EmmyLuaCodeStyle * stylua -> EmmyLuaCodeStyle
1 parent 9650e73 commit 1ae1c33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+593
-586
lines changed

.editorconfig

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ root = true
44
insert_final_newline = true
55
end_of_line = lf
66

7+
[nvim-tree-lua.txt]
8+
max_line_length = 78
9+
710
[*.lua]
811
indent_style = space
12+
max_line_length = 140
913
indent_size = 2
1014

11-
[nvim-tree-lua.txt]
12-
max_line_length = 78
15+
# EmmyLuaCodeStyle specific, see
16+
# https://github.com/CppCXY/EmmyLuaCodeStyle/blob/master/lua.template.editorconfig
17+
continuation_indent = 2
18+
quote_style = double
19+
call_arg_parentheses = always
20+
space_before_closure_open_parenthesis = false

.github/workflows/ci.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,24 @@ jobs:
3838
runs-on: ubuntu-latest
3939

4040
concurrency:
41-
group: ${{ github.workflow }}-${{ matrix.stylua_version }}-${{ github.head_ref || github.ref_name }}
41+
group: ${{ github.workflow }}-${{ matrix.emmy_lua_code_style_version }}-${{ github.head_ref || github.ref_name }}
4242
cancel-in-progress: true
4343

4444
strategy:
4545
matrix:
46-
stylua_version: [ 0.19.1 ]
46+
emmy_lua_code_style_version: [ 1.5.6 ]
4747

4848
steps:
4949
- uses: actions/checkout@v4
5050

51-
- name: stylua
52-
uses: JohnnyMorganz/stylua-action@v4
53-
with:
54-
token: ${{ secrets.GITHUB_TOKEN }}
55-
version: ${{ matrix.stylua_version }}
56-
args: --check lua
51+
- name: install emmy_lua_code_style
52+
run: |
53+
mkdir -p CodeFormat
54+
curl -L "https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/${{ matrix.emmy_lua_code_style_version }}/linux-x64.tar.gz" | tar zx --directory CodeFormat
55+
56+
- run: echo "CodeFormat/linux-x64/bin" >> "$GITHUB_PATH"
57+
58+
- run: make style
5759

5860
- run: make style-doc
5961

.stylua.toml

-6
This file was deleted.

CONTRIBUTING.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ See [Development](https://github.com/nvim-tree/nvim-tree.lua/wiki/Development) f
88

99
Following are used during CI and strongly recommended during local development.
1010

11+
Language server: [luals](https://luals.github.io)
12+
1113
Lint: [luacheck](https://github.com/lunarmodules/luacheck/)
1214

13-
Style: [StyLua](https://github.com/JohnnyMorganz/StyLua)
15+
Style: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeCheck`
1416

15-
Language server: [luals](https://luals.github.io)
17+
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
1618

1719
You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks`
1820

@@ -34,14 +36,14 @@ make lint
3436

3537
## style
3638

37-
1. Runs stylua using `.stylua.toml` settings
39+
1. Runs CodeCheck using `.editorconfig` settings
3840
1. Runs `scripts/doc-comments.sh` to validate annotated documentation
3941

4042
```sh
4143
make style
4244
```
4345

44-
You can automatically fix stylua issues via:
46+
You can automatically fix `CodeCheck` issues via:
4547

4648
```sh
4749
make style-fix

Makefile

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ all: lint style check
55
#
66
lint: luacheck
77

8-
style: stylua style-doc
8+
style: style-check style-doc
99

1010
check: luals
1111

@@ -15,8 +15,9 @@ check: luals
1515
luacheck:
1616
luacheck -q lua
1717

18-
stylua:
19-
stylua lua --check
18+
# --diagnosis-as-error does not function for workspace, hence we post-process the output
19+
style-check:
20+
CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua
2021

2122
style-doc:
2223
scripts/doc-comments.sh
@@ -28,7 +29,7 @@ luals:
2829
# fixes
2930
#
3031
style-fix:
31-
stylua lua
32+
CodeFormat format --config .editorconfig --workspace lua
3233

3334
#
3435
# utility
@@ -43,5 +44,5 @@ help-check: help-update
4344
git diff --exit-code doc/nvim-tree-lua.txt
4445

4546

46-
.PHONY: all lint style check luacheck stylua style-doc luals style-fix help-update help-check
47+
.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check
4748

lua/nvim-tree.lua

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
local lib = require "nvim-tree.lib"
2-
local log = require "nvim-tree.log"
3-
local appearance = require "nvim-tree.appearance"
4-
local view = require "nvim-tree.view"
5-
local utils = require "nvim-tree.utils"
6-
local actions = require "nvim-tree.actions"
7-
local core = require "nvim-tree.core"
8-
local notify = require "nvim-tree.notify"
1+
local lib = require("nvim-tree.lib")
2+
local log = require("nvim-tree.log")
3+
local appearance = require("nvim-tree.appearance")
4+
local view = require("nvim-tree.view")
5+
local utils = require("nvim-tree.utils")
6+
local actions = require("nvim-tree.actions")
7+
local core = require("nvim-tree.core")
8+
local notify = require("nvim-tree.notify")
99

1010
local _config = {}
1111

@@ -21,7 +21,7 @@ function M.change_root(path, bufnr)
2121
if type(bufnr) == "number" then
2222
local ft
2323

24-
if vim.fn.has "nvim-0.10" == 1 then
24+
if vim.fn.has("nvim-0.10") == 1 then
2525
ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or ""
2626
else
2727
ft = vim.api.nvim_buf_get_option(bufnr, "filetype") or "" ---@diagnostic disable-line: deprecated
@@ -76,11 +76,11 @@ function M.change_root(path, bufnr)
7676
end
7777

7878
function M.tab_enter()
79-
if view.is_visible { any_tabpage = true } then
79+
if view.is_visible({ any_tabpage = true }) then
8080
local bufname = vim.api.nvim_buf_get_name(0)
8181

8282
local ft
83-
if vim.fn.has "nvim-0.10" == 1 then
83+
if vim.fn.has("nvim-0.10") == 1 then
8484
ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or ""
8585
else
8686
ft = vim.api.nvim_buf_get_option(0, "ft") ---@diagnostic disable-line: deprecated
@@ -91,7 +91,7 @@ function M.tab_enter()
9191
return
9292
end
9393
end
94-
view.open { focus_tree = false }
94+
view.open({ focus_tree = false })
9595

9696
local explorer = core.get_explorer()
9797
if explorer then
@@ -145,8 +145,8 @@ end
145145
---@param hijack_netrw boolean
146146
local function manage_netrw(disable_netrw, hijack_netrw)
147147
if hijack_netrw then
148-
vim.cmd "silent! autocmd! FileExplorer *"
149-
vim.cmd "autocmd VimEnter * ++once silent! autocmd! FileExplorer *"
148+
vim.cmd("silent! autocmd! FileExplorer *")
149+
vim.cmd("autocmd VimEnter * ++once silent! autocmd! FileExplorer *")
150150
end
151151
if disable_netrw then
152152
vim.g.loaded_netrw = 1
@@ -316,7 +316,7 @@ local function setup_autocommands(opts)
316316
callback = function()
317317
vim.schedule(function()
318318
vim.api.nvim_buf_call(0, function()
319-
vim.cmd [[norm! zz]]
319+
vim.cmd([[norm! zz]])
320320
end)
321321
end)
322322
end,
@@ -811,8 +811,8 @@ end
811811

812812
---@param conf table|nil
813813
function M.setup(conf)
814-
if vim.fn.has "nvim-0.9" == 0 then
815-
notify.warn "nvim-tree.lua requires Neovim 0.9 or higher"
814+
if vim.fn.has("nvim-0.9") == 0 then
815+
notify.warn("nvim-tree.lua requires Neovim 0.9 or higher")
816816
return
817817
end
818818

@@ -840,7 +840,7 @@ function M.setup(conf)
840840
require("nvim-tree.notify").setup(opts)
841841
require("nvim-tree.log").setup(opts)
842842

843-
if log.enabled "config" then
843+
if log.enabled("config") then
844844
log.line("config", "default config + user")
845845
log.raw("config", "%s\n", vim.inspect(opts))
846846
end

lua/nvim-tree/actions/finders/find-file.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
local log = require "nvim-tree.log"
2-
local view = require "nvim-tree.view"
3-
local utils = require "nvim-tree.utils"
4-
local core = require "nvim-tree.core"
5-
local Iterator = require "nvim-tree.iterators.node-iterator"
1+
local log = require("nvim-tree.log")
2+
local view = require("nvim-tree.view")
3+
local utils = require("nvim-tree.utils")
4+
local core = require("nvim-tree.core")
5+
local Iterator = require("nvim-tree.iterators.node-iterator")
66

77
local M = {}
88

@@ -76,7 +76,7 @@ function M.fn(path)
7676

7777
if found and view.is_visible() then
7878
explorer.renderer:draw()
79-
view.set_cursor { line, 0 }
79+
view.set_cursor({ line, 0 })
8080
end
8181

8282
running[path_real] = false
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local M = {}
22

3-
M.find_file = require "nvim-tree.actions.finders.find-file"
4-
M.search_node = require "nvim-tree.actions.finders.search-node"
3+
M.find_file = require("nvim-tree.actions.finders.find-file")
4+
M.search_node = require("nvim-tree.actions.finders.search-node")
55

66
return M

lua/nvim-tree/actions/finders/search-node.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local core = require "nvim-tree.core"
1+
local core = require("nvim-tree.core")
22
local find_file = require("nvim-tree.actions.finders.find-file").fn
33

44
local M = {}
@@ -75,7 +75,7 @@ function M.fn()
7575
local bufnr = vim.api.nvim_get_current_buf()
7676

7777
local path_existed, path_opt
78-
if vim.fn.has "nvim-0.10" == 1 then
78+
if vim.fn.has("nvim-0.10") == 1 then
7979
path_existed, path_opt = pcall(vim.api.nvim_get_option_value, "path", { buf = bufnr })
8080
vim.api.nvim_set_option_value("path", core.get_cwd() .. "/**", { buf = bufnr })
8181
else
@@ -89,13 +89,13 @@ function M.fn()
8989
end
9090
-- reset &path
9191
if path_existed then
92-
if vim.fn.has "nvim-0.10" == 1 then
92+
if vim.fn.has("nvim-0.10") == 1 then
9393
vim.api.nvim_set_option_value("path", path_opt, { buf = bufnr })
9494
else
9595
vim.api.nvim_buf_set_option(bufnr, "path", path_opt) ---@diagnostic disable-line: deprecated
9696
end
9797
else
98-
if vim.fn.has "nvim-0.10" == 1 then
98+
if vim.fn.has("nvim-0.10") == 1 then
9999
vim.api.nvim_set_option_value("path", nil, { buf = bufnr })
100100
else
101101
vim.api.nvim_buf_set_option(bufnr, "path", nil) ---@diagnostic disable-line: deprecated

lua/nvim-tree/actions/fs/clipboard.lua

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
local lib = require "nvim-tree.lib"
2-
local log = require "nvim-tree.log"
3-
local utils = require "nvim-tree.utils"
4-
local core = require "nvim-tree.core"
5-
local events = require "nvim-tree.events"
6-
local notify = require "nvim-tree.notify"
1+
local lib = require("nvim-tree.lib")
2+
local log = require("nvim-tree.log")
3+
local utils = require("nvim-tree.utils")
4+
local core = require("nvim-tree.core")
5+
local events = require("nvim-tree.events")
6+
local notify = require("nvim-tree.notify")
77

88
local find_file = require("nvim-tree.actions.finders.find-file").fn
99

@@ -89,8 +89,8 @@ local function do_copy(source, destination)
8989
break
9090
end
9191

92-
local new_name = utils.path_join { source, name }
93-
local new_destination = utils.path_join { destination, name }
92+
local new_name = utils.path_join({ source, name })
93+
local new_destination = utils.path_join({ destination, name })
9494
success, errmsg = do_copy(new_name, new_destination)
9595
if not success then
9696
return false, errmsg
@@ -191,7 +191,7 @@ end
191191
function Clipboard:clear_clipboard()
192192
self.data[ACTION.copy] = {}
193193
self.data[ACTION.cut] = {}
194-
notify.info "Clipboard has been emptied."
194+
notify.info("Clipboard has been emptied.")
195195
self.explorer.renderer:draw()
196196
end
197197

@@ -240,7 +240,7 @@ function Clipboard:do_paste(node, action, action_fn)
240240
end
241241

242242
for _, _node in ipairs(clip) do
243-
local dest = utils.path_join { destination, _node.name }
243+
local dest = utils.path_join({ destination, _node.name })
244244
do_single_paste(_node.absolute_path, dest, action, action_fn)
245245
end
246246

@@ -361,7 +361,7 @@ function Clipboard:copy_path(node)
361361

362362
if node.name == ".." then
363363
-- root
364-
content = utils.path_add_trailing ""
364+
content = utils.path_add_trailing("")
365365
else
366366
-- node
367367
local absolute_path = node.absolute_path

lua/nvim-tree/actions/fs/create-file.lua

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
local utils = require "nvim-tree.utils"
2-
local events = require "nvim-tree.events"
3-
local lib = require "nvim-tree.lib"
4-
local core = require "nvim-tree.core"
5-
local notify = require "nvim-tree.notify"
1+
local utils = require("nvim-tree.utils")
2+
local events = require("nvim-tree.events")
3+
local lib = require("nvim-tree.lib")
4+
local core = require("nvim-tree.core")
5+
local notify = require("nvim-tree.notify")
66

77
local find_file = require("nvim-tree.actions.finders.find-file").fn
88

@@ -72,7 +72,7 @@ function M.fn(node)
7272
end
7373

7474
if utils.file_exists(new_file_path) then
75-
notify.warn "Cannot create: file already exists"
75+
notify.warn("Cannot create: file already exists")
7676
return
7777
end
7878

@@ -87,10 +87,10 @@ function M.fn(node)
8787
for path in utils.path_split(new_file_path) do
8888
idx = idx + 1
8989
local p = utils.path_remove_trailing(path)
90-
if #path_to_create == 0 and vim.fn.has "win32" == 1 then
91-
path_to_create = utils.path_join { p, path_to_create }
90+
if #path_to_create == 0 and vim.fn.has("win32") == 1 then
91+
path_to_create = utils.path_join({ p, path_to_create })
9292
else
93-
path_to_create = utils.path_join { path_to_create, p }
93+
path_to_create = utils.path_join({ path_to_create, p })
9494
end
9595
if is_last_path_file and idx == num_nodes then
9696
create_and_notify(path_to_create)

lua/nvim-tree/actions/fs/init.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
local M = {}
22

3-
M.create_file = require "nvim-tree.actions.fs.create-file"
4-
M.remove_file = require "nvim-tree.actions.fs.remove-file"
5-
M.rename_file = require "nvim-tree.actions.fs.rename-file"
6-
M.trash = require "nvim-tree.actions.fs.trash"
3+
M.create_file = require("nvim-tree.actions.fs.create-file")
4+
M.remove_file = require("nvim-tree.actions.fs.remove-file")
5+
M.rename_file = require("nvim-tree.actions.fs.rename-file")
6+
M.trash = require("nvim-tree.actions.fs.trash")
77

88
function M.setup(opts)
99
M.remove_file.setup(opts)

0 commit comments

Comments
 (0)