GithubHelp home page GithubHelp logo

Update CWD on file manager close about fm-nvim HOT 4 CLOSED

is0n avatar is0n commented on July 4, 2024
Update CWD on file manager close

from fm-nvim.

Comments (4)

jakobkhansen avatar jakobkhansen commented on July 4, 2024 1

Great, I went with that idea and it worked! If anyone wants to do something similar, this is what I ended up with:

on_close = {
  function()
            local file = io.open("/tmp/ranger_dir", "r")
  
            io.input(file)
  
  
            local dir = io.read()
            command('cd ' .. dir)
  end,
},

and a mapping to this command (Ranger):

<CMD>Ranger --choosedir="/tmp/ranger_dir"<CR>

from fm-nvim.

is0n avatar is0n commented on July 4, 2024

You can actually do this with a vim setting called autochdir. You can set this by using the following in your init.lua...

vim.opt.autochdir = true

Is this what you had in mind?

from fm-nvim.

jakobkhansen avatar jakobkhansen commented on July 4, 2024

I more had in mind that I would like to be able to navigate to the root of a project, exit the file manager (without opening a file) and have cwd be in the directory that I left the file manager. I usually like to navigate to a project root (with something like this plugin), and then use a fuzzy-finder to open some file from there.

from fm-nvim.

is0n avatar is0n commented on July 4, 2024

Sorry for the late response but after the latest commit, you might be able to do this.

The latest commit allows you to run functions upon exiting the floating window. This can be seen on the README.

If you were using Lf for example, you could change the command to use -last-dir-path which would write the file manager's last directory path to a specified file. Then using on_close and your function, you could read that file and then cd there.

The code would be something like...

local function updateCWD()
	-- some code that checks /tmp/cwd
end

require('fm-nvim').setup{
	cmds = {
		lf_cmd = "lf -last-dir-path /tmp/cwd"
	}
	on_close = { updateCWD }
}

I think the issue should be resolved but please LMK if there's anything missing :)

from fm-nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.