andreyorst / plug.kak

Plugin manager for Kakoune
MIT License
197 stars 18 forks source link

fix: pass correct load-path to plug_load command #86

Closed andreyorst closed 3 years ago

andreyorst commented 3 years ago

There is an error with when loading plugin with the plug command, and specifying the load-path argument, the plug_load shell command tries to load from standard path.

andreyorst commented 3 years ago

https://github.com/andreyorst/plug.kak/pull/84#issuecomment-864378403

@mralusw could you please test this branch?

mralusw commented 3 years ago

Maybe I'm not trying the right thing, but 2f70aaef6db19b81e45a9955cb8ed290d11d3665 still tries to download from github no matter what I try. I have this in my kakrc:

plug 'mru-files.kak' load-path '/home/user1000/Projects/mru-files.kak'

In kak, :plug-list, go to the mru-files line ("Not installed"), press I. Shows "Download error", press L. The log is

Cloning into 'mru-files.kak'...
remote: Not Found
fatal: repository 'https://github.com/mru-files.kak/' not found
andreyorst commented 3 years ago

In kak, :plug-list, go to the mru-files line ("Not installed"), press I. Shows "Download error", press L. The log is

Not installed is what you should be seeing (since it is not installed in the plugins directory), and you're not supposed to press I the plugin should already be loaded. The log you've provided is a normal log for load-path loaded plugin, as it indeed has no remote, and plug.kak can't construct it's github URL from just the name.

I think I can improve this Not installed thing, previously there was no good way to mark plugins as manually loaded, but now there is the .build dir, where the configuration is stored, so I can check that at least. I'll add it to the todo list.

mralusw commented 3 years ago

I can attest that branch fix-load-path indeed allows me to use unmanaged plugins as advertised, even though plug-list says Not installed.

Fixing the message would avoid confusion. Also, since users are not supposed to press I on load-path plugins, perhaps echo a warning or just ignore the action.

basbebe commented 3 years ago

+1 fixed it for me

andreyorst commented 3 years ago

Also, since users are not supposed to press I on load-path plugins, perhaps echo a warning or just ignore the action.

Unfortunately kakscript is not a programming language, and doesn't have efficient (or any, for that matter) data structures, so only runtime information plug.kak stores is the names of the loaded plugins, e.g. the plugins that were referenced with plug command. When you put plug "something" into your kakrc the something is stored in the list of loaded plugins, hidden in a variable. When you invokde plug-list it simply gets all names and arranges their names in a column, and constructs URLs based on the other info in the .build dir. Mappings doesn't know anything about whether there was or wasn't a load-path argument to the plug command.

I'm working on a patch, that will mark these plugins as manually-loaded in the .build dir, so maybe I could query it in the mappings too, but for now it's user's problem.