2017-04-12 07:37:19 -07:00
|
|
|
let s:suggest_faq = 'https://github.com/neovim/neovim/wiki/FAQ'
|
2016-10-25 06:28:34 -07:00
|
|
|
|
2016-10-27 20:07:51 -07:00
|
|
|
function! s:check_config() abort
|
2017-04-12 07:37:19 -07:00
|
|
|
let ok = v:true
|
2016-10-27 20:07:51 -07:00
|
|
|
call health#report_start('Configuration')
|
2017-04-12 07:37:19 -07:00
|
|
|
|
2018-08-26 16:31:57 -07:00
|
|
|
let vimrc = empty($MYVIMRC) ? stdpath('config').'/init.vim' : $MYVIMRC
|
|
|
|
if !filereadable(vimrc)
|
|
|
|
let ok = v:false
|
|
|
|
let has_vim = filereadable(expand('~/.vimrc'))
|
2019-06-24 16:31:41 -07:00
|
|
|
call health#report_warn((-1 == getfsize(vimrc) ? 'Missing' : 'Unreadable').' user config file: '.vimrc,
|
2018-08-26 16:31:57 -07:00
|
|
|
\[ has_vim ? ':help nvim-from-vim' : ':help init.vim' ])
|
|
|
|
endif
|
|
|
|
|
2017-10-16 15:10:52 -07:00
|
|
|
" If $VIM is empty we don't care. Else make sure it is valid.
|
|
|
|
if !empty($VIM) && !filereadable($VIM.'/runtime/doc/nvim.txt')
|
|
|
|
let ok = v:false
|
2018-02-21 18:30:39 -07:00
|
|
|
call health#report_error('$VIM is invalid: '.$VIM)
|
2017-10-16 15:10:52 -07:00
|
|
|
endif
|
|
|
|
|
2017-04-12 07:37:19 -07:00
|
|
|
if exists('$NVIM_TUI_ENABLE_CURSOR_SHAPE')
|
|
|
|
let ok = v:false
|
2018-02-21 18:30:39 -07:00
|
|
|
call health#report_warn('$NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+',
|
2017-04-12 07:37:19 -07:00
|
|
|
\ [ "Use the 'guicursor' option to configure cursor shape. :help 'guicursor'",
|
|
|
|
\ 'https://github.com/neovim/neovim/wiki/Following-HEAD#20170402' ])
|
|
|
|
endif
|
2017-10-16 15:10:52 -07:00
|
|
|
|
2019-01-25 16:41:42 -07:00
|
|
|
if v:ctype ==# 'C'
|
|
|
|
let ok = v:false
|
|
|
|
call health#report_error('Locale does not support UTF-8. Unicode characters may not display correctly.'
|
|
|
|
\ .printf("\n$LANG=%s $LC_ALL=%s $LC_CTYPE=%s", $LANG, $LC_ALL, $LC_CTYPE),
|
|
|
|
\ [ 'If using tmux, try the -u option.',
|
|
|
|
\ 'Ensure that your terminal/shell/tmux/etc inherits the environment, or set $LANG explicitly.' ,
|
|
|
|
\ 'Configure your system locale.' ])
|
|
|
|
endif
|
|
|
|
|
2017-10-10 10:09:14 -07:00
|
|
|
if &paste
|
|
|
|
let ok = v:false
|
|
|
|
call health#report_error("'paste' is enabled. This option is only for pasting text.\nIt should not be set in your config.",
|
|
|
|
\ [ 'Remove `set paste` from your init.vim, if applicable.',
|
|
|
|
\ 'Check `:verbose set paste?` to see if a plugin or script set the option.', ])
|
|
|
|
endif
|
2017-04-12 07:37:19 -07:00
|
|
|
|
2019-06-24 16:31:41 -07:00
|
|
|
let shadafile = (empty(&shadafile) || &shadafile ==# 'NONE') ? stdpath('data').'/shada/main.shada' : &shadafile
|
|
|
|
if !empty(shadafile) && (!filereadable(shadafile) || !filewritable(shadafile))
|
|
|
|
let ok = v:false
|
|
|
|
call health#report_error('shada file is not '.(filereadable(shadafile) ? 'writeable' : 'readable').":\n".shadafile)
|
|
|
|
endif
|
|
|
|
|
2017-04-12 07:37:19 -07:00
|
|
|
if ok
|
|
|
|
call health#report_ok('no issues found')
|
|
|
|
endif
|
2016-10-27 20:07:51 -07:00
|
|
|
endfunction
|
|
|
|
|
2016-06-16 14:01:47 -07:00
|
|
|
" Load the remote plugin manifest file and check for unregistered plugins
|
2016-10-25 06:28:34 -07:00
|
|
|
function! s:check_rplugin_manifest() abort
|
2016-06-16 14:01:47 -07:00
|
|
|
call health#report_start('Remote Plugins')
|
|
|
|
let existing_rplugins = {}
|
|
|
|
|
|
|
|
for item in remote#host#PluginsForHost('python')
|
|
|
|
let existing_rplugins[item.path] = 'python'
|
|
|
|
endfor
|
|
|
|
|
|
|
|
for item in remote#host#PluginsForHost('python3')
|
|
|
|
let existing_rplugins[item.path] = 'python3'
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let require_update = 0
|
|
|
|
|
|
|
|
for path in map(split(&runtimepath, ','), 'resolve(v:val)')
|
|
|
|
let python_glob = glob(path.'/rplugin/python*', 1, 1)
|
|
|
|
if empty(python_glob)
|
|
|
|
continue
|
|
|
|
endif
|
|
|
|
|
|
|
|
let python_dir = python_glob[0]
|
|
|
|
let python_version = fnamemodify(python_dir, ':t')
|
|
|
|
|
|
|
|
for script in glob(python_dir.'/*.py', 1, 1)
|
|
|
|
\ + glob(python_dir.'/*/__init__.py', 1, 1)
|
|
|
|
let contents = join(readfile(script))
|
|
|
|
if contents =~# '\<\%(from\|import\)\s\+neovim\>'
|
2017-01-08 13:26:00 -07:00
|
|
|
if script =~# '[\/]__init__\.py$'
|
2017-11-12 18:10:06 -07:00
|
|
|
let script = tr(fnamemodify(script, ':h'), '\', '/')
|
2016-06-16 14:01:47 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
if !has_key(existing_rplugins, script)
|
|
|
|
let msg = printf('"%s" is not registered.', fnamemodify(path, ':t'))
|
|
|
|
if python_version ==# 'pythonx'
|
|
|
|
if !has('python2') && !has('python3')
|
|
|
|
let msg .= ' (python2 and python3 not available)'
|
|
|
|
endif
|
|
|
|
elseif !has(python_version)
|
|
|
|
let msg .= printf(' (%s not available)', python_version)
|
|
|
|
else
|
|
|
|
let require_update = 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
call health#report_warn(msg)
|
|
|
|
endif
|
|
|
|
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfor
|
|
|
|
|
|
|
|
if require_update
|
|
|
|
call health#report_warn('Out of date', ['Run `:UpdateRemotePlugins`'])
|
|
|
|
else
|
|
|
|
call health#report_ok('Up to date')
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2016-10-25 06:28:34 -07:00
|
|
|
function! s:check_performance() abort
|
|
|
|
call health#report_start('Performance')
|
|
|
|
|
|
|
|
" check buildtype
|
|
|
|
let buildtype = matchstr(execute('version'), '\v\cbuild type:?\s*[^\n\r\t ]+')
|
|
|
|
if empty(buildtype)
|
|
|
|
call health#report_error('failed to get build type from :version')
|
|
|
|
elseif buildtype =~# '\v(MinSizeRel|Release|RelWithDebInfo)'
|
|
|
|
call health#report_ok(buildtype)
|
|
|
|
else
|
|
|
|
call health#report_info(buildtype)
|
|
|
|
call health#report_warn(
|
2019-08-04 03:27:44 -07:00
|
|
|
\ 'Non-optimized '.(has('debug')?'(DEBUG) ':'').'build. Nvim will be slower.',
|
2018-02-21 18:30:39 -07:00
|
|
|
\ ['Install a different Nvim package, or rebuild with `CMAKE_BUILD_TYPE=RelWithDebInfo`.',
|
2016-10-25 06:28:34 -07:00
|
|
|
\ s:suggest_faq])
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2016-10-16 08:01:19 -07:00
|
|
|
function! s:check_tmux() abort
|
|
|
|
if empty($TMUX) || !executable('tmux')
|
|
|
|
return
|
|
|
|
endif
|
2016-10-25 06:28:34 -07:00
|
|
|
call health#report_start('tmux')
|
|
|
|
|
|
|
|
" check escape-time
|
|
|
|
let suggestions = ["Set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10",
|
|
|
|
\ s:suggest_faq]
|
2016-10-16 08:01:19 -07:00
|
|
|
let cmd = 'tmux show-option -qvgs escape-time'
|
|
|
|
let out = system(cmd)
|
|
|
|
let tmux_esc_time = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
|
|
|
if v:shell_error
|
|
|
|
call health#report_error('command failed: '.cmd."\n".out)
|
|
|
|
elseif empty(tmux_esc_time)
|
|
|
|
call health#report_error('escape-time is not set', suggestions)
|
2016-10-29 05:48:19 -07:00
|
|
|
elseif tmux_esc_time > 300
|
2016-10-16 08:01:19 -07:00
|
|
|
call health#report_error(
|
2016-10-16 08:51:00 -07:00
|
|
|
\ 'escape-time ('.tmux_esc_time.') is higher than 300ms', suggestions)
|
2016-10-16 08:01:19 -07:00
|
|
|
else
|
2016-10-25 06:28:34 -07:00
|
|
|
call health#report_ok('escape-time: '.tmux_esc_time.'ms')
|
|
|
|
endif
|
|
|
|
|
2017-03-05 19:02:43 -07:00
|
|
|
" check default-terminal and $TERM
|
2016-10-25 06:28:34 -07:00
|
|
|
call health#report_info('$TERM: '.$TERM)
|
2017-03-05 19:02:43 -07:00
|
|
|
let cmd = 'tmux show-option -qvg default-terminal'
|
|
|
|
let out = system(cmd)
|
|
|
|
let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
2017-03-23 17:38:01 -07:00
|
|
|
if empty(tmux_default_term)
|
|
|
|
let cmd = 'tmux show-option -qvgs default-terminal'
|
|
|
|
let out = system(cmd)
|
|
|
|
let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
|
|
|
endif
|
|
|
|
|
2017-03-05 19:02:43 -07:00
|
|
|
if v:shell_error
|
|
|
|
call health#report_error('command failed: '.cmd."\n".out)
|
|
|
|
elseif tmux_default_term !=# $TERM
|
|
|
|
call health#report_info('default-terminal: '.tmux_default_term)
|
|
|
|
call health#report_error(
|
|
|
|
\ '$TERM differs from the tmux `default-terminal` setting. Colors might look wrong.',
|
|
|
|
\ ['$TERM may have been set by some rc (.bashrc, .zshrc, ...).'])
|
|
|
|
elseif $TERM !~# '\v(tmux-256color|screen-256color)'
|
2016-10-25 06:28:34 -07:00
|
|
|
call health#report_error(
|
2017-03-05 19:02:43 -07:00
|
|
|
\ '$TERM should be "screen-256color" or "tmux-256color" in tmux. Colors might look wrong.',
|
2016-10-25 06:28:34 -07:00
|
|
|
\ ["Set default-terminal in ~/.tmux.conf:\nset-option -g default-terminal \"screen-256color\"",
|
|
|
|
\ s:suggest_faq])
|
2016-10-16 08:01:19 -07:00
|
|
|
endif
|
2019-04-20 10:02:19 -07:00
|
|
|
|
|
|
|
" check for RGB capabilities
|
|
|
|
let info = system('tmux server-info')
|
|
|
|
let has_tc = stridx(info, " Tc: (flag) true") != -1
|
|
|
|
let has_rgb = stridx(info, " RGB: (flag) true") != -1
|
|
|
|
if !has_tc && !has_rgb
|
|
|
|
call health#report_warn(
|
|
|
|
\ "Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.",
|
|
|
|
\ ["Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:\nset-option -sa terminal-overrides ',XXX:RGB'",
|
|
|
|
\ "For older tmux versions use this instead:\nset-option -ga terminal-overrides ',XXX:Tc'"])
|
|
|
|
endif
|
2016-10-16 08:01:19 -07:00
|
|
|
endfunction
|
|
|
|
|
2016-12-13 11:54:06 -07:00
|
|
|
function! s:check_terminal() abort
|
2016-10-16 08:51:00 -07:00
|
|
|
if !executable('infocmp')
|
|
|
|
return
|
|
|
|
endif
|
2016-12-13 11:54:06 -07:00
|
|
|
call health#report_start('terminal')
|
2016-10-16 08:51:00 -07:00
|
|
|
let cmd = 'infocmp -L'
|
|
|
|
let out = system(cmd)
|
2016-12-13 11:54:06 -07:00
|
|
|
let kbs_entry = matchstr(out, 'key_backspace=[^,[:space:]]*')
|
|
|
|
let kdch1_entry = matchstr(out, 'key_dc=[^,[:space:]]*')
|
2016-10-16 08:51:00 -07:00
|
|
|
|
|
|
|
if v:shell_error
|
|
|
|
call health#report_error('command failed: '.cmd."\n".out)
|
|
|
|
else
|
2016-12-13 11:54:06 -07:00
|
|
|
call health#report_info('key_backspace (kbs) terminfo entry: '
|
2016-10-16 08:51:00 -07:00
|
|
|
\ .(empty(kbs_entry) ? '? (not found)' : kbs_entry))
|
2016-12-13 11:54:06 -07:00
|
|
|
call health#report_info('key_dc (kdch1) terminfo entry: '
|
|
|
|
\ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry))
|
2016-10-16 08:51:00 -07:00
|
|
|
endif
|
2017-11-06 16:53:26 -07:00
|
|
|
for env_var in ['XTERM_VERSION', 'VTE_VERSION', 'TERM_PROGRAM', 'COLORTERM', 'SSH_TTY']
|
2017-12-16 13:33:59 -07:00
|
|
|
if exists('$'.env_var)
|
2017-11-06 16:53:26 -07:00
|
|
|
call health#report_info(printf("$%s='%s'", env_var, eval('$'.env_var)))
|
|
|
|
endif
|
|
|
|
endfor
|
2016-10-16 08:51:00 -07:00
|
|
|
endfunction
|
|
|
|
|
2016-06-16 14:01:47 -07:00
|
|
|
function! health#nvim#check() abort
|
2016-10-27 20:07:51 -07:00
|
|
|
call s:check_config()
|
2016-10-25 06:28:34 -07:00
|
|
|
call s:check_performance()
|
2016-10-27 20:07:51 -07:00
|
|
|
call s:check_rplugin_manifest()
|
2016-12-13 11:54:06 -07:00
|
|
|
call s:check_terminal()
|
2016-10-27 20:07:51 -07:00
|
|
|
call s:check_tmux()
|
2016-06-16 14:01:47 -07:00
|
|
|
endfunction
|