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

feat: automatic lazy loading + health check + support configuration with vim.g #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mrcjkb
Copy link

@mrcjkb mrcjkb commented May 6, 2024

Hey 👋

Nice plugin!

I would love to use it, but the need to call a setup function to enable this plugin's functionality has some caveats:

  • It forces users to either use lazy.nvim, or implement lazy loading manually, or always run the setup function, even without using oil.nvim.
  • Users have to ensure that oil.nvim is configured before this plugin.
  • See also rocks.nvim#should-i-lazy-load-plugins.

This PR uses Neovim's built-in ftplugin feature (see :h runtimepath) to make sure this plugin initialises itself lazily, when opening a oil filetype.
As a nice side-effect, this also means that users (or plugin managers) don't have to worry about the order in which oil.nvim and this plugin are configured (oil.nvim must be loaded in order for Neovim to know about the oil filetype).
The setup function only sets the config, but doesn't load anything.

  • I've also added a small health check.

  • And, since setup now only overrides the default configuration, I have added support for configuring this plugin with a vim.g.oil_git_status table.
    This has two benefits over a setup function:

    1. If the plugin is not installed or loaded, Neovim won't error on a require call (allowing users to disable the plugin without deleting the config).
    2. It allows configuration from vimscript: g:oil_git_status = { "show_ignored": 1 }

@mrcjkb
Copy link
Author

mrcjkb commented May 6, 2024

Oh, by the way: I noticed there's no license?
Technically, this makes it illegal for me to fork this plugin 😅

@ryoppippi
Copy link

@mrcjkb Hi
haha, so I made an issue lol

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

Successfully merging this pull request may close these issues.

2 participants