diff options
author | dundargoc <gocdundar@gmail.com> | 2024-05-18 18:35:26 +0200 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-05-19 11:46:34 +0200 |
commit | 0f4f7d32ce5d6d3b751b0b01455770f3b72531b9 (patch) | |
tree | 44341b33654b2361319c799de28a40bd06bb3fdf /runtime/lua/provider/perl | |
parent | 63e3a63d2fcd72c40ed2b4128a232c0931ef21cf (diff) | |
download | rneovim-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/provider/perl')
-rw-r--r-- | runtime/lua/provider/perl/health.lua | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/runtime/lua/provider/perl/health.lua b/runtime/lua/provider/perl/health.lua deleted file mode 100644 index 535093d793..0000000000 --- a/runtime/lua/provider/perl/health.lua +++ /dev/null @@ -1,90 +0,0 @@ -local health = vim.health - -local M = {} - -function M.check() - health.start('Perl provider (optional)') - - if health.provider_disabled('perl') then - return - end - - local perl_exec, perl_warnings = vim.provider.perl.detect() - - if not perl_exec then - health.warn(assert(perl_warnings), { - 'See :help provider-perl for more information.', - 'You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim', - }) - health.warn('No usable perl executable found') - return - end - - health.info('perl executable: ' .. perl_exec) - - -- we cannot use cpanm that is on the path, as it may not be for the perl - -- set with g:perl_host_prog - local ok = health.cmd_ok({ perl_exec, '-W', '-MApp::cpanminus', '-e', '' }) - if not ok then - return { perl_exec, '"App::cpanminus" module is not installed' } - end - - local latest_cpan_cmd = { - perl_exec, - '-MApp::cpanminus::fatscript', - '-e', - 'my $app = App::cpanminus::script->new; $app->parse_options ("--info", "-q", "Neovim::Ext"); exit $app->doit', - } - local latest_cpan - ok, latest_cpan = health.cmd_ok(latest_cpan_cmd) - if not ok or latest_cpan:find('^%s*$') then - health.error( - 'Failed to run: ' .. table.concat(latest_cpan_cmd, ' '), - { "Make sure you're connected to the internet.", 'Are you behind a firewall or proxy?' } - ) - return - elseif latest_cpan[1] == '!' then - local cpanm_errs = vim.split(latest_cpan, '!') - if cpanm_errs[1]:find("Can't write to ") then - local advice = {} - for i = 2, #cpanm_errs do - advice[#advice + 1] = cpanm_errs[i] - end - - health.warn(cpanm_errs[1], advice) - -- Last line is the package info - latest_cpan = cpanm_errs[#cpanm_errs] - else - health.error('Unknown warning from command: ' .. latest_cpan_cmd, cpanm_errs) - return - end - end - latest_cpan = vim.fn.matchstr(latest_cpan, [[\(\.\?\d\)\+]]) - if latest_cpan:find('^%s*$') then - health.error('Cannot parse version number from cpanm output: ' .. latest_cpan) - return - end - - local current_cpan_cmd = { perl_exec, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION' } - local current_cpan - ok, current_cpan = health.cmd_ok(current_cpan_cmd) - if not ok then - health.error( - 'Failed to run: ' .. table.concat(current_cpan_cmd, ' '), - { 'Report this issue with the output of: ', table.concat(current_cpan_cmd, ' ') } - ) - return - end - - if vim.version.lt(current_cpan, latest_cpan) then - local message = 'Module "Neovim::Ext" is out-of-date. Installed: ' - .. current_cpan - .. ', latest: ' - .. latest_cpan - health.warn(message, 'Run in shell: cpanm -n Neovim::Ext') - else - health.ok('Latest "Neovim::Ext" cpan module is installed: ' .. current_cpan) - end -end - -return M |