-
-
Notifications
You must be signed in to change notification settings - Fork 826
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
Add change directory functionality to file browser & find files #644
Conversation
Hey @ranjithshegde, could you please fix indentation to using two space per-tab and force push before conni sees this 😆 . Thanks |
I would prefer the mapping |
Done |
Nice. Can you add this into an action so it can be used by other finders such as |
I will try tomorrow. Will be a bit tricky for find_files..etc as this function gets the value when the selection is a directory, not a file. |
Tried to rebase to master, had forgotten about this PR. Will get to it this weekend |
Works for find_files and file_browser
Just did. Please let me know how that looks to you. Sorry this took a while, busy with my thesis |
fix wrong indent
change lcd to cd. lcd only affects TelescopePrompt buffer
@Conni2461 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the code looks good, documentation would be nice, like so
But i personally have a couple of issues with this. This is too opinionated and too easy that people could just pass in opts.attach_mappings
function to their function call. Couple of issue:
Its mapped, and people cant change this mapping because both are local functions.
cd
vs lcd
vs tcd
whats correct for what workflow. lcd
is not much harder to implement. You just need the previous bufnr and then you can do vim.api.nvim_buf_call(bufnr, function() lcd_here end)
but i personally only do tcd
and a lot of other people will feel like that.
Idk what to say, i know you spent time on it.
And also this is just my opinion, maybe other people like tami or ober see it differently. They at least started reviewing this PR 😆
I added it as configuration Recipes and created you: https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#change-directory I think this works better. Still thanks for you work tho :) |
It is indeed better as a config recipe than a PR. Besides I see that the file browser itself might be removed from core! |
@Conni2461 I couldn't get it to work how the recipe showed, as the mappings were under pickers --> find_files --> mappings, while mappings are usually under defaults --> mappings. Moving them to match what's shown below made it work for me, so I'm wondering if the recipe should be updated to match that. Sorry if bringing this up in a comment on a closed request isn't the proper way to do it or whatever - I don't have much experience with this kind of stuff. require("telescope").setup({
defaults = {
-- ....
mappings = {
n = {
["cd"] = function(prompt_bufnr)
local selection = require("telescope.actions.state").get_selected_entry()
local dir = vim.fn.fnamemodify(selection.path, ":p:h")
require("telescope.actions").close(prompt_bufnr)
-- Depending on what you want put `cd`, `lcd`, `tcd`
vim.cmd(string.format("silent lcd %s", dir))
end,
},
},
},
}) |
Just a small piece of lua code to change nvim's pwd while using the builtin file_browser
Navigate to the directory and type (capitol) C in normal mode