Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION]: :new command gives an error 'terminal': no such command when using Kakoune with Alacritty #5139

Open
VKondakoff opened this issue Apr 10, 2024 · 13 comments

Comments

@VKondakoff
Copy link

Question

Hi!

I'm trying to use :new command to create new Kakoune client in new window (Alacritty is a terminal emulator). Unfortunately this fires an error 'terminal': no such command:

Снимок экрана 2024-04-10 в 12 24 08

What should I add to kakrc to be able to create new Kakoune client in new window in Alacritty? I'm a little bit lost... ;(

Thank you!

@Screwtapello
Copy link
Contributor

Are there any messages in the *debug* buffer?

@VKondakoff
Copy link
Author

Nothing new, just the same error: Error: 1:1: 'new': 2:5: 'terminal': no such command.
I'm pretty sure the problem is that terminal command is not set correctly. I suppose it should contain something like alacritty -e sh -c. But I have no idea where and how it should be set.
These two files seems related: https://raw.githubusercontent.com/mawww/kakoune/master/rc/windowing/x11.kak and https://raw.githubusercontent.com/mawww/kakoune/master/rc/windowing/new-client.kak

Any ideas?

@schragge
Copy link

Looks like x11.kak doesn't define the alias terminal for x11-terminal-window? What would happen if you add the line

alias global terminal x11-terminal-window

@VKondakoff
Copy link
Author

VKondakoff commented Apr 10, 2024

If I'm just adding line alias global terminal x11-terminal-window to kakrc I'm receiving error:

Снимок экрана 2024-04-10 в 17 04 57

Here is debug buffer:

Снимок экрана 2024-04-10 в 17 06 58

Should I source or require something first?

Edit: I have added X11.kak to autoload and added the following to kakrc:

hook global ModuleLoaded x11 %{
  alias global terminal X11-terminal-window
}

Startup error is gone, but the :new command still fires the same error...

@krobelus
Copy link
Contributor

you should not need to change anything. In fact, it's best to try with HOME=$(mktemp -d) kak to rule out your config.
For some reason no windowing module is loaded. Run as kak -debug commands and look at the contents of the *debug* buffer.

It should contain a snippet like this one.

command require-module tmux
command evaluate-commands fail\ tmux\ not\ detected
command fail tmux not detected
command require-module screen
command evaluate-commands fail\ screen\ not\ detected
command fail screen not detected
command require-module zellij
command require-module kitty
command require-module iterm
command require-module appleterminal
command require-module sway
command evaluate-commands 
command require-module wayland
command evaluate-commands 
command declare-option -docstring shell\ command\ run\ to\ spawn\ a\ new\ terminal
a\ shell\ command\ is\ appended\ to\ the\ one\ set\ in\ this\ option\ at\ runtime str termcmd alacritty\ \ \ \ \ \ -e\ sh\ -c
command define-command wayland-terminal-window -params 1.. -docstring 

here, wayland succeeds which you can see from the fact that wayland-terminal-window is being defined.

I guess for you none of those windowing modules is detected successfully.
x11 is only detected if $DISPLAY is set. Can you confirm it fails with fail DISPLAY is not set?

@VKondakoff
Copy link
Author

@krobelus

Thank you for helping!

Run as kak -debug commands

When I run kak with debug option there is missing value error:
Снимок экрана 2024-04-10 в 18 56 05

Where can I find the args for -debug option?

Thank you!

@schragge
Copy link

You omitted commands from

kak -debug commands

@VKondakoff
Copy link
Author

Ah, sorry. I was thinking commands is a placeholder, like args or something... Got it.

@VKondakoff
Copy link
Author

Can you confirm it fails with fail DISPLAY is not set?

Yes. Here is the debug output (this is what I receive when running kak from Alacritty and Terminal):

echo\ -debug\ 'no\ windowing\ module\ detected'\ 
command require-module tmux
command evaluate-commands fail\ tmux\ not\ detected
command fail tmux not detected
command require-module screen
command evaluate-commands fail\ screen\ not\ detected
command fail screen not detected
command require-module zellij
command evaluate-commands fail\ zellij\ not\ detected
command fail zellij not detected
command require-module kitty
command evaluate-commands fail\ Kitty\ not\ detected
command fail Kitty not detected
command require-module iterm
command evaluate-commands fail\ iTerm\ not\ detected
command fail iTerm not detected
command require-module sway
command evaluate-commands fail\ SWAYSOCK\ is\ not\ set
command fail SWAYSOCK is not set
command require-module wayland
command evaluate-commands fail\ WAYLAND_DISPLAY\ is\ not\ set
command fail WAYLAND_DISPLAY is not set
command require-module x11
command evaluate-commands fail\ DISPLAY\ is\ not\ set
command fail DISPLAY is not set
command require-module wezterm
command evaluate-commands fail\ wezterm\ not\ detected
command fail wezterm not detected
command echo -debug no\ windowing\ module\ detected
no windowing module detected
command autorestore-restore-buffer
command evaluate-commands 
command new
Error: 1:1: 'new': 2:5: 'terminal': no such command

This is Kitty (does not work as well: no errors, but nothing happens):

command new
command terminal kak -c 27835 -e 
command nop 

And this is Term2, which works as expected:

command new
command terminal kak -c 27895 -e 
command iterm-terminal-impl vertically kak -c 27895 -e 
command nop 
remote client connected: 5
Снимок экрана 2024-04-10 в 19 28 28

@krobelus
Copy link
Contributor

right, macos does not set DISPLAY, and loading x11.kak would be wrong because it uses tools like xdotool that presumably won't work.

I think we should create a quartz.kak using similar terminal options as x11.kak.
If you wanna try that, I think it can be mostly copy-pasted from x11.kak except it should be loaded based on [ $(uname) = Darwin ] or similar.
Also we can't use setsid because I don't think that exists on macos but I think it's mostly fine without it.

My guess is that so far macos users have been using iterm and Terminal.app which have specific integrations in iterm.kak and appleterminal.kak.

@VKondakoff
Copy link
Author

Another one related issue: there is no 'terminal': no such command error if I'm using iTerm2. But currently I'm experimenting with Kakoune client-server possibilities and it turns out that the :new command works correctly in iTerm2 only if the Kakoune server was started manually from the interactive shell. If the Kakoune server was started by running the shell-script

cd "~"
/usr/local/bin/kak -d -s vk &

from Keyboard Maestro - I'm receiving the same 'terminal': no such command error. (I just want to start headless Kakuone server at user login).

accepting connection failed: socket read failed: No such file or directory
remote client connected: 4
Error: 1:1: 'new': 2:5: 'terminal': no such command
remote client disconnected: 4
remote client connected: 4
Error: 1:1: 'new': 2:5: 'terminal': no such command
remote client disconnected: 4
remote client connected: 4
Error: 1:1: 'new': 2:5: 'terminal': no such command
Error: 1:1: 'e': wrong argument count
Error: 1:1: 'e': wrong argument count
Error: 1:1: 'e': wrong argument count
remote client disconnected: 4
remote client connected: 4
Error: 1:1: 'new': 2:5: 'terminal': no such command

Anything I can do about this?

@krobelus
Copy link
Contributor

Looks like the same issue.
Kakoune ships integrations for iterm, wayland, tmux etc.
If you lanuch it from outside any of those environments, it will not work.
If you want to make it work, build Kakoune from source, do something like cp rc/windowing/{wayland,quartz}.kak, edit it as explained above and make sure to add it to rc/windowing/detection.kak.
Ideally also share it upstream.

@iacore
Copy link

iacore commented Jul 8, 2024

For some reason, kakoune doesn't use the terminal I want.

I fixed it by adding the following to the start of kakrc.

set global windowing_modules 'x11'
require-module x11
set global termcmd 'kitty sh -c'

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

No branches or pull requests

5 participants