diff --git a/browser/src/App.ts b/browser/src/App.ts index ae1d2e8372..3537ae72df 100644 --- a/browser/src/App.ts +++ b/browser/src/App.ts @@ -105,12 +105,14 @@ export const start = async (args: string[]): Promise => { const cssPromise = import("./CSS") const completionProvidersPromise = import("./Services/Completion/CompletionProviders") - const parsedArgs = minimist(args, { string: "_" }) + const parsedArgs = minimist(args, { "--": true, string: "_" }) const currentWorkingDirectory = process.cwd() const normalizedFiles = parsedArgs._.map( arg => (path.isAbsolute(arg) ? arg : path.join(currentWorkingDirectory, arg)), ) + const additionalArgs = parsedArgs["--"] || [] + const filesToOpen = normalizedFiles.filter(f => { if (fs.existsSync(f)) { return fs.statSync(f).isFile() @@ -293,6 +295,7 @@ export const start = async (args: string[]): Promise => { const initializeAllEditors = async () => { await startEditors( filesToOpen, + additionalArgs, Colors.getInstance(), CompletionProviders.getInstance(), configuration, diff --git a/browser/src/Editor/NeovimEditor/NeovimEditor.tsx b/browser/src/Editor/NeovimEditor/NeovimEditor.tsx index a67f0e4a23..56105da781 100644 --- a/browser/src/Editor/NeovimEditor/NeovimEditor.tsx +++ b/browser/src/Editor/NeovimEditor/NeovimEditor.tsx @@ -998,15 +998,23 @@ export class NeovimEditor extends Editor implements Oni.Editor { public async init( filesToOpen: string[], + additionalArgs?: string[], startOptions?: Partial, ): Promise { - Log.info("[NeovimEditor::init] Called with filesToOpen: " + filesToOpen) + Log.info( + "[NeovimEditor::init] Called with filesToOpen: " + + filesToOpen + + " and args: " + + additionalArgs, + ) + additionalArgs = additionalArgs || [] const defaultOptions: INeovimStartOptions = { runtimePaths: this._pluginManager.getAllRuntimePaths(), transport: this._configuration.getValue("experimental.neovim.transport"), neovimPath: this._configuration.getValue("debug.neovimPath"), loadInitVim: this._configuration.getValue("oni.loadInitVim"), useDefaultConfig: this._configuration.getValue("oni.useDefaultConfig"), + additionalArgs: additionalArgs, } const combinedOptions = { diff --git a/browser/src/Editor/OniEditor/OniEditor.tsx b/browser/src/Editor/OniEditor/OniEditor.tsx index 8694900520..01831b02ce 100644 --- a/browser/src/Editor/OniEditor/OniEditor.tsx +++ b/browser/src/Editor/OniEditor/OniEditor.tsx @@ -331,10 +331,10 @@ export class OniEditor extends Utility.Disposable implements Oni.Editor { this._neovimEditor.bufferDelete(bufferId) } - public async init(filesToOpen: string[]): Promise { + public async init(filesToOpen: string[], additionalArgs?: string[]): Promise { Log.info("[OniEditor::init] Called with filesToOpen: " + filesToOpen) - return this._neovimEditor.init(filesToOpen) + return this._neovimEditor.init(filesToOpen, additionalArgs) } public async input(key: string): Promise { diff --git a/browser/src/Services/Learning/Tutorial/TutorialBufferLayer.tsx b/browser/src/Services/Learning/Tutorial/TutorialBufferLayer.tsx index 6c56aed169..f90e1ebfba 100644 --- a/browser/src/Services/Learning/Tutorial/TutorialBufferLayer.tsx +++ b/browser/src/Services/Learning/Tutorial/TutorialBufferLayer.tsx @@ -132,7 +132,7 @@ export class TutorialBufferLayer implements Oni.BufferLayer { alert("quit!") }) - this._initPromise = this._editor.init([], { + this._initPromise = this._editor.init([], [], { loadInitVim: false, }) diff --git a/browser/src/neovim/NeovimProcessSpawner.ts b/browser/src/neovim/NeovimProcessSpawner.ts index 97715d6663..6034b62b66 100644 --- a/browser/src/neovim/NeovimProcessSpawner.ts +++ b/browser/src/neovim/NeovimProcessSpawner.ts @@ -32,6 +32,9 @@ export interface INeovimStartOptions { // Explicitly specify the path to Neovim. If not specified, // the default path will be used. neovimPath?: string + + // Additional arguments to pass directly to Neovim + additionalArgs: string[] } const DefaultStartOptions: INeovimStartOptions = { @@ -39,6 +42,7 @@ const DefaultStartOptions: INeovimStartOptions = { transport: "stdio", loadInitVim: true, useDefaultConfig: true, + additionalArgs: [], } const getSessionFromProcess = async ( @@ -122,15 +126,17 @@ export const startNeovim = async ( initVimArg = ["-u", loadInitVimConfigOption] } - const argsToPass = initVimArg.concat([ - "--cmd", - `let &rtp.=',${joinedRuntimePaths}'`, - "--cmd", - "let g:gui_oni = 1", - "-N", - "--embed", - "--", - ]) + const argsToPass = initVimArg + .concat([ + "--cmd", + `let &rtp.=',${joinedRuntimePaths}'`, + "--cmd", + "let g:gui_oni = 1", + "-N", + "--embed", + ]) + .concat(options.additionalArgs) + .concat(["--"]) Log.verbose( "[NeovimProcessSpawner::startNeovim] Sending these args to Neovim: " + diff --git a/browser/src/neovim/SharedNeovimInstance.ts b/browser/src/neovim/SharedNeovimInstance.ts index a18cb3f5fa..fd8f88dcfc 100644 --- a/browser/src/neovim/SharedNeovimInstance.ts +++ b/browser/src/neovim/SharedNeovimInstance.ts @@ -167,6 +167,7 @@ class SharedNeovimInstance implements SharedNeovimInstance { public async start(): Promise { const startOptions: INeovimStartOptions = { + additionalArgs: [], runtimePaths: this._pluginManager.getAllRuntimePaths(), loadInitVim: false, useDefaultConfig: true, diff --git a/browser/src/startEditors.ts b/browser/src/startEditors.ts index 69b3c7ee5b..4ad78dc676 100644 --- a/browser/src/startEditors.ts +++ b/browser/src/startEditors.ts @@ -22,7 +22,8 @@ import { windowManager } from "./Services/WindowManager" import { Workspace } from "./Services/Workspace" export const startEditors = async ( - args: any, + filesToOpen: string[], + additionalArgs: string[], colors: Colors, completionProviders: CompletionProviders, configuration: Configuration, @@ -52,5 +53,5 @@ export const startEditors = async ( ) windowManager.createSplit("horizontal", editor) - await editor.init(args) + await editor.init(filesToOpen, additionalArgs) }