diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2024-03-09 15:00:41 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2024-03-09 15:00:41 -0700 |
| commit | 7a7f497b483cd65e340064f23ed1c73425ecba0a (patch) | |
| tree | d5c99ea22a1e10300d06165f8ac96df6b0dc59e1 /runtime/lua | |
| parent | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (diff) | |
| parent | ade1b12f49c3b3914c74847d791eb90ea90b56b7 (diff) | |
| download | rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.tar.gz rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.tar.bz2 rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.zip | |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpost
Diffstat (limited to 'runtime/lua')
88 files changed, 12605 insertions, 6618 deletions
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index dcdfc2b87f..ac15aff60c 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -238,7 +238,7 @@ local function get_path(sect, name, silent) -- If you run man -w strlen and string.3 comes up first, this is a problem. We -- should search for a matching named one in the results list. -- However, if you search for man -w clock_gettime, you will *only* get - -- clock_getres.2, which is the right page. Searching the resuls for + -- clock_getres.2, which is the right page. Searching the results for -- clock_gettime will no longer work. In this case, we should just use the -- first one that was found in the correct section. -- diff --git a/runtime/lua/nvim/health.lua b/runtime/lua/nvim/health.lua index 6b6370fa19..0480e4df4e 100644 --- a/runtime/lua/nvim/health.lua +++ b/runtime/lua/nvim/health.lua @@ -17,15 +17,21 @@ local shell_error = function() return vim.v.shell_error ~= 0 end -local suggest_faq = 'https://github.com/neovim/neovim/wiki/Building-Neovim#optimized-builds' +local suggest_faq = 'https://github.com/neovim/neovim/blob/docs/install/BUILD.md#building' local function check_runtime() health.start('Runtime') -- Files from an old installation. local bad_files = { + ['plugin/health.vim'] = false, + ['autoload/health/nvim.vim'] = false, + ['autoload/health/provider.vim'] = false, + ['autoload/man.vim'] = false, ['plugin/man.vim'] = false, + ['queries/help/highlights.scm'] = false, + ['queries/help/injections.scm'] = false, ['scripts.vim'] = false, - ['autoload/man.vim'] = false, + ['syntax/syncolor.vim'] = false, } local bad_files_msg = '' for k, _ in pairs(bad_files) do @@ -42,10 +48,10 @@ local function check_runtime() if not ok then health.error( string.format( - '$VIMRUNTIME has files from an old installation (this can cause weird behavior):\n%s', + 'Found old files in $VIMRUNTIME (this can cause weird behavior):\n%s', bad_files_msg ), - { 'Delete $VIMRUNTIME (or uninstall Nvim), then reinstall Nvim.' } + { 'Delete the $VIMRUNTIME directory (or uninstall Nvim), then reinstall Nvim.' } ) end end @@ -183,10 +189,6 @@ local function check_rplugin_manifest() health.start('Remote Plugins') local existing_rplugins = {} - for _, item in ipairs(vim.fn['remote#host#PluginsForHost']('python')) do - existing_rplugins[item.path] = 'python' - end - for _, item in ipairs(vim.fn['remote#host#PluginsForHost']('python3')) do existing_rplugins[item.path] = 'python3' end @@ -324,24 +326,17 @@ local function check_tmux() end -- check for RGB capabilities - local info = vim.fn.system({ 'tmux', 'display-message', '-p', '#{client_termfeatures}' }) - info = vim.split(vim.trim(info), ',', { trimempty = true }) - if not vim.list_contains(info, 'RGB') then - local has_rgb = false - if #info == 0 then - -- client_termfeatures may not be supported; fallback to checking show-messages - info = vim.fn.system({ 'tmux', 'show-messages', '-JT' }) - has_rgb = info:find(' Tc: (flag) true', 1, true) or info:find(' RGB: (flag) true', 1, true) - end - if not has_rgb then - health.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-features ',XXX:RGB'", - "For older tmux versions use this instead:\nset-option -ga terminal-overrides ',XXX:Tc'", - } - ) - end + local info = vim.fn.system({ 'tmux', 'show-messages', '-T' }) + local has_setrgbb = vim.fn.stridx(info, ' setrgbb: (string)') ~= -1 + local has_setrgbf = vim.fn.stridx(info, ' setrgbf: (string)') ~= -1 + if not has_setrgbb or not has_setrgbf then + health.warn( + "True color support could not be detected. |'termguicolors'| won't work properly.", + { + "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'", + "For older tmux versions use this instead:\nset-option -a terminal-overrides 'XXX:Tc'", + } + ) end end diff --git a/runtime/lua/provider/clipboard/health.lua b/runtime/lua/provider/clipboard/health.lua new file mode 100644 index 0000000000..dc33cb0ab0 --- /dev/null +++ b/runtime/lua/provider/clipboard/health.lua @@ -0,0 +1,40 @@ +local health = vim.health +local executable = health.executable + +local M = {} + +function M.check() + health.start('Clipboard (optional)') + + if + os.getenv('TMUX') + and executable('tmux') + and executable('pbpaste') + and not health.cmd_ok('pbpaste') + then + local tmux_version = string.match(vim.fn.system('tmux -V'), '%d+%.%d+') + local advice = { + 'Install tmux 2.6+. https://superuser.com/q/231130', + 'or use tmux with reattach-to-user-namespace. https://superuser.com/a/413233', + } + health.error('pbcopy does not work with tmux version: ' .. tmux_version, advice) + end + + local clipboard_tool = vim.fn['provider#clipboard#Executable']() + if vim.g.clipboard ~= nil and clipboard_tool == '' then + local error_message = vim.fn['provider#clipboard#Error']() + health.error( + error_message, + "Use the example in :help g:clipboard as a template, or don't set g:clipboard at all." + ) + elseif clipboard_tool:find('^%s*$') then + health.warn( + 'No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.', + ':help clipboard' + ) + else + health.ok('Clipboard tool found: ' .. clipboard_tool) + end +end + +return M diff --git a/runtime/lua/provider/health.lua b/runtime/lua/provider/health.lua deleted file mode 100644 index d33f74f6e9..0000000000 --- a/runtime/lua/provider/health.lua +++ /dev/null @@ -1,916 +0,0 @@ -local M = {} - -local start = vim.health.start -local ok = vim.health.ok -local info = vim.health.info -local warn = vim.health.warn -local error = vim.health.error -local iswin = vim.uv.os_uname().sysname == 'Windows_NT' - -local shell_error_code = 0 -local function shell_error() - return shell_error_code ~= 0 -end - --- Returns true if `cmd` exits with success, else false. -local function cmd_ok(cmd) - vim.fn.system(cmd) - return vim.v.shell_error == 0 -end - -local function executable(exe) - return vim.fn.executable(exe) == 1 -end - -local function is_blank(s) - return s:find('^%s*$') ~= nil -end - -local function isdir(path) - if not path then - return false - end - local stat = vim.uv.fs_stat(path) - if not stat then - return false - end - return stat.type == 'directory' -end - -local function isfile(path) - if not path then - return false - end - local stat = vim.uv.fs_stat(path) - if not stat then - return false - end - return stat.type == 'file' -end - --- Handler for s:system() function. -local function system_handler(self, _, data, event) - if event == 'stderr' then - if self.add_stderr_to_output then - self.output = self.output .. vim.fn.join(data, '') - else - self.stderr = self.stderr .. vim.fn.join(data, '') - end - elseif event == 'stdout' then - self.output = self.output .. vim.fn.join(data, '') - elseif event == 'exit' then - shell_error_code = data - end -end - --- Attempts to construct a shell command from an args list. --- Only for display, to help users debug a failed command. -local function shellify(cmd) - if type(cmd) ~= 'table' then - return cmd - end - return vim.fn.join( - vim.fn.map(vim.fn.copy(cmd), [[v:val =~# ''\m[^\-.a-zA-Z_/]'' ? shellescape(v:val) : v:val]]), - ' ' - ) -end - --- Run a system command and timeout after 30 seconds. -local function system(cmd, ...) - local args = { ... } - local args_count = vim.tbl_count(args) - - local stdin = (args_count > 0 and args[1] or '') - local stderr = (args_count > 1 and args[2] or false) - local ignore_error = (args_count > 2 and args[3] or false) - - local opts = { - add_stderr_to_output = stderr, - output = '', - stderr = '', - on_stdout = system_handler, - on_stderr = system_handler, - on_exit = system_handler, - } - local jobid = vim.fn.jobstart(cmd, opts) - - if jobid < 1 then - local message = 'Command error (job=' - .. jobid - .. '): `' - .. shellify(cmd) - .. '` (in ' - .. vim.fn.string(vim.fn.getcwd()) - .. ')' - - error(message) - shell_error_code = 1 - return opts.output - end - - if not is_blank(stdin) then - vim.api.nvim_chan_send(jobid, stdin) - end - - local res = vim.fn.jobwait({ jobid }, 30000) - if res[1] == -1 then - error('Command timed out: ' .. shellify(cmd)) - vim.fn.jobstop(jobid) - elseif shell_error() and not ignore_error then - local emsg = 'Command error (job=' - .. jobid - .. ', exit code ' - .. shell_error_code - .. '): `' - .. shellify(cmd) - .. '` (in ' - .. vim.fn.string(vim.fn.getcwd()) - .. ')' - if not is_blank(opts.output) then - emsg = emsg .. '\noutput: ' .. opts.output - end - if not is_blank(opts.stderr) then - emsg = emsg .. '\nstderr: ' .. opts.stderr - end - error(emsg) - end - - -- return opts.output - local _ = ... - return vim.trim(vim.fn.system(cmd)) -end - -local function clipboard() - start('Clipboard (optional)') - - if - os.getenv('TMUX') - and executable('tmux') - and executable('pbpaste') - and not cmd_ok('pbpaste') - then - local tmux_version = string.match(vim.fn.system('tmux -V'), '%d+%.%d+') - local advice = { - 'Install tmux 2.6+. https://superuser.com/q/231130', - 'or use tmux with reattach-to-user-namespace. https://superuser.com/a/413233', - } - error('pbcopy does not work with tmux version: ' .. tmux_version, advice) - end - - local clipboard_tool = vim.fn['provider#clipboard#Executable']() - if vim.g.clipboard and is_blank(clipboard_tool) then - local error_message = vim.fn['provider#clipboard#Error']() - error( - error_message, - "Use the example in :help g:clipboard as a template, or don't set g:clipboard at all." - ) - elseif is_blank(clipboard_tool) then - warn( - 'No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.', - ':help clipboard' - ) - else - ok('Clipboard tool found: ' .. clipboard_tool) - end -end - -local function disabled_via_loaded_var(provider) - local loaded_var = 'loaded_' .. provider .. '_provider' - local v = vim.g[loaded_var] - if v == 0 then - info('Disabled (' .. loaded_var .. '=' .. v .. ').') - return true - end - return false -end - --- Check if pyenv is available and a valid pyenv root can be found, then return --- their respective paths. If either of those is invalid, return two empty --- strings, effectively ignoring pyenv. -local function check_for_pyenv() - local pyenv_path = vim.fn.resolve(vim.fn.exepath('pyenv')) - - if is_blank(pyenv_path) then - return { '', '' } - end - - info('pyenv: Path: ' .. pyenv_path) - - local pyenv_root = os.getenv('PYENV_ROOT') and vim.fn.resolve(os.getenv('PYENV_ROOT')) or '' - - if is_blank(pyenv_root) then - pyenv_root = vim.trim(system({ pyenv_path, 'root' })) - info('pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.') - end - - if not isdir(pyenv_root) then - local message = 'pyenv: Root does not exist: ' - .. pyenv_root - .. '. Ignoring pyenv for all following checks.' - warn(message) - return { '', '' } - end - - info('pyenv: Root: ' .. pyenv_root) - - |