Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: file completion for fs-action #1635

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions lua/neo-tree/sources/filesystem/lib/fs_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ local function get_unused_name(
local new_path = parent_path and parent_path .. utils.path_separator .. new_name or new_name
get_unused_name(new_path, using_root_directory, name_chosen_callback)
end
end)
end, {}, "file")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file completion completes relative to the cwd of neo-tree, not relative to the file being renamed. For configs that use show_path="absolute" it's fine but the default is to prefill just the filename/dirname. I think you might be able to modify the buffer-local 'path' option and use file_in_path completion to get better completion?

Copy link
Author

@parisni parisni Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. First of all, I realize file completion for rename has no value. So only remains copy, add, add_directory and move to be relevant with file completion.

For configs that use show_path="absolute" it's fine

It's also perfect for show_path="relative"

but the default is to prefill just the filename/dirname

Yes currently the default does not work.

modify the buffer-local 'path' option

This sounds kind of hacky WDYT?
BTW the completion needs use_popups_for_input=false, so I wonder if it's worth adding the code you suggest or just activating (and documenting) file completion in case both are meet:

use_popups_for_input=false
show_path=relative|absolute

An other reason not to support show_path=none is most of the action here are relevant on the cwd. For eg, move has no value if not using absolute or relative path, you might wan't to move the file at least in the whole project, not only in the current node

else
name_chosen_callback(destination)
end
Expand Down Expand Up @@ -336,7 +336,7 @@ M.create_directory = function(in_directory, callback, using_root_directory)
end
end)
end
end)
end, {}, "file")
end

--- Create Node
Expand Down Expand Up @@ -411,7 +411,7 @@ M.create_node = function(in_directory, callback, using_root_directory)
end
end)
end
end)
end, {}, "file")
end

-- Delete Node
Expand Down Expand Up @@ -608,7 +608,7 @@ local rename_node = function(msg, name, get_destination, path, callback)
return
end
fs_rename()
end)
end, {}, "file")
end

-- Rename Node
Expand Down