Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

[WIP] Allow the passing of a custom init.vim path. #784

Merged
merged 5 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser/src/Services/Commands.ts
Expand Up @@ -53,7 +53,7 @@ export const registerBuiltInCommands = (commandManager: CommandManager, pluginMa
// Menu commands
new CallbackCommand("oni.config.openConfigJs", "Edit Oni Config", "Edit configuration file ('config.js') for Oni", () => openDefaultConfig(neovimInstance)),

new CallbackCommand("oni.config.openInitVim", "Edit Neovim Config", "Edit configuration file ('init.vim') for Neovim", () => neovimInstance.open("$MYVIMRC")),
new CallbackCommand("oni.config.openInitVim", "Edit Neovim Config", "Edit configuration file ('init.vim') for Neovim", () => neovimInstance.openInitVim()),
Copy link
Member

Choose a reason for hiding this comment

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

I like that you factored this out to a separate method, thanks!


new CallbackCommand("oni.openFolder", "Open Folder", "Set a folder as the working directory for Oni", () => openFolder(neovimInstance)),

Expand Down
3 changes: 2 additions & 1 deletion browser/src/Services/Configuration/IConfigurationValues.ts
Expand Up @@ -34,7 +34,8 @@ export interface IConfigurationValues {

// By default, user's init.vim is not loaded, to avoid conflicts.
// Set this to `true` to enable loading of init.vim.
"oni.loadInitVim": boolean
// Set this to a string to override the init.vim path.
"oni.loadInitVim": string | boolean

// Sets the `popupmenu_external` option in Neovim
// This will override the default UI to show a consistent popupmenu,
Expand Down
11 changes: 11 additions & 0 deletions browser/src/neovim/NeovimInstance.ts
Expand Up @@ -109,6 +109,7 @@ export interface INeovimInstance {
getApiVersion(): Promise<INeovimApiVersion>

open(fileName: string): Promise<void>
openInitVim(): Promise<void>

executeAutoCommand(autoCommand: string): Promise<void>
}
Expand Down Expand Up @@ -324,6 +325,16 @@ export class NeovimInstance extends EventEmitter implements INeovimInstance {
return this.command(`e! ${fileName}`)
}

public openInitVim(): Promise<void> {
const loadInitVim = configuration.getValue("oni.loadInitVim")

if (typeof(loadInitVim) === "string") {
return this.open(loadInitVim)
} else {
return this.open("$MYVIMRC")
}
}

public eval<T>(expression: string): Promise<T> {
return this._neovim.request("nvim_eval", [expression])
}
Expand Down
11 changes: 8 additions & 3 deletions browser/src/neovim/NeovimProcessSpawner.ts
Expand Up @@ -37,12 +37,17 @@ export const startNeovim = (runtimePaths: string[], args: string[]): Session =>
.map((p) => remapPathToUnpackedAsar(p))
.join(",")

const shouldLoadInitVim = configuration.getValue("oni.loadInitVim")
const loadInitVimConfigOption = configuration.getValue("oni.loadInitVim")
const useDefaultConfig = configuration.getValue("oni.useDefaultConfig")

const vimRcArg = (shouldLoadInitVim || !useDefaultConfig) ? [] : ["-u", noopInitVimPath]
let initVimArg = []
initVimArg = (loadInitVimConfigOption || !useDefaultConfig) ? [] : ["-u", noopInitVimPath]

const argsToPass = vimRcArg
if (typeof(loadInitVimConfigOption) === "string") {
initVimArg = ["-u", loadInitVimConfigOption]
}

const argsToPass = initVimArg
.concat(["--cmd", `let &rtp.='${joinedRuntimePaths}'`, "--cmd", "let g:gui_oni = 1", "-N", "--embed", "--"])
.concat(args)

Expand Down