diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-29 15:57:51 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-29 15:57:51 +0800 |
commit | d2ee2b2d2821e1f2306bbe99c050b2d052c028ec (patch) | |
tree | ed7c20d3c29c22731d14449b2a3af5e04729ea4d /server/src | |
parent | af6359bd573164ef09979263eac4a4c986b9796a (diff) | |
download | lua-language-server-d2ee2b2d2821e1f2306bbe99c050b2d052c028ec.zip |
修改生成的配置文件样式
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/json/encode.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/server/src/json/encode.lua b/server/src/json/encode.lua index 4bba26de..93d0b954 100644 --- a/server/src/json/encode.lua +++ b/server/src/json/encode.lua @@ -27,14 +27,14 @@ local esc_map = { local function encode(data, key) n = n + 1 if not tabs[n] then - tabs[n] = rep('\t', n) + tabs[n] = rep(' ', n) end local tp = type(data) if tp == 'table' then if not data[1] and next(data) then -- 认为这个是哈希表 if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : {\n' + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": {\n' else index=index+1;lines[index] = tabs[n] .. '{\n' end @@ -69,7 +69,7 @@ local function encode(data, key) else -- 认为这个是数组 if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : [\n' + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": [\n' else index=index+1;lines[index] = tabs[n] .. '[\n' end @@ -92,26 +92,26 @@ local function encode(data, key) data = '0' end if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : ' .. data + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": ' .. data else index=index+1;lines[index] = tabs[n] .. data end elseif tp == 'boolean' then if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : ' .. tostring(data) + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": ' .. tostring(data) else index=index+1;lines[index] = tabs[n] .. tostring(data) end elseif tp == 'nil' then if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : null' + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": null' else index=index+1;lines[index] = tabs[n] .. 'null' end elseif tp == 'string' then local str = gsub(data, '[\\\r\n\t"]', esc_map) if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : "' .. str .. '"' + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": "' .. str .. '"' else index=index+1;lines[index] = tabs[n] .. '"' .. str .. '"' end |