Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
feat: added function to check if a fiven fqname is a lua object
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 11, 2022
1 parent fb82dcc commit 3d1d469
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lua/lua-dev/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ function M.options()
return ret
end

function M.is_lua(name)
local real_fn = vim.tbl_get(_G, unpack(vim.split(name, ".", { plain = true })))
if type(real_fn) == "function" then
local info = debug.getinfo(real_fn, "S")
return info.what == "Lua"
elseif type(real_fn) == "table" then
return true
elseif not real_fn then
return true
end
return false
end

function M.lua()
---@type table<string, VimFunction>
local ret = {}
Expand All @@ -149,21 +162,9 @@ function M.lua()
if parse then
local name = parse.name

local skip = false

local real_fn = vim.tbl_get(_G, unpack(vim.split(name, ".", { plain = true })))
if type(real_fn) == "function" then
local info = debug.getinfo(real_fn, "S")
if info.what == "Lua" then
skip = true
end
elseif type(real_fn) == "table" then
skip = true
elseif not real_fn then
skip = true
end

if not skip then
-- Skip real lua functions
-- We're only interested in C type functions
if not M.is_lua(name) then
ret[name] = {
name = name,
fqname = name,
Expand Down

0 comments on commit 3d1d469

Please sign in to comment.