Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

how do you include local plugins during dev? #181

Closed
molleweide opened this issue Oct 22, 2021 · 15 comments
Closed

how do you include local plugins during dev? #181

molleweide opened this issue Oct 22, 2021 · 15 comments
Labels
scope: enhancement New feature or request

Comments

@molleweide
Copy link
Contributor

I am looking into adapting Folke's pattern for automatically including local plugins and then creating a set_local_plugins_path in doom_config.lua

@NTBBloodbath
Copy link
Collaborator

@molleweide Hmm can you please explain me a bit more about this? Maybe send a link as a reference 👀

@molleweide
Copy link
Contributor Author

molleweide commented Oct 22, 2021

Look here at how here how he first checks for local plugs and prioritizes those over packer installed modules.

https://github.com/folke/dot/blob/master/config/nvim/lua/util/packer.lua

I want to get into plugin dev and the goal would be to have an option in the config file where you specify the path where your plugins are, eg. $HOME/code/plugins and then use this in the packer.init({ config }) and then reuse Folke's wrap function to prioritize local plugins/forks.

I note that Folke's structure of the plugin config is a little bit different so I have to understand how it can be integrated and this is a bit difficult for me. Folke is the guy who build which-key, todo-comments and many other nice plugins that doom already uses.

@molleweide
Copy link
Contributor Author

accidentally closed

@molleweide
Copy link
Contributor Author

molleweide commented Oct 22, 2021

  1. Folke passes the packer config and the plugins use function to a bootstrap fn.
  2. He calse the wrap function on the function(use) which processes all plugins and
    checks which plugins exist in local plugins path and prioritizes those instead of the
    packer installed plugin.

Here fn is the

function(use)
    -----[[------------]]-----
    ---     Essentials     ---
    -----]]------------[[-----
    -- Plugins manager
    use({
        "wbthomason/packer.nvim",
        opt = true,
    })
....
....

in doom.

function M.setup(config, fn)
  -- HACK: see https://github.com/wbthomason/packer.nvim/issues/180
  vim.fn.setenv("MACOSX_DEPLOYMENT_TARGET", "10.15")

  M.bootstrap()
  local packer = require("packer")
  packer.init(config)
  M.local_plugins = config.local_plugins or {}
  return packer.startup({
    function(use)
      use = M.wrap(use)
      fn(use)
    end,
  })
end

return M

@NTBBloodbath
Copy link
Collaborator

Hmm alright so folke does this so packer will not spit his cleaning window, right?

I think this could be dead simple since end user just needs to use a fullpath to his plugin, e.g.

use({
    "/home/user/Development/Nvim/foo.nvim",
    config = function()
        -- some good stuff here
    end
})

Lemme know if I'm misunderstanding it :p

@molleweide
Copy link
Contributor Author

wait maybe you can do it that simple. I didn't know that but in that case you could add them in user plugins right?
BUT, what would happen if I include a local plugin, eg. neorg, and then packer installs the upstream version. Wouldn't it becomes somekind of conflict then?

@NTBBloodbath
Copy link
Collaborator

wait maybe you can do it that simple. I didn't know that but in that case you could add them in user plugins right?

Yeah this should work as expected IMO

BUT, what would happen if I include a local plugin, eg. neorg, and then packer installs the upstream version. Wouldn't it becomes somekind of conflict then?

Hmm right so this could supposes a problem, I don't know nor think that packer is smart enough to deal with this other than telling you that X plugin definition is duplicated 🤔

@molleweide
Copy link
Contributor Author

molleweide commented Oct 22, 2021

Yeah and I believe this is the problem that folke is fixing. That is why it could be nice with something similar to his functionality, and it seems that he has done all of the work already.
We would just have to wrap doom modules init in a module I think. I am trying to understand how it is done myself now but conceptually it is quite simple to you, right?

Could you explain to me where modules/init.lua is required/run?

@molleweide
Copy link
Contributor Author

No i avtually think that it would require some more thought in order to do this. I need to read through doom source more thouroughly first

@molleweide
Copy link
Contributor Author

molleweide commented Oct 25, 2021

Brainstorming:

paths and dirs:

user creates a, eg. $HOME/code/nvim/plugins
user adds this to doom_config -> local_plugins_path

strategies:

folke strategy - list local plugins you want

in doom config you specify table of strings representing the
plugins from `local_plugins_path` which you want to use

inverted folke - list local plugins you DON'T want

list any plugins that should be ignored, ie. assume most local
plugins should be used.

pre/post fix

use some kind of dir name pre or postfix, eg `myplugin~` in order
to prevent from being used.

use all

why not you know. this means that user would put not ready plugins or whatever
under `dir_not_ready` and then move them to `local_plugins_path` when ready.

configs

1. prioritize local plugins but use doom configs
2. give user ability to create custom local plugin config
    that overrides doom modules core config

(i pasted this from norg so it lookes a bit wierd. i need to keep issues/github ideas in markdown from now on)

@NTBBloodbath
Copy link
Collaborator

Hey, thanks for this. I think folke's approach is the most easier one for us, less logic and code to be written 👀

For configurations it looks great, first point is gonna be hard because you know lol, packer acts in some weird ways sometimes IMO, however I'll try to hack it :p

Btw what do you think if we leave this feature for Doom v3.3? The reason of this proposal is because v3.2 is almost done and I want to release it asap to stable branch because it has some very important changes (like using cmp instead of compe) and some other neat features and improvements.

Regards

@NTBBloodbath NTBBloodbath added the scope: enhancement New feature or request label Oct 26, 2021
@molleweide
Copy link
Contributor Author

lol of course we can wait for vesion 3.3 :D I am just documenting stuff as fast as I can. There is absolutely no stress at all.
This is a lot of fun and I am getting back on track now!!!

@molleweide
Copy link
Contributor Author

molleweide commented Nov 2, 2021

Idea:

modules/init

For each plug use bool var
use_local if exista in doom_config.local_plugins

So that if one wants, one can quickly toggle btw local and remote version

Then it would also be nice to put big LOCAL next to plugin when packer syncing/status

@molleweide
Copy link
Contributor Author

Would it make sense to put a dir like modules/config/local where u can put your local configs with higher priority, or maybe this should reside in doom root like doom-nvim/local

@molleweide
Copy link
Contributor Author

molleweide commented Nov 2, 2021

there should also be a bool so you can toggle autoreloading currently worked on plugin or something.

I just found plenary has reload func:
https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/reload.lua

EDIT:

I realize that this might already be implemented in the reloader module, but atm
something is broken for me.

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

No branches or pull requests

2 participants