diff options
| author | Gregory Anders <greg@gpanders.com> | 2023-04-10 16:48:58 -0600 |
|---|---|---|
| committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-01-01 20:12:37 +0100 |
| commit | 164f1ea06d17e935f41e178e46bb05bbb676af20 (patch) | |
| tree | 6e04a060877aef5f979326ae025329828dcb4ac9 /runtime/lua/provider/clipboard | |
| parent | b49d4e18a67d16548fa72013237a87564656170e (diff) | |
| download | rneovim-164f1ea06d17e935f41e178e46bb05bbb676af20.tar.gz rneovim-164f1ea06d17e935f41e178e46bb05bbb676af20.tar.bz2 rneovim-164f1ea06d17e935f41e178e46bb05bbb676af20.zip | |
refactor(health): refactor provider healthchecks
* Prefer pure Lua functions over vim.fn
* Split up provider healthchecks into separate modules to help manage
complexity
Diffstat (limited to 'runtime/lua/provider/clipboard')
| -rw-r--r-- | runtime/lua/provider/clipboard/health.lua | 40 |
1 files changed, 40 insertions, 0 deletions
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 |