mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: use npcall from vim.F
This commit is contained in:
parent
8a5c7e91f2
commit
8bccefcb87
@ -2,30 +2,10 @@ local vim = vim
|
||||
local a = vim.api
|
||||
local validate = vim.validate
|
||||
local util = require('vim.lsp.util')
|
||||
local npcall = vim.F.npcall
|
||||
|
||||
local M = {}
|
||||
|
||||
---@private
|
||||
--- Returns nil if {status} is false or nil, otherwise returns the rest of the
|
||||
--- arguments.
|
||||
local function ok_or_nil(status, ...)
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
return ...
|
||||
end
|
||||
|
||||
---@private
|
||||
--- Swallows errors.
|
||||
---
|
||||
---@param fn Function to run
|
||||
---@param ... Function arguments
|
||||
---@returns Result of `fn(...)` if there are no errors, otherwise nil.
|
||||
--- Returns nil if errors occur during {fn}, otherwise returns
|
||||
local function npcall(fn, ...)
|
||||
return ok_or_nil(pcall(fn, ...))
|
||||
end
|
||||
|
||||
---@private
|
||||
--- Sends an async request to all active clients attached to the current
|
||||
--- buffer.
|
||||
|
Loading…
Reference in New Issue
Block a user