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

feat: Add option afterInitConfig #1695

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

xiyaowong
Copy link
Collaborator

@xiyaowong xiyaowong commented Dec 9, 2023

The main idea: Save the config to a temporary file, and then use nvim's startup option -c and command source to load the file.

This configuration is suitable for simple operations such as configuring mappings in a temporary environment, but it can also execute any logic. The reason for using "after" is to avoid conflicting with existing configurations, and at the same time, it can be used to determine whether local configurations have been loaded in this configuration, thus executing different logic.

In addition, this configuration will not be automatically ignored based on neovimClean. Users can use "finish" on the first line to end the logic.

Close #1350

Config to be sourced after init config
@xiyaowong xiyaowong changed the title feat: Add option initialPostConfig feat: Add option afterInitConfig Dec 13, 2023
@xiyaowong xiyaowong merged commit ec2b287 into vscode-neovim:master Dec 13, 2023
8 checks passed
@xiyaowong xiyaowong deleted the feat/source-after-config branch December 13, 2023 03:41
const storagePath = this.extContext.globalStorageUri.fsPath;
if (!existsSync(storagePath)) mkdirSync(storagePath, { recursive: true });
const vim = path.join(storagePath, "afterInitConfig.vim");
writeFileSync(vim, config.afterInitConfig, { encoding: "utf8" });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing a file should not be needed. Nvim has nvim_exec2, or you can :source a temporary buffer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I seem to have made it complicated (misled by the previous requirement of startup parameters in the #1350).

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

3 participants