Skip to content

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

Open
mrcjkb wants to merge 3 commits intorefractalize:mainfrom
mrcjkb:ftplugin
Open

feat: automatic lazy loading + health check + support configuration with vim.g#7
mrcjkb wants to merge 3 commits intorefractalize:mainfrom
mrcjkb:ftplugin

Conversation

@mrcjkb
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown

@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