diff --git a/src/Neovim.ts b/src/Neovim.ts index 631f7601..7cd606c7 100644 --- a/src/Neovim.ts +++ b/src/Neovim.ts @@ -126,13 +126,8 @@ export async function neovim( stdout.setTypes(apiInfo.types); Object.assign(functions, apiInfo.functions - .filter(f => f.deprecated_since === undefined) .reduce((acc, cur) => { - let name = cur.name; - if (name.startsWith("nvim_")) { - name = name.slice(5); - } - acc[name] = (...args: any[]) => request(cur.name, args); + acc[cur.name] = (...args: any[]) => request(cur.name, args); return acc; }, {} as {[k: string]: (...args: any[]) => any})); functions.get_current_channel = () => channel; diff --git a/src/frame.ts b/src/frame.ts index fa82f7d5..80a10c67 100644 --- a/src/frame.ts +++ b/src/frame.ts @@ -36,21 +36,21 @@ export const isReady = browser const nvim = await nvimPromise; - keyHandler.on("input", (s: string) => nvim.input(s)); + keyHandler.on("input", (s: string) => nvim.nvim_input(s)); rendererEvents.on("modeChange", (s: NvimMode) => keyHandler.setMode(s)); // We need to set client info before running ui_attach because we want this // info to be available when UIEnter is triggered const extInfo = browser.runtime.getManifest(); const [major, minor, patch] = extInfo.version.split("."); - nvim.set_client_info(extInfo.name, + nvim.nvim_set_client_info(extInfo.name, { major, minor, patch }, "ui", {}, {}, ); - nvim.ui_attach( + nvim.nvim_ui_attach( cols < 1 ? 1 : cols, rows < 1 ? 1 : rows, { @@ -75,40 +75,40 @@ export const isReady = browser width * window.devicePixelRatio, height * window.devicePixelRatio ); - nvim.ui_try_resize_grid(getGridId(), nCols, nRows); + nvim.nvim_ui_try_resize_grid(getGridId(), nCols, nRows); page.resizeEditor(Math.floor(width / nCols) * nCols, Math.floor(height / nRows) * nRows); } }); - page.on("frame_sendKey", (args) => nvim.input(args.join(""))); - page.on("get_buf_content", (r: any) => r(nvim.buf_get_lines(0, 0, -1, 0))); + page.on("frame_sendKey", (args) => nvim.nvim_input(args.join(""))); + page.on("get_buf_content", (r: any) => r(nvim.nvim_buf_get_lines(0, 0, -1, 0))); // Create file, set its content to the textarea's, write it const filename = toFileName(urlSettings.filename, url, selector, language); const content = await contentPromise; const [line, col] = cursor; - const writeFilePromise = nvim.call_function("writefile", [content.split("\n"), filename]) - .then(() => nvim.command(`edit ${filename} ` + const writeFilePromise = nvim.nvim_call_function("writefile", [content.split("\n"), filename]) + .then(() => nvim.nvim_command(`edit ${filename} ` + `| call nvim_win_set_cursor(0, [${line}, ${col}])`)); // Can't get coverage for this as browsers don't let us reliably // push data to the server on beforeunload. /* istanbul ignore next */ window.addEventListener("beforeunload", () => { - nvim.ui_detach(); - nvim.command("qall!"); + nvim.nvim_ui_detach(); + nvim.nvim_command("qall!"); }); // Keep track of last active instance (necessary for firenvim#focus_input() & others) const chan = nvim.get_current_channel(); function setCurrentChan() { - nvim.set_var("last_focused_firenvim_channel", chan); + nvim.nvim_set_var("last_focused_firenvim_channel", chan); } setCurrentChan(); window.addEventListener("focus", setCurrentChan); window.addEventListener("click", setCurrentChan); // Ask for notifications when user writes/leaves firenvim - nvim.exec_lua(` + nvim.nvim_exec_lua(` local args = {...} local augroupName = args[1] local filename = args[2] @@ -181,7 +181,7 @@ export const isReady = browser (evt.metaKey ? "D" : "") + (evt.shiftKey ? "S" : ""); const [x, y] = getGridCoordinates(evt.pageX, evt.pageY); - nvim.input_mouse(button, + nvim.nvim_input_mouse(button, action, modifiers, getGridId(), @@ -208,11 +208,11 @@ export const isReady = browser window.addEventListener("focus", () => { document.documentElement.style.opacity = "1"; keyHandler.focus(); - nvim.command("doautocmd FocusGained"); + nvim.nvim_command("doautocmd FocusGained"); }); window.addEventListener("blur", () => { document.documentElement.style.opacity = "0.5"; - nvim.command("doautocmd FocusLost"); + nvim.nvim_command("doautocmd FocusLost"); }); keyHandler.focus(); return new Promise ((resolve, reject) => setTimeout(() => {