blob: de7f30ed940556e895911753ba1c3f9016ebe2ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
local files = require("files")
local log = require("log")
return function(uri, options)
local suc, codeFormat = pcall(require, "code_format")
if not suc then
return
end
local text = files.getOriginText(uri)
local state = files.getState(uri)
if not state then
return
end
local status, formattedText = codeFormat.format(uri, text, options)
if not status then
if formattedText ~= nil then
log.error(formattedText)
end
return
end
return {
{
start = state.ast.start,
finish = state.ast.finish,
text = formattedText,
}
}
end
|