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

Commit

Permalink
[WIP] Allow the passing of a custom init.vim path. (#784)
Browse files Browse the repository at this point in the history
* Allow the passing of a custom init.vim path.

* Fixed linting error.

* Consolidated loading init vim and choosing path in to one option.

Also refactored the opening of the init.vim to use the existing open command.

* Renamed variable.

* Fixed linting issues.
  • Loading branch information
CrossR authored and bryphe committed Oct 12, 2017
1 parent 64ebbe5 commit 4bf40fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion browser/src/Services/Commands.ts
Original file line number Diff line number Diff line change
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()),

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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 4bf40fd

Please sign in to comment.