Unclear errors in relation to `plug.kak`

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:

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 [x] is already defined”

I’m attempting to install peneira, and this is my configuration with plug.kak:

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.

/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:

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*:

/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.

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?

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:

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

or a duplication message will occur when using:

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 :wave:


Hey BD this might solve the other issue,

kakhist is a sub-package of mru-files so go with one call only to mru-files and just do the require-module kakhist; kakhist-init thing in a config %{ block }.

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

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

1 Like

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?

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:

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

Is the same as:

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.

#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?

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; I haven’t necessarily read the forum over the summer.