lir.nvim
lir.nvim copied to clipboard
`vim.opt.autochdir = true` causing lir to always go one directory up when being toggled in an empty window
Hey, thank you for this great plugins! I really love the minimalistic style of this file explorer. Unfortunately though, I likely found an issue. I set vim.opt.autochdir
to true
in my config, and that's causing lir to always go up one directory whenever I toggle it in a newly opened nvim.
EDIT
Okay I likely find a fix/workaround. I read about lir.float.toggle()
that takes a path as parameter. By defaults it expands "%:p:h"
. Storing the expanded string to a variable would make the issue gone. But I think I'll keep this open in case you interested to investigate more.
Expected behavior
lir should always be in the same directory whenever it's being toggled on an empty buffer
Actual behavior
lir always jumps one directory up whenever being toggled
Steps to reproduce
- The minimal
init.lua
local fn = vim.fn
local cmd = vim.cmd
local fmt = string.format
-- vim.cmd [[ set autochdir ]]
vim.opt.autochdir = true
local function ensure(user, repo)
local path = fmt("%s/site/pack/packer/start/%s", fn.stdpath("data"), repo)
if fn.empty(fn.glob(path)) > 0 then
cmd(fmt("!git clone --depth 1 https://github.com/%s/%s %s", user, repo, path))
cmd(fmt("packadd %s", repo))
end
end
ensure("wbthomason", "packer.nvim")
local packer = require("packer")
packer.startup(function(use)
use("wbthomason/packer.nvim")
use({
"tamago324/lir.nvim",
module = "lir",
config = function()
local lir = require("lir")
lir.setup({})
end,
requires = {
{ "nvim-lua/plenary.nvim", module = "plenary" },
},
})
end)
vim.keymap.set({ "n" }, "<C-a>", "<cmd>lua require'lir.float'.toggle()<cr>")
- run
nvim
- toggle lir by pressing the keymap multiple times, and you would see it always jump one directory back everytime it's being toggled
Extra
I've also made a screencast, hope it would give a better illustration of this issue. First, I set it to true, then opening nvim inside a deeply nested directory (~/directory/nested/deep/very/a/is/this), that would cause the issue, then I set to false and the issue would gone
https://user-images.githubusercontent.com/59758342/174489032-08644e2f-21d3-4ddc-a91e-699b2f1ca6f2.mov
Sorry for the delay in replying. Also, thank you for your report.
The help for autochdir says the following, and I thought it might be better to turn off autochdir since it is incompatible with lir.nvim.
:h 'autochdir' Note: When this option is on some plugins may not work.
Sorry for the late reply I see, sad that it behaves like that, though I must say I still need autochdir. Thanks for the answer