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

Errors calling Goneovim commands during initialization #440

Open
mars0i opened this issue Feb 13, 2023 · 6 comments
Open

Errors calling Goneovim commands during initialization #440

mars0i opened this issue Feb 13, 2023 · 6 comments

Comments

@mars0i
Copy link

mars0i commented Feb 13, 2023

I don't know whether this is an issue--maybe only a question.

I define some vim functions that configure the goneovim window. Some of these functions calls the new GonvimWinPos command. The commands work if I entered them at at the : prompt. However, they usually won't work in my initialization script .vim/vimrc. If I put the line Code in .vim/vimrc, I two similar errors. The first is "E492: Not an editor command GonvimWinpos 400 0" from this script, which is called from .vim/vimrc:

function! Tall()
	set lines=59
	GonvimWinpos 400 0
endfunction
function! CodeWide()
	set columns=100
	call Tall()
	GonvimWinpos 980 0
endfunction
command! Code call CodeWide()

However, if I enter Code at the : prompt, it always works.

I don't always get the error! Sometimes columns gets set to 100, and the window is moved to the correct position, but the lines are not set to 59.

Is there a special way to call goneovim commands during initialization? (Could there be a race conditions, since it works sometimes??)

Thanks!

@akiyosi
Copy link
Owner

akiyosi commented Feb 13, 2023

@mars0i
Hi :)
Thanks for the issue report!

Goneovim registers Goneovim's own commands and functions necessary for command execution with neovim at startup. The problem may be a timing issue between this registration process and the vimrc loading process in startup.
One solution is to run your vimscript with Ginitvim in settings.toml. Ginitvim is run after the Goneovim initialization process so timing issues do not arise.

[Editor]
# ...
Ginitvim = '''
function! Tall()
	set lines=59
	GonvimWinpos 400 0
endfunction
function! CodeWide()
	set columns=100
	call Tall()
	GonvimWinpos 980 0
endfunction
command! Code call CodeWide()

Code
'''

@mars0i
Copy link
Author

mars0i commented Feb 13, 2023

Thanks @akiyosi . That's exactly what I wanted to know. Trying that out now. Since the behavior wasn't entirely consistent, I'll wait to see after I run Goneovim several times.

@mars0i
Copy link
Author

mars0i commented Feb 15, 2023

The Code command is consistently being executed from settings.toml. It works the same way whether I define CodeWide() directly in the Ginitvim block, or source it in another file. I can also just put the commands I want directly into the Ginitvim block, i.e.

Ginitvim = '''
GonvimWinpos 980 0
set columns=100
set lines=66
'''

However, there is one odd thing. GonvimWinpos is executed, and set columnes=100 is executed, but set lines=66 is not. If I then enter Code at the : prompt, the set lines command is executed.

Or if I add sleep 1 before set lines in settings.toml or in the script file that I source from there, then set lines=66 is executed (after a pause, of course).

Maybe set lines needs something that's not yet loaded at first? I don't know. This is not a big problem for me, but I thought I should mention it.

@mars0i
Copy link
Author

mars0i commented Feb 15, 2023

If I add sleep 100m, set lines works, and the delay is not noticeable to me. So my problem is solved--though the issue is interesting.

@mars0i
Copy link
Author

mars0i commented Feb 15, 2023

That was on a Macbook Pro. On my Macbook Air, no sleep is needed--maybe because the computer is slower. (It also uses a different MacOS version, but it seems unlikely that that would matter.)

@akiyosi
Copy link
Owner

akiyosi commented Feb 16, 2023

@mars0i
I imagine that in a fast-processing computer, these commands are instantaneously transmitted to the OS window management system, but there are layers where they are processed asynchronously, so that one may be ignored at certain times.

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

2 participants