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

dynamic --headless, nvim_ui_builtin() #7438

Open
lucc opened this issue Oct 24, 2017 · 4 comments
Open

dynamic --headless, nvim_ui_builtin() #7438

lucc opened this issue Oct 24, 2017 · 4 comments
Labels
enhancement feature request gsoc community: Google Summer of Code project tui ui
Milestone

Comments

@lucc
Copy link
Contributor

lucc commented Oct 24, 2017

I would like to request a vimscript function or api function that should negate the effect of the --headless command line switch. Lets call it nvim_launch_builtin_tui() for now. I imagine something like this:

if My_condition()
  call nvim_launch_builtin_tui()
  " now it looks as if we did start nvim without --headless
else
  " this text will go directly to stdout
  echo "running headless"
endif'

and then one would do nvim --headless -S above-file.vim. Depending on the user function My_condition one would effectively end up in a "normal" TUI nvim instance or in a headless nvim.

If I can express the logic of the My_condition() vimscript function in the my_condition shell command/function I can currently do something similar with this shell script:

if my_condition; then
  # this now *is* a nvim without --headless
  nvim
else
  # this text will go directly to stdout
  nvim --headless --cmd 'echo "running headless"'
fi
@justinmk
Copy link
Member

What's the use case?

We should at least provide a way to connect the TUI to another nvim instance.

@lucc
Copy link
Contributor Author

lucc commented Oct 24, 2017

My use case at least would be to simplify the implementation of https://github.com/lucc/nvimpager. I have something like the "my_condition" stuff above but the shell version is much more complicated and inacurate than what I assume the vimscript version would be.

Currently I have kind of this control flow in the shell script:

  1. make a guess which arguments are files and which are command line switches for nvim
  2. check if we should read from stdin, if so, save stdin to a temp file.
  3. guess if all files combined will fit on the screen (just count lines, don't consider wrapping or conceal)
  4. depending on the above start nvim in my "pager mode" or nvim --headless in my "cat mode"

With a nvim_launch_builtin_tui() function I guess I could implement this in vimscript:

  1. (still in the shell) start nvim --headless with all options and file arguments given by the user
  2. decide if we should read stdin
  3. count file arguments and their size (should be more accurate here)
  4. depending on the above call nvim_launch_builtin_tui() to go to "pager mode" or continue in "cat mode"

About your additional remark:

We should at least provide a way to connect the TUI to another nvim instance.

Do you mean one could start a headless nvim in the background (maybe even a systemd unit) and then connect a TUI to it from any xterm window? That sounds like a very nice use case similar to emacsclient -ct, which I consider a very interesting (although unrelated to this PR) use case.

@justinmk
Copy link
Member

justinmk commented Oct 24, 2017

Do you mean one could start a headless nvim in the background (maybe even a systemd unit) and then connect a TUI to it from any xterm window?

Yes. (Update: Proposed as a GSoC project)

@justinmk justinmk added enhancement feature request tui ui labels Oct 24, 2017
@justinmk justinmk added this to the todo milestone Oct 24, 2017
@justinmk justinmk changed the title Feature request: start the TUI with a vimscript function from a --headless instance connect TUI to another nvim instance (WAS: undo --headless) Feb 11, 2018
@justinmk justinmk added the gsoc community: Google Summer of Code project label Feb 11, 2018
justinmk pushed a commit that referenced this issue Mar 3, 2018
@justinmk justinmk changed the title connect TUI to another nvim instance (WAS: undo --headless) dynamic --headless, nvim_ui_builtin() May 9, 2018
@justinmk
Copy link
Member

justinmk commented May 9, 2018

The original request here is addressed by #8246.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request gsoc community: Google Summer of Code project tui ui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants