mhinz / vim-startify

:link: The fancy start screen for Vim.
MIT License
5.3k stars 186 forks source link

E117: Unknown function: strwidth #386

Closed Piping closed 5 years ago

Piping commented 5 years ago

Hi,

Older version 7.2 does not have this function.

Could you remove the use of this function for maximum compatibility?

Thanks

mhinz commented 5 years ago

I can't since there's no alternative in 7.2. It only provides len() but that gets me the bytes of a character and not the number of cells it takes.

The function is used in the cowsay implementation which is used by default. You can work around it by disabling it:

let g:startify_custom_header = []
mhinz commented 5 years ago

If the workaround above works for you and there's no other function breaking under 7.2, I'll hardcode this:

diff --git i/autoload/startify.vim w/autoload/startify.vim
index 23ecdd0..0327cfc 100644
--- i/autoload/startify.vim
+++ w/autoload/startify.vim
@@ -64,7 +64,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
   " Must be global so that it can be read by syntax/startify.vim.
   let g:startify_header = exists('g:startify_custom_header')
         \ ? s:set_custom_section(g:startify_custom_header)
-        \ : startify#fortune#cowsay()
+        \ : (exists('*strwidth') ? startify#fortune#cowsay() : [])
   if !empty(g:startify_header)
     let g:startify_header += ['']  " add blank line
   endif
Piping commented 5 years ago

yeah, it works fine. As long as no error reports. Thank you!