summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-06 20:36:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-06 20:36:39 +0800
commit9c51d20d0ac570e65920e030e78dd7d1759ecae3 (patch)
treedde78361e9786aa1eb9ba4245b4cac5349a1bd3f
parentc78478e993df1c1a95ca3ae972e40238016ea796 (diff)
downloadlua-language-server-9c51d20d0ac570e65920e030e78dd7d1759ecae3.zip
pcall code_format
-rw-r--r--main.lua8
-rw-r--r--script/provider/formatting.lua6
2 files changed, 13 insertions, 1 deletions
diff --git a/main.lua b/main.lua
index f61b0e32..e7bff185 100644
--- a/main.lua
+++ b/main.lua
@@ -68,6 +68,14 @@ log.info('LOGPATH:', LOGPATH)
log.info('METAPATH:', METAPATH)
log.info('VERSION:', version.getVersion())
+local stdRequire = require
+require = function (name)
+ if name == 'code_format' then
+ error('cannot found code_format')
+ end
+ return stdRequire(name)
+end
+
require 'tracy'
require 'cli'
diff --git a/script/provider/formatting.lua b/script/provider/formatting.lua
index f73b0dc0..73b6608d 100644
--- a/script/provider/formatting.lua
+++ b/script/provider/formatting.lua
@@ -1,4 +1,8 @@
-local codeFormat = require 'code_format'
+local suc, codeFormat = pcall(require, 'code_format')
+if not suc then
+ return
+end
+
local ws = require 'workspace'
local furi = require 'file-uri'
local fs = require 'bee.filesystem'