aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/secure.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:15:05 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:27:38 +0000
commitc5d770d311841ea5230426cc4c868e8db27300a8 (patch)
treedd21f70127b4b8b5f109baefc8ecc5016f507c91 /runtime/lua/vim/secure.lua
parent9be89f131f87608f224f0ee06d199fcd09d32176 (diff)
parent081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff)
downloadrneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/lua/vim/secure.lua')
-rw-r--r--runtime/lua/vim/secure.lua20
1 files changed, 7 insertions, 13 deletions
diff --git a/runtime/lua/vim/secure.lua b/runtime/lua/vim/secure.lua
index 266725cce2..7b1d071270 100644
--- a/runtime/lua/vim/secure.lua
+++ b/runtime/lua/vim/secure.lua
@@ -26,7 +26,7 @@ end
---
---@param trust table<string, string> Trust table to write
local function write_trust(trust)
- vim.validate({ trust = { trust, 't' } })
+ vim.validate('trust', trust, 'table')
local f = assert(io.open(vim.fn.stdpath('state') .. '/trust', 'w'))
local t = {} ---@type string[]
@@ -49,7 +49,7 @@ end
---@return (string|nil) The contents of the given file if it exists and is
--- trusted, or nil otherwise.
function M.read(path)
- vim.validate({ path = { path, 's' } })
+ vim.validate('path', path, 'string')
local fullpath = vim.uv.fs_realpath(vim.fs.normalize(path))
if not fullpath then
return nil
@@ -132,17 +132,11 @@ end
---@return boolean success true if operation was successful
---@return string msg full path if operation was successful, else error message
function M.trust(opts)
- vim.validate({
- path = { opts.path, 's', true },
- bufnr = { opts.bufnr, 'n', true },
- action = {
- opts.action,
- function(m)
- return m == 'allow' or m == 'deny' or m == 'remove'
- end,
- [["allow" or "deny" or "remove"]],
- },
- })
+ vim.validate('path', opts.path, 'string', true)
+ vim.validate('bufnr', opts.bufnr, 'number', true)
+ vim.validate('action', opts.action, function(m)
+ return m == 'allow' or m == 'deny' or m == 'remove'
+ end, [["allow" or "deny" or "remove"]])
---@cast opts vim.trust.opts
local path = opts.path