neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

health.lua (21343B)


      1 local M = {}
      2 local health = require('vim.health')
      3 
      4 ---Run a system command and return ok and its stdout and stderr combined.
      5 ---@param cmd string[]
      6 ---@return boolean
      7 ---@return string
      8 local function system(cmd)
      9  local result = vim.system(cmd, { text = true }):wait()
     10  return result.code == 0, vim.trim(('%s\n%s'):format(result.stdout, result.stderr))
     11 end
     12 
     13 local suggest_faq = 'https://neovim.io/doc/build/#building'
     14 
     15 local function check_runtime()
     16  health.start('Runtime')
     17  -- Files from an old installation.
     18  local bad_files = {
     19    ['autoload/health/nvim.vim'] = false,
     20    ['autoload/health/provider.vim'] = false,
     21    ['autoload/man.vim'] = false,
     22    ['lua/provider/node/health.lua'] = false,
     23    ['lua/provider/perl/health.lua'] = false,
     24    ['lua/provider/python/health.lua'] = false,
     25    ['lua/provider/ruby/health.lua'] = false,
     26    ['lua/vim/_defaults.lua'] = false,
     27    ['lua/vim/_editor.lua'] = false,
     28    ['lua/vim/_extui.lua'] = false,
     29    ['lua/vim/_extui/cmdline.lua'] = false,
     30    ['lua/vim/_extui/messages.lua'] = false,
     31    ['lua/vim/_extui/shared.lua'] = false,
     32    ['lua/vim/_options.lua'] = false,
     33    ['lua/vim/_stringbuffer.lua'] = false,
     34    ['lua/vim/_system.lua'] = false,
     35    ['lua/vim/shared.lua'] = false,
     36    ['plugin/health.vim'] = false,
     37    ['plugin/man.vim'] = false,
     38    ['queries/help/highlights.scm'] = false,
     39    ['queries/help/injections.scm'] = false,
     40    ['scripts.vim'] = false,
     41    ['syntax/syncolor.vim'] = false,
     42  }
     43  local bad_files_msg = ''
     44  for k, _ in pairs(bad_files) do
     45    local path = ('%s/%s'):format(vim.env.VIMRUNTIME, k)
     46    if vim.uv.fs_stat(path) then
     47      bad_files[k] = true
     48      bad_files_msg = ('%s%s\n'):format(bad_files_msg, path)
     49    end
     50  end
     51 
     52  local ok = (bad_files_msg == '')
     53  local info = ok and health.ok or health.info
     54  info(string.format('$VIMRUNTIME: %s', vim.env.VIMRUNTIME))
     55  if not ok then
     56    health.error(
     57      string.format(
     58        'Found old files in $VIMRUNTIME (this can cause weird behavior):\n%s',
     59        bad_files_msg
     60      ),
     61      { 'Delete the $VIMRUNTIME directory, then reinstall Nvim.' }
     62    )
     63  end
     64 end
     65 
     66 local function check_config()
     67  health.start('Configuration')
     68  local ok = true
     69 
     70  local init_lua = vim.fn.stdpath('config') .. '/init.lua'
     71  local init_vim = vim.fn.stdpath('config') .. '/init.vim'
     72  local vimrc = vim.env.MYVIMRC and vim.fs.normalize(vim.env.MYVIMRC) or init_lua
     73 
     74  if vim.fn.filereadable(vimrc) == 0 and vim.fn.filereadable(init_vim) == 0 then
     75    ok = false
     76    local has_vim = vim.fn.filereadable(vim.fs.normalize('~/.vimrc')) == 1
     77    health.warn(
     78      ('%s user config file: %s'):format(
     79        -1 == vim.fn.getfsize(vimrc) and 'Missing' or 'Unreadable',
     80        vimrc
     81      ),
     82      { has_vim and ':help nvim-from-vim' or ':help config' }
     83    )
     84  end
     85 
     86  -- If $VIM is empty we don't care. Else make sure it is valid.
     87  if vim.env.VIM and vim.fn.filereadable(vim.env.VIM .. '/runtime/doc/nvim.txt') == 0 then
     88    ok = false
     89    health.error('$VIM is invalid: ' .. vim.env.VIM)
     90  end
     91 
     92  if vim.env.NVIM_TUI_ENABLE_CURSOR_SHAPE then
     93    ok = false
     94    health.warn('$NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+', {
     95      "Use the 'guicursor' option to configure cursor shape. :help 'guicursor'",
     96      'https://github.com/neovim/neovim/wiki/Following-HEAD#20170402',
     97    })
     98  end
     99 
    100  if vim.v.ctype == 'C' then
    101    ok = false
    102    health.error(
    103      'Locale does not support UTF-8. Unicode characters may not display correctly.'
    104        .. ('\n$LANG=%s $LC_ALL=%s $LC_CTYPE=%s'):format(
    105          vim.env.LANG or '',
    106          vim.env.LC_ALL or '',
    107          vim.env.LC_CTYPE or ''
    108        ),
    109      {
    110        'If using tmux, try the -u option.',
    111        'Ensure that your terminal/shell/tmux/etc inherits the environment, or set $LANG explicitly.',
    112        'Configure your system locale.',
    113      }
    114    )
    115  end
    116 
    117  if vim.o.paste == 1 then
    118    ok = false
    119    health.error(
    120      "'paste' is enabled. This option is only for pasting text.\nIt should not be set in your config.",
    121      {
    122        'Remove `set paste` from your init.vim, if applicable.',
    123        'Check `:verbose set paste?` to see if a plugin or script set the option.',
    124      }
    125    )
    126  end
    127 
    128  local writeable = true
    129  local shadaopt = vim.fn.split(vim.o.shada, ',')
    130  local shadafile = (
    131    vim.o.shada == '' and vim.o.shada
    132    or vim.fn.substitute(vim.fn.matchstr(shadaopt[#shadaopt], '^n.\\+'), '^n', '', '')
    133  )
    134  shadafile = (
    135    vim.o.shadafile == ''
    136      and (shadafile == '' and vim.fn.stdpath('state') .. '/shada/main.shada' or vim.fs.normalize(
    137        shadafile
    138      ))
    139    or (vim.o.shadafile == 'NONE' and '' or vim.o.shadafile)
    140  )
    141  if shadafile ~= '' and vim.fn.glob(shadafile) == '' then
    142    -- Since this may be the first time Nvim has been run, try to create a shada file.
    143    if not pcall(vim.cmd.wshada) then
    144      writeable = false
    145    end
    146  end
    147  if
    148    not writeable
    149    or (
    150      shadafile ~= ''
    151      and (vim.fn.filereadable(shadafile) == 0 or vim.fn.filewritable(shadafile) ~= 1)
    152    )
    153  then
    154    ok = false
    155    health.error(
    156      'shada file is not '
    157        .. ((not writeable or vim.fn.filereadable(shadafile) == 1) and 'writeable' or 'readable')
    158        .. ':\n'
    159        .. shadafile
    160    )
    161  end
    162 
    163  if ok then
    164    health.ok('no issues found')
    165  end
    166 end
    167 
    168 local function check_performance()
    169  health.start('Performance')
    170 
    171  -- Check buildtype
    172  local buildtype = vim.fn.matchstr(vim.fn.execute('version'), [[\v\cbuild type:?\s*[^\n\r\t ]+]])
    173  if buildtype == '' then
    174    health.error('failed to get build type from :version')
    175  elseif vim.regex([[\v(MinSizeRel|Release|RelWithDebInfo)]]):match_str(buildtype) then
    176    health.ok(buildtype)
    177  else
    178    health.info(buildtype)
    179    health.warn('Non-optimized debug build. Nvim will be slower.', {
    180      'Install a different Nvim package, or rebuild with `CMAKE_BUILD_TYPE=RelWithDebInfo`.',
    181      suggest_faq,
    182    })
    183  end
    184 
    185  -- check for slow shell invocation
    186  local slow_cmd_time = 1.5e9
    187  local start_time = vim.uv.hrtime()
    188  -- Vimscript's system() is used to actually invoke a shell
    189  vim.fn.system('echo')
    190  local elapsed_time = vim.uv.hrtime() - start_time
    191  if elapsed_time > slow_cmd_time then
    192    health.warn(
    193      'Slow shell invocation (took ' .. vim.fn.printf('%.2f', elapsed_time) .. ' seconds).'
    194    )
    195  end
    196 end
    197 
    198 -- Load the remote plugin manifest file and check for unregistered plugins
    199 local function check_rplugin_manifest()
    200  health.start('Remote Plugins')
    201 
    202  local existing_rplugins = {} --- @type table<string,string>
    203  --- @type {path:string}[]
    204  local items = vim.fn['remote#host#PluginsForHost']('python3')
    205  for _, item in ipairs(items) do
    206    existing_rplugins[item.path] = 'python3'
    207  end
    208 
    209  local require_update = false
    210  local handle_path = function(path)
    211    --- @type string[]
    212    local python_glob = vim.fn.glob(path .. '/rplugin/python*', true, true)
    213    if vim.tbl_isempty(python_glob) then
    214      return
    215    end
    216 
    217    local python_dir = python_glob[1]
    218    local python_version = vim.fs.basename(python_dir)
    219 
    220    --- @type string[]
    221    local scripts = vim.fn.glob(python_dir .. '/*.py', true, true)
    222    vim.list_extend(scripts, vim.fn.glob(python_dir .. '/*/__init__.py', true, true))
    223 
    224    for _, script in ipairs(scripts) do
    225      local contents = vim.fn.join(vim.fn.readfile(script))
    226      if vim.regex([[\<\%(from\|import\)\s\+neovim\>]]):match_str(contents) then
    227        if vim.regex([[[\/]__init__\.py$]]):match_str(script) then
    228          script = vim.fs.normalize(vim.fs.dirname(script))
    229        end
    230        if not existing_rplugins[script] then
    231          local msg = vim.fn.printf('"%s" is not registered.', vim.fs.basename(path))
    232          if python_version == 'pythonx' then
    233            if vim.fn.has('python3') == 0 then
    234              msg = msg .. ' (python3 not available)'
    235            end
    236          elseif vim.fn.has(python_version) == 0 then
    237            msg = msg .. vim.fn.printf(' (%s not available)', python_version)
    238          else
    239            require_update = true
    240          end
    241 
    242          health.warn(msg)
    243        end
    244 
    245        break
    246      end
    247    end
    248  end
    249 
    250  --- @type string[]
    251  local paths = vim.fn.map(vim.split(vim.o.runtimepath, ','), 'resolve(v:val)')
    252 
    253  for _, path in ipairs(paths) do
    254    handle_path(path)
    255  end
    256 
    257  if require_update then
    258    health.warn('Out of date', { 'Run `:UpdateRemotePlugins`' })
    259  else
    260    health.ok('Up to date')
    261  end
    262 end
    263 
    264 local function check_tmux()
    265  if not vim.env.TMUX or vim.fn.executable('tmux') == 0 then
    266    return
    267  end
    268 
    269  ---@param option string
    270  local get_tmux_option = function(option)
    271    local cmd = { 'tmux', 'show-option', '-qvg', option } -- try global scope
    272    local ok, out = system(cmd)
    273    local val = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g')
    274    if not ok then
    275      health.error(('command failed: %s\n%s'):format(vim.inspect(cmd), out))
    276      return 'error'
    277    elseif val == '' then
    278      cmd = { 'tmux', 'show-option', '-qvgs', option } -- try session scope
    279      ok, out = system(cmd)
    280      val = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g')
    281      if not ok then
    282        health.error(('command failed: %s\n%s'):format(vim.inspect(cmd), out))
    283        return 'error'
    284      end
    285    end
    286    return val
    287  end
    288 
    289  health.start('tmux')
    290 
    291  -- check escape-time
    292  local suggestions =
    293    { 'set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10', suggest_faq }
    294  local tmux_esc_time = get_tmux_option('escape-time')
    295  if tmux_esc_time ~= 'error' then
    296    if tmux_esc_time == '' then
    297      health.error('`escape-time` is not set', suggestions)
    298    elseif tonumber(tmux_esc_time) > 300 then
    299      health.error('`escape-time` (' .. tmux_esc_time .. ') is higher than 300ms', suggestions)
    300    else
    301      health.ok('escape-time: ' .. tmux_esc_time)
    302    end
    303  end
    304 
    305  -- check focus-events
    306  local tmux_focus_events = get_tmux_option('focus-events')
    307  if tmux_focus_events ~= 'error' then
    308    if tmux_focus_events == '' or tmux_focus_events ~= 'on' then
    309      health.warn(
    310        "`focus-events` is not enabled. |'autoread'| may not work.",
    311        { '(tmux 1.9+ only) Set `focus-events` in ~/.tmux.conf:\nset-option -g focus-events on' }
    312      )
    313    else
    314      health.ok('focus-events: ' .. tmux_focus_events)
    315    end
    316  end
    317 
    318  -- check default-terminal and $TERM
    319  health.info('$TERM: ' .. vim.env.TERM)
    320  local cmd = { 'tmux', 'show-option', '-qvg', 'default-terminal' }
    321  local ok, out = system(cmd)
    322  local tmux_default_term = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g')
    323  if tmux_default_term == '' then
    324    cmd = { 'tmux', 'show-option', '-qvgs', 'default-terminal' }
    325    ok, out = system(cmd)
    326    tmux_default_term = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g')
    327  end
    328 
    329  if not ok then
    330    health.error(('command failed: %s\n%s'):format(vim.inspect(cmd), out))
    331  elseif tmux_default_term ~= vim.env.TERM then
    332    health.info('default-terminal: ' .. tmux_default_term)
    333    health.error(
    334      '$TERM differs from the tmux `default-terminal` setting. Colors might look wrong.',
    335      { '$TERM may have been set by some rc (.bashrc, .zshrc, ...).' }
    336    )
    337  elseif
    338    not vim.regex([[\v(tmux-256color|tmux-direct|screen-256color)]]):match_str(vim.env.TERM)
    339  then
    340    health.error(
    341      '$TERM should be "screen-256color", "tmux-256color", or "tmux-direct" in tmux. Colors might look wrong.',
    342      {
    343        'Set default-terminal in ~/.tmux.conf:\nset-option -g default-terminal "screen-256color"',
    344        suggest_faq,
    345      }
    346    )
    347  end
    348 
    349  -- check for RGB capabilities
    350  local _, info = system({ 'tmux', 'show-messages', '-T' })
    351  local has_setrgbb = vim.fn.stridx(info, ' setrgbb: (string)') ~= -1
    352  local has_setrgbf = vim.fn.stridx(info, ' setrgbf: (string)') ~= -1
    353  if not has_setrgbb or not has_setrgbf then
    354    health.warn(
    355      "True color support could not be detected. |'termguicolors'| won't work properly.",
    356      {
    357        "Add the following to your tmux configuration file, replacing XXX by the value of $TERM outside of tmux:\nset-option -a terminal-features 'XXX:RGB'",
    358        "For older tmux versions use this instead:\nset-option -a terminal-overrides 'XXX:Tc'",
    359      }
    360    )
    361  end
    362 end
    363 
    364 local function check_terminal()
    365  if vim.fn.executable('infocmp') == 0 then
    366    return
    367  end
    368 
    369  health.start('Terminal')
    370  local cmd = { 'infocmp', '-L' }
    371  local ok, out = system(cmd)
    372  local kbs_entry = vim.fn.matchstr(out, 'key_backspace=[^,[:space:]]*')
    373  local kdch1_entry = vim.fn.matchstr(out, 'key_dc=[^,[:space:]]*')
    374 
    375  if
    376    not ok
    377    and (
    378      vim.fn.has('win32') == 0
    379      or vim.fn.matchstr(
    380          out,
    381          [[infocmp: couldn't open terminfo file .\+\%(conemu\|vtpcon\|win32con\)]]
    382        )
    383        == ''
    384    )
    385  then
    386    health.error(('command failed: %s\n%s'):format(vim.inspect(cmd), out))
    387  else
    388    health.info(
    389      vim.fn.printf(
    390        'key_backspace (kbs) terminfo entry: `%s`',
    391        (kbs_entry == '' and '? (not found)' or kbs_entry)
    392      )
    393    )
    394 
    395    health.info(
    396      vim.fn.printf(
    397        'key_dc (kdch1) terminfo entry: `%s`',
    398        (kbs_entry == '' and '? (not found)' or kdch1_entry)
    399      )
    400    )
    401  end
    402 
    403  for _, env_var in ipairs({
    404    'XTERM_VERSION',
    405    'VTE_VERSION',
    406    'TERM_PROGRAM',
    407    'COLORTERM',
    408    'SSH_TTY',
    409  }) do
    410    if vim.env[env_var] then
    411      health.info(string.format('$%s="%s"', env_var, vim.env[env_var]))
    412    end
    413  end
    414 end
    415 
    416 local function check_external_tools()
    417  health.start('External Tools')
    418 
    419  if vim.fn.executable('rg') == 1 then
    420    local rg_path = vim.fn.exepath('rg')
    421    local rg_job = vim.system({ rg_path, '-V' }):wait()
    422    if rg_job.code == 0 then
    423      health.ok(('%s (%s)'):format(vim.trim(rg_job.stdout), rg_path))
    424    else
    425      health.warn('found `rg` but failed to run `rg -V`', { rg_job.stderr })
    426    end
    427  else
    428    health.warn('ripgrep not available')
    429  end
    430 
    431  local open_cmd, err = vim.ui._get_open_cmd()
    432  if open_cmd then
    433    health.ok(('vim.ui.open: handler found (%s)'):format(open_cmd[1]))
    434  else
    435    --- @cast err string
    436    health.warn(err)
    437  end
    438 
    439  -- `vim.pack` prefers git 2.36 but tries to work with 2.x.
    440  if vim.fn.executable('git') == 1 then
    441    local git = vim.fn.exepath('git')
    442    local version = vim.system({ 'git', 'version' }, {}):wait().stdout or ''
    443    health.ok(('%s (%s)'):format(vim.trim(version), git))
    444  else
    445    health.warn('git not available (required by `vim.pack`)')
    446  end
    447 
    448  if vim.fn.executable('curl') == 1 then
    449    local curl_path = vim.fn.exepath('curl')
    450    local curl_job = vim.system({ curl_path, '--version' }):wait()
    451 
    452    if curl_job.code == 0 then
    453      local curl_out = curl_job.stdout
    454      if not curl_out or curl_out == '' then
    455        health.warn(
    456          string.format('`%s --version` produced no output', curl_path),
    457          { curl_job.stderr }
    458        )
    459        return
    460      end
    461      local curl_version = vim.version.parse(curl_out)
    462      if not curl_version then
    463        health.warn('Unable to parse curl version from `curl --version`')
    464        return
    465      end
    466      if vim.version.le(curl_version, { 7, 12, 3 }) then
    467        health.warn('curl version %s not compatible', curl_version)
    468        return
    469      end
    470      local lines = { string.format('curl %s (%s)', curl_version, curl_path) }
    471 
    472      for line in vim.gsplit(curl_out, '\n', { plain = true }) do
    473        if line ~= '' then
    474          table.insert(lines, line)
    475        end
    476      end
    477 
    478      -- Add subtitle only if any env var is present
    479      local added_env_header = false
    480      for _, var in ipairs({
    481        'curl_ca_bundle',
    482        'curl_home',
    483        'curl_ssl_backend',
    484        'ssl_cert_dir',
    485        'ssl_cert_file',
    486        'https_proxy',
    487        'http_proxy',
    488        'all_proxy',
    489        'no_proxy',
    490      }) do
    491        ---@type string?
    492        local val = vim.env[var] or vim.env[var:upper()]
    493        if val then
    494          if not added_env_header then
    495            table.insert(lines, 'curl-related environment variables:')
    496            added_env_header = true
    497          end
    498          local shown_var = vim.env[var] and var or var:upper()
    499          table.insert(lines, string.format('  %s=%s', shown_var, val))
    500        end
    501      end
    502 
    503      health.ok(table.concat(lines, '\n'))
    504    else
    505      health.warn('curl is installed but failed to run `curl --version`', { curl_job.stderr })
    506    end
    507  else
    508    health.error('curl not found', {
    509      'Required for vim.net.request() to function.',
    510      'Install curl using your package manager.',
    511    })
    512  end
    513 end
    514 
    515 local function detect_terminal()
    516  local e = vim.env
    517  if e.TERM_PROGRAM then
    518    local v = e.TERM_PROGRAM_VERSION --- @type string?
    519    return e.TERM_PROGRAM_VERSION and (e.TERM_PROGRAM .. ' ' .. v) or e.TERM_PROGRAM
    520  end
    521 
    522  local map = {
    523    KITTY_WINDOW_ID = 'kitty',
    524    ALACRITTY_SOCKET = 'alacritty',
    525    ALACRITTY_LOG = 'alacritty',
    526    WEZTERM_EXECUTABLE = 'wezterm',
    527    KONSOLE_VERSION = function()
    528      return 'konsole ' .. e.KONSOLE_VERSION
    529    end,
    530    VTE_VERSION = function()
    531      return 'vte ' .. e.VTE_VERSION
    532    end,
    533  }
    534 
    535  for key, val in pairs(map) do
    536    local env = e[key] --- @type string?
    537    if env then
    538      return type(val) == 'function' and val() or val
    539    end
    540  end
    541 
    542  return 'unknown'
    543 end
    544 
    545 ---@param nvim_version string
    546 local function check_stable_version(nvim_version)
    547  local result = vim
    548    .system(
    549      { 'git', 'ls-remote', '--tags', 'https://github.com/neovim/neovim' },
    550      { text = true, timeout = 5000 }
    551    )
    552    :wait()
    553  if result.code ~= 0 or not result.stdout or result.stdout == '' then
    554    return
    555  end
    556  local stable_sha = assert(
    557    result.stdout:match('(%x+)%s+refs/tags/stable%^{}')
    558      or result.stdout:match('(%x+)%s+refs/tags/stable\n')
    559  )
    560  local latest_version =
    561    assert(result.stdout:match(stable_sha .. '%s+refs/tags/v?(%d+%.%d+%.%d+)%^{}'))
    562  local current_version = assert(nvim_version:match('v?(%d+%.%d+%.%d+)'))
    563  local current = vim.version.parse(current_version)
    564  local latest = vim.version.parse(latest_version)
    565  if current and latest and vim.version.lt(current, latest) then
    566    vim.health.warn(('Nvim %s is available (current: %s)'):format(latest_version, current_version))
    567  else
    568    vim.health.ok(('Up to date (%s)'):format(current_version))
    569  end
    570 end
    571 
    572 ---@param commit string
    573 local function check_head_hash(commit)
    574  local result = vim
    575    .system(
    576      { 'git', 'ls-remote', 'https://github.com/neovim/neovim', 'HEAD' },
    577      { text = true, timeout = 5000 }
    578    )
    579    :wait()
    580  if result.code ~= 0 or not result.stdout or result.stdout == '' then
    581    return
    582  end
    583  local upstream = assert(result.stdout:match('^(%x+)'))
    584  if not vim.startswith(upstream, commit) then
    585    vim.health.warn(
    586      ('Build is outdated. Local: %s, Latest: %s'):format(commit, upstream:sub(1, 12))
    587    )
    588  else
    589    vim.health.ok(('Using latest HEAD: %s'):format(upstream:sub(1, 12)))
    590  end
    591 end
    592 
    593 local function check_sysinfo()
    594  vim.health.start('System Info')
    595 
    596  -- Use :version because `vim.version().build` returns "Homebrew" for brew installs.
    597  local version_out = vim.api.nvim_exec2('version', { output = true }).output
    598  local nvim_version = version_out:match('NVIM (v[^\n]+)') or 'unknown'
    599  local commit --[[@type string]] = (version_out:match('%+g(%x+)') or ''):sub(1, 12)
    600 
    601  if vim.fn.executable('git') ~= 1 then
    602    vim.health.warn('Cannot check for updates: git not found')
    603  elseif vim.trim(commit) ~= '' then
    604    check_head_hash(commit)
    605  else
    606    check_stable_version(nvim_version)
    607  end
    608 
    609  local os_info = vim.uv.os_uname()
    610  local os_string = os_info.sysname .. ' ' .. os_info.release
    611  local terminal = detect_terminal()
    612  local term_env = vim.env.TERM or 'unknown'
    613 
    614  vim.health.info(('Nvim version: `%s` %s'):format(nvim_version, commit))
    615  vim.health.info('Operating system: ' .. os_string)
    616  vim.health.info('Terminal: ' .. terminal)
    617  vim.health.info('$TERM: ' .. term_env)
    618 
    619  local body = vim.text.indent(
    620    0,
    621    string.format(
    622      [[
    623    ## Problem
    624 
    625    Describe the problem (concisely).
    626 
    627    ## Steps to reproduce
    628 
    629    ```
    630    nvim --clean
    631    ```
    632 
    633    ## Expected behavior
    634 
    635    ## System info
    636 
    637    - Nvim version (nvim -v): `%s` neovim/neovim@%s
    638    - Vim (not Nvim) behaves the same?: ?
    639    - Operating system/version: %s
    640    - Terminal name/version: %s
    641    - $TERM environment variable: `%s`
    642    - Installation: ?
    643 
    644 ]],
    645      nvim_version,
    646      commit,
    647      os_string,
    648      terminal,
    649      term_env
    650    )
    651  )
    652 
    653  vim.api.nvim_create_autocmd('FileType', {
    654    pattern = 'checkhealth',
    655    once = true,
    656    callback = function(args)
    657      local buf = args.buf
    658      local win = vim.fn.bufwinid(buf)
    659      if win == -1 then
    660        return
    661      end
    662      local encoded_body = vim.uri_encode(body) --- @type string
    663      local issue_url = 'https://github.com/neovim/neovim/issues/new?type=Bug&body=' .. encoded_body
    664 
    665      _G.nvim_health_bugreport_open = function()
    666        vim.ui.open(issue_url)
    667      end
    668      vim.wo[win].winbar =
    669        '%#WarningMsg#%@v:lua.nvim_health_bugreport_open@Click to Create Bug Report on GitHub%X%*'
    670 
    671      vim.api.nvim_create_autocmd('BufDelete', {
    672        buffer = buf,
    673        once = true,
    674        command = 'lua _G.nvim_health_bugreport_open = nil',
    675      })
    676    end,
    677  })
    678 end
    679 
    680 function M.check()
    681  check_sysinfo()
    682  check_config()
    683  check_runtime()
    684  check_performance()
    685  check_rplugin_manifest()
    686  check_terminal()
    687  check_tmux()
    688  check_external_tools()
    689 end
    690 
    691 return M