mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
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`.
This commit is contained in:
committed by
GitHub
parent
74ca73d545
commit
a8dd5c7e41
@ -8,6 +8,12 @@ local M = {}
|
|||||||
--- @param env? table<string,string|number>
|
--- @param env? table<string,string|number>
|
||||||
--- @return string
|
--- @return string
|
||||||
local function system(cmd, silent, env)
|
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()
|
local r = vim.system(cmd, { env = env, timeout = 10000 }):wait()
|
||||||
|
|
||||||
if not silent then
|
if not silent then
|
||||||
@ -577,7 +583,10 @@ function M.man_complete(arg_lead, cmd_line)
|
|||||||
return {}
|
return {}
|
||||||
end
|
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
|
-- We check for duplicates in case the same manpage in different languages
|
||||||
-- was found.
|
-- was found.
|
||||||
|
@ -8,7 +8,7 @@ vim.api.nvim_create_user_command('Man', function(params)
|
|||||||
if params.bang then
|
if params.bang then
|
||||||
man.init_pager()
|
man.init_pager()
|
||||||
else
|
else
|
||||||
local err = man.open_page(params.count, params.smods, params.fargs)
|
local _, err = pcall(man.open_page, params.count, params.smods, params.fargs)
|
||||||
if err then
|
if err then
|
||||||
vim.notify('man.lua: ' .. err, vim.log.levels.ERROR)
|
vim.notify('man.lua: ' .. err, vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user