Skip to content
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

is there a "ranger closed" event I can use? #116

Open
brunobmello25 opened this issue Feb 22, 2024 · 0 comments
Open

is there a "ranger closed" event I can use? #116

brunobmello25 opened this issue Feb 22, 2024 · 0 comments

Comments

@brunobmello25
Copy link

I'm trying to make ranger open on a floating window (because when I'm working with splits ranger opens on a split and is hard to visualize)

here is my current code:

local M = {
  window_id = nil
}

function M.toggle_ranger_floating()
  local width = math.floor(vim.api.nvim_get_option("columns") * 0.9)
  local height = math.floor(vim.api.nvim_get_option("lines") * 0.9)

  local buf = vim.api.nvim_create_buf(false, true)

  local col = 10 -- horizontal position
  local row = 5  -- vertical position

  local opts = {
    style = "minimal",
    relative = "editor",
    width = width,
    height = height,
    col = col,
    row = row,
    border = "rounded"
  }

  M.window_id = vim.api.nvim_open_win(buf, true, opts)

  vim.cmd("Ranger")
end

return {
  {
    "francoiscabrol/ranger.vim",
    dependencies = {
      "rbgrouleff/bclose.vim",
    },
    init = function()
      vim.g.ranger_map_keys = 0
    end,
    config = function()
      -- vim.keymap.set("n", "<leader>e", "<cmd>Ranger<cr>", { desc = "Open ranger" })
      vim.keymap.set("n", "<leader>e", function()
        M.toggle_ranger_floating()
      end, { desc = "Open ranger" })
    end,
  },
}

I managed to open it up fine in a floating window, but when I close ranger I want to close that floating window. A close event would be ideal for this. Is there any?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant