nvim-ghost.nvim icon indicating copy to clipboard operation
nvim-ghost.nvim copied to clipboard

Server does not run due to empty g:nvim_ghost_binary_path

Open mostafatouny opened this issue 1 year ago • 9 comments

Hello, If I manually run nvim-ghost-binary the server runs and everything works as expected. However, whenever I launch neovim and load nvim-ghost I get error message "could not connect to localhost:4001". When I debugged I figured out:

echo g:nvim_ghost_installation_dir returns the correct installation path but nvim_ghost_binary_path returns the empty string. When I attempted to manually set nvim_ghost_binary_path to the path of binary file, I would still get an empty string. Any other string can be set to nvim_ghost_binary_path.

In my init.lua I have vim.g.nvim_ghost_binary_path = "/home/touny/.local/share/nvim/lazy/nvim-ghost.nvim/nvim-ghost-binary" and echo g:nvim_ghost_binary_path returns the empty string.

mostafatouny avatar Nov 10 '24 09:11 mostafatouny

What do these return?

  • echo g:nvim_ghost_installation_dir
  • echo g:nvim_ghost_scripts_dir
  • echo g:nvim_ghost_script_path
  • echo g:nvim_ghost_binary_path

Also, what's the output of :version?

subnut avatar Nov 10 '24 09:11 subnut

echo g:nvim_ghost_installation_dir

/home/touny/.local/share/nvim/lazy/nvim-ghost.nvim

echo g:nvim_ghost_scripts_dir

/home/touny/.local/share/nvim/lazy/nvim-ghost.nvim/scripts/

echo g:nvim_ghost_script_path

/home/touny/.local/share/nvim/lazy/nvim-ghost.nvim/binary.py

echo g:nvim_ghost_binary_path

empty string

:version

NVIM v0.10.2 LuaJIT 2.1.1727870382

mostafatouny avatar Nov 10 '24 10:11 mostafatouny

Moreover doing let tem = g:nvim_ghost_binary_path = g:nvim_ghost_installation_dir .. "nvim-ghost-binary" then echo tem returns the empty string also

mostafatouny avatar Nov 10 '24 10:11 mostafatouny

.... this is perplexing.

what's the output of

echo "a/b/c/" .. "a-b-c"
echo g:nvim_ghost_installation_dir
echo g:nvim_ghost_installation_dir .. "HI"
echo g:nvim_ghost_installation_dir .. "nvim-ghost-binary"

subnut avatar Nov 10 '24 10:11 subnut

I cloned nvim-ghost-binary to nvim-ghost and cloned nvim-ghost-binary.version to nvim-ghost.version, and modified nvim_ghost with let g:nvim_ghost_binary_path = g:nvim_ghost_installation_dir .. 'nvim-ghost' in place of " let g:nvim_ghost_binary_path = g:nvim_ghost_installation_dir .. 'nvim-ghost-binary' .. (has('win32') ? '.exe' : '')

The server does run at expected. When I manually run call nvim_ghost#helper#start_server() it works

mostafatouny avatar Nov 10 '24 10:11 mostafatouny

echo "a/b/c/" .. "a-b-c"

a/b/c/a-b-c

echo g:nvim_ghost_installation_dir

/home/touny/.local/share/nvim/lazy/nvim-ghost.nvim/

echo g:nvim_ghost_installation_dir .. "HI"

/home/touny/.local/share/nvim/lazy/nvim-ghost.nvim/HI

echo g:nvim_ghost_installation_dir .. "nvim-ghost-binary"

empty string

mostafatouny avatar Nov 10 '24 10:11 mostafatouny

Also note :GhostTextStart returns E492: Not an editor command: GhostTextStart.

mostafatouny avatar Nov 10 '24 10:11 mostafatouny

To fix the server startup, I modified file nvim_ghost.vim, function nvim_ghost#enable, changing function! nvim_ghost#init(defer = 1) to function! nvim_ghost#init(defer = 0) so that line call s:start_server_or_request_focus() inside function nvim_ghost#enable runs on startup.

mostafatouny avatar Nov 10 '24 11:11 mostafatouny

I think you should modify nvim_ghost.vim file, augroup nvim_ghost, and add autocmd ExitPre * call nvim_ghost#helper#kill_server() also.

mostafatouny avatar Nov 10 '24 11:11 mostafatouny