-
Notifications
You must be signed in to change notification settings - Fork 4
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
Possible to convert windows \
paths to /
?
#8
Comments
avario-cpu
changed the title
Anything feasible regarding to windows
Anything feasible regarding to windows Aug 25, 2024
\
path ?\
paths ?
avario-cpu
changed the title
Anything feasible regarding to windows
Possible to convert windows Aug 25, 2024
\
paths ?\
paths to /
?
Hi, currently there's no way to insert path with replacing, but I'm open to review a PR if you wish to implement it. |
I don't think I'm anywhere near remotely capable for this now. But I did end up implementing a much simpler version of what you've done in my config. If that's useful to anyone else looking for something similar: codelocal action_state = require("telescope.actions.state")
local actions = require("telescope.actions")
local telescope = require("telescope")
local function convert_path(path)
-- Convert backslashes to forward slashes
return path:gsub("\\", "/")
end
local function get_relative_path(path)
local relative = vim.fn.fnamemodify(path, ":.")
return convert_path(relative)
end
local function insert_path(prompt_bufnr, use_relative)
local selection = action_state.get_selected_entry()
if selection == nil then
print("No selection")
return
end
local path = selection.path
if path == nil then
print("No path")
return
end
if use_relative then
path = get_relative_path(path)
else
path = convert_path(path)
end
actions.close(prompt_bufnr)
vim.api.nvim_put({ path }, "", false, true)
end
local insert_absolute_path = function(prompt_bufnr)
insert_path(prompt_bufnr, false)
end
local insert_relative_path = function(prompt_bufnr)
insert_path(prompt_bufnr, true)
end
telescope.setup({
defaults = {
mappings = {
n = {
["="] = insert_absolute_path,
["-"] = insert_relative_path,
},
},
},
})
-- Set up the Ctrl+t binding for insert mode Telescope call
vim.keymap.set("i", "<C-t>", function()
require("telescope.builtin").find_files()
end, { noremap = true, silent = true, desc = "Telescope find files" }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Amazing plugin but afaik it will insert paths with
\
on Windows which are basically useless, unless there's an option to replace\
with/
I'm unaware of ?The text was updated successfully, but these errors were encountered: