diff options
| author | Emanuel Krollmann <115734183+Sodastream11@users.noreply.github.com> | 2025-04-12 19:54:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-12 10:54:20 -0700 |
| commit | a8dd5c7e41dde33a5e130eb6d8945def13ebb8d6 (patch) | |
| tree | 9b8effd2b894fd04503e8e02f15bc71783730f8f /runtime/lua/man.lua | |
| parent | 74ca73d545daf9aff6a6b041572be062d46d51ef (diff) | |
| download | rneovim-a8dd5c7e41dde33a5e130eb6d8945def13ebb8d6.tar.gz rneovim-a8dd5c7e41dde33a5e130eb6d8945def13ebb8d6.tar.bz2 rneovim-a8dd5c7e41dde33a5e130eb6d8945def13ebb8d6.zip | |
fix(man.lua): noisy "ENOENT" error on Windows #33409
Problem:
:Man shows noisy "ENOENT: no such file or directory" error on Windows.
Solution:
Do some checks before calling `vim.system`.
Diffstat (limited to 'runtime/lua/man.lua')
| -rw-r--r-- | runtime/lua/man.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index a7596bb1c3..c6b05d1412 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -8,6 +8,12 @@ local M = {} --- @param env? table<string,string|number> --- @return string local function system(cmd, silent, env) + if vim.fn.executable(cmd[1]) == 0 then + error(string.format('not found: "%s"', cmd[1]), 0) + elseif vim.uv.fs_access(cmd[1], 'X') then + error(string.format('not executable : "%s"', cmd[1]), 0) + end + local r = vim.system(cmd, { env = env, timeout = 10000 }):wait() if not silent then @@ -577,7 +583,10 @@ function M.man_complete(arg_lead, cmd_line) return {} end - local pages = get_paths(name, sect) + local ok, pages = pcall(get_paths, name, sect) + if not ok then + return nil + end -- We check for duplicates in case the same manpage in different languages -- was found. |