aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/provider/clipboard/health.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-05-18 18:35:26 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-05-19 11:46:34 +0200
commit0f4f7d32ce5d6d3b751b0b01455770f3b72531b9 (patch)
tree44341b33654b2361319c799de28a40bd06bb3fdf /runtime/lua/vim/provider/clipboard/health.lua
parent63e3a63d2fcd72c40ed2b4128a232c0931ef21cf (diff)
downloadrneovim-0f4f7d32ce5d6d3b751b0b01455770f3b72531b9.tar.gz
rneovim-0f4f7d32ce5d6d3b751b0b01455770f3b72531b9.tar.bz2
rneovim-0f4f7d32ce5d6d3b751b0b01455770f3b72531b9.zip
refactor!: remove `nvim` and `provider` module for checkhealth
The namespacing for healthchecks for neovim modules is inconsistent and confusing. The completion for `:checkhealth` with `--clean` gives ``` nvim provider.clipboard provider.node provider.perl provider.python provider.ruby vim.lsp vim.treesitter ``` There are now three top-level module names for nvim: `nvim`, `provider` and `vim` with no signs of stopping. The `nvim` name is especially confusing as it does not contain all neovim checkhealths, which makes it almost a decoy healthcheck. The confusion only worsens if you add plugins to the mix: ``` lazy mason nvim nvim-treesitter provider.clipboard provider.node provider.perl provider.python provider.ruby telescope vim.lsp vim.treesitter ``` Another problem with the current approach is that it's not easy to run nvim-only healthchecks since they don't share the same namespace. The current approach would be to run `:che nvim vim.* provider.*` and would also require the user to know these are the neovim modules. Instead, use this alternative structure: ``` vim.health vim.lsp vim.provider.clipboard vim.provider.node vim.provider.perl vim.provider.python vim.provider.ruby vim.treesitter ``` and ``` lazy mason nvim-treesitter telescope vim.health vim.lsp vim.provider.clipboard vim.provider.node vim.provider.perl vim.provider.python vim.provider.ruby vim.treesitter ``` Now, the entries are properly sorted and running nvim-only healthchecks requires running only `:che vim.*`.
Diffstat (limited to 'runtime/lua/vim/provider/clipboard/health.lua')
-rw-r--r--runtime/lua/vim/provider/clipboard/health.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/lua/vim/provider/clipboard/health.lua b/runtime/lua/vim/provider/clipboard/health.lua
new file mode 100644
index 0000000000..e44f7d32cc
--- /dev/null
+++ b/runtime/lua/vim/provider/clipboard/health.lua
@@ -0,0 +1,39 @@
+local health = vim.health
+
+local M = {}
+
+function M.check()
+ health.start('Clipboard (optional)')
+
+ if
+ os.getenv('TMUX')
+ and vim.fn.executable('tmux') == 1
+ and vim.fn.executable('pbpaste') == 1
+ 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