subnut / nvim-ghost.nvim

:ghost: GhostText plugin for Neovim with zero dependencies :tada: Supports neovim running inside WSL too! :partying_face: Windows/Linux/macOS supported out-of-the-box! :smile: (Other OSes need python3.6+ installed)
MIT License
157 stars 6 forks source link

Packer syntax? ("Undefined variable: g:nvim_ghost_binary_path") #48

Closed hjhp closed 1 year ago

hjhp commented 1 year ago

I must have confused the syntax trying to translate your Plug example to Packer.nvim, could you please help?

In my config file I have:

-- Automatically install packer
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'

if fn.empty(fn.glob(install_path)) > 0 then
  packer_bootstrap = fn.system({
    'git',
    'clone',
    '--depth',
    '1',
    'https://github.com/wbthomason/packer.nvim',
    install_path
  })
  vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' .. vim.o.runtimepath
end

-- Autocommand that reloads neovim whenever you save the packer_init.lua file
vim.cmd [[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost packer_init.lua source <afile> | PackerSync
  augroup end
]]

-- Use a protected call so we don't error out on first use
local status_ok, packer = pcall(require, 'packer')
if not status_ok then
  return
end

-- Install plugins
return packer.startup(function(use)
  -- Add you plugins here:
  use 'wbthomason/packer.nvim' -- packer can manage itself

  -- (snip)

  -- GhostText: edit browser form fields in Neovim
  use {
      'subnut/nvim-ghost.nvim',
      config = 'vim.cmd[[:call nvim_ghost#installer#install()]]'
  }
  -- Automatically set up your configuration after cloning packer.nvim
  -- Put this at the end after all plugins
  if packer_bootstrap then
    require('packer').sync()
  end
end)

On start, I get:

Error in packer_compiled: ...tfiles/neovim/neovim-lua/nvim/plugin/packer_compiled.lua:241: Vim(i
f):E121: Undefined variable: g:nvim_ghost_binary_path
subnut commented 1 year ago

Ah yes... this seems to be a problem with the nvim_ghost#installer#install() function. There's some bug in it.

To make the plugin work for now, manually execute :call nvim_ghost#installer#install() after installing the plugin. I am very busy this week, so I won't be able to look at this bug till the weekend, sorry.

hjhp commented 1 year ago

Thanks! This works now.

Just for future reference, I got it working with:

use {
      'subnut/nvim-ghost.nvim',
  }

and then running

:call nvim_ghost#installer#install()

I would love to know for sure if there's a way to get Packer.nvim to run this function automatically after install, for example would run be applicable here?

use {
      'subnut/nvim-ghost.nvim',
      run = vim.cmd[[:call nvim_ghost#installer#install()]]
  }

I'm not sure of this syntax or the validity of my reasoning, I'm very new to neovim and lua. I base this idea on wbthomason's example of "Plugins can have post-install/update hooks":

  use {'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', cmd = 'MarkdownPreview'}
subnut commented 1 year ago

v0.2.0 installs the binary automatically, and we no longer need to run :call nvim_ghost#installer#install ourselves.


Now, the relevant packer.nvim syntax should be

use 'subnut/nvim-ghost.nvim'