From f6a6226e63301e753e643bf98e88e8be063a04ef Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 28 Sep 2024 15:30:30 +1000 Subject: [PATCH 01/10] stylua -> EmmyLuaCodeStyle: config and doc --- .editorconfig | 12 ++++++++++-- .stylua.toml | 6 ------ CONTRIBUTING.md | 6 +++--- Makefile | 10 +++++----- 4 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 .stylua.toml diff --git a/.editorconfig b/.editorconfig index e4a883f6966..1e574fe7ff2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,9 +4,17 @@ root = true insert_final_newline = true end_of_line = lf +[nvim-tree-lua.txt] +max_line_length = 78 + [*.lua] indent_style = space +max_line_length = 140 indent_size = 2 -[nvim-tree-lua.txt] -max_line_length = 78 +# EmmyLuaCodeStyle specific, see +# https://github.com/CppCXY/EmmyLuaCodeStyle/blob/master/lua.template.editorconfig +continuation_indent = 2 +quote_style = double +call_arg_parentheses = always +space_before_closure_open_parenthesis = false diff --git a/.stylua.toml b/.stylua.toml deleted file mode 100644 index ee66248283f..00000000000 --- a/.stylua.toml +++ /dev/null @@ -1,6 +0,0 @@ -column_width = 140 -line_endings = "Unix" -indent_type = "Spaces" -indent_width = 2 -quote_style = "AutoPreferDouble" -call_parentheses = "None" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90c0ecb4b04..9e95aff7be1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Following are used during CI and strongly recommended during local development. Lint: [luacheck](https://github.com/lunarmodules/luacheck/) -Style: [StyLua](https://github.com/JohnnyMorganz/StyLua) +Style: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle) (`CodeCheck`) Language server: [luals](https://luals.github.io) @@ -34,14 +34,14 @@ make lint ## style -1. Runs stylua using `.stylua.toml` settings +1. Runs CodeCheck using `.editorconfig` settings 1. Runs `scripts/doc-comments.sh` to validate annotated documentation ```sh make style ``` -You can automatically fix stylua issues via: +You can automatically fix `CodeCheck` issues via: ```sh make style-fix diff --git a/Makefile b/Makefile index 52b77b9a971..fa7a0395cae 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: lint style check # lint: luacheck -style: stylua style-doc +style: style-check style-doc check: luals @@ -15,8 +15,8 @@ check: luals luacheck: luacheck -q lua -stylua: - stylua lua --check +style-check: + CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua style-doc: scripts/doc-comments.sh @@ -28,7 +28,7 @@ luals: # fixes # style-fix: - stylua lua + CodeFormat format --config .editorconfig --workspace lua # # utility @@ -43,5 +43,5 @@ help-check: help-update git diff --exit-code doc/nvim-tree-lua.txt -.PHONY: all lint style check luacheck stylua style-doc luals style-fix help-update help-check +.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check From ee56c052088ce1fde6822816285cfd9f4b8c137d Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 28 Sep 2024 15:45:19 +1000 Subject: [PATCH 02/10] stylua -> EmmyLuaCodeStyle: CI --- .github/workflows/ci.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7065496874a..746a5a47af1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,22 +38,24 @@ jobs: runs-on: ubuntu-latest concurrency: - group: ${{ github.workflow }}-${{ matrix.stylua_version }}-${{ github.head_ref || github.ref_name }} + group: ${{ github.workflow }}-${{ matrix.emmy_lua_code_style_version }}-${{ github.head_ref || github.ref_name }} cancel-in-progress: true strategy: matrix: - stylua_version: [ 0.19.1 ] + emmy_lua_code_style_version: [ 1.5.4 ] steps: - uses: actions/checkout@v4 - - name: stylua - uses: JohnnyMorganz/stylua-action@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: ${{ matrix.stylua_version }} - args: --check lua + - name: install emmy_lua_code_style + run: | + mkdir -p CodeFormat + curl -L "https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/${{ matrix.emmy_lua_code_style_version }}/linux-x64.tar.gz" | tar zx --directory CodeFormat + + - run: echo "CodeFormat/linux-64/bin" >> "$GITHUB_PATH" + + - run: make style - run: make style-doc From 628387d079ab3cd5a3f2ae56bd4e2ff3323bd854 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 28 Sep 2024 15:48:59 +1000 Subject: [PATCH 03/10] stylua -> EmmyLuaCodeStyle: CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 746a5a47af1..e767b2bd79d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: mkdir -p CodeFormat curl -L "https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/${{ matrix.emmy_lua_code_style_version }}/linux-x64.tar.gz" | tar zx --directory CodeFormat - - run: echo "CodeFormat/linux-64/bin" >> "$GITHUB_PATH" + - run: echo "CodeFormat/linux-x64/bin" >> "$GITHUB_PATH" - run: make style From 91c14d52ceb57a0c85dd038717eb6e9c31a876d5 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 28 Sep 2024 16:24:16 +1000 Subject: [PATCH 04/10] stylua -> EmmyLuaCodeStyle: CI --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fa7a0395cae..768bbe82f9a 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,9 @@ check: luals luacheck: luacheck -q lua +# --diagnosis-as-error does not function for workspace, hence we post-process the output style-check: - CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua + CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua 2>&1 | tee /tmp/CodeFormat.out ; ! grep -qE "warning|error" /tmp/CodeFormat.out style-doc: scripts/doc-comments.sh From 3d89c52dc6bbfb167113e905e3c1b2472763aed1 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 28 Sep 2024 16:43:19 +1000 Subject: [PATCH 05/10] stylua -> EmmyLuaCodeStyle: CI --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 768bbe82f9a..8df41f7c588 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ luacheck: # --diagnosis-as-error does not function for workspace, hence we post-process the output style-check: - CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua 2>&1 | tee /tmp/CodeFormat.out ; ! grep -qE "warning|error" /tmp/CodeFormat.out + CodeFormat check --config .editorconfig --diagnosis-as-error --workspace lua style-doc: scripts/doc-comments.sh From 51fd004e4c325751a5117a9d6b47b90cd9b63376 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Sep 2024 09:23:49 +1000 Subject: [PATCH 06/10] stylua -> EmmyLuaCodeStyle: CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e767b2bd79d..f1cc8a1a815 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: strategy: matrix: - emmy_lua_code_style_version: [ 1.5.4 ] + emmy_lua_code_style_version: [ 1.5.5 ] steps: - uses: actions/checkout@v4 From b9c2c095fea8826c77dab39000a35d1ee0fa66e1 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Sep 2024 13:28:51 +1000 Subject: [PATCH 07/10] stylua -> EmmyLuaCodeStyle --- lua/nvim-tree/actions/moves/item.lua | 4 +- lua/nvim-tree/appearance/init.lua | 156 +++++++++++++-------------- lua/nvim-tree/buffers.lua | 4 +- lua/nvim-tree/git/init.lua | 8 +- lua/nvim-tree/help.lua | 2 +- lua/nvim-tree/keymap.lua | 46 ++++---- lua/nvim-tree/notify.lua | 4 +- lua/nvim-tree/renderer/builder.lua | 2 +- 8 files changed, 112 insertions(+), 114 deletions(-) diff --git a/lua/nvim-tree/actions/moves/item.lua b/lua/nvim-tree/actions/moves/item.lua index 9714b3b5001..4bb5e0fa485 100644 --- a/lua/nvim-tree/actions/moves/item.lua +++ b/lua/nvim-tree/actions/moves/item.lua @@ -175,7 +175,7 @@ local function move_prev_recursive(what, skip_gitignored) if node_cur == nil or node_cur == node_init -- we didn't move - or not node_cur.nodes -- node is a file + or not node_cur.nodes -- node is a file then return end @@ -186,7 +186,7 @@ local function move_prev_recursive(what, skip_gitignored) -- 4.3) if node_init.name == ".." then -- root node - view.set_cursor { 1, 0 } -- move to root node (position 1) + view.set_cursor { 1, 0 } -- move to root node (position 1) else local node_init_line = utils.find_node_line(node_init) if node_init_line < 0 then diff --git a/lua/nvim-tree/appearance/init.lua b/lua/nvim-tree/appearance/init.lua index 9a8c67efe67..61714af644e 100644 --- a/lua/nvim-tree/appearance/init.lua +++ b/lua/nvim-tree/appearance/init.lua @@ -12,126 +12,126 @@ local M = {} M.HIGHLIGHT_GROUPS = { -- Standard - { group = "NvimTreeNormal", link = "Normal" }, - { group = "NvimTreeNormalFloat", link = "NormalFloat" }, - { group = "NvimTreeNormalFloatBorder", link = "FloatBorder" }, - { group = "NvimTreeNormalNC", link = "NvimTreeNormal" }, + { group = "NvimTreeNormal", link = "Normal" }, + { group = "NvimTreeNormalFloat", link = "NormalFloat" }, + { group = "NvimTreeNormalFloatBorder", link = "FloatBorder" }, + { group = "NvimTreeNormalNC", link = "NvimTreeNormal" }, - { group = "NvimTreeLineNr", link = "LineNr" }, - { group = "NvimTreeWinSeparator", link = "WinSeparator" }, - { group = "NvimTreeEndOfBuffer", link = "EndOfBuffer" }, - { group = "NvimTreePopup", link = "Normal" }, - { group = "NvimTreeSignColumn", link = "NvimTreeNormal" }, + { group = "NvimTreeLineNr", link = "LineNr" }, + { group = "NvimTreeWinSeparator", link = "WinSeparator" }, + { group = "NvimTreeEndOfBuffer", link = "EndOfBuffer" }, + { group = "NvimTreePopup", link = "Normal" }, + { group = "NvimTreeSignColumn", link = "NvimTreeNormal" }, - { group = "NvimTreeCursorColumn", link = "CursorColumn" }, - { group = "NvimTreeCursorLine", link = "CursorLine" }, - { group = "NvimTreeCursorLineNr", link = "CursorLineNr" }, + { group = "NvimTreeCursorColumn", link = "CursorColumn" }, + { group = "NvimTreeCursorLine", link = "CursorLine" }, + { group = "NvimTreeCursorLineNr", link = "CursorLineNr" }, - { group = "NvimTreeStatusLine", link = "StatusLine" }, - { group = "NvimTreeStatusLineNC", link = "StatusLineNC" }, + { group = "NvimTreeStatusLine", link = "StatusLine" }, + { group = "NvimTreeStatusLineNC", link = "StatusLineNC" }, -- File Text - { group = "NvimTreeExecFile", link = "Question" }, - { group = "NvimTreeImageFile", link = "Question" }, - { group = "NvimTreeSpecialFile", link = "Title" }, - { group = "NvimTreeSymlink", link = "Underlined" }, + { group = "NvimTreeExecFile", link = "Question" }, + { group = "NvimTreeImageFile", link = "Question" }, + { group = "NvimTreeSpecialFile", link = "Title" }, + { group = "NvimTreeSymlink", link = "Underlined" }, -- Folder Text - { group = "NvimTreeRootFolder", link = "Title" }, - { group = "NvimTreeFolderName", link = "Directory" }, - { group = "NvimTreeEmptyFolderName", link = "Directory" }, - { group = "NvimTreeOpenedFolderName", link = "Directory" }, - { group = "NvimTreeSymlinkFolderName", link = "Directory" }, + { group = "NvimTreeRootFolder", link = "Title" }, + { group = "NvimTreeFolderName", link = "Directory" }, + { group = "NvimTreeEmptyFolderName", link = "Directory" }, + { group = "NvimTreeOpenedFolderName", link = "Directory" }, + { group = "NvimTreeSymlinkFolderName", link = "Directory" }, -- File Icons - { group = "NvimTreeFileIcon", link = "NvimTreeNormal" }, - { group = "NvimTreeSymlinkIcon", link = "NvimTreeNormal" }, + { group = "NvimTreeFileIcon", link = "NvimTreeNormal" }, + { group = "NvimTreeSymlinkIcon", link = "NvimTreeNormal" }, -- Folder Icons - { group = "NvimTreeFolderIcon", def = "guifg=#8094b4 ctermfg=Blue" }, - { group = "NvimTreeOpenedFolderIcon", link = "NvimTreeFolderIcon" }, - { group = "NvimTreeClosedFolderIcon", link = "NvimTreeFolderIcon" }, - { group = "NvimTreeFolderArrowClosed", link = "NvimTreeIndentMarker" }, - { group = "NvimTreeFolderArrowOpen", link = "NvimTreeIndentMarker" }, + { group = "NvimTreeFolderIcon", def = "guifg=#8094b4 ctermfg=Blue" }, + { group = "NvimTreeOpenedFolderIcon", link = "NvimTreeFolderIcon" }, + { group = "NvimTreeClosedFolderIcon", link = "NvimTreeFolderIcon" }, + { group = "NvimTreeFolderArrowClosed", link = "NvimTreeIndentMarker" }, + { group = "NvimTreeFolderArrowOpen", link = "NvimTreeIndentMarker" }, -- Indent - { group = "NvimTreeIndentMarker", link = "NvimTreeFolderIcon" }, + { group = "NvimTreeIndentMarker", link = "NvimTreeFolderIcon" }, -- Picker - { group = "NvimTreeWindowPicker", def = "guifg=#ededed guibg=#4493c8 gui=bold ctermfg=White ctermbg=DarkBlue" }, + { group = "NvimTreeWindowPicker", def = "guifg=#ededed guibg=#4493c8 gui=bold ctermfg=White ctermbg=DarkBlue" }, -- LiveFilter - { group = "NvimTreeLiveFilterPrefix", link = "PreProc" }, - { group = "NvimTreeLiveFilterValue", link = "ModeMsg" }, + { group = "NvimTreeLiveFilterPrefix", link = "PreProc" }, + { group = "NvimTreeLiveFilterValue", link = "ModeMsg" }, -- Clipboard - { group = "NvimTreeCutHL", link = "SpellBad" }, - { group = "NvimTreeCopiedHL", link = "SpellRare" }, + { group = "NvimTreeCutHL", link = "SpellBad" }, + { group = "NvimTreeCopiedHL", link = "SpellRare" }, -- Bookmark - { group = "NvimTreeBookmarkIcon", link = "NvimTreeFolderIcon" }, - { group = "NvimTreeBookmarkHL", link = "SpellLocal" }, + { group = "NvimTreeBookmarkIcon", link = "NvimTreeFolderIcon" }, + { group = "NvimTreeBookmarkHL", link = "SpellLocal" }, -- Modified - { group = "NvimTreeModifiedIcon", link = "Type" }, - { group = "NvimTreeModifiedFileHL", link = "NvimTreeModifiedIcon" }, - { group = "NvimTreeModifiedFolderHL", link = "NvimTreeModifiedFileHL" }, + { group = "NvimTreeModifiedIcon", link = "Type" }, + { group = "NvimTreeModifiedFileHL", link = "NvimTreeModifiedIcon" }, + { group = "NvimTreeModifiedFolderHL", link = "NvimTreeModifiedFileHL" }, -- Hidden - { group = "NvimTreeHiddenIcon", link = "Conceal" }, - { group = "NvimTreeHiddenFileHL", link = "NvimTreeHiddenIcon" }, - { group = "NvimTreeHiddenFolderHL", link = "NvimTreeHiddenFileHL" }, + { group = "NvimTreeHiddenIcon", link = "Conceal" }, + { group = "NvimTreeHiddenFileHL", link = "NvimTreeHiddenIcon" }, + { group = "NvimTreeHiddenFolderHL", link = "NvimTreeHiddenFileHL" }, -- Hidden Display - { group = "NvimTreeHiddenDisplay", link = "Conceal" }, + { group = "NvimTreeHiddenDisplay", link = "Conceal" }, -- Opened - { group = "NvimTreeOpenedHL", link = "Special" }, + { group = "NvimTreeOpenedHL", link = "Special" }, -- Git Icon - { group = "NvimTreeGitDeletedIcon", link = "Statement" }, - { group = "NvimTreeGitDirtyIcon", link = "Statement" }, - { group = "NvimTreeGitIgnoredIcon", link = "Comment" }, - { group = "NvimTreeGitMergeIcon", link = "Constant" }, - { group = "NvimTreeGitNewIcon", link = "PreProc" }, - { group = "NvimTreeGitRenamedIcon", link = "PreProc" }, - { group = "NvimTreeGitStagedIcon", link = "Constant" }, + { group = "NvimTreeGitDeletedIcon", link = "Statement" }, + { group = "NvimTreeGitDirtyIcon", link = "Statement" }, + { group = "NvimTreeGitIgnoredIcon", link = "Comment" }, + { group = "NvimTreeGitMergeIcon", link = "Constant" }, + { group = "NvimTreeGitNewIcon", link = "PreProc" }, + { group = "NvimTreeGitRenamedIcon", link = "PreProc" }, + { group = "NvimTreeGitStagedIcon", link = "Constant" }, -- Git File Highlight - { group = "NvimTreeGitFileDeletedHL", link = "NvimTreeGitDeletedIcon" }, - { group = "NvimTreeGitFileDirtyHL", link = "NvimTreeGitDirtyIcon" }, - { group = "NvimTreeGitFileIgnoredHL", link = "NvimTreeGitIgnoredIcon" }, - { group = "NvimTreeGitFileMergeHL", link = "NvimTreeGitMergeIcon" }, - { group = "NvimTreeGitFileNewHL", link = "NvimTreeGitNewIcon" }, - { group = "NvimTreeGitFileRenamedHL", link = "NvimTreeGitRenamedIcon" }, - { group = "NvimTreeGitFileStagedHL", link = "NvimTreeGitStagedIcon" }, + { group = "NvimTreeGitFileDeletedHL", link = "NvimTreeGitDeletedIcon" }, + { group = "NvimTreeGitFileDirtyHL", link = "NvimTreeGitDirtyIcon" }, + { group = "NvimTreeGitFileIgnoredHL", link = "NvimTreeGitIgnoredIcon" }, + { group = "NvimTreeGitFileMergeHL", link = "NvimTreeGitMergeIcon" }, + { group = "NvimTreeGitFileNewHL", link = "NvimTreeGitNewIcon" }, + { group = "NvimTreeGitFileRenamedHL", link = "NvimTreeGitRenamedIcon" }, + { group = "NvimTreeGitFileStagedHL", link = "NvimTreeGitStagedIcon" }, -- Git Folder Highlight - { group = "NvimTreeGitFolderDeletedHL", link = "NvimTreeGitFileDeletedHL" }, - { group = "NvimTreeGitFolderDirtyHL", link = "NvimTreeGitFileDirtyHL" }, - { group = "NvimTreeGitFolderIgnoredHL", link = "NvimTreeGitFileIgnoredHL" }, - { group = "NvimTreeGitFolderMergeHL", link = "NvimTreeGitFileMergeHL" }, - { group = "NvimTreeGitFolderNewHL", link = "NvimTreeGitFileNewHL" }, - { group = "NvimTreeGitFolderRenamedHL", link = "NvimTreeGitFileRenamedHL" }, - { group = "NvimTreeGitFolderStagedHL", link = "NvimTreeGitFileStagedHL" }, + { group = "NvimTreeGitFolderDeletedHL", link = "NvimTreeGitFileDeletedHL" }, + { group = "NvimTreeGitFolderDirtyHL", link = "NvimTreeGitFileDirtyHL" }, + { group = "NvimTreeGitFolderIgnoredHL", link = "NvimTreeGitFileIgnoredHL" }, + { group = "NvimTreeGitFolderMergeHL", link = "NvimTreeGitFileMergeHL" }, + { group = "NvimTreeGitFolderNewHL", link = "NvimTreeGitFileNewHL" }, + { group = "NvimTreeGitFolderRenamedHL", link = "NvimTreeGitFileRenamedHL" }, + { group = "NvimTreeGitFolderStagedHL", link = "NvimTreeGitFileStagedHL" }, -- Diagnostics Icon - { group = "NvimTreeDiagnosticErrorIcon", link = "DiagnosticError" }, - { group = "NvimTreeDiagnosticWarnIcon", link = "DiagnosticWarn" }, - { group = "NvimTreeDiagnosticInfoIcon", link = "DiagnosticInfo" }, - { group = "NvimTreeDiagnosticHintIcon", link = "DiagnosticHint" }, + { group = "NvimTreeDiagnosticErrorIcon", link = "DiagnosticError" }, + { group = "NvimTreeDiagnosticWarnIcon", link = "DiagnosticWarn" }, + { group = "NvimTreeDiagnosticInfoIcon", link = "DiagnosticInfo" }, + { group = "NvimTreeDiagnosticHintIcon", link = "DiagnosticHint" }, -- Diagnostics File Highlight - { group = "NvimTreeDiagnosticErrorFileHL", link = "DiagnosticUnderlineError" }, - { group = "NvimTreeDiagnosticWarnFileHL", link = "DiagnosticUnderlineWarn" }, - { group = "NvimTreeDiagnosticInfoFileHL", link = "DiagnosticUnderlineInfo" }, - { group = "NvimTreeDiagnosticHintFileHL", link = "DiagnosticUnderlineHint" }, + { group = "NvimTreeDiagnosticErrorFileHL", link = "DiagnosticUnderlineError" }, + { group = "NvimTreeDiagnosticWarnFileHL", link = "DiagnosticUnderlineWarn" }, + { group = "NvimTreeDiagnosticInfoFileHL", link = "DiagnosticUnderlineInfo" }, + { group = "NvimTreeDiagnosticHintFileHL", link = "DiagnosticUnderlineHint" }, -- Diagnostics Folder Highlight { group = "NvimTreeDiagnosticErrorFolderHL", link = "NvimTreeDiagnosticErrorFileHL" }, - { group = "NvimTreeDiagnosticWarnFolderHL", link = "NvimTreeDiagnosticWarnFileHL" }, - { group = "NvimTreeDiagnosticInfoFolderHL", link = "NvimTreeDiagnosticInfoFileHL" }, - { group = "NvimTreeDiagnosticHintFolderHL", link = "NvimTreeDiagnosticHintFileHL" }, + { group = "NvimTreeDiagnosticWarnFolderHL", link = "NvimTreeDiagnosticWarnFileHL" }, + { group = "NvimTreeDiagnosticInfoFolderHL", link = "NvimTreeDiagnosticInfoFileHL" }, + { group = "NvimTreeDiagnosticHintFolderHL", link = "NvimTreeDiagnosticHintFileHL" }, } -- nvim-tree highlight groups to legacy diff --git a/lua/nvim-tree/buffers.lua b/lua/nvim-tree/buffers.lua index 7327428350a..bf7ac7b0b80 100644 --- a/lua/nvim-tree/buffers.lua +++ b/lua/nvim-tree/buffers.lua @@ -11,11 +11,9 @@ function M.reload_modified() local path = buf.name if path ~= "" then -- not a [No Name] buffer -- mark all the parent as modified as well - while - M._modified[path] ~= true + while M._modified[path] ~= true do -- no need to keep going if already recorded -- This also prevents an infinite loop - do M._modified[path] = true path = vim.fn.fnamemodify(path, ":h") end diff --git a/lua/nvim-tree/git/init.lua b/lua/nvim-tree/git/init.lua index 4889c12766f..f3a011c8bdd 100644 --- a/lua/nvim-tree/git/init.lua +++ b/lua/nvim-tree/git/init.lua @@ -23,10 +23,10 @@ local M = { -- Utilities (like watchman) can also write to this directory (often) and aren't useful for us. local WATCHED_FILES = { "FETCH_HEAD", -- remote ref - "HEAD", -- local ref - "HEAD.lock", -- HEAD will not always be updated e.g. revert - "config", -- user config - "index", -- staging area + "HEAD", -- local ref + "HEAD.lock", -- HEAD will not always be updated e.g. revert + "config", -- user config + "index", -- staging area } ---@param toplevel string|nil diff --git a/lua/nvim-tree/help.lua b/lua/nvim-tree/help.lua index 2bca25ce5e9..8d1d0e9eae0 100644 --- a/lua/nvim-tree/help.lua +++ b/lua/nvim-tree/help.lua @@ -130,7 +130,7 @@ local function compute(map) -- header highlight, assume one character keys local hl = { - { "NvimTreeFolderName", 0, 0, #head_lhs }, + { "NvimTreeFolderName", 0, 0, #head_lhs }, { "NvimTreeFolderName", 0, width - 1, width }, { "NvimTreeFolderName", 1, width - 1, width }, } diff --git a/lua/nvim-tree/keymap.lua b/lua/nvim-tree/keymap.lua index 1999c73d262..cad4fb0657f 100644 --- a/lua/nvim-tree/keymap.lua +++ b/lua/nvim-tree/keymap.lua @@ -19,21 +19,40 @@ local function generate_keymap(fn) return keymap end --- stylua: ignore start +---@return table +function M.get_keymap() + return generate_keymap(M.on_attach) +end + +---@return table +function M.get_keymap_default() + return generate_keymap(M.default_on_attach) +end + +function M.setup(opts) + if type(opts.on_attach) ~= "function" then + M.on_attach = M.default_on_attach + else + M.on_attach = opts.on_attach + end +end + ---@param bufnr integer function M.default_on_attach(bufnr) - local api = require('nvim-tree.api') + local api = require("nvim-tree.api") local function opts(desc) return { - desc = 'nvim-tree: ' .. desc, + desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true, - } + } end + -- formatting cannot be re-enabled, hence this is at the end + ---@format disable -- BEGIN_DEFAULT_ON_ATTACH vim.keymap.set('n', '', api.tree.change_root_to_node, opts('CD')) vim.keymap.set('n', '', api.node.open.replace_tree_buffer, opts('Open: In Place')) @@ -95,24 +114,5 @@ function M.default_on_attach(bufnr) vim.keymap.set('n', '<2-RightMouse>', api.tree.change_root_to_node, opts('CD')) -- END_DEFAULT_ON_ATTACH end --- stylua: ignore end - ----@return table -function M.get_keymap() - return generate_keymap(M.on_attach) -end - ----@return table -function M.get_keymap_default() - return generate_keymap(M.default_on_attach) -end - -function M.setup(opts) - if type(opts.on_attach) ~= "function" then - M.on_attach = M.default_on_attach - else - M.on_attach = opts.on_attach - end -end return M diff --git a/lua/nvim-tree/notify.lua b/lua/nvim-tree/notify.lua index 03f7d6dedef..0ad5a88396e 100644 --- a/lua/nvim-tree/notify.lua +++ b/lua/nvim-tree/notify.lua @@ -21,8 +21,8 @@ end local modes = { { name = "trace", level = vim.log.levels.TRACE }, { name = "debug", level = vim.log.levels.DEBUG }, - { name = "info", level = vim.log.levels.INFO }, - { name = "warn", level = vim.log.levels.WARN }, + { name = "info", level = vim.log.levels.INFO }, + { name = "warn", level = vim.log.levels.WARN }, { name = "error", level = vim.log.levels.ERROR }, } diff --git a/lua/nvim-tree/renderer/builder.lua b/lua/nvim-tree/renderer/builder.lua index 2cccec8d033..6ca86fffeb6 100644 --- a/lua/nvim-tree/renderer/builder.lua +++ b/lua/nvim-tree/renderer/builder.lua @@ -397,7 +397,7 @@ function Builder:add_hidden_count_string(node, idx, num_children) -- if we change the traversal, we might need to sort by depth before rendering `self.virtual_lines` -- to maintain proper ordering of parent and child folder hidden count info. table.insert(self.virtual_lines[line_nr], { - { indent_string, indent_markers.hl }, + { indent_string, indent_markers.hl }, { string.rep(indent_padding, (node.parent == nil and 0 or 1)) .. hidden_count_string, "NvimTreeHiddenDisplay" }, }) end From a6774c6f076376e171ed90b688d060451424fc60 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Sep 2024 13:34:22 +1000 Subject: [PATCH 08/10] stylua -> EmmyLuaCodeStyle: call_arg_parentheses = always --- lua/nvim-tree.lua | 36 +++---- lua/nvim-tree/actions/finders/find-file.lua | 12 +-- lua/nvim-tree/actions/finders/init.lua | 4 +- lua/nvim-tree/actions/finders/search-node.lua | 8 +- lua/nvim-tree/actions/fs/clipboard.lua | 22 ++--- lua/nvim-tree/actions/fs/create-file.lua | 18 ++-- lua/nvim-tree/actions/fs/init.lua | 8 +- lua/nvim-tree/actions/fs/remove-file.lua | 18 ++-- lua/nvim-tree/actions/fs/rename-file.lua | 16 ++-- lua/nvim-tree/actions/fs/trash.lua | 16 ++-- lua/nvim-tree/actions/init.lua | 12 +-- lua/nvim-tree/actions/moves/init.lua | 6 +- lua/nvim-tree/actions/moves/item.lua | 20 ++-- lua/nvim-tree/actions/moves/parent.lua | 12 +-- lua/nvim-tree/actions/moves/sibling.lua | 6 +- lua/nvim-tree/actions/node/file-popup.lua | 4 +- lua/nvim-tree/actions/node/init.lua | 8 +- lua/nvim-tree/actions/node/open-file.lua | 34 +++---- lua/nvim-tree/actions/node/run-command.lua | 4 +- lua/nvim-tree/actions/node/system-open.lua | 8 +- lua/nvim-tree/actions/root/change-dir.lua | 6 +- lua/nvim-tree/actions/root/dir-up.lua | 6 +- lua/nvim-tree/actions/root/init.lua | 4 +- lua/nvim-tree/actions/tree/find-file.lua | 12 +-- lua/nvim-tree/actions/tree/init.lua | 10 +- .../actions/tree/modifiers/collapse-all.lua | 8 +- .../actions/tree/modifiers/expand-all.lua | 8 +- lua/nvim-tree/actions/tree/modifiers/init.lua | 6 +- .../actions/tree/modifiers/toggles.lua | 6 +- lua/nvim-tree/actions/tree/open.lua | 10 +- lua/nvim-tree/actions/tree/resize.lua | 2 +- lua/nvim-tree/actions/tree/toggle.lua | 12 +-- lua/nvim-tree/api.lua | 94 +++++++++---------- lua/nvim-tree/appearance/diagnostics.lua | 4 +- lua/nvim-tree/buffers.lua | 2 +- lua/nvim-tree/commands.lua | 18 ++-- lua/nvim-tree/core.lua | 6 +- lua/nvim-tree/diagnostics.lua | 18 ++-- lua/nvim-tree/events.lua | 2 +- lua/nvim-tree/explorer/filters.lua | 6 +- lua/nvim-tree/explorer/init.lua | 42 ++++----- lua/nvim-tree/explorer/live-filter.lua | 16 ++-- lua/nvim-tree/explorer/node-builders.lua | 4 +- lua/nvim-tree/explorer/node.lua | 2 +- lua/nvim-tree/explorer/sorters.lua | 10 +- lua/nvim-tree/explorer/watch.lua | 4 +- lua/nvim-tree/git/init.lua | 18 ++-- lua/nvim-tree/git/runner.lua | 16 ++-- lua/nvim-tree/git/utils.lua | 18 ++-- lua/nvim-tree/help.lua | 10 +- lua/nvim-tree/legacy.lua | 13 +-- lua/nvim-tree/lib.lua | 18 ++-- lua/nvim-tree/log.lua | 10 +- lua/nvim-tree/marks/init.lua | 26 ++--- lua/nvim-tree/notify.lua | 6 +- lua/nvim-tree/renderer/builder.lua | 33 +++---- .../renderer/components/diagnostics.lua | 2 +- .../renderer/components/full-name.lua | 6 +- lua/nvim-tree/renderer/components/icons.lua | 2 +- lua/nvim-tree/renderer/components/init.lua | 8 +- lua/nvim-tree/renderer/components/padding.lua | 2 +- .../renderer/decorator/bookmarks.lua | 2 +- lua/nvim-tree/renderer/decorator/copied.lua | 2 +- lua/nvim-tree/renderer/decorator/cut.lua | 2 +- .../renderer/decorator/diagnostics.lua | 4 +- lua/nvim-tree/renderer/decorator/git.lua | 6 +- lua/nvim-tree/renderer/decorator/hidden.lua | 4 +- lua/nvim-tree/renderer/decorator/modified.lua | 4 +- lua/nvim-tree/renderer/decorator/opened.lua | 4 +- lua/nvim-tree/renderer/init.lua | 22 ++--- lua/nvim-tree/utils.lua | 28 +++--- lua/nvim-tree/view.lua | 34 +++---- lua/nvim-tree/watcher.lua | 8 +- 73 files changed, 450 insertions(+), 448 deletions(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 06f8ab74afc..4bca0dce450 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -1,11 +1,11 @@ -local lib = require "nvim-tree.lib" -local log = require "nvim-tree.log" -local appearance = require "nvim-tree.appearance" -local view = require "nvim-tree.view" -local utils = require "nvim-tree.utils" -local actions = require "nvim-tree.actions" -local core = require "nvim-tree.core" -local notify = require "nvim-tree.notify" +local lib = require("nvim-tree.lib") +local log = require("nvim-tree.log") +local appearance = require("nvim-tree.appearance") +local view = require("nvim-tree.view") +local utils = require("nvim-tree.utils") +local actions = require("nvim-tree.actions") +local core = require("nvim-tree.core") +local notify = require("nvim-tree.notify") local _config = {} @@ -21,7 +21,7 @@ function M.change_root(path, bufnr) if type(bufnr) == "number" then local ft - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) or "" else ft = vim.api.nvim_buf_get_option(bufnr, "filetype") or "" ---@diagnostic disable-line: deprecated @@ -76,11 +76,11 @@ function M.change_root(path, bufnr) end function M.tab_enter() - if view.is_visible { any_tabpage = true } then + if view.is_visible({ any_tabpage = true }) then local bufname = vim.api.nvim_buf_get_name(0) local ft - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) or "" else ft = vim.api.nvim_buf_get_option(0, "ft") ---@diagnostic disable-line: deprecated @@ -91,7 +91,7 @@ function M.tab_enter() return end end - view.open { focus_tree = false } + view.open({ focus_tree = false }) local explorer = core.get_explorer() if explorer then @@ -145,8 +145,8 @@ end ---@param hijack_netrw boolean local function manage_netrw(disable_netrw, hijack_netrw) if hijack_netrw then - vim.cmd "silent! autocmd! FileExplorer *" - vim.cmd "autocmd VimEnter * ++once silent! autocmd! FileExplorer *" + vim.cmd("silent! autocmd! FileExplorer *") + vim.cmd("autocmd VimEnter * ++once silent! autocmd! FileExplorer *") end if disable_netrw then vim.g.loaded_netrw = 1 @@ -316,7 +316,7 @@ local function setup_autocommands(opts) callback = function() vim.schedule(function() vim.api.nvim_buf_call(0, function() - vim.cmd [[norm! zz]] + vim.cmd([[norm! zz]]) end) end) end, @@ -811,8 +811,8 @@ end ---@param conf table|nil function M.setup(conf) - if vim.fn.has "nvim-0.9" == 0 then - notify.warn "nvim-tree.lua requires Neovim 0.9 or higher" + if vim.fn.has("nvim-0.9") == 0 then + notify.warn("nvim-tree.lua requires Neovim 0.9 or higher") return end @@ -840,7 +840,7 @@ function M.setup(conf) require("nvim-tree.notify").setup(opts) require("nvim-tree.log").setup(opts) - if log.enabled "config" then + if log.enabled("config") then log.line("config", "default config + user") log.raw("config", "%s\n", vim.inspect(opts)) end diff --git a/lua/nvim-tree/actions/finders/find-file.lua b/lua/nvim-tree/actions/finders/find-file.lua index 7798de4b05b..174ffbdbd81 100644 --- a/lua/nvim-tree/actions/finders/find-file.lua +++ b/lua/nvim-tree/actions/finders/find-file.lua @@ -1,8 +1,8 @@ -local log = require "nvim-tree.log" -local view = require "nvim-tree.view" -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" -local Iterator = require "nvim-tree.iterators.node-iterator" +local log = require("nvim-tree.log") +local view = require("nvim-tree.view") +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") +local Iterator = require("nvim-tree.iterators.node-iterator") local M = {} @@ -76,7 +76,7 @@ function M.fn(path) if found and view.is_visible() then explorer.renderer:draw() - view.set_cursor { line, 0 } + view.set_cursor({ line, 0 }) end running[path_real] = false diff --git a/lua/nvim-tree/actions/finders/init.lua b/lua/nvim-tree/actions/finders/init.lua index efa9dc47dad..55ae5a9d156 100644 --- a/lua/nvim-tree/actions/finders/init.lua +++ b/lua/nvim-tree/actions/finders/init.lua @@ -1,6 +1,6 @@ local M = {} -M.find_file = require "nvim-tree.actions.finders.find-file" -M.search_node = require "nvim-tree.actions.finders.search-node" +M.find_file = require("nvim-tree.actions.finders.find-file") +M.search_node = require("nvim-tree.actions.finders.search-node") return M diff --git a/lua/nvim-tree/actions/finders/search-node.lua b/lua/nvim-tree/actions/finders/search-node.lua index 49678002b5c..3ad65c377d5 100644 --- a/lua/nvim-tree/actions/finders/search-node.lua +++ b/lua/nvim-tree/actions/finders/search-node.lua @@ -1,4 +1,4 @@ -local core = require "nvim-tree.core" +local core = require("nvim-tree.core") local find_file = require("nvim-tree.actions.finders.find-file").fn local M = {} @@ -75,7 +75,7 @@ function M.fn() local bufnr = vim.api.nvim_get_current_buf() local path_existed, path_opt - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then path_existed, path_opt = pcall(vim.api.nvim_get_option_value, "path", { buf = bufnr }) vim.api.nvim_set_option_value("path", core.get_cwd() .. "/**", { buf = bufnr }) else @@ -89,13 +89,13 @@ function M.fn() end -- reset &path if path_existed then - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value("path", path_opt, { buf = bufnr }) else vim.api.nvim_buf_set_option(bufnr, "path", path_opt) ---@diagnostic disable-line: deprecated end else - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value("path", nil, { buf = bufnr }) else vim.api.nvim_buf_set_option(bufnr, "path", nil) ---@diagnostic disable-line: deprecated diff --git a/lua/nvim-tree/actions/fs/clipboard.lua b/lua/nvim-tree/actions/fs/clipboard.lua index 0127249f3f9..c6808eb550c 100644 --- a/lua/nvim-tree/actions/fs/clipboard.lua +++ b/lua/nvim-tree/actions/fs/clipboard.lua @@ -1,9 +1,9 @@ -local lib = require "nvim-tree.lib" -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" -local events = require "nvim-tree.events" -local notify = require "nvim-tree.notify" +local lib = require("nvim-tree.lib") +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") +local events = require("nvim-tree.events") +local notify = require("nvim-tree.notify") local find_file = require("nvim-tree.actions.finders.find-file").fn @@ -89,8 +89,8 @@ local function do_copy(source, destination) break end - local new_name = utils.path_join { source, name } - local new_destination = utils.path_join { destination, name } + local new_name = utils.path_join({ source, name }) + local new_destination = utils.path_join({ destination, name }) success, errmsg = do_copy(new_name, new_destination) if not success then return false, errmsg @@ -191,7 +191,7 @@ end function Clipboard:clear_clipboard() self.data[ACTION.copy] = {} self.data[ACTION.cut] = {} - notify.info "Clipboard has been emptied." + notify.info("Clipboard has been emptied.") self.explorer.renderer:draw() end @@ -240,7 +240,7 @@ function Clipboard:do_paste(node, action, action_fn) end for _, _node in ipairs(clip) do - local dest = utils.path_join { destination, _node.name } + local dest = utils.path_join({ destination, _node.name }) do_single_paste(_node.absolute_path, dest, action, action_fn) end @@ -361,7 +361,7 @@ function Clipboard:copy_path(node) if node.name == ".." then -- root - content = utils.path_add_trailing "" + content = utils.path_add_trailing("") else -- node local absolute_path = node.absolute_path diff --git a/lua/nvim-tree/actions/fs/create-file.lua b/lua/nvim-tree/actions/fs/create-file.lua index 4e5b59c2849..dbd1bc7e99c 100644 --- a/lua/nvim-tree/actions/fs/create-file.lua +++ b/lua/nvim-tree/actions/fs/create-file.lua @@ -1,8 +1,8 @@ -local utils = require "nvim-tree.utils" -local events = require "nvim-tree.events" -local lib = require "nvim-tree.lib" -local core = require "nvim-tree.core" -local notify = require "nvim-tree.notify" +local utils = require("nvim-tree.utils") +local events = require("nvim-tree.events") +local lib = require("nvim-tree.lib") +local core = require("nvim-tree.core") +local notify = require("nvim-tree.notify") local find_file = require("nvim-tree.actions.finders.find-file").fn @@ -72,7 +72,7 @@ function M.fn(node) end if utils.file_exists(new_file_path) then - notify.warn "Cannot create: file already exists" + notify.warn("Cannot create: file already exists") return end @@ -87,10 +87,10 @@ function M.fn(node) for path in utils.path_split(new_file_path) do idx = idx + 1 local p = utils.path_remove_trailing(path) - if #path_to_create == 0 and vim.fn.has "win32" == 1 then - path_to_create = utils.path_join { p, path_to_create } + if #path_to_create == 0 and vim.fn.has("win32") == 1 then + path_to_create = utils.path_join({ p, path_to_create }) else - path_to_create = utils.path_join { path_to_create, p } + path_to_create = utils.path_join({ path_to_create, p }) end if is_last_path_file and idx == num_nodes then create_and_notify(path_to_create) diff --git a/lua/nvim-tree/actions/fs/init.lua b/lua/nvim-tree/actions/fs/init.lua index 5cdf78cd4ea..b308a86a01e 100644 --- a/lua/nvim-tree/actions/fs/init.lua +++ b/lua/nvim-tree/actions/fs/init.lua @@ -1,9 +1,9 @@ local M = {} -M.create_file = require "nvim-tree.actions.fs.create-file" -M.remove_file = require "nvim-tree.actions.fs.remove-file" -M.rename_file = require "nvim-tree.actions.fs.rename-file" -M.trash = require "nvim-tree.actions.fs.trash" +M.create_file = require("nvim-tree.actions.fs.create-file") +M.remove_file = require("nvim-tree.actions.fs.remove-file") +M.rename_file = require("nvim-tree.actions.fs.rename-file") +M.trash = require("nvim-tree.actions.fs.trash") function M.setup(opts) M.remove_file.setup(opts) diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index 14a30d3aa7e..327a107122d 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -1,9 +1,9 @@ -local core = require "nvim-tree.core" -local utils = require "nvim-tree.utils" -local events = require "nvim-tree.events" -local view = require "nvim-tree.view" -local lib = require "nvim-tree.lib" -local notify = require "nvim-tree.notify" +local core = require("nvim-tree.core") +local utils = require("nvim-tree.utils") +local events = require("nvim-tree.events") +local view = require("nvim-tree.view") +local lib = require("nvim-tree.lib") +local notify = require("nvim-tree.notify") local M = { config = {}, @@ -27,13 +27,13 @@ end ---@param absolute_path string local function clear_buffer(absolute_path) - local bufs = vim.fn.getbufinfo { bufloaded = 1, buflisted = 1 } + local bufs = vim.fn.getbufinfo({ bufloaded = 1, buflisted = 1 }) for _, buf in pairs(bufs) do if buf.name == absolute_path then local tree_winnr = vim.api.nvim_get_current_win() if buf.hidden == 0 and (#bufs > 1 or view.View.float.enable) then vim.api.nvim_set_current_win(buf.windows[1]) - vim.cmd ":bn" + vim.cmd(":bn") end vim.api.nvim_buf_delete(buf.bufnr, { force = true }) if not view.View.float.quit_on_focus_loss then @@ -62,7 +62,7 @@ local function remove_dir(cwd) break end - local new_cwd = utils.path_join { cwd, name } + local new_cwd = utils.path_join({ cwd, name }) -- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility local stat = vim.loop.fs_stat(new_cwd) diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index b75c511d856..9539cd7e730 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -1,8 +1,8 @@ -local core = require "nvim-tree.core" -local lib = require "nvim-tree.lib" -local utils = require "nvim-tree.utils" -local events = require "nvim-tree.events" -local notify = require "nvim-tree.notify" +local core = require("nvim-tree.core") +local lib = require("nvim-tree.lib") +local utils = require("nvim-tree.utils") +local events = require("nvim-tree.events") +local notify = require("nvim-tree.notify") local find_file = require("nvim-tree.actions.finders.find-file").fn @@ -64,10 +64,10 @@ function M.rename(node, to) idx = idx + 1 local p = utils.path_remove_trailing(path) - if #path_to_create == 0 and vim.fn.has "win32" == 1 then - path_to_create = utils.path_join { p, path_to_create } + if #path_to_create == 0 and vim.fn.has("win32") == 1 then + path_to_create = utils.path_join({ p, path_to_create }) else - path_to_create = utils.path_join { path_to_create, p } + path_to_create = utils.path_join({ path_to_create, p }) end if idx == num_nodes then diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index 09d9c19a985..15d96852a2b 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -1,23 +1,23 @@ -local core = require "nvim-tree.core" -local lib = require "nvim-tree.lib" -local notify = require "nvim-tree.notify" +local core = require("nvim-tree.core") +local lib = require("nvim-tree.lib") +local notify = require("nvim-tree.notify") local M = { config = {}, } -local utils = require "nvim-tree.utils" -local events = require "nvim-tree.events" +local utils = require("nvim-tree.utils") +local events = require("nvim-tree.events") ---@param absolute_path string local function clear_buffer(absolute_path) - local bufs = vim.fn.getbufinfo { bufloaded = 1, buflisted = 1 } + local bufs = vim.fn.getbufinfo({ bufloaded = 1, buflisted = 1 }) for _, buf in pairs(bufs) do if buf.name == absolute_path then if buf.hidden == 0 and #bufs > 1 then local winnr = vim.api.nvim_get_current_win() vim.api.nvim_set_current_win(buf.windows[1]) - vim.cmd ":bn" + vim.cmd(":bn") vim.api.nvim_set_current_win(winnr) end vim.api.nvim_buf_delete(buf.bufnr, {}) @@ -48,7 +48,7 @@ function M.remove(node) on_stderr = on_stderr, }) if need_sync_wait then - vim.fn.jobwait { job } + vim.fn.jobwait({ job }) end end diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index 72523ba7299..0a85a26832c 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -1,11 +1,11 @@ local M = {} -M.finders = require "nvim-tree.actions.finders" -M.fs = require "nvim-tree.actions.fs" -M.moves = require "nvim-tree.actions.moves" -M.node = require "nvim-tree.actions.node" -M.root = require "nvim-tree.actions.root" -M.tree = require "nvim-tree.actions.tree" +M.finders = require("nvim-tree.actions.finders") +M.fs = require("nvim-tree.actions.fs") +M.moves = require("nvim-tree.actions.moves") +M.node = require("nvim-tree.actions.node") +M.root = require("nvim-tree.actions.root") +M.tree = require("nvim-tree.actions.tree") function M.setup(opts) M.fs.setup(opts) diff --git a/lua/nvim-tree/actions/moves/init.lua b/lua/nvim-tree/actions/moves/init.lua index acefa3dcbd3..b1e5be74afe 100644 --- a/lua/nvim-tree/actions/moves/init.lua +++ b/lua/nvim-tree/actions/moves/init.lua @@ -1,7 +1,7 @@ local M = {} -M.item = require "nvim-tree.actions.moves.item" -M.parent = require "nvim-tree.actions.moves.parent" -M.sibling = require "nvim-tree.actions.moves.sibling" +M.item = require("nvim-tree.actions.moves.item") +M.parent = require("nvim-tree.actions.moves.parent") +M.sibling = require("nvim-tree.actions.moves.sibling") return M diff --git a/lua/nvim-tree/actions/moves/item.lua b/lua/nvim-tree/actions/moves/item.lua index 4bb5e0fa485..c38618e9c74 100644 --- a/lua/nvim-tree/actions/moves/item.lua +++ b/lua/nvim-tree/actions/moves/item.lua @@ -1,9 +1,9 @@ -local utils = require "nvim-tree.utils" -local view = require "nvim-tree.view" -local core = require "nvim-tree.core" -local lib = require "nvim-tree.lib" -local explorer_node = require "nvim-tree.explorer.node" -local diagnostics = require "nvim-tree.diagnostics" +local utils = require("nvim-tree.utils") +local view = require("nvim-tree.view") +local core = require("nvim-tree.core") +local lib = require("nvim-tree.lib") +local explorer_node = require("nvim-tree.explorer.node") +local diagnostics = require("nvim-tree.diagnostics") local M = {} local MAX_DEPTH = 100 @@ -65,9 +65,9 @@ local function move(where, what, skip_gitignored) end if nex then - view.set_cursor { nex, 0 } + view.set_cursor({ nex, 0 }) elseif vim.o.wrapscan and first then - view.set_cursor { first, 0 } + view.set_cursor({ first, 0 }) end end @@ -186,13 +186,13 @@ local function move_prev_recursive(what, skip_gitignored) -- 4.3) if node_init.name == ".." then -- root node - view.set_cursor { 1, 0 } -- move to root node (position 1) + view.set_cursor({ 1, 0 }) -- move to root node (position 1) else local node_init_line = utils.find_node_line(node_init) if node_init_line < 0 then return end - view.set_cursor { node_init_line, 0 } + view.set_cursor({ node_init_line, 0 }) end -- 4.4) diff --git a/lua/nvim-tree/actions/moves/parent.lua b/lua/nvim-tree/actions/moves/parent.lua index dd04c365efe..e00bc49e7e5 100644 --- a/lua/nvim-tree/actions/moves/parent.lua +++ b/lua/nvim-tree/actions/moves/parent.lua @@ -1,7 +1,7 @@ -local view = require "nvim-tree.view" -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" -local lib = require "nvim-tree.lib" +local view = require("nvim-tree.view") +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") +local lib = require("nvim-tree.lib") local M = {} @@ -24,14 +24,14 @@ function M.fn(should_close) local parent = utils.get_parent_of_group(node).parent if not parent or not parent.parent then - return view.set_cursor { 1, 0 } + return view.set_cursor({ 1, 0 }) end local _, line = utils.find_node(core.get_explorer().nodes, function(n) return n.absolute_path == parent.absolute_path end) - view.set_cursor { line + 1, 0 } + view.set_cursor({ line + 1, 0 }) if should_close then parent.open = false if explorer then diff --git a/lua/nvim-tree/actions/moves/sibling.lua b/lua/nvim-tree/actions/moves/sibling.lua index 16e95ba8f05..afab9ef3efa 100644 --- a/lua/nvim-tree/actions/moves/sibling.lua +++ b/lua/nvim-tree/actions/moves/sibling.lua @@ -1,6 +1,6 @@ -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" -local Iterator = require "nvim-tree.iterators.node-iterator" +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") +local Iterator = require("nvim-tree.iterators.node-iterator") local M = {} diff --git a/lua/nvim-tree/actions/node/file-popup.lua b/lua/nvim-tree/actions/node/file-popup.lua index 5736b3ee0d6..1b9ed6a3b21 100644 --- a/lua/nvim-tree/actions/node/file-popup.lua +++ b/lua/nvim-tree/actions/node/file-popup.lua @@ -1,4 +1,4 @@ -local utils = require "nvim-tree.utils" +local utils = require("nvim-tree.utils") local M = {} @@ -57,7 +57,7 @@ end function M.close_popup() if current_popup ~= nil then vim.api.nvim_win_close(current_popup.winnr, true) - vim.cmd "augroup NvimTreeRemoveFilePopup | au! CursorMoved | augroup END" + vim.cmd("augroup NvimTreeRemoveFilePopup | au! CursorMoved | augroup END") current_popup = nil end diff --git a/lua/nvim-tree/actions/node/init.lua b/lua/nvim-tree/actions/node/init.lua index 67d5e6d17ee..f82ad4ae38d 100644 --- a/lua/nvim-tree/actions/node/init.lua +++ b/lua/nvim-tree/actions/node/init.lua @@ -1,9 +1,9 @@ local M = {} -M.file_popup = require "nvim-tree.actions.node.file-popup" -M.open_file = require "nvim-tree.actions.node.open-file" -M.run_command = require "nvim-tree.actions.node.run-command" -M.system_open = require "nvim-tree.actions.node.system-open" +M.file_popup = require("nvim-tree.actions.node.file-popup") +M.open_file = require("nvim-tree.actions.node.open-file") +M.run_command = require("nvim-tree.actions.node.run-command") +M.system_open = require("nvim-tree.actions.node.system-open") function M.setup(opts) require("nvim-tree.actions.node.system-open").setup(opts) diff --git a/lua/nvim-tree/actions/node/open-file.lua b/lua/nvim-tree/actions/node/open-file.lua index cb72df3a20e..3cbd2e50475 100644 --- a/lua/nvim-tree/actions/node/open-file.lua +++ b/lua/nvim-tree/actions/node/open-file.lua @@ -1,8 +1,8 @@ -- Copyright 2019 Yazdani Kiyan under MIT License -local lib = require "nvim-tree.lib" -local notify = require "nvim-tree.notify" -local utils = require "nvim-tree.utils" -local view = require "nvim-tree.view" +local lib = require("nvim-tree.lib") +local notify = require("nvim-tree.notify") +local utils = require("nvim-tree.utils") +local view = require("nvim-tree.view") local M = {} @@ -27,7 +27,7 @@ local function usable_win_ids() local bufid = vim.api.nvim_win_get_buf(id) for option, v in pairs(M.window_picker.exclude) do local ok, option_value - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then ok, option_value = pcall(vim.api.nvim_get_option_value, option, { buf = bufid }) else ok, option_value = pcall(vim.api.nvim_buf_get_option, bufid, option) ---@diagnostic disable-line: deprecated @@ -91,7 +91,7 @@ local function pick_win_id() for _, win_id in ipairs(not_selectable) do local ok_status, statusline, ok_hl, winhl - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = win_id }) ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = win_id }) else @@ -105,7 +105,7 @@ local function pick_win_id() } -- Clear statusline for windows not selectable - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value("statusline", " ", { win = win_id }) else vim.api.nvim_win_set_option(win_id, "statusline", " ") ---@diagnostic disable-line: deprecated @@ -118,7 +118,7 @@ local function pick_win_id() local char = M.window_picker.chars:sub(i, i) local ok_status, statusline, ok_hl, winhl - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = id }) ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = id }) else @@ -132,7 +132,7 @@ local function pick_win_id() } win_map[char] = id - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value("statusline", "%=" .. char .. "%=", { win = id }) vim.api.nvim_set_option_value("winhl", "StatusLine:NvimTreeWindowPicker,StatusLineNC:NvimTreeWindowPicker", { win = id }) else @@ -146,9 +146,9 @@ local function pick_win_id() end end - vim.cmd "redraw" + vim.cmd("redraw") if vim.opt.cmdheight._value ~= 0 then - print "Pick window: " + print("Pick window: ") end local _, resp = pcall(get_user_input_char) resp = (resp or ""):upper() @@ -157,7 +157,7 @@ local function pick_win_id() -- Restore window options for _, id in ipairs(selectable) do for opt, value in pairs(win_opts[id]) do - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value(opt, value, { win = id }) else vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated @@ -170,7 +170,7 @@ local function pick_win_id() -- Ensure window still exists at this point if vim.api.nvim_win_is_valid(id) then for opt, value in pairs(win_opts[id]) do - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value(opt, value, { win = id }) else vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated @@ -300,7 +300,7 @@ local function open_in_new_window(filename, mode) -- No need to split, as we created a new window. create_new_window = false - if mode:match "split$" then + if mode:match("split$") then mode = "edit" end elseif not vim.o.hidden then @@ -309,14 +309,14 @@ local function open_in_new_window(filename, mode) local target_bufid = vim.api.nvim_win_get_buf(target_winid) local modified - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then modified = vim.api.nvim_get_option_value("modified", { buf = target_bufid }) else modified = vim.api.nvim_buf_get_option(target_bufid, "modified") ---@diagnostic disable-line: deprecated end if modified then - if not mode:match "split$" then + if not mode:match("split$") then mode = "vsplit" end end @@ -342,7 +342,7 @@ local function open_in_new_window(filename, mode) if create_new_window then -- generated from vim.api.nvim_parse_cmd("belowright vsplit foo", {}) command = { cmd = "vsplit", mods = { split = new_window_side }, args = { fname } } - elseif mode:match "split$" then + elseif mode:match("split$") then command = { cmd = mode, args = { fname } } else command = { cmd = "edit", args = { fname } } diff --git a/lua/nvim-tree/actions/node/run-command.lua b/lua/nvim-tree/actions/node/run-command.lua index 18bd8f8b0f2..1d99b37249f 100644 --- a/lua/nvim-tree/actions/node/run-command.lua +++ b/lua/nvim-tree/actions/node/run-command.lua @@ -1,5 +1,5 @@ -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") local M = {} diff --git a/lua/nvim-tree/actions/node/system-open.lua b/lua/nvim-tree/actions/node/system-open.lua index 6393f1f9267..37a63115f50 100644 --- a/lua/nvim-tree/actions/node/system-open.lua +++ b/lua/nvim-tree/actions/node/system-open.lua @@ -1,12 +1,12 @@ -local notify = require "nvim-tree.notify" -local utils = require "nvim-tree.utils" +local notify = require("nvim-tree.notify") +local utils = require("nvim-tree.utils") local M = {} ---@param node Node local function user(node) if #M.config.system_open.cmd == 0 then - require("nvim-tree.utils").notify.warn "Cannot open file with system application. Unrecognized platform." + require("nvim-tree.utils").notify.warn("Cannot open file with system application. Unrecognized platform.") return end @@ -69,7 +69,7 @@ function M.setup(opts) M.config = {} M.config.system_open = opts.system_open or {} - if vim.fn.has "nvim-0.10" == 1 and #M.config.system_open.cmd == 0 then + if vim.fn.has("nvim-0.10") == 1 and #M.config.system_open.cmd == 0 then M.open = native else M.open = user diff --git a/lua/nvim-tree/actions/root/change-dir.lua b/lua/nvim-tree/actions/root/change-dir.lua index 8ba5763d151..0aa416127b0 100644 --- a/lua/nvim-tree/actions/root/change-dir.lua +++ b/lua/nvim-tree/actions/root/change-dir.lua @@ -1,6 +1,6 @@ -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") local M = { current_tab = vim.api.nvim_get_current_tabpage(), diff --git a/lua/nvim-tree/actions/root/dir-up.lua b/lua/nvim-tree/actions/root/dir-up.lua index ac963280b29..a8c41c8c6f0 100644 --- a/lua/nvim-tree/actions/root/dir-up.lua +++ b/lua/nvim-tree/actions/root/dir-up.lua @@ -1,12 +1,12 @@ -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") local M = {} ---@param node Node function M.fn(node) if not node or node.name == ".." then - require("nvim-tree.actions.root.change-dir").fn ".." + require("nvim-tree.actions.root.change-dir").fn("..") else local cwd = core.get_cwd() if cwd == nil then diff --git a/lua/nvim-tree/actions/root/init.lua b/lua/nvim-tree/actions/root/init.lua index f1610384dc7..1177e2050e1 100644 --- a/lua/nvim-tree/actions/root/init.lua +++ b/lua/nvim-tree/actions/root/init.lua @@ -1,7 +1,7 @@ local M = {} -M.change_dir = require "nvim-tree.actions.root.change-dir" -M.dir_up = require "nvim-tree.actions.root.dir-up" +M.change_dir = require("nvim-tree.actions.root.change-dir") +M.dir_up = require("nvim-tree.actions.root.dir-up") function M.setup(opts) M.change_dir.setup(opts) diff --git a/lua/nvim-tree/actions/tree/find-file.lua b/lua/nvim-tree/actions/tree/find-file.lua index 3ba7b13421a..8a05bf6db45 100644 --- a/lua/nvim-tree/actions/tree/find-file.lua +++ b/lua/nvim-tree/actions/tree/find-file.lua @@ -1,7 +1,7 @@ -local core = require "nvim-tree.core" -local lib = require "nvim-tree.lib" -local view = require "nvim-tree.view" -local finders_find_file = require "nvim-tree.actions.finders.find-file" +local core = require("nvim-tree.core") +local lib = require("nvim-tree.lib") +local view = require("nvim-tree.view") +local finders_find_file = require("nvim-tree.actions.finders.find-file") local M = {} @@ -49,9 +49,9 @@ function M.fn(opts) end elseif opts.open then -- open - lib.open { current_window = opts.current_window, winid = opts.winid } + lib.open({ current_window = opts.current_window, winid = opts.winid }) if not opts.focus then - vim.cmd "noautocmd wincmd p" + vim.cmd("noautocmd wincmd p") end end diff --git a/lua/nvim-tree/actions/tree/init.lua b/lua/nvim-tree/actions/tree/init.lua index 8e38fc58720..2ff9e9b71cf 100644 --- a/lua/nvim-tree/actions/tree/init.lua +++ b/lua/nvim-tree/actions/tree/init.lua @@ -1,10 +1,10 @@ local M = {} -M.find_file = require "nvim-tree.actions.tree.find-file" -M.modifiers = require "nvim-tree.actions.tree.modifiers" -M.open = require "nvim-tree.actions.tree.open" -M.toggle = require "nvim-tree.actions.tree.toggle" -M.resize = require "nvim-tree.actions.tree.resize" +M.find_file = require("nvim-tree.actions.tree.find-file") +M.modifiers = require("nvim-tree.actions.tree.modifiers") +M.open = require("nvim-tree.actions.tree.open") +M.toggle = require("nvim-tree.actions.tree.toggle") +M.resize = require("nvim-tree.actions.tree.resize") function M.setup(opts) M.find_file.setup(opts) diff --git a/lua/nvim-tree/actions/tree/modifiers/collapse-all.lua b/lua/nvim-tree/actions/tree/modifiers/collapse-all.lua index e15f185ab69..136bd357297 100644 --- a/lua/nvim-tree/actions/tree/modifiers/collapse-all.lua +++ b/lua/nvim-tree/actions/tree/modifiers/collapse-all.lua @@ -1,7 +1,7 @@ -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" -local lib = require "nvim-tree.lib" -local Iterator = require "nvim-tree.iterators.node-iterator" +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") +local lib = require("nvim-tree.lib") +local Iterator = require("nvim-tree.iterators.node-iterator") local M = {} diff --git a/lua/nvim-tree/actions/tree/modifiers/expand-all.lua b/lua/nvim-tree/actions/tree/modifiers/expand-all.lua index 22fe97cea97..25be0b90803 100644 --- a/lua/nvim-tree/actions/tree/modifiers/expand-all.lua +++ b/lua/nvim-tree/actions/tree/modifiers/expand-all.lua @@ -1,7 +1,7 @@ -local core = require "nvim-tree.core" -local Iterator = require "nvim-tree.iterators.node-iterator" -local notify = require "nvim-tree.notify" -local lib = require "nvim-tree.lib" +local core = require("nvim-tree.core") +local Iterator = require("nvim-tree.iterators.node-iterator") +local notify = require("nvim-tree.notify") +local lib = require("nvim-tree.lib") local M = {} diff --git a/lua/nvim-tree/actions/tree/modifiers/init.lua b/lua/nvim-tree/actions/tree/modifiers/init.lua index 101191517e8..717b8d7e8f0 100644 --- a/lua/nvim-tree/actions/tree/modifiers/init.lua +++ b/lua/nvim-tree/actions/tree/modifiers/init.lua @@ -1,8 +1,8 @@ local M = {} -M.collapse_all = require "nvim-tree.actions.tree.modifiers.collapse-all" -M.expand_all = require "nvim-tree.actions.tree.modifiers.expand-all" -M.toggles = require "nvim-tree.actions.tree.modifiers.toggles" +M.collapse_all = require("nvim-tree.actions.tree.modifiers.collapse-all") +M.expand_all = require("nvim-tree.actions.tree.modifiers.expand-all") +M.toggles = require("nvim-tree.actions.tree.modifiers.toggles") function M.setup(opts) M.expand_all.setup(opts) diff --git a/lua/nvim-tree/actions/tree/modifiers/toggles.lua b/lua/nvim-tree/actions/tree/modifiers/toggles.lua index 9cf8e5dde65..782ab35e1dd 100644 --- a/lua/nvim-tree/actions/tree/modifiers/toggles.lua +++ b/lua/nvim-tree/actions/tree/modifiers/toggles.lua @@ -1,6 +1,6 @@ -local lib = require "nvim-tree.lib" -local utils = require "nvim-tree.utils" -local core = require "nvim-tree.core" +local lib = require("nvim-tree.lib") +local utils = require("nvim-tree.utils") +local core = require("nvim-tree.core") local M = {} ---@param explorer Explorer diff --git a/lua/nvim-tree/actions/tree/open.lua b/lua/nvim-tree/actions/tree/open.lua index d4e759f8692..ff2da837b87 100644 --- a/lua/nvim-tree/actions/tree/open.lua +++ b/lua/nvim-tree/actions/tree/open.lua @@ -1,6 +1,6 @@ -local lib = require "nvim-tree.lib" -local view = require "nvim-tree.view" -local finders_find_file = require "nvim-tree.actions.finders.find-file" +local lib = require("nvim-tree.lib") +local view = require("nvim-tree.view") +local finders_find_file = require("nvim-tree.actions.finders.find-file") local M = {} @@ -29,11 +29,11 @@ function M.fn(opts) view.focus() else -- open - lib.open { + lib.open({ path = opts.path, current_window = opts.current_window, winid = opts.winid, - } + }) end -- find file diff --git a/lua/nvim-tree/actions/tree/resize.lua b/lua/nvim-tree/actions/tree/resize.lua index b3a3c687ccb..e8d4e950729 100644 --- a/lua/nvim-tree/actions/tree/resize.lua +++ b/lua/nvim-tree/actions/tree/resize.lua @@ -1,4 +1,4 @@ -local view = require "nvim-tree.view" +local view = require("nvim-tree.view") local M = {} diff --git a/lua/nvim-tree/actions/tree/toggle.lua b/lua/nvim-tree/actions/tree/toggle.lua index 10bff08c7eb..10aa978467e 100644 --- a/lua/nvim-tree/actions/tree/toggle.lua +++ b/lua/nvim-tree/actions/tree/toggle.lua @@ -1,6 +1,6 @@ -local lib = require "nvim-tree.lib" -local view = require "nvim-tree.view" -local finders_find_file = require "nvim-tree.actions.finders.find-file" +local lib = require("nvim-tree.lib") +local view = require("nvim-tree.view") +local finders_find_file = require("nvim-tree.actions.finders.find-file") local M = {} @@ -45,11 +45,11 @@ function M.fn(opts, no_focus, cwd, bang) view.close() else -- open - lib.open { + lib.open({ path = opts.path, current_window = opts.current_window, winid = opts.winid, - } + }) -- find file if M.config.update_focused_file.enable or opts.find_file then @@ -64,7 +64,7 @@ function M.fn(opts, no_focus, cwd, bang) -- restore focus if not opts.focus then - vim.cmd "noautocmd wincmd p" + vim.cmd("noautocmd wincmd p") end end end diff --git a/lua/nvim-tree/api.lua b/lua/nvim-tree/api.lua index 91054db54e0..27da1d206df 100644 --- a/lua/nvim-tree/api.lua +++ b/lua/nvim-tree/api.lua @@ -1,13 +1,13 @@ -local lib = require "nvim-tree.lib" -local core = require "nvim-tree.core" -local view = require "nvim-tree.view" -local utils = require "nvim-tree.utils" -local actions = require "nvim-tree.actions" -local appearance_diagnostics = require "nvim-tree.appearance.diagnostics" -local events = require "nvim-tree.events" -local help = require "nvim-tree.help" -local keymap = require "nvim-tree.keymap" -local notify = require "nvim-tree.notify" +local lib = require("nvim-tree.lib") +local core = require("nvim-tree.core") +local view = require("nvim-tree.view") +local utils = require("nvim-tree.utils") +local actions = require("nvim-tree.actions") +local appearance_diagnostics = require("nvim-tree.appearance.diagnostics") +local events = require("nvim-tree.events") +local help = require("nvim-tree.help") +local keymap = require("nvim-tree.keymap") +local notify = require("nvim-tree.notify") local Api = { tree = {}, @@ -47,7 +47,7 @@ local function wrap(f) if vim.g.NvimTreeSetup == 1 then return f(...) else - notify.error "nvim-tree setup not called" + notify.error("nvim-tree setup not called") end end end @@ -121,7 +121,7 @@ Api.tree.toggle = wrap(actions.tree.toggle.fn) Api.tree.close = wrap(view.close) Api.tree.close_in_this_tab = wrap(view.close_this_tab_only) Api.tree.close_in_all_tabs = wrap(view.close_all_tabs) -Api.tree.reload = wrap_explorer "reload_explorer" +Api.tree.reload = wrap_explorer("reload_explorer") ---@class ApiTreeResizeOpts ---@field width string|function|number|table|nil @@ -136,7 +136,7 @@ end) Api.tree.change_root_to_node = wrap_node(function(node) if node.name == ".." then - actions.root.change_dir.fn ".." + actions.root.change_dir.fn("..") elseif node.nodes ~= nil then actions.root.change_dir.fn(lib.get_last_group_node(node).absolute_path) end @@ -182,11 +182,11 @@ Api.tree.winid = wrap(view.winid) Api.fs.create = wrap_node_or_nil(actions.fs.create_file.fn) Api.fs.remove = wrap_node(actions.fs.remove_file.fn) Api.fs.trash = wrap_node(actions.fs.trash.fn) -Api.fs.rename_node = wrap_node(actions.fs.rename_file.fn ":t") -Api.fs.rename = wrap_node(actions.fs.rename_file.fn ":t") -Api.fs.rename_sub = wrap_node(actions.fs.rename_file.fn ":p:h") -Api.fs.rename_basename = wrap_node(actions.fs.rename_file.fn ":t:r") -Api.fs.rename_full = wrap_node(actions.fs.rename_file.fn ":p") +Api.fs.rename_node = wrap_node(actions.fs.rename_file.fn(":t")) +Api.fs.rename = wrap_node(actions.fs.rename_file.fn(":t")) +Api.fs.rename_sub = wrap_node(actions.fs.rename_file.fn(":p:h")) +Api.fs.rename_basename = wrap_node(actions.fs.rename_file.fn(":t:r")) +Api.fs.rename_full = wrap_node(actions.fs.rename_file.fn(":p")) Api.fs.cut = wrap_node(wrap_explorer_member("clipboard", "cut")) Api.fs.paste = wrap_node(wrap_explorer_member("clipboard", "paste")) Api.fs.clear_clipboard = wrap_explorer_member("clipboard", "clear_clipboard") @@ -212,7 +212,7 @@ end local function open_or_expand_or_dir_up(mode, toggle_group) return function(node) if node.name == ".." then - actions.root.change_dir.fn ".." + actions.root.change_dir.fn("..") elseif node.nodes then lib.expand_or_collapse(node, toggle_group) elseif not toggle_group then @@ -221,42 +221,42 @@ local function open_or_expand_or_dir_up(mode, toggle_group) end end -Api.node.open.edit = wrap_node(open_or_expand_or_dir_up "edit") -Api.node.open.drop = wrap_node(open_or_expand_or_dir_up "drop") -Api.node.open.tab_drop = wrap_node(open_or_expand_or_dir_up "tab_drop") -Api.node.open.replace_tree_buffer = wrap_node(open_or_expand_or_dir_up "edit_in_place") -Api.node.open.no_window_picker = wrap_node(open_or_expand_or_dir_up "edit_no_picker") -Api.node.open.vertical = wrap_node(open_or_expand_or_dir_up "vsplit") -Api.node.open.horizontal = wrap_node(open_or_expand_or_dir_up "split") -Api.node.open.tab = wrap_node(open_or_expand_or_dir_up "tabnew") +Api.node.open.edit = wrap_node(open_or_expand_or_dir_up("edit")) +Api.node.open.drop = wrap_node(open_or_expand_or_dir_up("drop")) +Api.node.open.tab_drop = wrap_node(open_or_expand_or_dir_up("tab_drop")) +Api.node.open.replace_tree_buffer = wrap_node(open_or_expand_or_dir_up("edit_in_place")) +Api.node.open.no_window_picker = wrap_node(open_or_expand_or_dir_up("edit_no_picker")) +Api.node.open.vertical = wrap_node(open_or_expand_or_dir_up("vsplit")) +Api.node.open.horizontal = wrap_node(open_or_expand_or_dir_up("split")) +Api.node.open.tab = wrap_node(open_or_expand_or_dir_up("tabnew")) Api.node.open.toggle_group_empty = wrap_node(open_or_expand_or_dir_up("toggle_group_empty", true)) -Api.node.open.preview = wrap_node(open_or_expand_or_dir_up "preview") -Api.node.open.preview_no_picker = wrap_node(open_or_expand_or_dir_up "preview_no_picker") +Api.node.open.preview = wrap_node(open_or_expand_or_dir_up("preview")) +Api.node.open.preview_no_picker = wrap_node(open_or_expand_or_dir_up("preview_no_picker")) Api.node.show_info_popup = wrap_node(actions.node.file_popup.toggle_file_info) Api.node.run.cmd = wrap_node(actions.node.run_command.run_file_command) Api.node.run.system = wrap_node(actions.node.system_open.fn) -Api.node.navigate.sibling.next = wrap_node(actions.moves.sibling.fn "next") -Api.node.navigate.sibling.prev = wrap_node(actions.moves.sibling.fn "prev") -Api.node.navigate.sibling.first = wrap_node(actions.moves.sibling.fn "first") -Api.node.navigate.sibling.last = wrap_node(actions.moves.sibling.fn "last") +Api.node.navigate.sibling.next = wrap_node(actions.moves.sibling.fn("next")) +Api.node.navigate.sibling.prev = wrap_node(actions.moves.sibling.fn("prev")) +Api.node.navigate.sibling.first = wrap_node(actions.moves.sibling.fn("first")) +Api.node.navigate.sibling.last = wrap_node(actions.moves.sibling.fn("last")) Api.node.navigate.parent = wrap_node(actions.moves.parent.fn(false)) Api.node.navigate.parent_close = wrap_node(actions.moves.parent.fn(true)) -Api.node.navigate.git.next = wrap_node(actions.moves.item.fn { where = "next", what = "git" }) -Api.node.navigate.git.next_skip_gitignored = wrap_node(actions.moves.item.fn { where = "next", what = "git", skip_gitignored = true }) -Api.node.navigate.git.next_recursive = wrap_node(actions.moves.item.fn { where = "next", what = "git", recurse = true }) -Api.node.navigate.git.prev = wrap_node(actions.moves.item.fn { where = "prev", what = "git" }) -Api.node.navigate.git.prev_skip_gitignored = wrap_node(actions.moves.item.fn { where = "prev", what = "git", skip_gitignored = true }) -Api.node.navigate.git.prev_recursive = wrap_node(actions.moves.item.fn { where = "prev", what = "git", recurse = true }) -Api.node.navigate.diagnostics.next = wrap_node(actions.moves.item.fn { where = "next", what = "diag" }) -Api.node.navigate.diagnostics.next_recursive = wrap_node(actions.moves.item.fn { where = "next", what = "diag", recurse = true }) -Api.node.navigate.diagnostics.prev = wrap_node(actions.moves.item.fn { where = "prev", what = "diag" }) -Api.node.navigate.diagnostics.prev_recursive = wrap_node(actions.moves.item.fn { where = "prev", what = "diag", recurse = true }) -Api.node.navigate.opened.next = wrap_node(actions.moves.item.fn { where = "next", what = "opened" }) -Api.node.navigate.opened.prev = wrap_node(actions.moves.item.fn { where = "prev", what = "opened" }) - -Api.git.reload = wrap_explorer "reload_git" +Api.node.navigate.git.next = wrap_node(actions.moves.item.fn({ where = "next", what = "git" })) +Api.node.navigate.git.next_skip_gitignored = wrap_node(actions.moves.item.fn({ where = "next", what = "git", skip_gitignored = true })) +Api.node.navigate.git.next_recursive = wrap_node(actions.moves.item.fn({ where = "next", what = "git", recurse = true })) +Api.node.navigate.git.prev = wrap_node(actions.moves.item.fn({ where = "prev", what = "git" })) +Api.node.navigate.git.prev_skip_gitignored = wrap_node(actions.moves.item.fn({ where = "prev", what = "git", skip_gitignored = true })) +Api.node.navigate.git.prev_recursive = wrap_node(actions.moves.item.fn({ where = "prev", what = "git", recurse = true })) +Api.node.navigate.diagnostics.next = wrap_node(actions.moves.item.fn({ where = "next", what = "diag" })) +Api.node.navigate.diagnostics.next_recursive = wrap_node(actions.moves.item.fn({ where = "next", what = "diag", recurse = true })) +Api.node.navigate.diagnostics.prev = wrap_node(actions.moves.item.fn({ where = "prev", what = "diag" })) +Api.node.navigate.diagnostics.prev_recursive = wrap_node(actions.moves.item.fn({ where = "prev", what = "diag", recurse = true })) +Api.node.navigate.opened.next = wrap_node(actions.moves.item.fn({ where = "next", what = "opened" })) +Api.node.navigate.opened.prev = wrap_node(actions.moves.item.fn({ where = "prev", what = "opened" })) + +Api.git.reload = wrap_explorer("reload_git") Api.events.subscribe = events.subscribe Api.events.Event = events.Event diff --git a/lua/nvim-tree/appearance/diagnostics.lua b/lua/nvim-tree/appearance/diagnostics.lua index eacef5e9165..5c292104655 100644 --- a/lua/nvim-tree/appearance/diagnostics.lua +++ b/lua/nvim-tree/appearance/diagnostics.lua @@ -1,4 +1,4 @@ -local appearance = require "nvim-tree.appearance" +local appearance = require("nvim-tree.appearance") -- others with name and links less than this arbitrary value are short local SHORT_LEN = 50 @@ -129,7 +129,7 @@ function M.hi_test() render_displays("other, long", displays_long, bufnr, l) -- finalise and focus the buffer - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr }) else vim.api.nvim_buf_set_option(bufnr, "modifiable", false) ---@diagnostic disable-line: deprecated diff --git a/lua/nvim-tree/buffers.lua b/lua/nvim-tree/buffers.lua index bf7ac7b0b80..51ebe141a93 100644 --- a/lua/nvim-tree/buffers.lua +++ b/lua/nvim-tree/buffers.lua @@ -6,7 +6,7 @@ M._modified = {} ---refresh M._modified function M.reload_modified() M._modified = {} - local bufs = vim.fn.getbufinfo { bufmodified = 1, buflisted = 1 } + local bufs = vim.fn.getbufinfo({ bufmodified = 1, buflisted = 1 }) for _, buf in pairs(bufs) do local path = buf.name if path ~= "" then -- not a [No Name] buffer diff --git a/lua/nvim-tree/commands.lua b/lua/nvim-tree/commands.lua index f5a7ac82106..bff880c14fd 100644 --- a/lua/nvim-tree/commands.lua +++ b/lua/nvim-tree/commands.lua @@ -1,5 +1,5 @@ -local api = require "nvim-tree.api" -local view = require "nvim-tree.view" +local api = require("nvim-tree.api") +local view = require("nvim-tree.view") local M = {} @@ -12,7 +12,7 @@ local CMDS = { complete = "dir", }, command = function(c) - api.tree.open { path = c.args } + api.tree.open({ path = c.args }) end, }, { @@ -33,12 +33,12 @@ local CMDS = { complete = "dir", }, command = function(c) - api.tree.toggle { + api.tree.toggle({ find_file = false, focus = true, path = c.args, update_root = false, - } + }) end, }, { @@ -79,11 +79,11 @@ local CMDS = { bar = true, }, command = function(c) - api.tree.find_file { + api.tree.find_file({ open = true, focus = true, update_root = c.bang, - } + }) end, }, { @@ -95,12 +95,12 @@ local CMDS = { complete = "dir", }, command = function(c) - api.tree.toggle { + api.tree.toggle({ find_file = true, focus = true, path = c.args, update_root = c.bang, - } + }) end, }, { diff --git a/lua/nvim-tree/core.lua b/lua/nvim-tree/core.lua index 186a8b17d77..d3e6d20ffff 100644 --- a/lua/nvim-tree/core.lua +++ b/lua/nvim-tree/core.lua @@ -1,6 +1,6 @@ -local events = require "nvim-tree.events" -local view = require "nvim-tree.view" -local log = require "nvim-tree.log" +local events = require("nvim-tree.events") +local view = require("nvim-tree.view") +local log = require("nvim-tree.log") local M = {} diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 4fa314d67ac..05845ba274b 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -1,7 +1,7 @@ -local core = require "nvim-tree.core" -local utils = require "nvim-tree.utils" -local view = require "nvim-tree.view" -local log = require "nvim-tree.log" +local core = require("nvim-tree.core") +local utils = require("nvim-tree.utils") +local view = require("nvim-tree.view") +local log = require("nvim-tree.log") local M = {} @@ -42,7 +42,7 @@ local function from_nvim_lsp() -- is_enabled is not present in all 0.10 builds/releases, see #2781 local is_enabled = false - if vim.fn.has "nvim-0.10" == 1 and type(vim.diagnostic.is_enabled) == "function" then + if vim.fn.has("nvim-0.10") == 1 and type(vim.diagnostic.is_enabled) == "function" then is_enabled = vim.diagnostic.is_enabled() elseif type(vim.diagnostic.is_disabled) == "function" then ---@diagnostic disable-line: deprecated is_enabled = not vim.diagnostic.is_disabled() ---@diagnostic disable-line: deprecated @@ -77,7 +77,7 @@ local function handle_coc_exception(err) local notify = true -- avoid distractions on interrupts (CTRL-C) - if err:find "Vim:Interrupt" or err:find "Keyboard interrupt" then + if err:find("Vim:Interrupt") or err:find("Keyboard interrupt") then notify = false end @@ -100,7 +100,7 @@ local function from_coc() end local ok, diagnostic_list = xpcall(function() - return vim.fn.CocAction "diagnosticList" + return vim.fn.CocAction("diagnosticList") end, handle_coc_exception) if not ok or type(diagnostic_list) ~= "table" or vim.tbl_isempty(diagnostic_list) then return {} @@ -152,14 +152,14 @@ function M.update() return end utils.debounce("diagnostics", M.debounce_delay, function() - local profile = log.profile_start "diagnostics update" + local profile = log.profile_start("diagnostics update") if is_using_coc() then NODE_SEVERITIES = from_coc() else NODE_SEVERITIES = from_nvim_lsp() end NODE_SEVERITIES_VERSION = NODE_SEVERITIES_VERSION + 1 - if log.enabled "diagnostics" then + if log.enabled("diagnostics") then for bufname, severity in pairs(NODE_SEVERITIES) do log.line("diagnostics", "Indexing bufname '%s' with severity %d", bufname, severity) end diff --git a/lua/nvim-tree/events.lua b/lua/nvim-tree/events.lua index 4ab74932226..7b57333aee3 100644 --- a/lua/nvim-tree/events.lua +++ b/lua/nvim-tree/events.lua @@ -1,4 +1,4 @@ -local notify = require "nvim-tree.notify" +local notify = require("nvim-tree.notify") local M = {} diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index e6e4cc8fc76..5dd595d5999 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -1,4 +1,4 @@ -local utils = require "nvim-tree.utils" +local utils = require("nvim-tree.utils") local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON ---@class Filters to handle all opts.filters and related API @@ -165,7 +165,7 @@ local function custom(self, path) end end - local idx = path:match ".+()%.[^.]+$" + local idx = path:match(".+()%.[^.]+$") if idx then if self.ignore_list["*" .. string.sub(path, idx)] == true then return true @@ -189,7 +189,7 @@ function Filters:prepare(git_status) } if self.config.filter_no_buffer then - status.bufinfo = vim.fn.getbufinfo { buflisted = 1 } + status.bufinfo = vim.fn.getbufinfo({ buflisted = 1 }) end local explorer = require("nvim-tree.core").get_explorer() diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index a180bb707ec..a52a6bc8beb 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -1,22 +1,22 @@ -local builders = require "nvim-tree.explorer.node-builders" -local git = require "nvim-tree.git" -local log = require "nvim-tree.log" -local notify = require "nvim-tree.notify" -local utils = require "nvim-tree.utils" -local view = require "nvim-tree.view" -local watch = require "nvim-tree.explorer.watch" -local explorer_node = require "nvim-tree.explorer.node" - -local Iterator = require "nvim-tree.iterators.node-iterator" -local NodeIterator = require "nvim-tree.iterators.node-iterator" -local Watcher = require "nvim-tree.watcher" - -local Filters = require "nvim-tree.explorer.filters" -local Marks = require "nvim-tree.marks" -local LiveFilter = require "nvim-tree.explorer.live-filter" -local Sorters = require "nvim-tree.explorer.sorters" -local Clipboard = require "nvim-tree.actions.fs.clipboard" -local Renderer = require "nvim-tree.renderer" +local builders = require("nvim-tree.explorer.node-builders") +local git = require("nvim-tree.git") +local log = require("nvim-tree.log") +local notify = require("nvim-tree.notify") +local utils = require("nvim-tree.utils") +local view = require("nvim-tree.view") +local watch = require("nvim-tree.explorer.watch") +local explorer_node = require("nvim-tree.explorer.node") + +local Iterator = require("nvim-tree.iterators.node-iterator") +local NodeIterator = require("nvim-tree.iterators.node-iterator") +local Watcher = require("nvim-tree.watcher") + +local Filters = require("nvim-tree.explorer.filters") +local Marks = require("nvim-tree.marks") +local LiveFilter = require("nvim-tree.explorer.live-filter") +local Sorters = require("nvim-tree.explorer.sorters") +local Clipboard = require("nvim-tree.actions.fs.clipboard") +local Renderer = require("nvim-tree.renderer") local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON @@ -130,7 +130,7 @@ function Explorer:reload(node, git_status) break end - local abs = utils.path_join { cwd, name } + local abs = utils.path_join({ cwd, name }) ---@type uv.fs_stat.result|nil local stat = vim.loop.fs_lstat(abs) @@ -359,7 +359,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent) break end - local abs = utils.path_join { cwd, name } + local abs = utils.path_join({ cwd, name }) if Watcher.is_fs_event_capable(abs) then local profile = log.profile_start("populate_children %s", abs) diff --git a/lua/nvim-tree/explorer/live-filter.lua b/lua/nvim-tree/explorer/live-filter.lua index be2848969cc..7cdfc35dd80 100644 --- a/lua/nvim-tree/explorer/live-filter.lua +++ b/lua/nvim-tree/explorer/live-filter.lua @@ -1,6 +1,6 @@ -local view = require "nvim-tree.view" -local utils = require "nvim-tree.utils" -local Iterator = require "nvim-tree.iterators.node-iterator" +local view = require("nvim-tree.view") +local utils = require("nvim-tree.utils") +local Iterator = require("nvim-tree.iterators.node-iterator") ---@class LiveFilter ---@field explorer Explorer @@ -162,11 +162,11 @@ end local function create_overlay(self) if view.View.float.enable then -- don't close nvim-tree float when focus is changed to filter window - vim.api.nvim_clear_autocmds { + vim.api.nvim_clear_autocmds({ event = "WinLeave", pattern = "NvimTree_*", group = vim.api.nvim_create_augroup("NvimTree", { clear = false }), - } + }) end configure_buffer_overlay(self) @@ -180,14 +180,14 @@ local function create_overlay(self) style = "minimal", }) - if vim.fn.has "nvim-0.10" == 1 then + if vim.fn.has("nvim-0.10") == 1 then vim.api.nvim_set_option_value("modifiable", true, { buf = overlay_bufnr }) else vim.api.nvim_buf_set_option(overlay_bufnr, "modifiable", true) ---@diagnostic disable-line: deprecated end vim.api.nvim_buf_set_lines(overlay_bufnr, 0, -1, false, { self.filter }) - vim.cmd "startinsert" + vim.cmd("startinsert") vim.api.nvim_win_set_cursor(overlay_winnr, { 1, #self.filter + 1 }) end @@ -198,7 +198,7 @@ function LiveFilter:start_filtering() self.explorer.renderer:draw() local row = require("nvim-tree.core").get_nodes_starting_line() - 1 local col = #self.prefix > 0 and #self.prefix - 1 or 1 - view.set_cursor { row, col } + view.set_cursor({ row, col }) -- needs scheduling to let the cursor move before initializing the window vim.schedule(function() return create_overlay(self) diff --git a/lua/nvim-tree/explorer/node-builders.lua b/lua/nvim-tree/explorer/node-builders.lua index c9d5517c3d5..10e958168aa 100644 --- a/lua/nvim-tree/explorer/node-builders.lua +++ b/lua/nvim-tree/explorer/node-builders.lua @@ -1,5 +1,5 @@ -local utils = require "nvim-tree.utils" -local watch = require "nvim-tree.explorer.watch" +local utils = require("nvim-tree.utils") +local watch = require("nvim-tree.explorer.watch") local M = {} diff --git a/lua/nvim-tree/explorer/node.lua b/lua/nvim-tree/explorer/node.lua index 4380be542ff..27e31b131c5 100644 --- a/lua/nvim-tree/explorer/node.lua +++ b/lua/nvim-tree/explorer/node.lua @@ -177,7 +177,7 @@ function M.setup(opts) git = opts.git, } - git = require "nvim-tree.git" + git = require("nvim-tree.git") end return M diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index 3fa40c9d3b7..dd64a8a2efa 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -122,7 +122,7 @@ function Sorter:sort(t) absolute_path = n.absolute_path, executable = n.executable, extension = n.extension, - filetype = vim.filetype.match { filename = n.name }, + filetype = vim.filetype.match({ filename = n.name }), link_to = n.link_to, name = n.name, type = n.type, @@ -237,8 +237,8 @@ function C.suffix(a, b, cfg) end -- unsuffixed go third - local a_suffix_ndx = a.name:find "%.%w+$" - local b_suffix_ndx = b.name:find "%.%w+$" + local a_suffix_ndx = a.name:find("%.%w+$") + local b_suffix_ndx = b.name:find("%.%w+$") if not a_suffix_ndx and b_suffix_ndx then return true @@ -289,8 +289,8 @@ function C.extension(a, b, cfg) end function C.filetype(a, b, cfg) - local a_ft = vim.filetype.match { filename = a.name } - local b_ft = vim.filetype.match { filename = b.name } + local a_ft = vim.filetype.match({ filename = a.name }) + local b_ft = vim.filetype.match({ filename = b.name }) -- directories first local early_return = folders_or_files_first(a, b, cfg) diff --git a/lua/nvim-tree/explorer/watch.lua b/lua/nvim-tree/explorer/watch.lua index ad7b9254f73..317f3e54b7a 100644 --- a/lua/nvim-tree/explorer/watch.lua +++ b/lua/nvim-tree/explorer/watch.lua @@ -1,5 +1,5 @@ -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") local Watcher = require("nvim-tree.watcher").Watcher local M = { diff --git a/lua/nvim-tree/git/init.lua b/lua/nvim-tree/git/init.lua index f3a011c8bdd..caea8517a5e 100644 --- a/lua/nvim-tree/git/init.lua +++ b/lua/nvim-tree/git/init.lua @@ -1,10 +1,10 @@ -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" -local git_utils = require "nvim-tree.git.utils" -local Runner = require "nvim-tree.git.runner" +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") +local git_utils = require("nvim-tree.git.utils") +local Runner = require("nvim-tree.git.runner") local Watcher = require("nvim-tree.watcher").Watcher -local Iterator = require "nvim-tree.iterators.node-iterator" -local explorer_node = require "nvim-tree.explorer.node" +local Iterator = require("nvim-tree.iterators.node-iterator") +local explorer_node = require("nvim-tree.explorer.node") local M = { config = {}, @@ -243,12 +243,12 @@ function M.load_project_status(path) return status end - local git_status = Runner.run { + local git_status = Runner.run({ toplevel = toplevel, list_untracked = git_utils.should_show_untracked(toplevel), list_ignored = true, timeout = M.config.git.timeout, - } + }) local watcher = nil if M.config.filesystem_watchers.enable then @@ -264,7 +264,7 @@ function M.load_project_status(path) end) end - local git_dir = vim.env.GIT_DIR or M._git_dirs_by_toplevel[toplevel] or utils.path_join { toplevel, ".git" } + local git_dir = vim.env.GIT_DIR or M._git_dirs_by_toplevel[toplevel] or utils.path_join({ toplevel, ".git" }) watcher = Watcher:new(git_dir, WATCHED_FILES, callback, { toplevel = toplevel, }) diff --git a/lua/nvim-tree/git/runner.lua b/lua/nvim-tree/git/runner.lua index 7ec4ab6ddca..54d04438957 100644 --- a/lua/nvim-tree/git/runner.lua +++ b/lua/nvim-tree/git/runner.lua @@ -1,6 +1,6 @@ -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" -local notify = require "nvim-tree.notify" +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") +local notify = require("nvim-tree.notify") ---@class Runner local Runner = {} @@ -18,11 +18,11 @@ function Runner:_parse_status_output(status, path) end -- replacing slashes if on windows - if vim.fn.has "win32" == 1 then + if vim.fn.has("win32") == 1 then path = path:gsub("/", "\\") end if #status > 0 and #path > 0 then - self.output[utils.path_remove_trailing(utils.path_join { self.toplevel, path })] = status + self.output[utils.path_remove_trailing(utils.path_join({ self.toplevel, path }))] = status end end @@ -35,7 +35,7 @@ function Runner:_handle_incoming_data(prev_output, incoming) local prev = prev_output .. incoming local i = 1 local skip_next_line = false - for line in prev:gmatch "[^\n]*\n" do + for line in prev:gmatch("[^\n]*\n") do if skip_next_line then skip_next_line = false else @@ -57,7 +57,7 @@ function Runner:_handle_incoming_data(prev_output, incoming) return prev_output .. incoming end - for line in prev_output:gmatch "[^\n]*\n" do + for line in prev_output:gmatch("[^\n]*\n") do self:_parse_status_output(line) end @@ -79,7 +79,7 @@ end ---@param output string function Runner:_log_raw_output(output) - if log.enabled "git" and output and type(output) == "string" then + if log.enabled("git") and output and type(output) == "string" then log.raw("git", "%s", output) log.line("git", "done") end diff --git a/lua/nvim-tree/git/utils.lua b/lua/nvim-tree/git/utils.lua index d9f76bf8360..6a32b632e31 100644 --- a/lua/nvim-tree/git/utils.lua +++ b/lua/nvim-tree/git/utils.lua @@ -1,5 +1,5 @@ -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") local M = { use_cygpath = false, @@ -21,30 +21,30 @@ function M.get_toplevel(cwd) log.raw("git", out) log.profile_end(profile) - if vim.v.shell_error ~= 0 or not out or #out == 0 or out:match "fatal" then + if vim.v.shell_error ~= 0 or not out or #out == 0 or out:match("fatal") then return nil, nil end - local toplevel, git_dir = out:match "([^\n]+)\n+([^\n]+)" + local toplevel, git_dir = out:match("([^\n]+)\n+([^\n]+)") if not toplevel then return nil, nil end if not git_dir then - git_dir = utils.path_join { toplevel, ".git" } + git_dir = utils.path_join({ toplevel, ".git" }) end -- git always returns path with forward slashes - if vim.fn.has "win32" == 1 then + if vim.fn.has("win32") == 1 then -- msys2 git support -- cygpath calls must in array format to avoid shell compatibility issues if M.use_cygpath then - toplevel = vim.fn.system { "cygpath", "-w", toplevel } + toplevel = vim.fn.system({ "cygpath", "-w", toplevel }) if vim.v.shell_error ~= 0 then return nil, nil end -- remove trailing newline(\n) character added by vim.fn.system toplevel = toplevel:gsub("\n", "") - git_dir = vim.fn.system { "cygpath", "-w", git_dir } + git_dir = vim.fn.system({ "cygpath", "-w", git_dir }) if vim.v.shell_error ~= 0 then return nil, nil end @@ -128,7 +128,7 @@ end function M.setup(opts) if opts.git.cygwin_support then - M.use_cygpath = vim.fn.executable "cygpath" == 1 + M.use_cygpath = vim.fn.executable("cygpath") == 1 end end diff --git a/lua/nvim-tree/help.lua b/lua/nvim-tree/help.lua index 8d1d0e9eae0..ab4dfd85781 100644 --- a/lua/nvim-tree/help.lua +++ b/lua/nvim-tree/help.lua @@ -1,4 +1,4 @@ -local keymap = require "nvim-tree.keymap" +local keymap = require("nvim-tree.keymap") local api = {} -- circular dependency local PAT_MOUSE = "^<.*Mouse" @@ -27,12 +27,12 @@ local function tidy_lhs(lhs) lhs = lhs:gsub("^", "<") -- shorten ctrls - if lhs:lower():match "^ 0 then vim.api.nvim_set_current_win(vim.fn.win_getid(prev_win)) end @@ -264,7 +264,7 @@ function M.open(options) return end - local profile = log.profile_start "view open" + local profile = log.profile_start("view open") create_buffer() open_window() @@ -272,7 +272,7 @@ function M.open(options) local opts = options or { focus_tree = true } if not opts.focus_tree then - vim.cmd "wincmd p" + vim.cmd("wincmd p") end events._dispatch_on_tree_open() @@ -358,7 +358,7 @@ function M.resize(size) if new_size ~= vim.api.nvim_win_get_width(winnr) then vim.api.nvim_win_set_width(winnr, new_size) if not M.View.preserve_window_proportions then - vim.cmd ":wincmd =" + vim.cmd(":wincmd =") end end @@ -465,7 +465,7 @@ function M.winid(opts) if tabpage == 0 then tabpage = vim.api.nvim_get_current_tabpage() end - if M.is_visible { tabpage = tabpage } then + if M.is_visible({ tabpage = tabpage }) then return M.get_winnr(tabpage) else return nil @@ -514,7 +514,7 @@ function M._prevent_buffer_override() local curbuf = vim.api.nvim_win_get_buf(curwin) local bufname = vim.api.nvim_buf_get_name(curbuf) - if not bufname:match "NvimTree" then + if not bufname:match("NvimTree") then for i, tabpage in ipairs(M.View.tabpages) do if tabpage.winnr == view_winnr then M.View.tabpages[i] = nil @@ -528,9 +528,9 @@ function M._prevent_buffer_override() -- patch to avoid the overriding window to be fixed in size -- might need a better patch - vim.cmd "setlocal nowinfixwidth" - vim.cmd "setlocal nowinfixheight" - M.open { focus_tree = false } + vim.cmd("setlocal nowinfixwidth") + vim.cmd("setlocal nowinfixheight") + M.open({ focus_tree = false }) local explorer = require("nvim-tree.core").get_explorer() if explorer then diff --git a/lua/nvim-tree/watcher.lua b/lua/nvim-tree/watcher.lua index 92b3fbe4ae0..cad762e3dde 100644 --- a/lua/nvim-tree/watcher.lua +++ b/lua/nvim-tree/watcher.lua @@ -1,6 +1,6 @@ -local notify = require "nvim-tree.notify" -local log = require "nvim-tree.log" -local utils = require "nvim-tree.utils" +local notify = require("nvim-tree.notify") +local log = require("nvim-tree.log") +local utils = require("nvim-tree.utils") local M = { config = {}, @@ -79,7 +79,7 @@ function Event:start() rc, _, name = self._fs_event:start(self._path, FS_EVENT_FLAGS, event_cb) if rc ~= 0 then if name == "EMFILE" then - M.disable_watchers "fs.inotify.max_user_watches exceeded, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Troubleshooting" + M.disable_watchers("fs.inotify.max_user_watches exceeded, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Troubleshooting") else notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self._path, name)) end From 3b79bdccadb4c38b58a6bd56298f4820a814337e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Sep 2024 13:53:01 +1000 Subject: [PATCH 09/10] stylua -> EmmyLuaCodeStyle --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e95aff7be1..2a99bbe39f6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,11 +8,13 @@ See [Development](https://github.com/nvim-tree/nvim-tree.lua/wiki/Development) f Following are used during CI and strongly recommended during local development. +Language server: [luals](https://luals.github.io) + Lint: [luacheck](https://github.com/lunarmodules/luacheck/) -Style: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle) (`CodeCheck`) +Style: [EmmyLuaCodeStyle](https://github.com/CppCXY/EmmyLuaCodeStyle): `CodeCheck` -Language server: [luals](https://luals.github.io) +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 You can install them via you OS package manager e.g. `pacman`, `brew` or other via other package managers such as `cargo` or `luarocks` From bc8b906e93c5543e6017e9169d77cd3629c1c77e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 29 Sep 2024 14:04:29 +1000 Subject: [PATCH 10/10] stylua -> EmmyLuaCodeStyle --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1cc8a1a815..feac234f786 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: strategy: matrix: - emmy_lua_code_style_version: [ 1.5.5 ] + emmy_lua_code_style_version: [ 1.5.6 ] steps: - uses: actions/checkout@v4