diff --git a/.github/workflows/.luarc-5.1.json b/.github/workflows/.luarc-5.1.json index d3a9194a0..71bf1a09d 100644 --- a/.github/workflows/.luarc-5.1.json +++ b/.github/workflows/.luarc-5.1.json @@ -7,27 +7,26 @@ "version": "LuaJIT", "path": [ "lua/?.lua", - "lua/?/init.lua", - "library/?.lua", - "library/?/init.lua" + "lua/?/init.lua" ] }, "workspace": { "checkThirdParty": "Disable", "library": [ + "$VIMRUNTIME", "$PWD/.dependencies/pack/vendor/start/plenary.nvim", "$PWD/.dependencies/pack/vendor/start/nui.nvim", "$PWD/.dependencies/pack/vendor/start/nvim-web-devicons", + "$PWD/.dependencies/pack/vendor/start/image.nvim", "$PWD/.dependencies/pack/vendor/start/snacks.nvim", - "${3rd}/luassert", - "${3rd}/busted", - "${3rd}/luv", - "$VIMRUNTIME" + "$PWD/.dependencies/pack/vendor/start/nvim-window-picker" ], "ignoreDir": [ ".dependencies", ".luarocks", - ".lua" + ".lua", + ".repro", + "tests" ] } } diff --git a/.github/workflows/.luarc-luajit-master.json b/.github/workflows/.luarc-luajit-master.json index d3a9194a0..71bf1a09d 100644 --- a/.github/workflows/.luarc-luajit-master.json +++ b/.github/workflows/.luarc-luajit-master.json @@ -7,27 +7,26 @@ "version": "LuaJIT", "path": [ "lua/?.lua", - "lua/?/init.lua", - "library/?.lua", - "library/?/init.lua" + "lua/?/init.lua" ] }, "workspace": { "checkThirdParty": "Disable", "library": [ + "$VIMRUNTIME", "$PWD/.dependencies/pack/vendor/start/plenary.nvim", "$PWD/.dependencies/pack/vendor/start/nui.nvim", "$PWD/.dependencies/pack/vendor/start/nvim-web-devicons", + "$PWD/.dependencies/pack/vendor/start/image.nvim", "$PWD/.dependencies/pack/vendor/start/snacks.nvim", - "${3rd}/luassert", - "${3rd}/busted", - "${3rd}/luv", - "$VIMRUNTIME" + "$PWD/.dependencies/pack/vendor/start/nvim-window-picker" ], "ignoreDir": [ ".dependencies", ".luarocks", - ".lua" + ".lua", + ".repro", + "tests" ] } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 237ae7336..f34232f42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,13 +2,13 @@ name: CI on: push: branches: - - main - - v1.x - - v2.x - - v3.x + - "*" pull_request: workflow_dispatch: +env: + MISE_AUTO_INSTALL: "false" + jobs: stylua-check: runs-on: ubuntu-latest @@ -27,21 +27,23 @@ jobs: strategy: fail-fast: false matrix: - rev: ["0.8", "0.9", "0.10", "0.11"] + neovim: ["0.8", "0.9", "0.10", "0.11"] os: [ubuntu-22.04] include: - - rev: "latest" + - neovim: "latest" os: [windows-latest] steps: - uses: actions/checkout@v4 - - uses: jdx/mise-action@v2 + - name: "Install neovim and other deps" + uses: jdx/mise-action@v2 with: install: true # [default: true] run `mise install` - install_args: "neovim@${{matrix.rev}}" # [default: ""] additional arguments to `mise install` - - run: | - mise use neovim@${{matrix.rev}} - make setup - make test + install_args: "neovim@${{matrix.neovim}}" # [default: ""] additional arguments to `mise install` + - name: "Run tests" + run: | + mise use neovim@${{matrix.neovim}} + mise deps + mise test # - name: Upload coverage to Codecov # uses: codecov/codecov-action@v2 diff --git a/.github/workflows/emmylua-check.yml b/.github/workflows/emmylua-check.yml new file mode 100644 index 000000000..085890b83 --- /dev/null +++ b/.github/workflows/emmylua-check.yml @@ -0,0 +1,37 @@ +name: EmmyLua Analyzer Diagnostics +on: + pull_request: ~ + push: + branches: + - '*' + +env: + MISE_AUTO_INSTALL_DISABLE_TOOLS: lua-language-server + +jobs: + luals-check: + strategy: + matrix: + neovim: ["nightly"] + lua: ["luajit-master", "5.1"] + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: luarocks/gh-actions-lua@v10 + with: + luaVersion: ${{matrix.lua}} + + - name: Install tools + uses: jdx/mise-action@v2 + with: + install_args: "github:neovim/neovim@nightly" + + - name: Run emmylua_check + continue-on-error: true + run: | + mise use github:neovim/neovim@nightly + mise run deps + NEOTREE_LUARC=".github/workflows/.luarc-${{ matrix.lua }}.json" mise run emmylua-check diff --git a/.github/workflows/luals-check.yml b/.github/workflows/luals-check.yml index ea521523c..a3deddea1 100644 --- a/.github/workflows/luals-check.yml +++ b/.github/workflows/luals-check.yml @@ -5,12 +5,15 @@ on: branches: - '*' +env: + MISE_AUTO_INSTALL_DISABLE_TOOLS: cargo-binstall,cargo:emmylua_ls,cargo:emmylua_check + jobs: luals-check: strategy: matrix: - neovim: ["0.11"] - lua: ["5.1", "luajit-master"] + neovim: ["nightly"] + lua: ["luajit-master", "5.1"] runs-on: ubuntu-latest steps: @@ -21,24 +24,13 @@ jobs: with: luaVersion: ${{matrix.lua}} - - name: Install lua-language-server + - name: Install tools uses: jdx/mise-action@v2 with: - mise_toml: | - [tools] - neovim = "${{ matrix.neovim }}" - cargo-binstall = "latest" - "cargo:emmylua_check" = "latest" - "cargo:emmylua_ls" = "latest" - lua-language-server = "3.13.9" + install_args: "github:neovim/neovim@${{matrix.neovim}}" - name: Run lua-language-server check run: | - LUARC=".github/workflows/.luarc-${{ matrix.lua }}.json" - make luals-check CONFIGURATION="$LUARC" - - - name: Run emmylua_check - continue-on-error: true # Doesn't type-check well enough to be worth erroring on, but this runs so fast we might as well help test this out. - run: | - LUARC=".github/workflows/.luarc-${{ matrix.lua }}.json" - make emmylua-check CONFIGURATION="$LUARC" + mise use github:neovim/neovim@${{matrix.neovim}} + mise run deps + NEOTREE_LUARC=".github/workflows/.luarc-${{ matrix.lua }}.json" mise run luals-check diff --git a/.luarc.json b/.luarc.json index ebec32bf1..04e870411 100644 --- a/.luarc.json +++ b/.luarc.json @@ -4,31 +4,29 @@ "libraryFiles": "Disable" }, "runtime": { - "version": "LuaJIT", + "version": "Lua 5.1", "path": [ "lua/?.lua", - "lua/?/init.lua", - "library/?.lua", - "library/?/init.lua" + "lua/?/init.lua" ] }, "workspace": { "checkThirdParty": "Disable", "library": [ + "$VIMRUNTIME", "$PWD/.dependencies/pack/vendor/start/plenary.nvim", "$PWD/.dependencies/pack/vendor/start/nui.nvim", "$PWD/.dependencies/pack/vendor/start/nvim-web-devicons", + "$PWD/.dependencies/pack/vendor/start/image.nvim", "$PWD/.dependencies/pack/vendor/start/snacks.nvim", - "${3rd}/luassert", - "${3rd}/busted", - "${3rd}/luv", - "$VIMRUNTIME" + "$PWD/.dependencies/pack/vendor/start/nvim-window-picker" ], "ignoreDir": [ ".dependencies", ".luarocks", ".lua", - ".repro" + ".repro", + "tests" ] } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c043c7a2..bb5e044aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,32 @@ Contributions are welcome! To keep everything clean and tidy, please follow the guidelines below. +# Development setup + +View [mise.toml](./mise.toml) for tasks and their implementation. + +```bash +# Install/update dependencies +mise deps +# Or `mise update-dependencies` + +# Run stylua +mise format + +# Do a lua-language-server pass +mise luals-check + +# Do a emmylua-analyzer-rust pass (not important for now) +mise luals-check + +# Tests +mise test + +# Tests in Docker (for better sandboxing) +mise test-docker + +``` + ## Code Style This is open for debate, but here is the current style choices being observed: @@ -12,9 +38,6 @@ This is open for debate, but here is the current style choices being observed: - other OOP things, like method names should use camelCase - BUT we don't currently have any OOP parts and I don't think we want any -I prefer `local name = function()` over `local function name()`, just to be -consistent with the `M.name = function()` exports. - ### StyLua We use (StyLua)[https://github.com/JohnnyMorganz/StyLua] to enforce consistency @@ -50,10 +73,10 @@ current strategy is to maintain: in comments. This is the bare minimum documentation for an option. - The README contains "back of the box" high level overview of features. It is meant for people trying to decide if they want to install this plugin or not. - It should include references to the help file for more information: + It should include references to the help file for more information: `:h neo-tree-setup` - Whether something should be mentioned in the README or just in the help file - is a completely subjective judement call that is made on a case by case basis + is a completely subjective judgement call that is made on a case by case basis based on how many people are likely to be interested in that information. - The vim help file [doc/neo-tree.txt](doc/neo-tree.txt) is the definitive reference and should contain all information needed to configure and use the diff --git a/Makefile b/Makefile deleted file mode 100644 index 0dc509ab8..000000000 --- a/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -.PHONY: test -test: - nvim --headless --noplugin -u tests/mininit.lua -c "lua require('plenary.test_harness').test_directory('tests/neo-tree/', {minimal_init='tests/mininit.lua', sequential=true})" - -.PHONY: test-docker -test-docker: - docker build -t neo-tree . - docker run --rm neo-tree make test - -.PHONY: format -format: - stylua --glob '*.lua' --glob '!defaults.lua' . - -# Dependencies: - -DEPS := ${CURDIR}/.dependencies/pack/vendor/start - -$(DEPS): - mkdir -p "$(DEPS)" - -$(DEPS)/nui.nvim: $(DEPS) - @test -d "$(DEPS)/nui.nvim" || git clone https://github.com/MunifTanjim/nui.nvim "$(DEPS)/nui.nvim" - -$(DEPS)/nvim-web-devicons: $(DEPS) - @test -d "$(DEPS)/nvim-web-devicons" || git clone https://github.com/nvim-tree/nvim-web-devicons "$(DEPS)/nvim-web-devicons" - -$(DEPS)/plenary.nvim: $(DEPS) - @test -d "$(DEPS)/plenary.nvim" || git clone https://github.com/nvim-lua/plenary.nvim "$(DEPS)/plenary.nvim" - -$(DEPS)/snacks.nvim: $(DEPS) - @test -d "$(DEPS)/snacks.nvim" || git clone https://github.com/folke/snacks.nvim "$(DEPS)/snacks.nvim" - -setup: $(DEPS)/nui.nvim $(DEPS)/nvim-web-devicons $(DEPS)/plenary.nvim $(DEPS)/snacks.nvim - @echo "[setup] environment ready" - -.PHONY: clean -clean: - rm -rf "$(DEPS)" - -CONFIGURATION = ${CURDIR}/.luarc.json -luals-check: setup - VIMRUNTIME="`nvim --clean --headless --cmd 'lua io.write(vim.env.VIMRUNTIME)' --cmd 'quit'`" lua-language-server --configpath=$(CONFIGURATION) --check=. - -emmylua-check: setup - VIMRUNTIME="`nvim --clean --headless --cmd 'lua io.write(vim.env.VIMRUNTIME)' --cmd 'quit'`" emmylua_check -c $(CONFIGURATION) -i ".dependencies/**" -- . diff --git a/lua/neo-tree/git/init.lua b/lua/neo-tree/git/init.lua index a8f9a6714..34f767bda 100644 --- a/lua/neo-tree/git/init.lua +++ b/lua/neo-tree/git/init.lua @@ -307,7 +307,7 @@ M._parse_porcelain = function( renamed, copied, }) do - require("neo-tree.utils._compat").table_move( + require("neo-tree.utils._compat").luajit.table_move( list, 1, #list, diff --git a/lua/neo-tree/sources/common/commands.lua b/lua/neo-tree/sources/common/commands.lua index 0e5671101..f3b0c86ea 100644 --- a/lua/neo-tree/sources/common/commands.lua +++ b/lua/neo-tree/sources/common/commands.lua @@ -968,7 +968,7 @@ local use_window_picker = function(state, path, cmd) events.fire_event(events.FILE_OPENED, path) return end - local picked_window_id = picker.pick_window() + local picked_window_id = picker.pick_window({}) if picked_window_id then vim.api.nvim_set_current_win(picked_window_id) ---@diagnostic disable-next-line: param-type-mismatch diff --git a/lua/neo-tree/sources/filesystem/lib/fs_scan.lua b/lua/neo-tree/sources/filesystem/lib/fs_scan.lua index ae4c20d14..30cf9a775 100644 --- a/lua/neo-tree/sources/filesystem/lib/fs_scan.lua +++ b/lua/neo-tree/sources/filesystem/lib/fs_scan.lua @@ -201,8 +201,6 @@ local function get_children_async(path, callback) return end local readdir_batch - ---@param _ string? - ---@param stats uv.fs_readdir.entry[] readdir_batch = function(_, stats) if stats then local more = false diff --git a/lua/neo-tree/types/fixes/uv.lua b/lua/neo-tree/types/fixes/uv.lua index 0b209fa99..e2e422c84 100644 --- a/lua/neo-tree/types/fixes/uv.lua +++ b/lua/neo-tree/types/fixes/uv.lua @@ -2,24 +2,84 @@ ---A series of edited backports from neovim's 0.12 type files since lua-ls has incorrect types. ---@class uv ----@field constants {O_RDONLY: integer, O_WRONLY: integer, O_RDWR: integer, O_APPEND: integer, O_CREAT: integer, O_DSYNC: integer, O_EXCL: integer, O_NOCTTY: integer, O_NONBLOCK: integer, O_RSYNC: integer, O_SYNC: integer, O_TRUNC: integer, SOCK_STREAM: integer, SOCK_DGRAM: integer, SOCK_SEQPACKET: integer, SOCK_RAW: integer, SOCK_RDM: integer, AF_UNIX: integer, AF_INET: integer, AF_INET6: integer, AF_IPX: integer, AF_NETLINK: integer, AF_X25: integer, AF_AX25: integer, AF_ATMPVC: integer, AF_APPLETALK: integer, AF_PACKET: integer, AI_ADDRCONFIG: integer, AI_V4MAPPED: integer, AI_ALL: integer, AI_NUMERICHOST: integer, AI_PASSIVE: integer, AI_NUMERICSERV: integer, SIGHUP: integer, SIGINT: integer, SIGQUIT: integer, SIGILL: integer, SIGTRAP: integer, SIGABRT: integer, SIGIOT: integer, SIGBUS: integer, SIGFPE: integer, SIGKILL: integer, SIGUSR1: integer, SIGSEGV: integer, SIGUSR2: integer, SIGPIPE: integer, SIGALRM: integer, SIGTERM: integer, SIGCHLD: integer, SIGSTKFLT: integer, SIGCONT: integer, SIGSTOP: integer, SIGTSTP: integer, SIGTTIN: integer, SIGWINCH: integer, SIGIO: integer, SIGPOLL: integer, SIGXFSZ: integer, SIGVTALRM: integer, SIGPROF: integer, UDP_RECVMMSG: integer, UDP_MMSG_CHUNK: integer, UDP_REUSEADDR: integer, UDP_PARTIAL: integer, UDP_IPV6ONLY: integer, TCP_IPV6ONLY: integer, UDP_MMSG_FREE: integer, SIGSYS: integer, SIGPWR: integer, SIGTTOU: integer, SIGURG: integer, SIGXCPU: integer} local uv = {} +uv.constants = {} + +--- # Address Families +uv.constants.AF_UNIX = "unix" +uv.constants.AF_INET = "inet" +uv.constants.AF_INET6 = "inet6" +uv.constants.AF_IPX = "ipx" +uv.constants.AF_NETLINK = "netlink" +uv.constants.AF_X25 = "x25" +uv.constants.AF_AX25 = "as25" +uv.constants.AF_ATMPVC = "atmpvc" +uv.constants.AF_APPLETALK = "appletalk" +uv.constants.AF_PACKET = "packet" + +--- # Signals +uv.constants.SIGHUP = "sighup" +uv.constants.SIGINT = "sigint" +uv.constants.SIGQUIT = "sigquit" +uv.constants.SIGILL = "sigill" +uv.constants.SIGTRAP = "sigtrap" +uv.constants.SIGABRT = "sigabrt" +uv.constants.SIGIOT = "sigiot" +uv.constants.SIGBUS = "sigbus" +uv.constants.SIGFPE = "sigfpe" +uv.constants.SIGKILL = "sigkill" +uv.constants.SIGUSR1 = "sigusr1" +uv.constants.SIGSEGV = "sigsegv" +uv.constants.SIGUSR2 = "sigusr2" +uv.constants.SIGPIPE = "sigpipe" +uv.constants.SIGALRM = "sigalrm" +uv.constants.SIGTERM = "sigterm" +uv.constants.SIGCHLD = "sigchld" +uv.constants.SIGSTKFLT = "sigstkflt" +uv.constants.SIGCONT = "sigcont" +uv.constants.SIGSTOP = "sigstop" +uv.constants.SIGTSTP = "sigtstp" +uv.constants.SIGBREAK = "sigbreak" +uv.constants.SIGTTIN = "sigttin" +uv.constants.SIGTTOU = "sigttou" +uv.constants.SIGURG = "sigurg" +uv.constants.SIGXCPU = "sigxcpu" +uv.constants.SIGXFSZ = "sigxfsz" +uv.constants.SIGVTALRM = "sigvtalrm" +uv.constants.SIGPROF = "sigprof" +uv.constants.SIGWINCH = "sigwinch" +uv.constants.SIGIO = "sigio" +uv.constants.SIGPOLL = "sigpoll" +uv.constants.SIGLOST = "siglost" +uv.constants.SIGPWR = "sigpwr" +uv.constants.SIGSYS = "sigsys" + +--- # Socket Types +uv.constants.SOCK_STREAM = "stream" +uv.constants.SOCK_DGRAM = "dgram" +uv.constants.SOCK_SEQPACKET = "seqpacket" +uv.constants.SOCK_RAW = "raw" +uv.constants.SOCK_RDM = "rdm" + +--- # TTY Modes +uv.constants.TTY_MODE_NORMAL = "normal" +uv.constants.TTY_MODE_RAW = "raw" +uv.constants.TTY_MODE_IO = "io" +uv.constants.TTY_MODE_RAW_VT = "raw_vt" + +--- # FS Modification Times +uv.constants.FS_UTIME_NOW = "now" +uv.constants.FS_UTIME_OMIT = "omit" + --- Opens path as a directory stream. Returns a handle that the user can pass to --- `uv.fs_readdir()`. The `entries` parameter defines the maximum number of entries --- that should be returned by each call to `uv.fs_readdir()`. --- @param path string +--- @param callback nil (async if provided, sync if `nil`) --- @param entries integer? --- @return uv.luv_dir_t? dir --- @return string? err ---- @return string? err_name +--- @return uv.error_name? err_name --- @overload fun(path: string, callback: fun(err: string?, dir: uv.luv_dir_t?), entries: integer?): uv.uv_fs_t -function uv.fs_opendir(path, entries) end - ---- Equivalent to `lstat(2)`. ---- @param path string ---- @return uv.fs_stat.result? stat ---- @return string? err ---- @return string? err_name ---- @overload fun(path: string, callback: fun(err: string?, stat: uv.fs_stat.result?)): uv.uv_fs_t -function uv.fs_lstat(path) end +function uv.fs_opendir(path, callback, entries) end diff --git a/lua/neo-tree/utils/_compat.lua b/lua/neo-tree/utils/_compat.lua index 13b1e24e3..7e6adc744 100644 --- a/lua/neo-tree/utils/_compat.lua +++ b/lua/neo-tree/utils/_compat.lua @@ -26,8 +26,10 @@ local table_move = function(a1, f, e, t, a2) return a2 end ----source: -compat.table_move = table.move or table_move + +compat.luajit = {} +---@diagnostic disable-next-line: deprecated +compat.luajit.table_move = table.move or table_move ---@vararg any local table_pack = function(...) @@ -37,7 +39,11 @@ local table_pack = function(...) t.n = #t return t end -compat.table_pack = table.pack or table_pack + +---@diagnostic disable-next-line: deprecated +compat.luajit.table_pack = table.pack or function(...) + return { n = select("#", ...), ... } +end --- Split a Windows path into a prefix and a body, such that the body can be processed like a POSIX --- path. The path must use forward slashes as path separator. diff --git a/lua/neo-tree/utils/init.lua b/lua/neo-tree/utils/init.lua index bf10858b6..4c22262d6 100644 --- a/lua/neo-tree/utils/init.lua +++ b/lua/neo-tree/utils/init.lua @@ -52,10 +52,7 @@ local diag_severity_to_string = function(severity) end end --- Backwards compatibility -M.pack = table.pack or function(...) - return { n = select("#", ...), ... } -end +M.pack = compat.luajit.table_pack local tracked_functions = {} ---@enum neotree.utils.DebounceStrategy diff --git a/mise.toml b/mise.toml index 4e8b2ba14..3c2b5ea19 100644 --- a/mise.toml +++ b/mise.toml @@ -1,5 +1,140 @@ +[settings] +windows_default_inline_shell_args = "powershell -NoProfile -NoLogo -Command" +[env] +NEOTREE_LUARC = ".luarc.json" + [tools] +lua-language-server = "3.15" cargo-binstall = "latest" -"cargo:emmylua_check" = "latest" "cargo:emmylua_ls" = "latest" -lua-language-server = "latest" +"cargo:emmylua_check" = "latest" +"github:EmmyLuaLs/emmylua-analyzer-rust" = "latest" + +[tasks.test] +run = """ +nvim --headless --noplugin -u tests/mininit.lua -c "lua require('plenary.test_harness').test_directory('tests/neo-tree/', {minimal_init='tests/mininit.lua'})" +""" + +[tasks.test-docker] +run = [ + "docker build -t neo-tree .", + "docker run --rm neo-tree mise test" +] + +[tasks.format] +run = "stylua --glob '*.lua' --glob '!defaults.lua' ." + +[vars] +deps_dir = '.dependencies/pack/vendor/start' + +[tasks.update-dependencies] +alias = 'deps' +run = """ +#!/usr/bin/env bash +update() { + local git_url="$1" + local repo_name="$2" + + mkdir -p "{{vars.deps_dir}}" + + local target_dir="{{vars.deps_dir}}/$repo_name" + if [ -d "$target_dir" ]; then + echo "==> Directory '$target_dir' exists. Updating $repo_name..." + git -C $target_dir fetch --tags -f + git -C $target_dir pull + + # Check the exit code of the subshell command + if [ $? -ne 0 ]; then + echo "Error: Failed to pull updates for '$repo_name'." >&2 + return 1 + fi + echo "==> Successfully updated '$repo_name'." + + else + echo "==> Directory '$target_dir' not found. Cloning repository..." + git clone "$git_url" "$target_dir" + + if [ $? -ne 0 ]; then + echo "Error: Failed to clone '$git_url'." >&2 + return 1 + fi + echo "==> Successfully cloned '$repo_name'." + fi +} +update https://github.com/3rd/image.nvim image.nvim +update https://github.com/folke/snacks.nvim snacks.nvim +update https://github.com/MunifTanjim/nui.nvim nui.nvim +update https://github.com/nvim-tree/nvim-web-devicons nvim-web-devicons +update https://github.com/nvim-lua/plenary.nvim plenary.nvim +update https://github.com/s1n7ax/nvim-window-picker nvim-window-picker +""" +run_windows = """ +function Update-Repository { + param( + [Parameter(Mandatory=$true)] + [string]$GitUrl, + [Parameter(Mandatory=$true)] + [string]$RepoName + ) + + # Ensure the parent directory exists + $DepsDir = "{{vars.deps_dir}}" + if (-not (Test-Path -Path $DepsDir -PathType Container)) { + Write-Host "==> Creating dependency directory '$DepsDir'..." + New-Item -Path $DepsDir -ItemType Directory | Out-Null + } + + $TargetDir = Join-Path -Path $DepsDir -ChildPath $RepoName + + if (Test-Path -Path $TargetDir -PathType Container) { + Write-Host "==> Directory '$TargetDir' exists. Updating $RepoName..." + git -C $TargetDir fetch --tags -f + git -C $TargetDir pull | Out-Null 2>&1 + } else { + Write-Host "==> Directory '$TargetDir' not found. Cloning repository '$GitUrl'..." + git clone $GitUrl $TargetDir + $cloneExitCode = $LASTEXITCODE + Write-Host "==> Successfully cloned '$RepoName'." + } +} + +## 🛠️ Repository Update Calls + +# Call the function for each repository +Update-Repository -GitUrl "https://github.com/3rd/image.nvim" -RepoName "image.nvim" +Update-Repository -GitUrl "https://github.com/folke/snacks.nvim" -RepoName "snacks.nvim" +Update-Repository -GitUrl "https://github.com/MunifTanjim/nui.nvim" -RepoName "nui.nvim" +Update-Repository -GitUrl "https://github.com/nvim-tree/nvim-web-devicons" -RepoName "nvim-web-devicons" +Update-Repository -GitUrl "https://github.com/nvim-lua/plenary.nvim" -RepoName "plenary.nvim" +Update-Repository -GitUrl "https://github.com/s1n7ax/nvim-window-picker" -RepoName "nvim-window-picker" +""" + +[tasks.luals-check] +run = """ +#!/usr/bin/env bash +VIMRUNTIME_PATH=$(nvim --clean --headless --cmd 'lua io.write(vim.env.VIMRUNTIME)' --cmd 'qa') +VIMRUNTIME="${VIMRUNTIME_PATH}" lua-language-server --configpath=$NEOTREE_LUARC --check=. +""" +run_windows = """ +$env:VIMRUNTIME = (nvim --clean --headless --cmd 'lua io.write(vim.env.VIMRUNTIME)' --cmd 'qa') +lua-language-server --configpath=$env:NEOTREE_LUARC --check . +""" +wait_for = ['deps'] + +[tasks.emmylua-check] +run = """ +#!/usr/bin/env bash +VIMRUNTIME_PATH=$(nvim --clean --headless --cmd 'lua io.write(vim.env.VIMRUNTIME)' --cmd 'quit') +VIMRUNTIME="${VIMRUNTIME_PATH}" emmylua_check -c $NEOTREE_LUARC -i ".dependencies/**" -- . +""" +run_windows = """ +$env:VIMRUNTIME = (nvim --clean --headless --cmd 'lua io.write(vim.env.VIMRUNTIME)' --cmd 'quit') +$env:PWD = Get-Location +emmylua_check -c $env:NEOTREE_LUARC -i ".dependencies/**" -- . +""" +wait_for = ['deps'] + +[tasks.clean] +run = [ + "rm {{vars.deps_dir}} -rf" +] diff --git a/plugin/neo-tree.lua b/plugin/neo-tree.lua index c1ac52f87..b341e228e 100644 --- a/plugin/neo-tree.lua +++ b/plugin/neo-tree.lua @@ -59,6 +59,7 @@ vim.api.nvim_create_autocmd({ "WinEnter" }, { -- prune history local win_count = #tab_windows if win_count > 100 then + ---@diagnostic disable-next-line: deprecated if table.move then utils.prior_windows[tabid] = require("neo-tree.utils._compat").table_move(tab_windows, 80, win_count, 1, {}) diff --git a/release.sh b/release.sh index 2053009cf..4ca9fce76 100755 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash REPO="nvim-neo-tree/neo-tree.nvim" LAST_VERSION=$(curl --silent "https://api.github.com/repos/$REPO/releases/latest" | jq -r .tag_name) echo "LAST_VERSION=$LAST_VERSION" diff --git a/tests/.luarc.json b/tests/.luarc.json new file mode 100644 index 000000000..f0b4da8c2 --- /dev/null +++ b/tests/.luarc.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "diagnostics": { + "libraryFiles": "Disable" + }, + "runtime": { + "version": "LuaJIT", + "path": [ + "?.lua", + "?/init.lua" + ] + }, + "workspace": { + "checkThirdParty": "Disable", + "library": [ + "$VIMRUNTIME/lua", + "${3rd}/luassert/library", + "${3rd}/busted/library", + "../lua", + "../tests", + "../.dependencies/pack/vendor/start/plenary.nvim/lua", + "../.dependencies/pack/vendor/start/nui.nvim/lua", + "../.dependencies/pack/vendor/start/nvim-web-devicons/lua", + "../.dependencies/pack/vendor/start/image.nvim/lua", + "../.dependencies/pack/vendor/start/snacks.nvim/lua", + "../.dependencies/pack/vendor/start/nvim-window-picker/lua" + ], + "ignoreDir": [ + ".dependencies", + ".luarocks", + ".lua", + ".repro" + ] + } +} diff --git a/tests/neo-tree/clipboard/sync_spec.lua b/tests/neo-tree/clipboard/sync_spec.lua index 2f39fbea8..ce71a9c6d 100644 --- a/tests/neo-tree/clipboard/sync_spec.lua +++ b/tests/neo-tree/clipboard/sync_spec.lua @@ -39,7 +39,7 @@ describe("Clipboard sync", function() vim.cmd("Neotree") u.wait_for_neo_tree() - local state = verify.get_state() + local state = assert(verify.get_state()) local wait1 = u.changedtick_waiter() u.feedkeys("y") wait1() @@ -48,7 +48,7 @@ describe("Clipboard sync", function() vim.cmd("tabnew") vim.cmd("Neotree") u.wait_for_neo_tree() - local other_state = verify.get_state() + local other_state = assert(verify.get_state()) assert(next(other_state.clipboard)) local wait2 = u.changedtick_waiter(0, 1) u.feedkeys("y") diff --git a/tests/neo-tree/command/command_current_spec.lua b/tests/neo-tree/command/command_current_spec.lua index e53298864..7b7410e0c 100644 --- a/tests/neo-tree/command/command_current_spec.lua +++ b/tests/neo-tree/command/command_current_spec.lua @@ -17,7 +17,9 @@ end local run_close_command = function(command) vim.cmd(command) - u.wait_for(function() end, { interval = 200, timeout = 200 }) + u.wait_for(function() + return false + end, { interval = 200, timeout = 200 }) end describe("Command", function() diff --git a/tests/neo-tree/command/command_spec.lua b/tests/neo-tree/command/command_spec.lua index 2fad4899f..e4a1fa622 100644 --- a/tests/neo-tree/command/command_spec.lua +++ b/tests/neo-tree/command/command_spec.lua @@ -40,7 +40,9 @@ end local run_close_command = function(command) vim.cmd(command) - u.wait_for(function() end, { interval = 200, timeout = 200 }) + u.wait_for(function() + return false + end, { interval = 200, timeout = 200 }) end describe("Command", function() diff --git a/tests/utils/init.lua b/tests/utils/init.lua index b0cb24bb8..aadbf7d2c 100644 --- a/tests/utils/init.lua +++ b/tests/utils/init.lua @@ -174,7 +174,7 @@ function mod.assert_highlight(bufnr, ns_id, linenr, text, hl_group) mod.assert_extmark(extmarks[1], linenr, text, hl_group) end ----@param callback fun(): boolean +---@param callback fun():boolean ---@param options? { interval?: integer, timeout?: integer } function mod.wait_for(callback, options) options = options or {}