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

Add argument to open Oil in Preview-Mode #339

Closed
1 task done
jdsee opened this issue Mar 28, 2024 · 3 comments
Closed
1 task done

Add argument to open Oil in Preview-Mode #339

jdsee opened this issue Mar 28, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@jdsee
Copy link

jdsee commented Mar 28, 2024

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

It would be great if open had an argument for enabling preview mode as soon as Oil opens.

Suggestion:

oil.open({
  dir = '...',
  preview = true,
})

Provide background

I couldn't find a way to open Oil with preview-mode activated initially.

I tried the following but preview triggers too early this way:

require('oil').open()
require('oil.actions').preview()

What is the significance of this feature?

nice to have

Additional details

Edit: This is just an issue for opening Oil for the first time in a session. So maybe it would be better to offer an option for setup to enable preview by default.

@jdsee jdsee added the enhancement New feature or request label Mar 28, 2024
@musicq
Copy link

musicq commented Apr 11, 2024

It will be great If can support open in preview mode. Meanwhile, I'm using this to achieve it.

vim.keymap.set('n', '-', function()
  require('oil').open()

  require('oil.util').run_after_load(0, function()
    oil.select({ preview = true })
  end)
end)

AirKoala added a commit to AirKoala/dotfiles that referenced this issue Apr 12, 2024
@AirKoala
Copy link

This is what I'm using as a workaround to try opening the preview only after its available

vim.keymap.set('n', '-', function()
  oil.open()

  -- Wait until oil has opened, for a maximum of 1 second.
  vim.wait(1000, function()
    return oil.get_cursor_entry() ~= nil
  end)
  if oil.get_cursor_entry() then
    oil.open_preview()
  end
end)

@stevearc
Copy link
Owner

This is now supported as part of the oil.open and oil.open_float API, or via the command with :Oil --preview

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

No branches or pull requests

4 participants