danhper / fundle

A minimalist package manager for fish shell
MIT License
376 stars 22 forks source link

Plugins using init.fish don't work #8

Closed tcoenraad closed 8 years ago

tcoenraad commented 8 years ago

For example:

It seems that fundle.fish is invoking init_$plugin_name not at all, as is done by Oh My Fish: https://github.com/oh-my-fish/oh-my-fish/blob/93ddd6f213d6f21386651a1663f9f3460e35dbec/lib/require.fish#L34

danhper commented 8 years ago

@tcoenraad Thanks for reporting, I did not know that oh-my-fish was emitting an event after loading plugins. I want the plugins to be compatible, so I am going to add this.

danhper commented 8 years ago

@tcoenraad This should now be fixed, I would be glad if you could give it a try.

tcoenraad commented 8 years ago

@tuvistavie I think we're almost there, yet now the plugin name is incorrectly retrieved. For example for plugin-grc:

⋊> ~ echo 'oh-my-fish/plugin-grc' | awk -F/ '{print $NF}' | sed -e s/plugin//
-grc

This results in init_-grc to be invoked, what (of course) should be init_grc. Adding a - to the regex however results in these errors:

fish: Unknown command 'available grc'
~/.config/fish/fundle/oh-my-fish/plugin-grc/grc.fish (line 5):   if not available grc
                                                                        ^
in function 'init'
    called on line 135 of file ~/.config/fish/functions/fundle.fish
    with parameter list '/Users/twancoenraad/.config/fish/fundle/oh-my-fish/plugin-grc'

in event handler: handler for generic event 'init_grc'

Okay, I have to reorder plugins to load oh-my-fish-core first. Then the following error occurs:

fish: Unknown command 'grc.wrap cat'
~/.config/fish/config.fish (line 1): grc.wrap $executable $argv
                                     ^
in function 'cat'
    called on line 69 of file /usr/local/Cellar/fish/HEAD/share/fish/functions/psub.fish

Can you please look into this? I guess that dependencies of a plugin should be sourced first, before invoking any initializations.

Besides, in the future, string manipulation can be done in native Fish (see https://github.com/fish-shell/fish-shell/issues/156) :smile:

danhper commented 8 years ago

@tcoenraad Thanks for reporting. This should now be fixed in 0.3.1. Dependencies order is also respected now: the init event is sent only once the dependencies are initialized. However, this implies to have fundle plugin 'dependency' in the init.fish file of the plugin, so it will not work here.

oh-my-fish plugins are kind of a mess, sometimes functions are in the functions directory, sometimes hanging around in the root directory, that was the issue with grc. Anyway I restored the previous approach, which is to source all the .fish files in the root directory when no init.fish is there, so it should work for this one.

Please let me know if you still have any issue.

tcoenraad commented 8 years ago

I see that while I was commenting, you almost already fixed it. It's now working beautifully (well, as far it can with those messy oh-my-fish plugins), thank you! :+1:

danhper commented 8 years ago

Besides, in the future, string manipulation can be done in native Fish (see fish-shell/fish-shell#156) :smile:

Thanks, I am probably going to switch to the fish implementation, but fish 2.0 and 2.1 are (supposed to be) supported for now (and string manipulation has been added in 2.2 if I remember), so I will see when I drop the support for older fish versions.

I see that while I commenting, you almost already fixed it. It's now working beautifully (well, as far it can with those messy oh-my-fish plugins), thank you! :+1:

:+1:

mustaqimM commented 6 years ago

@tuvistavie I'm getting the same issue on 0.6.2 with plugin-gem from omf, it isn't loading the function with function init --on-event