Comments (6)
Try this out...
local function chg_cwd()
local file = vim.fn.readfile("/tmp/fm-nvim")[1]
if vim.fn.isdirectory(file) == 1 then
vim.cmd("cd " .. file)
os.remove("/tmp/fm-nvim")
end
end
require('fm-nvim').setup {
on_close = {
chg_cwd,
}
}
Note that including --print-pwd-as-result
will prevent this from working (but other args are fine)
You can still open files normally but when a directory is chosen, nvim will cd to that directory.
from fm-nvim.
Hmm, that didn't work for me, pressing enter on a dir still opens it instead of changing the working directory.
Here's the installation of fm-nvim by packer
local cfg = function(name)
return string.format('require("cfg.%s")', name)
end
return require('packer').startup(function(use)
use {
'is0n/fm-nvim',
config = cfg('fm'),
}
end)
and here's the config file fm.lua
itself
local ok, fm = pcall(require, 'fm-nvim')
if not ok then
vim.notify('unable to find fm-nvim')
return
end
local function chg_cwd()
local file = vim.fn.readfile('/tmp/fm-nvim')[1]
if vim.fn.isdirectory(file) == 1 then
vim.cmd('cd ' .. file)
os.remove('/tmp/fm-nvim')
end
end
fm.setup {
ui = {
default = 'split',
split = {
size = 50,
},
},
on_close = {
chg_cwd,
},
}
I wasn't sure about the [1]
and I removed it but that help either. I've also disabled netrw and I enabled it but just opens up the directory I select in netrw.
from fm-nvim.
Are you on the latest version of fm-nvim
?
from fm-nvim.
Yeah. I updated fm-nvim to add the latest commit, f75cdf4, but that doesn't help either.
from fm-nvim.
This is me using the chg_cwd
function and it works for me. I'm not sure what's preventing it from working on your machine.
Untitled.mp4
Here's the my config in case you might help:
local function chg_cwd()
local file = vim.fn.readfile("/tmp/fm-nvim")[1]
if vim.fn.isdirectory(file) == 1 then
vim.cmd("cd " .. file)
os.remove("/tmp/fm-nvim")
end
end
require('fm-nvim').setup{
ui = {
default = "float",
float = {
border = "single",
border_hl = "NONE",
},
},
cmds = {
fzf_cmd = "fzf --preview 'fzf-preview {}' -1 -m",
},
on_close = {
chg_cwd,
}
}
This is the output of nvim -v
:
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@iMac-Pro
From what I can tell, the problem isn't with the chg_cwd
function but rather something with your config.
from fm-nvim.
@is0n while what you are doing is definitely changing the directory, I believe the intended behavior @ayushnix wanted is to change the directory in xplr, not vim. This solution results in a flicker but gets the job done. The problem with this solution is that every time you hit enter to on a folder, you have to reenter insert mode with i
.
local function chg_cwd()
local file = vim.fn.readfile("/tmp/fm-nvim")[1]
if vim.fn.isdirectory(file) == 1 then
vim.cmd.Xplr(file)
os.remove("/tmp/fm-nvim")
end
end
require('fm-nvim').setup {
on_close = {
chg_cwd,
},
}
from fm-nvim.
Related Issues (20)
- Open browser with current file selected HOT 9
- Allow directional splits HOT 1
- Ctrl-j and Ctrl-k not working when using Broot HOT 4
- FEATURE:bookmark HOT 2
- LF icons not working HOT 6
- split mode does not work HOT 1
- [Feature] Change current directory HOT 2
- Close buffer along with window HOT 1
- Update buffer on file action with LF HOT 9
- [Feature Request] Allow custom border characters HOT 1
- Joshuto does not work HOT 3
- Make it possible to disable or override a mapping
- lazygit not open file in nvim HOT 3
- Xplr not open file inside already open buffer
- Can it run in the background permanently
- Joshuto does not work HOT 2
- broot just.. doesn't work?
- Add support for Yazi HOT 1
- Cannot open files that contain spaces in file/path name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fm-nvim.