diff --git a/packages/cursorless-neovim/src/extension.ts b/packages/cursorless-neovim/src/extension.ts index 474a9f3c08..9c1dd35f3e 100644 --- a/packages/cursorless-neovim/src/extension.ts +++ b/packages/cursorless-neovim/src/extension.ts @@ -108,6 +108,7 @@ export async function activate(context: NeovimExtensionContext) { async function createNeovimIde(context: ExtensionContext) { const neovimIDE = new NeovimIDE(context); + await neovimIDE.init(); const hats = new NeovimHats(neovimIDE, context); await hats.init(); diff --git a/packages/cursorless-neovim/src/ide/neovim/NeovimIDE.ts b/packages/cursorless-neovim/src/ide/neovim/NeovimIDE.ts index 46218d4ee4..8aca4ae15b 100644 --- a/packages/cursorless-neovim/src/ide/neovim/NeovimIDE.ts +++ b/packages/cursorless-neovim/src/ide/neovim/NeovimIDE.ts @@ -31,6 +31,9 @@ import NeovimGlobalState from "./NeovimGlobalState"; import NeovimMessages from "./NeovimMessages"; import { Window } from "neovim"; import { NeovimTextEditorImpl } from "./NeovimTextEditorImpl"; +import { NeovimExtensionContext } from "./NeovimExtensionContext"; +import { getTalonNvimPath } from "../../neovimApi"; +import path from "path"; export class NeovimIDE implements IDE { readonly configuration: NeovimConfiguration; @@ -50,6 +53,7 @@ export class NeovimIDE implements IDE { workspaceFolders: readonly WorkspaceFolder[] | undefined = undefined; private disposables: Disposable[] = []; private assetsRoot_: string | undefined; + private cursorlessNeovimPath: string | undefined; private quickPickReturnValue: string | undefined = undefined; constructor(private extensionContext: ExtensionContext) { @@ -60,7 +64,26 @@ export class NeovimIDE implements IDE { this.capabilities = new NeovimCapabilities(); this.editorMap = new Map(); this.activeWindow = undefined; - //this.assetsRoot_ = "C:\\"; // TODO: fix but not needed for now as used by snippets and cheatsheet only? + } + + async init() { + const client = (this.extensionContext as NeovimExtensionContext).client; + const talonNvimPath = await getTalonNvimPath(client); + // talon-nvim path: C:\Users\User\AppData\Local\nvim-data\lazy\talon.nvim + // we store the assets into a subfolder of talon.nvim + this.assetsRoot_ = path.join(talonNvimPath, "assets"); + // development cursorless-neovim path: C:\Users\User\AppData\Local\nvim\rplugin\node\cursorless-neovim + // TODO: we will need to change this once all the files are in talon.nvim/ + this.cursorlessNeovimPath = path.join( + talonNvimPath, + "..", + "..", + "..", + "nvim", + "rplugin", + "node", + "cursorless-neovim", + ); } async showQuickPick( diff --git a/packages/cursorless-neovim/src/neovimApi.ts b/packages/cursorless-neovim/src/neovimApi.ts index f424718a2d..4cfd351f18 100644 --- a/packages/cursorless-neovim/src/neovimApi.ts +++ b/packages/cursorless-neovim/src/neovimApi.ts @@ -95,11 +95,18 @@ export async function windowGetVisibleRanges( ]; } +export async function getTalonNvimPath(client: NeovimClient): Promise { + const luaCode = `return require("talon.utils").talon_nvim_path()`; + const data = await client.executeLua(luaCode, []); + // TODO: is there a better way to cast that? + return data as unknown as string; +} + export async function putToClipboard(data: string, client: NeovimClient) { await client.callFunction("setreg", ["*", data]); } -// TODO: this hasn't been tested yet +// TODO: this hasn't been tested yet and will be once we test "paste to row one" commands export async function getFromClipboard(client: NeovimClient): Promise { const luaCode = `return require("talon.cursorless").get_from_clipboard()`; const data = await client.executeLua(luaCode, []);