Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Kakoune doesn't source plugin files in the right order #45

Closed
yveoch opened this issue Mar 25, 2019 · 2 comments
Closed

Kakoune doesn't source plugin files in the right order #45

yveoch opened this issue Mar 25, 2019 · 2 comments

Comments

@yveoch
Copy link

yveoch commented Mar 25, 2019

Problem description

Hello! I know that you are recommending the use of plug.kak to install this plugin, but I don't have a use for a plugin manager right now, as having plugins as Git submodules in my autoload directory has been enough for now. I just wanted to report a problem that happens when using this native loading mechanism: since kakoune does find . -L -type f -name '*.kak' (source) to find plugin files, it will first find the modules files and then the main file of the FZF plugin:

> find -L . -type f -name '*.kak'
./rc/fzf-modules/fzf-cd.kak
./rc/fzf-modules/sk-grep.kak
./rc/fzf-modules/fzf-search.kak
./rc/fzf-modules/fzf-vcs.kak
./rc/fzf-modules/fzf-ctags.kak
./rc/fzf-modules/fzf-file.kak
./rc/fzf-modules/fzf-buffer.kak
./rc/fzf-modules/VCS/fzf-svn.kak
./rc/fzf-modules/VCS/fzf-hg.kak
./rc/fzf-modules/VCS/fzf-bzr.kak
./rc/fzf-modules/VCS/fzf-git.kak
./rc/fzf.kak

This then means that these files will be sourced in the wrong order, leading to these errors:

/home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-cd.kak:32:1331: 'map' no such keymap mode: 'fzf'
Autoload: could not load /home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-cd.kak
/home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-search.kak:11:733: 'map' no such keymap mode: 'fzf'
Autoload: could not load /home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-search.kak
/home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-vcs.kak:14:893: 'map' no such keymap mode: 'fzf'
Autoload: could not load /home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-vcs.kak
/home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-ctags.kak:14:899: 'map' no such keymap mode: 'fzf'
Autoload: could not load /home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-ctags.kak
/home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-file.kak:27:1210: 'map' no such keymap mode: 'fzf'
Autoload: could not load /home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-file.kak
/home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-buffer.kak:11:733: 'map' no such keymap mode: 'fzf'
Autoload: could not load /home/dryvenn/.config/kak/autoload/fzf/rc/fzf-modules/fzf-buffer.kak

I don't know what's the best course of action here, the easy solution would probably be renaming the main file.
I made a dirty hack in my own config: symlinking the main file up into my autoload directory so it's sourced first (but then it gets sourced twice...).

Steps to reproduce

  1. Clone fzf.kak in your user autoload directory
  2. Start kakoune
  3. Look at debug buffer

Environment information

Kakoune v2019.01.20
Ubuntu 18.10

@andreyorst
Copy link
Owner

I don't use autoload directory, because the first thing that I did after I've switched from Vim to Kakoune, was a plugin manager (which I've written just to avoid using autoload), but I'm aware of this behavior and I'm not sure what correct solution would be, as Kakoune doesn't support modules inside scripts AFAIK yet, and there's currently no standard plugin file structure layout defined. It's better to source this plugin manually, as stated in README, rather using it as Git submodule, in case you don't want to use plug.kak. I'm currently in a process of rewriting this plugin, and I suppose I'll simplify this plugin, including loading process, and order would not matter (I hope) anymore.

Also, plug.kak provides much more than simple loading plugins, like autoload directory does. It encapsulates configuration of a plugin, making it easy to maintain plugin related configurations; handles loading errors (including this one), so if anything breaks in one plugin your Kakoune and other plugins will be loaded just fine; can update or install your plugins more easily than with Git submodules; it can run shell commands after successful update of plugin (for example to recompile kak-lsp); and it can keep needed version of a plugin just like Git submodule.

@yveoch
Copy link
Author

yveoch commented Mar 28, 2019

Thanks @andreyorst!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants