aboutsummaryrefslogtreecommitdiff
path: root/src/cjson/lua_cjson.c
Commit message (Collapse)AuthorAge
* fix(vim.json)!: remove global options, "null", "array_mt" #24070Justin M. Keyes2023-06-21
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: - `vim.json` exposes various global options which: - affect all Nvim Lua plugins (especially the LSP client) - are undocumented and untested - can cause confusing problems such as: https://github.com/codota/tabnine-nvim/commit/cc76ae3abe2f129d44b5a8edee2529e0ee0dcf69 - `vim.json` exposes redundant mechanisms: - `vim.json.null` is redundant with `vim.NIL`. - `array_mt` is redundant because Nvim uses a metatable (`vim.empty_dict()`) for empty dict instead, which `vim.json` is configured to use by default (see `as_empty_dict`). Example: ``` :lua vim.print(vim.json.decode('{"bar":[],"foo":{}}')) --> { bar = {}, foo = vim.empty_dict() } ``` Thus we don't need to also decorate empty arrays with `array_mt`. Solution: Remove the functions from the public vim.json interface. Comment-out the implementation code to minimize drift from upstream. TODO: - Expose the options as arguments to `vim.json.new()`
* refactor: fix clang-tidy bugprone-signed-char-misuse warningsDundar Göc2022-03-04
| | | | | Prefer to declare variables with correct type instead of explicit casts wherever possible.
* feat(lua): add proper support of luv threadserw72022-02-26
|
* feat(lsp): improve json deserialization performance (#15854)Michael Lingelbach2021-10-05
| | | | | | | | | | * Add optional second table argument to vim.json.decode which takes a table 'luanil' which can include the 'object' and/or 'array' keys. These options use luanil when converting NULL in json objects and arrays respectively. The default behavior matches the original lua-cjson. * Remove recursive_convert_NIL function from rpc.lua, use vim.json.decode with luanil = { object = true } instead. This removes a hotpath in the json deserialization pipeline by dropping keys with json NULL values throughout the deserialized table.
* feat(lua): expose lua-cjson as vim.jsonMichael Lingelbach2021-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * add vim.json.encode and vim.json.decode * use vim.NIL instead of cjson.null * resolve strict-prototypes warnings * The following benchmark shows an approximately 2.5x (750 ms vs 300 ms) improvement in deserialization performance over vim.fn.json_decode on a medium package.json ```lua local uv = vim.loop local function readfile(path) return end local json_url = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/b24c8d5c89ee93d1172b4127564f5da3b0c88dad/editors/code/package.json" io.popen(string.format('curl -v -f -L -O %q &> /dev/null', json_url)) local json_string = io.open('package.json'):read '*a' uv.update_time() local start = uv.hrtime() for i = 1,1000 do vim.fn.json_decode(json_string) end uv.update_time() print(string.format("Deserialization time vim.fn.json_decode: %s ms", (uv.hrtime() - start) * (1e-6))) uv.update_time() local start = uv.hrtime() for i = 1,1000 do vim.json.decode(json_string) end uv.update_time() print(string.format("Deserialization time vim.json.decode: %s ms", (uv.hrtime() - start) * (1e-6))) ``` Co-Authored-By: Björn Linse <bjorn.linse@gmail.com>
* feat(lua): add lua-cjson as vendored dependencyMichael Lingelbach2021-09-26
Derived from the openresty lua-cjson fork at commit https://github.com/openresty/lua-cjson/commit/3d93d297092172eac3d52a1b3b6c1d479da5341a