Allow to take the full SourceConfig from source API (#561)

* - SourceConfig.opts -> SourceConfig.option
- Add SourceConfig.trigger_characters
- Allow accessing full SourceConfig from source

* fmt&lint
This commit is contained in:
hrsh7th
2021-11-23 21:17:03 +09:00
committed by GitHub
parent ea10d5bd2f
commit 1944b46336
7 changed files with 73 additions and 38 deletions

View File

@@ -168,6 +168,19 @@ misc.to_vimindex = function(text, utfindex)
return utfindex + 1
end
---Return readonly version object
---@generic T
---@param tbl T
---@return T
misc.readonly = function(tbl)
return setmetatable({}, {
__index = tbl,
__newindex = function()
error('this table is readonly.')
end,
})
end
---Mark the function as deprecated
misc.deprecated = function(fn, msg)
local printed = false

View File

@@ -48,4 +48,13 @@ describe('misc', function()
})
assert.are.equal(merged.a, nil)
end)
it('readonly', function()
local o = { a = 1, b = 2 }
local r = misc.readonly(o)
assert.are.equal(r.a, 1)
assert.has_error(function()
r.a = 5
end)
end)
end)