# Unclear errors in relation to \`plug.kak\`

**URL:** <https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853>\
**Category:** Plugins\
**Tags:** plugins\
**Created:** [August 29, 2021, 9:35pm UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853 "2021-08-29T21:35:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![The-BigDaddy](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/the-bigdaddy/32/1562_2.png) [@The-BigDaddy](https://discuss.kakoune.com/u/The-BigDaddy)\
**Post date:** [August 29, 2021, 9:35pm UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/1 "2021-08-29T21:35:05Z")

</div>

Hey everyone!

I’ve been meaning to update my config, and I’m having some annoyances with plugins. Mostly with `plug.kak`.

Here’s the configuration I have for `plug.kak`, which might be useful here:

```auto
evaluate-commands %sh{
	plugins="$XDG_CONFIG_HOME/kak/plugins"
	mkdir -p "$plugins"
	[! -e "$plugins"] && \
		git clone -q https://github.com/andreyorst/plug.kak "$plugins/plug.kak"
	printf "%s\n" "source '$plugins/plug.kak/rc/plug.kak'"
}

plug "andreyorst/plug.kak" noload config %{
	set-option global plug_max_active_downloads 16
	set-option global plug_always_ensure false
}

```

## “command is already defined”

I’m attempting to install [peneira](https://github.com/gustavo-hms/peneira), and this is my configuration with `plug.kak`:

```auto
plug "gustavo-hms/luar" %{
	set-option global luar_interpreter luajit
	plug "gustavo-hms/peneira" %{
		require-module peneira
	}
} 

```

Not much different from what given in the `README`. Here’s what I’m seeing in `*debug*` after having none of peneira’s command available.

```auto
/home/my_user/.config/kak/plugins/plug.kak/..//.build/peneira/config:3:3: 'require-module': 3:1: 'require-module': 3:1: 'require-module': 2:5: 'define-command': command 'lua' already defined

```

I don’t understand what that means, or how I could fix this.

This is also something I see when I have `kak-lsp`. This is the following configuration I have for that:

```auto
plug "ul/kak-lsp" do %{
    cargo build --release --locked
    cargo install --force --path . --locked
    cargo clean
} config %{
	
    set-option global lsp_cmd "kak-lsp -vvv -c $HOME/.config/kak-lsp/kak-lsp.toml -s %val{session} --log $HOME/.config/kak-lsp/kak-lsp.log"

    #define-command lsp-restart %{ lsp-stop; lsp-start }

    set-option global lsp_completion_trigger "execute-keys 'h<a-h><a-k>\S[^\s,=;*(){}\[\]]\z<ret>'"
    set-option global lsp_diagnostic_line_error_sign "!"
    set-option global lsp_diagnostic_line_warning_sign "?"
    hook global WinSetOption filetype=(c|cpp|objc|nim|crystal|python|latex|javascript|typescript) %{

        #lsp-start
    	lsp-enable-window
    	echo -debug "Enabling LSP for filtetype %opt{filetype}"
    	
		lsp-auto-hover-enable
    	lsp-auto-hover-insert-mode-disable
    	set-option global lsp_auto_highlight_references true
    	set-option global lsp_hover_anchor true
    	
        # Semantic highlighting
    	# TODO maybe there's more servers that support this 
        hook -once global WinSetOption filetype=rust %{ 

            hook window -group semantic-tokens BufReload .* lsp-semantic-tokens
        	hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens
        	hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens

        	hook -once -always window WinSetOption filetype=.* %{
        		 remove-hooks window semantic-tokens
        	}
        }
    	
    	# Other things
    	#hook window BufWritePre .* lsp-formatting-sync # this breaks shit
    	hook window BufWritePost .* lsp-diagnostics
    	hook -always global KakEnd .* lsp-exit
        hook global WinSetOption filetype=rust %{
            set-option window lsp_server_configuration rust.clippy_preference="on"
        }
    }
}

```

And I get this in `*debug*`:

```auto
/home/my_user/.config/kak/plugins/plug.kak/..//kak-lsp/rc/lsp.kak:103:1: 'define-command': command 'lsp-start' already defined

```

_What does this mean?_ How do I fix this?

## “no such command”

I also have configuration for [mru-files.kak](https://gitlab.com/kstr0k/mru-files.kak).

```auto
plug "https://gitlab.com/kstr0k/mru-files.kak.git" domain "gitlab.com" defer mru-files %{
	set-option global mru_files_history %sh{ echo "$HOME/.local/share/kak/mru.txt" }
} config %{
	require-module kakhist; kakhist-init 
	map global goto ':' '<esc>: kakhist-buf-show<ret>' -docstring "show command history"
	map global fuzzy 'r' '<esc>: mru-files<ret>' -docstring "recent files"
}

```

But I get `'mru-files': no such command` with the above, and have gotten it with many different configurations.

How do I fix this?

---

<div class="post-metadata">

**Author:** ![duncan](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/duncan/32/95_2.png) [@duncan](https://discuss.kakoune.com/u/duncan)\
**Post date:** [September 1, 2021, 9:41am UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/2 "2021-09-01T09:41:31Z")

</div>

Hi BD,

When one thing goes wrong in kakoune or plugins.kak it can give you additional chain errors that just aren’t there.

First with `lua` make sure nowhere in plugins.kak has this line:

```auto
plug "gustavo-hms/luar" %{
    require-module luar
}

```

or a duplication message will occur when using:

```auto
plug "gustavo-hms/luar" %{
    plug "gustavo-hms/peneira" %{
        require-module peneira
    }
}

```

Fix that up and the rest may settle down, also pays to look at the line/code above the reported error as it can often be the actual cause of your problems.

Its a start, hang in there and someone else will chime in with some more help/info for you.  
@andreyorst is always about and willing to help out.

Bye 👋

* * *

Hey BD this might solve the other issue,

[kakhist](https://gitlab.com/kstr0k/mru-files.kak/-/tree/master/kakhist) is a sub-package of [mru-files](https://gitlab.com/kstr0k/mru-files.kak) so go with one call only to `mru-files` and just do the `require-module kakhist; kakhist-init` thing in a `config %{ block }`.

> [@Kakhist: persist command history, history UI](https://discuss.kakoune.com/t/kakhist-persist-command-history-history-ui/1795):
>
> I’ve added [kakhist](https://gitlab.com/kstr0k/mru-files.kak/-/tree/master/kakhist) to [mru-files.kak](https://gitlab.com/kstr0k/mru-files.kak). It’s a separate module, so those who have their own MRU’s can use kakhist independently (it does, however, require the sh library module in the same repo). There’s also a vim [q: replacement](#command-history-buffer) which you can map to g: (command history buffer). kakhist saves & restores command (slight_smile history to/from a single kakhist.txt file. It works with multiple, overlapping sessions without clobbering unrelated histories — it figures out which commands have been loaded and which…

Good luck, I would like to give `kak-lsp` a go but haven’t as yet so no help from me on that one.

> [@andreyorst](#):
>
> `plug "kstr0k/mru-files.kak" domain "gitlab.com" defer mru-files %{`

this is helpful especially on a small monitor when doing `:plug-list`.

---

<div class="post-metadata">

**Author:** ![The-BigDaddy](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/the-bigdaddy/32/1562_2.png) [@The-BigDaddy](https://discuss.kakoune.com/u/The-BigDaddy)\
**Post date:** [September 2, 2021, 11:25pm UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/3 "2021-09-02T23:25:27Z")

</div>

Hey duncan,

Thanks! I don’t see anything in `*debug*` for luar and peneira now.

This `kak-lsp` one is alluding me still. @andreyorst have any ideas by chance?

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [September 5, 2021, 5:24pm UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/4 "2021-09-05T17:24:29Z")

</div>

I don’t have Rust toolchain, and I don’t use Kakoune for code editing, so I don’t think I can help with kak lsp configuration, but it worked for me as specified above without issues (and without building an executable, so maybe that’s the case why I didn’t have same error)

Some notes:

Y can use `demand` instead of `require-module`;  
You don’t need `domain` if you specify full URL:

```auto
plug "https://gitlab.com/kstr0k/mru-files.kak.git" defer mru-files %{...}

```

Is the same as:

```auto
plug "kstr0k/mru-files.kak" domain "gitlab.com" defer mru-files %{

```

I don’t know what is `fuzzy` keymap, so I can’t fully reproduce this.

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [September 5, 2021, 9:52pm UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/5 "2021-09-05T21:52:23Z")

</div>

> #define-command lsp-restart %{ lsp-stop; lsp-start }

Not sure if this can work since those commands are async.

> hook -always global KakEnd .\* lsp-exit

this is already done by kak-lsp AFAIK

> 103:1: ‘define-command’: command ‘lsp-start’ already defined

sounds like you are sourcing `kak-lsp/rc/lsp.kak` twice  
plug.kak will source by default, so make sure it’s not in your autoload dir.  
Maybe you are accidentally sourcing it a again by doing `eval %sh{kak-lsp --kakoune -s $kak_session}` somewhere?

First thing to try would be to reproduce this with minimal configuration. Can you try launching kak in a temporary `$HOME`? Maybe kak-lsp should provide nightly builds for plug.kak users… I take it kak-lsp works when installing outside plug.kak?

---

<div class="post-metadata">

**Author:** ![almr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/almr/32/934_2.png) [@almr](https://discuss.kakoune.com/u/almr)\
**Post date:** [September 8, 2021, 7:57am UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/6 "2021-09-08T07:57:28Z")

</div>

Hi @The-BigDaddy , are you still having problems with `mru-files`? The configuration you quoted has a single problem: it tries to use `defer` instead of `demand`. Unless you `require-module mru-files` elsewhere, the module simply won’t load.

Is there any reason for preferring `defer` over the `demand` recommended in the README / project homepage?

In any case, I’ll shortly push a (rather huge) update; there has been a ton of work on the `work` branch, and there’s also a `test` branch. Please, _do_ report bugs, or any installation problems, in the [mru-files issue tracker](https://gitlab.com/kstr0k/mru-files.kak/-/issues); I haven’t necessarily read the forum over the summer.

---

<div class="post-metadata">

**Author:** ![The-BigDaddy](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/the-bigdaddy/32/1562_2.png) [@The-BigDaddy](https://discuss.kakoune.com/u/The-BigDaddy)\
**Post date:** [December 3, 2021, 3:28am UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/7 "2021-12-03T03:28:54Z")

</div>

Hey friend, I still have

```auto
plug "https://gitlab.com/kstr0k/mru-files.kak.git" domain "gitlab.com" defer mru-files %{
	set-option global mru_files_history %sh{ echo "$HOME/.local/share/kak/mru.txt" }
} config %{
	require-module kakhist; kakhist-init 
	map global goto ':' '<esc>: kakhist-buf-show<ret>' -docstring "show command history"
	map global fuzzy 'r' '<esc>: mru-files<ret>' -docstring "recent files"
}

```

in my config and I’m getting the `'mru-files': no such command` error. Though, as you can tell about how late my reply is, I haven’t looked at it further. I’ll change some things and get back.

---

<div class="post-metadata">

**Author:** ![almr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/almr/32/934_2.png) [@almr](https://discuss.kakoune.com/u/almr)\
**Post date:** [December 10, 2021, 1:00pm UTC](https://discuss.kakoune.com/t/unclear-errors-in-relation-to-plug-kak/1853/8 "2021-12-10T13:00:27Z")

</div>

Hi, see above; use `demand` instead of `defer` if you mean to load the module, or add `require-module mru-files`. If you also want persistent command history, also add `require-module kakhist; kakhist-init`.
