Skip to content

Commit

Permalink
Improve error handling some more for #1483
Browse files Browse the repository at this point in the history
  • Loading branch information
glacambre committed Jan 5, 2023
1 parent d9a2a73 commit d1909c7
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions autoload/firenvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,6 @@ endfunction
" - Write the security token + tcp port number to stdout()
" - Take care of forwarding messages received on the TCP port to neovim
function! firenvim#run() abort
if !exists('g:firenvim_o')
let g:firenvim_o=[]
endif
" g:Firenvim_oo so far only added on_print messages to g:Firenvim_o,
" so that messages emitted before firenvim is loaded could be caught.
" When firenvim#run() is called, we know Firenvim has been properly
" loaded by the user's plugin manager, and so we can redefine it to
" send messages to stderr
let g:Firenvim_oo={t->chansend(2,[string(t)]+add(g:firenvim_o,t))}
if len(g:firenvim_o) > 0
call chansend(2,string(g:firenvim_o))
endif
" Write messages to stdout according to the format expected by
" Firefox's native messaging protocol
function! WriteStdout(id, data) abort
Expand Down Expand Up @@ -605,7 +593,7 @@ function! s:get_executable_content(data_dir, prolog) abort
\'let g:firenvim_i=[]|' .
\'let g:firenvim_o=[]|' .
\'let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)}|' .
\'let g:Firenvim_oo={t->add(g:firenvim_o,t)}|' .
\'let g:Firenvim_oo={t->[chansend(2,t)]+add(g:firenvim_o,t)}|' .
\"let g:firenvim_c=stdioopen({'on_stdin':{i,d,e->g:Firenvim_oi(i,d,e)},'on_print':{t->g:Firenvim_oo(t)}})".
\'"'
endif
Expand Down Expand Up @@ -654,11 +642,15 @@ function! s:get_executable_content(data_dir, prolog) abort
\ " --cmd 'let g:started_by_firenvim = v:true' " .
\ "-c 'try|" .
\ 'call firenvim#run()|' .
\ 'catch|' .
\ 'catch /Unknown function/|' .
\ "call chansend(g:firenvim_c,[\"f\\n\\n\\n\"..json_encode({\"messages\":[\"Your plugin manager did not load the Firenvim plugin for neovim.\"],\"version\":\"0.0.0\"})])|" .
\ "call chansend(2,[\"Firenvim not in rtp:\"..&rtp]+g:firenvim_o)|" .
\ 'qall!' .
\ "|endtry'\n"
\ "call chansend(2,[\"Firenvim not in runtime path. &rtp=\"..&rtp])|" .
\ 'qall!|' .
\ 'catch|' .
\ "call chansend(g:firenvim_c,[\"l\\n\\n\\n\"..json_encode({\"messages\": [\"Something went wrong when running firenvim. See troubleshooting guide.\"],\"version\":\"0.0.0\"})])|" .
\ 'call chansend(2,[v:exception])|' .
\ 'qall!|' .
\ "endtry'\n"
endfunction

function! s:get_manifest_beginning(execute_nvim_path) abort
Expand Down

0 comments on commit d1909c7

Please sign in to comment.