Skip to content

Commit

Permalink
fix: improve missing rplugin error handling; less agressive tracebacks
Browse files Browse the repository at this point in the history
Avoid exceptions inside the FileType python autocmd, because the
stacktrace is ugly and often difficult to read.

Instead, show an asynchronous notification that something is broken
and users should run `:UpdateRemotePlugins`.
  • Loading branch information
wookayin committed Oct 31, 2023
1 parent 69bfe64 commit f615d62
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugin/semshi.vim
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,27 @@ function! s:remove_builtin_extra()
hi link pythonKeyword pythonNumber
endfunction

" Ensure the rplugin manifest
if exists(':Semshi') == 0
command! -nargs=* Semshi call nvim_err_writeln(":Semshi not found. Run :UpdateRemotePlugins.")

let s:semshi_rplugin_error = 1
if exists(':lua') && has('nvim-0.5.0') > 0
lua << EOF
vim.schedule(function()
vim.notify(":Semshi not found. Run :UpdateRemotePlugins.", 'ERROR', { title = "semshi" })
end)
EOF
endif
endif

function! s:filetype_changed()
if exists('s:semshi_rplugin_error')
" Avoid exceptions inside FileType autocmd, because the stacktrace is ugly.
" Instead, an asynchronous notification that something is broken will be made.
return
end

let l:ft = expand('<amatch>')
if index(g:semshi#filetypes, l:ft) != -1
if !get(b:, 'semshi_attached', v:false)
Expand Down

0 comments on commit f615d62

Please sign in to comment.