glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.
GNU General Public License v3.0
4.65k stars 143 forks source link

Unable to run firenvim in Windows 10 Host System #1547

Closed xudyang1 closed 12 months ago

xudyang1 commented 1 year ago

What I tried to do

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)
-- ~/.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,
  }
}
# 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/" ]}

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.

xudyang1 commented 1 year ago

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?

glacambre commented 1 year ago

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...

xudyang1 commented 1 year ago

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.

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
glacambre commented 1 year ago

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.

ogios commented 12 months ago

same with Unknown function: firenvim#install

glacambre commented 12 months ago

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

ogios commented 12 months ago

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

ok👌🏻