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 2 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
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()),
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
1 change: 1 addition & 0 deletions browser/src/Services/Configuration/DefaultConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const BaseConfiguration: IConfigurationValues = {
"oni.useDefaultConfig": true,

"oni.loadInitVim": false,
"oni.customInitVimPath" : "",

"oni.useExternalPopupMenu": true,

Expand Down
3 changes: 3 additions & 0 deletions browser/src/Services/Configuration/IConfigurationValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export interface IConfigurationValues {
// Set this to `true` to enable loading of init.vim.
"oni.loadInitVim": boolean

// Option to override init.vim path.
"oni.customInitVimPath": string

// Sets the `popupmenu_external` option in Neovim
// This will override the default UI to show a consistent popupmenu,
// whether using Oni's completion mechanisms or VIMs
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 customInitVimPath = configuration.getValue("oni.customInitVimPath")

if (customInitVimPath) {
return this.command(`e! ${customInitVimPath}`)
Copy link
Member Author

Choose a reason for hiding this comment

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

I should probably refactor this to just use the open command, so the logic isn't duplicated.

Copy link
Member

Choose a reason for hiding this comment

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

Good idea 👍

} else {
return this.command(`e! $MYVIMRC`)
}
}

public eval<T>(expression: string): Promise<T> {
return this._neovim.request("nvim_eval", [expression])
}
Expand Down
10 changes: 8 additions & 2 deletions browser/src/neovim/NeovimProcessSpawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ export const startNeovim = (runtimePaths: string[], args: string[]): Session =>
.join(",")

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

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

const argsToPass = vimRcArg
if ((shouldLoadInitVim || !useDefaultConfig) && customInitVimPath) {
initVimArg = ["-u", customInitVimPath]
}

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

Expand Down