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

Add support for non-interactive bootstrapping #2528

Merged
merged 2 commits into from
Jan 2, 2024
Merged

Conversation

x0wllaar
Copy link
Contributor

Currently, bootstrapping NvChad requires interactive input on the first run, which makes it impossible to use in Dockerfiles. This PR adds a way to answer the "Do you want to install example custom config?" prompt non-interactively via an environment variable.

To run bootstrapping non-interactively, set the NVCHAD_INSTALL_EXAMPLE_CONFIG environment variable to the answer you want, and then run nvim, e.g.:

NVCHAD_INSTALL_EXAMPLE_CONFIG=no nvim -c "autocmd User PackerComplete quitall" -c "quitall"

Which will automatically do all bootstrapping without installing the example config and then immediately exit.

@siduck siduck changed the base branch from v2.0 to v3.0 November 28, 2023 00:19
@siduck siduck changed the base branch from v3.0 to v2.0 November 28, 2023 00:19
@siduck
Copy link
Member

siduck commented Nov 28, 2023

there should be a cleaner way to do this imo, i'll look into it this weekend

@comfysage
Copy link

I suggest just changing line 43 to:

local input = env.NVCHAD_INSTALL_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): "

instead of creating an unnecessary function that won't ever be used again

@geekobiloba
Copy link

This is interesting.

Any update on this workaround?

@siduck
Copy link
Member

siduck commented Dec 28, 2023

I suggest just changing line 43 to:

local input = env.NVCHAD_INSTALL_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): "

instead of creating an unnecessary function that won't ever be used again

env is always empty here, how does one set env var?

@pwnwriter
Copy link

Well, Technically we can use something like
nvim +"NoInput" or something like that while NoInput being a bool to check while first installation?

@pwnwriter
Copy link

Hey, there's a method you can use: nvim_create_user_command(). If users provides the cmd, proceed; otherwise, prompt them for input. For example.

vim.api.nvim_create_user_command("NoInput", function ()
local file = io.open("foo.txt", "w")
if file then
    file:close()
else
    print("Error creating the file.")
end
end,{})

This creates a file if they provide nvim +"NoInput"

@comfysage
Copy link

I suggest just changing line 43 to:

local input = env.NVCHAD_INSTALL_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): "

instead of creating an unnecessary function that won't ever be used again

env is always empty here, how does one set env var?

@siduck in this specific codeblock env is set to vim.env which assumes all environment variables set at runtime.

@siduck
Copy link
Member

siduck commented Jan 2, 2024

I suggest just changing line 43 to:

local input = env.NVCHAD_INSTALL_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): "

instead of creating an unnecessary function that won't ever be used again

env is always empty here, how does one set env var?

@siduck in this specific codeblock env is set to vim.env which assumes all environment variables set at runtime.

oh cool, ive to actually read the PR now

@siduck siduck merged commit 2fedda1 into NvChad:v2.0 Jan 2, 2024
siduck added a commit that referenced this pull request Jan 2, 2024
#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
@lucario387
Copy link
Contributor

why again?

vim.env.NVCHAD_EXAMPLE_CONFIG can be yes and it will fail, even though the intention is probably to still install example config

@siduck
Copy link
Member

siduck commented Jan 2, 2024

wym again?

vim.env.NVCHAD_EXAMPLE_CONFIG can be yes and it will fail

such users are supposed to keep it y or n ,if it fails then its their problem. We have provided env var check then they must follow it

@lucario387
Copy link
Contributor

And now the next question. Where is the documentation for the env var?

sim-o pushed a commit to sim-o/NvChadOld that referenced this pull request Jan 2, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
sim-o pushed a commit to sim-o/NvChadOld that referenced this pull request Jan 2, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
sim-o pushed a commit to sim-o/NvChadOld that referenced this pull request Jan 2, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
YanTree pushed a commit to YanTree/NvChad that referenced this pull request Jan 10, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
toantk238 added a commit to toantk238/NvChad that referenced this pull request Jan 13, 2024
Add support for non-interactive bootstrapping (NvChad#2528)
stylovich pushed a commit to stylovich/NvChad that referenced this pull request Jan 24, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
(cherry picked from commit 2fedda1)
le4ker pushed a commit to le4ker/NvMegaChad that referenced this pull request Feb 13, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
chkg2a pushed a commit to chkg2a/neovim that referenced this pull request Feb 14, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
PraveenGongada pushed a commit to PraveenGongada/NvChad that referenced this pull request Feb 18, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
le4ker pushed a commit to le4ker/NvMegaChad that referenced this pull request Feb 21, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
le4ker pushed a commit to le4ker/NvMegaChad that referenced this pull request Feb 27, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
le4ker pushed a commit to le4ker/NvMegaChad that referenced this pull request Feb 27, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
mdj2812 pushed a commit to mdj2812/NvChad that referenced this pull request Mar 11, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
atomicmm pushed a commit to atomicmm/NvChad that referenced this pull request Apr 18, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
ethanh6 pushed a commit to ethanh6/NvChad that referenced this pull request Apr 27, 2024
NvChad#2528 (comment)

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
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

Successfully merging this pull request may close these issues.

None yet

6 participants