glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to run firenvim in Windows 10 Host System

xudyang1 opened this issue · comments

  • OS Version: Windows 10 22H2
  • Browser Version: Version 114.0.5735.199 (Official Build) (64-bit)
  • Browser Addon Version: 0.2.14
  • Neovim Plugin Version: 0.2.14

What I tried to do

  • Neovim installed by: scoop
  • Neovim version: 0.9.1
  • Neovim plugin manager: lazy.nvim

Note: I created environment variable $XDG_CONFIG_HOME with value as $HOME/.config in Windows to change config path from original ~/AppData/...

  • Lazy configuration:
-- ~/.config/nvim/lua/core/lazy.lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

function GET_NVIM_QT_RUNTIME_PATH()
  if vim.fn.has('gui_running') == 1 then
    return vim.fn.expand("~/scoop/apps/neovim/current/share/nvim-qt/runtime")
  else
    return nil
  end
end

local options = {
  defaults = {
    lazy = true -- should plugins be lazy-loaded?
    -- version = false -- default for latest commit
  },
  ui = { -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
    border = "rounded"
  },
  performance = {
    rtp = {
      -- lazy.nvim resets rtp, which clears NVIM_QT_RUNTIME_PATH: https://github.com/folke/lazy.nvim/issues/584
      paths = { GET_NVIM_QT_RUNTIME_PATH() },
      disabled_plugins = {
        "gzip",
        -- "matchit",
        -- "matchparen",
        "netrwPlugin",
        "tarPlugin",
        "tohtml",
        "tutor",
        "zipPlugin"
      }
    }
  }
}
require("lazy").setup("plugins", options)
  • Firenvim configuration:
-- ~/.config/nvim/lua/plugin/firenvim.lua
return {
  {
    'glacambre/firenvim',
    -- Lazy load firenvim
    -- Explanation: https://github.com/folke/lazy.nvim/discussions/463#discussioncomment-4819297
    cond = not not vim.g.started_by_firenvim,
    lazy = false,
    build = function()
      require("lazy").load({ plugins = "firenvim", wait = true })
      vim.fn["firenvim#install"](0)
    end,
  }
}
  • Inside TUI neovim: firenvim marked as disabled in lazy.nvim panel

    • pressed i to install firenvim, got error msg Vim:E117: Unknown function: firenvim#install
    • manually type in command mode: call firenvim#install(0) returns same error Vim:E117: Unknown function: firenvim#install
    • but the function did exist: lua print(vim.fn["firenvim#install"]) returns function: 0x01e...
    • checked path ~/AppData/Local/firenvim which contains files:
      chrome.ps1
      edge.ps1
      firefox.ps1
      firenvim-chrome.json
      firenvim-edge.json
      firenvim-firefox.json
      firenvim.bat
    • Running in powershell: echo 'abcde{}' | ~\AppData\Local\firenvim\firenvim
      f{"messages": [], "version": "0.2.14", "settings": {"localSettings": {".*": {}}, "globalSettings": {}}}
  • From the TROUBLESHOOTING.md

On Windows: in %APPDATA%\firenvim and check that the following registry keys exist and point to the native manifest:
For Firefox: HKEY_CURRENT_USER\SOFTWARE\Mozilla\NativeMessagingHosts\firenvim
For Chrome/Chromium: HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\NativeMessagingHosts\firenvim
  • checked in Registry Editor: the firenvim registry was not created
  • but inside chrome.ps1 and firenvim-chrome.json, the path attributes are correct
# chrome.ps1
New-Item -Path "HKCU:\Software\Google"
New-Item -Path "HKCU:\Software\Google\Chrome"
New-Item -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts"
New-Item -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\firenvim"
Set-Item -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\firenvim\" -Value "C:\Users\username\AppData\Local\firenvim\firenvim-chrome.json"
// firenvim-chrome.json
{ "name": "firenvim", "description": "Turn your browser into a Neovim GUI.", "path": "C:\\Users\\username\\AppData\\Local\\firenvim\\firenvim.bat", "type": "stdio", "allowed_origins": [ "chrome-extension://longrandomstringid/" ]}
  • Inside chrome:
    • clicked github textarea, pressed and nothing happened
    • cliked firenvim plugin icon, and reload settings, still got neovim died without answering
    • in developer mode, the console outputs:
      Unchecked runtime.lastError: Specified native messaging host not found.
      Uncaught (in promise) Neovim died without answering.

What happened

Looks like I should manually create registry key for firenvim? I am not sure what exactly I should do to create a proper key.

Solved by manually creating key under HKCU:\Software\Google\Chrome\NativeMessagingHosts\firenvim\.

It seems the firenvim scripts in windows system did not run automatically after first installation? Or, this may be caused by some permission error?

Hi, thank you for opening this issue and spending time on solving it yourself, sorry I wasn't able to answer before now.

pressed i to install firenvim, got error msg Vim:E117: Unknown function: firenvim#install
manually type in command mode: call firenvim#install(0) returns same error Vim:E117: Unknown function: firenvim#install
but the function did exist: lua print(vim.fn["firenvim#install"])

This part is extremely weird and it probably the reason the registry keys were not created. I don't understand while the files to create them would be created though...

Reopen this issue: after completely reinstall firenvim and reset the registry key, there is no more ~/AppData/Local/firenvim directory created. So the issue is about the lazy.nvim configuration provided by the README.md.

  • To create the ~/AppData/Local/firenvim, I commented out cond = not not vim.g.started_by_firenvim and manually called the build command inside neovim :lua vim.fn["firenvim#install"](0).
  • The installation results in errors other than the unknown function
No config detected for chromium. Skipping.
No config detected for librewolf. Skipping.
No config detected for arc. Skipping.
No config detected for opera. Skipping.
No config detected for brave. Skipping.
No config detected for ungoogled-chromium. Skipping.
No config detected for chrome-dev. Skipping.
Installed native manifest for firefox.
Creating registry key for firefox. This may take a while. Script: C
Created registry key for firefox.
No config detected for vivaldi. Skipping.
No config detected for chrome-canary. Skipping.
Installed native manifest for chrome.
Creating registry key for chrome. This may take a while. Script: C:
Created registry key for chrome.
Installed native manifest for edge.
Creating registry key for edge. This may take a while. Script: C:/U
Created registry key for edge.
Installation complete on the wsl side. Performing install on the wi
E5107: Error loading lua [string ":lua"]:1: '=' expected near '<eof>'
E5108: Error executing lua function firenvim#install[108]..firenvim#install[24]..<SNR>20_maybe_execute, line 5: Vim(let):E739: Cannot create directory /mnt/c//users: file already exists
stack traceback:
        [C]: in function 'firenvim#install'
        [string ":lua"]:1: in main chunk
  • Now, exited neovim and checked ~/AppData/Local/firenvim dir was created.
  • Likely, the registry key was not created because the installation fails. So the final step is to manually add keys via registry editor.

Thanks, this log is very useful! It looks like the manifest directory path is not correctly computed for firefox from the windows side. I'm not sure what exactly is going wrong here, I'll need to perform some tests.

same with Unknown function: firenvim#install

@ogios Could you open a new issue? The problem reported by xudyang1 has been fixed, I forgot to close the issue.

@ogios Could you open a new issue? The problem reported by xudyang1 has been fixed, I forgot to close the issue.

ok👌🏻