diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-10-12 17:33:32 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-10-12 17:33:32 +0800 |
commit | 12efa3035f85df148b23e54e051b0769572d1589 (patch) | |
tree | 08f16d7317068e6410086dcf88c16041413e9ce1 /src/service | |
parent | 87dd78bf46c4ff0d02f851acd927e3d3f521392c (diff) | |
download | lua-language-server-12efa3035f85df148b23e54e051b0769572d1589.zip |
先打印一下标准输入
Diffstat (limited to 'src/service')
-rw-r--r-- | src/service/init.lua | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/service/init.lua b/src/service/init.lua index 91e0a4d4..53e6e4b3 100644 --- a/src/service/init.lua +++ b/src/service/init.lua @@ -1,5 +1,35 @@ -local api = { - definition = require 'service.definition' +local sleep = require 'ffi.sleep' +local ext = require 'process.ext' + +local function listen(self, input, output) + if input then + log.info('指定输入文件,路径为:', input) + fs.create_directories(input:parent_path()) + io.input(io.open(input:string(), 'rb')) + else + ext.set_filemode(io.stdin, 'b') + end + if output then + log.info('指定输出文件,路径为:', output) + fs.create_directories(output:parent_path()) + io.output(io.open(output:string(), 'wb')) + else + ext.set_filemode(io.stdout, 'b') + io.stdout:setvbuf 'no' + end + + for line in io.input():lines 'L' do + log.debug('标准输入:\n', line) + end +end + +local mt = { + definition = require 'service.definition', + listen = listen, } +mt.__index = mt -return api +return function () + local session = setmetatable({}, mt) + return session +end |