Skip to content

feat: add open_files_using_relative_paths option #1634

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

Merged
merged 2 commits into from
Jan 26, 2025
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ use {
enable_git_status = true,
enable_diagnostics = true,
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
open_files_using_relative_paths = false,
sort_case_insensitive = false, -- used when sorting files and directories in the tree
sort_function = nil , -- use a custom function for sorting files and directories in the tree
-- sort_function = function (a,b)
Expand Down
1 change: 1 addition & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ local config = {
log_to_file = false, -- true, false, "/path/to/file.log", use :NeoTreeLogs to show the file
open_files_in_last_window = true, -- false = open files in top left window
open_files_do_not_replace_types = { "terminal", "Trouble", "qf", "edgy" }, -- when opening files, do not use windows containing these filetypes or buftypes
open_files_using_relative_paths = false,
-- popup_border_style is for input and confirmation dialogs.
-- Configurtaion of floating window is done in the individual source sections.
-- "NC" is a special style that works well with NormalNC set
Expand Down
3 changes: 2 additions & 1 deletion lua/neo-tree/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ M.open_file = function(state, path, open_cmd, bufnr)
end

if M.truthy(path) then
local escaped_path = M.escape_path_for_cmd(path)
local relative = require("neo-tree").config.open_files_using_relative_paths
local escaped_path = M.escape_path_for_cmd(relative and vim.fn.fnamemodify(path, ":.") or path)
local bufnr_or_path = bufnr or escaped_path
local events = require("neo-tree.events")
local result = true
Expand Down
Loading