Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 9 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,19 @@ jobs:
strategy:
fail-fast: false
matrix:
rev: ["0.8", "0.9", "0.10", "0.11"]
os: [ubuntu-22.04]
include:
- os: ubuntu-22.04
rev: nightly/nvim-linux-x86_64.tar.gz
- os: ubuntu-22.04
rev: v0.8.3/nvim-linux64.tar.gz
- os: ubuntu-22.04
rev: v0.9.5/nvim-linux64.tar.gz
- os: ubuntu-22.04
rev: v0.10.4/nvim-linux-x86_64.tar.gz
- rev: "latest"
os: [windows-latest]
steps:
- uses: actions/checkout@v4
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v4
- uses: jdx/mise-action@v2
with:
path: build
key: ${{ runner.os }}-${{ matrix.rev }}-${{ hashFiles('todays-date') }}
- name: Prepare
run: |
test -d build || {
mkdir -p build
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}" | tar xzf - --strip-components=1 -C "${PWD}/build"
}

# - name: Get Luver Cache Key
# id: luver-cache-key
# env:
# CI_RUNNER_OS: ${{ runner.os }}
# run: |
# echo "::set-output name=value::${CI_RUNNER_OS}-luver-v1-$(date -u +%Y-%m-%d)"
# shell: bash
# - name: Setup Luver Cache
# uses: actions/cache@v2
# with:
# path: ~/.local/share/luver
# key: ${{ steps.luver-cache-key.outputs.value }}

# - name: Setup Lua
# uses: MunifTanjim/luver-action@v1
# with:
# default: 5.1.5
# lua_versions: 5.1.5
# luarocks_versions: 5.1.5:3.8.0
# - name: Setup luacov
# run: |
# luarocks install luacov

- name: Run tests
run: |
export PATH="${PWD}/build/bin:${PATH}"
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

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.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})"
nvim --headless --noplugin -u tests/mininit.lua -c "lua require('plenary.test_harness').test_directory('tests/neo-tree/', {minimal_init='tests/mininit.lua'})"

.PHONY: test-docker
test-docker:
Expand Down
3 changes: 0 additions & 3 deletions lua/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ end

M.paste_default_config = function()
local utils = require("neo-tree.utils")
---@type string
local base_path = assert(debug.getinfo(utils.truthy).source:match("@(.*)/utils/init.lua$"))
---@type string
local config_path = base_path .. utils.path_separator .. "defaults.lua"
---@type string[]?
local lines = vim.fn.readfile(config_path)
if lines == nil then
error("Could not read neo-tree.defaults")
Expand Down
4 changes: 1 addition & 3 deletions lua/neo-tree/command/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ end
---@param path string
---@param validate_type string?
M.resolve_path = function(path, validate_type)
path = vim.fs.normalize(path)
local expanded = vim.fn.expand(path)
local abs_path = vim.fn.fnamemodify(expanded, ":p")
local abs_path = utils.path_join(vim.fn.getcwd(), path)
if validate_type then
local stat = uv.fs_stat(abs_path)
if not stat or stat.type ~= validate_type then
Expand Down
12 changes: 6 additions & 6 deletions lua/neo-tree/sources/common/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -686,14 +686,14 @@ end

---@param config neotree.Component.Common.SymlinkTarget
M.symlink_target = function(config, node, _)
if node.is_link then
return {
text = string.format(config.text_format or "-> %s", node.link_to),
highlight = config.highlight or highlights.SYMBOLIC_LINK_TARGET,
}
else
if not node.is_link then
return {}
end

return {
text = (config.text_format or "-> %s"):format(node.link_to),
highlight = config.highlight or highlights.SYMBOLIC_LINK_TARGET,
}
end

---@class (exact) neotree.Component.Common.Type : neotree.Component
Expand Down
4 changes: 2 additions & 2 deletions lua/neo-tree/sources/common/file-items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function create_item(context, path, _type, bufnr)
if item.type == "link" then
---@cast item neotree.FileItem.Link
item.is_link = true
item.link_to = uv.fs_realpath(path)
item.link_to = uv.fs_readlink(path)
if item.link_to ~= nil then
item.type = uv.fs_stat(item.link_to).type
end
Expand Down Expand Up @@ -294,7 +294,7 @@ function set_parents(context, item)
local success
success, parent = pcall(create_item, context, item.parent_path, "directory")
if not success then
log.error("error creating item for ", item.parent_path)
log.error("Error creating item for ", item.parent_path, ":", parent)
end
---@cast parent neotree.FileItem.Directory
context.folders[parent.id] = parent
Expand Down
5 changes: 1 addition & 4 deletions lua/neo-tree/sources/filesystem/lib/fs_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ M.move_node = function(source, destination, callback, using_root_directory)
end

-- Resolve user-inputted relative paths out of the absolute paths
dest = vim.fs.normalize(dest)
if utils.is_windows then
dest = utils.windowize_path(dest)
end
dest = utils.normalize_path(dest)
local function move_file()
create_all_parents(dest)
uv.fs_rename(source, dest, function(err)
Expand Down
8 changes: 4 additions & 4 deletions lua/neo-tree/sources/filesystem/lib/fs_scan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ local function async_scan(context, path)
table.insert(ctx.paths_to_load, item.path)
end
else
log.error("error creating item for ", path)
log.error("Error creating item for ", path, ":", item)
end
end

Expand Down Expand Up @@ -439,13 +439,13 @@ local function sync_scan(context, path_to_scan)
for i, stat in ipairs(stats) do
more = i == ENTRIES_BATCH_SIZE
local path = utils.path_join(path_to_scan, stat.name)
local success, _ = pcall(file_items.create_item, context, path, stat.type)
local success, item = pcall(file_items.create_item, context, path, stat.type)
if success then
if context.recursive and stat.type == "directory" then
table.insert(context.paths_to_load, path)
end
else
log.error("error creating item for ", path)
log.error("Error creating item for ", path, ":", item)
end
end
until not more
Expand Down Expand Up @@ -555,7 +555,7 @@ local handle_refresh_or_up = function(context, async_dir_scan)
local path_to_reveal_parts = utils.split(path_to_reveal, utils.path_separator)
table.remove(path_to_reveal_parts) -- remove the file name
-- add all parent folders to the list of paths to load
utils.reduce(path_to_reveal_parts, "", function(acc, part)
utils.reduce(path_to_reveal_parts, utils.abspath_prefix(path_to_reveal), function(acc, part)
local current_path = utils.path_join(acc, part)
if #current_path > #path then -- within current root
table.insert(context.paths_to_load, current_path)
Expand Down
18 changes: 12 additions & 6 deletions lua/neo-tree/sources/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,30 @@ M.get_state_for_window = function(winid)
end
end

---Get the path to reveal in the file tree.
---@param include_terminals boolean?
---@return string? path
M.get_path_to_reveal = function(include_terminals)
local win_id = vim.api.nvim_get_current_win()
local cfg = vim.api.nvim_win_get_config(win_id)
if cfg.relative > "" or cfg.external then
if utils.is_floating(win_id) then
-- floating window, ignore
return nil
end

if vim.bo.filetype == "neo-tree" then
return nil
end
local path = vim.fn.expand("%:p")
if not utils.truthy(path) then

local buf_relpath = utils.normalize_path(vim.fn.expand("%"))
if not utils.truthy(buf_relpath) then
return nil
end
if not include_terminals and path:match("term://") then

if not include_terminals and buf_relpath:match("term://") then
return nil
end
return path

return utils.path_join(vim.fn.getcwd(), buf_relpath)
end

---@param source_name string
Expand Down
Loading
Loading