rmagatti / auto-session

A small automated session manager for Neovim
MIT License
1.29k stars 46 forks source link

[BUG] restore from path argument incompatible with oil.nvim #372

Open niderhoff opened 2 months ago

niderhoff commented 2 months ago

Describe the bug Trying to restore a session from a path argument like this:

nvim /my_folder/

will fail, because it is compatible, with oil.nvim, because the latter is rewriting the argument from /my_folder/ to oil:///my_folder.

To Reproduce Steps to reproduce the behavior:

  1. save a session in /my_folder
  2. Install oil.nvim
  3. run nvim /my_folder/
  4. session is not restored, instead oil file explorer is started

Expected behavior Session is restored.

Screenshots Before oil.nvim:

image

after:

image

Checkhealth

image

Baseline (please complete the following information):

Additional context

cameronr commented 2 months ago

I use oil as well and I think the trick is to make sure it's lazy loaded until after the session is restored. What does your oil config look like?

For mine, i set keys:

return {
  'stevearc/oil.nvim',
  keys = {
    {
      '<Bslash><Bslash>',
      function() require('oil').toggle_float() end,
      desc = 'Oil popup',
    },
  },
...
niderhoff commented 2 months ago

@cameronr

return {
    "stevearc/oil.nvim",
    opts = {},
    dependencies = { "nvim-tree/nvim-web-devicons" },
    config = function()
        require("oil").setup({
            default_file_explorer = true,
            delete_to_trash = true,
            skip_confirm_for_simple_edits = false,
            view_options = {
                show_hidden = false,
                natural_order = true,
                is_always_hidden = function(name, _)
                    return name == '..' or name == '.git'
                end,
            },
            win_options = {
                wrap = true,
            }
        })
    end,
}

its probably due to default_file_explorer ?

cameronr commented 2 months ago

Shouldn't depend on default_file_explorer (i have that in mine as well). What key do you use to open oil / how do you open it?

Or you can try my config:

return {
  'stevearc/oil.nvim',

  keys = {
    {
      '<Bslash><Bslash>',
      function() require('oil').toggle_float() end,
      desc = 'Oil',
    },
  },
  opts = {
    default_file_explorer = true,
    delete_to_trash = true,
    skip_confirm_for_simple_edits = false,
    view_options = {
      show_hidden = true,
      natural_order = true,
      is_always_hidden = function(name, _) return name == '..' or name == '.git' end,
    },
    float = {
      padding = 2,
      max_width = 90,
      max_height = 0,
    },
    win_options = {
      wrap = true,
      winblend = 0,
    },
    keymaps = {
      ['<C-c>'] = false,
      ['q'] = 'actions.close',
      ['<Esc>'] = 'actions.close',
    },
  },
}

With the keys block, oil isn't loaded until I press \\ so it doesn't interfere when launching nvim with a directory argument.

cameronr commented 2 months ago

@niderhoff are you still running into problems or did this resolve it for you?