summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-05-13 15:36:24 +0800
committersumneko <sumneko@hotmail.com>2019-05-13 15:36:24 +0800
commit6cfd613662f54fead966e4aa3c1d1aa4616c8eb5 (patch)
tree7aef8b06c118210ec40f4d06eab2167fba8743f8 /server/src
parent81f035d6e3b4025240e79564ea57cd76ddae7229 (diff)
downloadlua-language-server-6cfd613662f54fead966e4aa3c1d1aa4616c8eb5.zip
读取文件排除
Diffstat (limited to 'server/src')
-rw-r--r--server/src/method/textDocument/didChange.lua8
-rw-r--r--server/src/service.lua25
2 files changed, 25 insertions, 8 deletions
diff --git a/server/src/method/textDocument/didChange.lua b/server/src/method/textDocument/didChange.lua
index 6856b729..0235f431 100644
--- a/server/src/method/textDocument/didChange.lua
+++ b/server/src/method/textDocument/didChange.lua
@@ -1,6 +1,14 @@
return function (lsp, params)
local doc = params.textDocument
local change = params.contentChanges
+ if lsp.workspace then
+ local path = lsp.workspace:relativePathByUri(doc.uri)
+ if not lsp.workspace:isLuaFile(path)
+ or lsp.workspace.gitignore(path:string())
+ then
+ return
+ end
+ end
-- TODO 支持差量更新
lsp:saveText(doc.uri, doc.version, change[1].text)
return true
diff --git a/server/src/service.lua b/server/src/service.lua
index fafa5901..9cab6946 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -185,12 +185,12 @@ end
function mt:open(uri, version, text)
if self.workspace then
- local fileName = self.workspace:uriDecode(uri)
- if not self.workspace:isLuaFile(fileName) then
+ local path = self.workspace:relativePathByUri(uri)
+ if not self.workspace:isLuaFile(path) then
return
end
- if self.workspace.gitignore(fileName:string()) then
- log.debug('Open ignored file:', fileName:string())
+ if self.workspace.gitignore(path:string()) then
+ log.debug('Open ignored file:', path:string())
end
end
self:saveText(uri, version, text)
@@ -206,13 +206,13 @@ function mt:close(uri)
obj._openByClient = false
end
if self.workspace then
- local fileName = self.workspace:uriDecode(uri)
- if not self.workspace:isLuaFile(fileName) then
+ local path = self.workspace:relativePathByUri(uri)
+ if not self.workspace:isLuaFile(path) then
self:removeText(uri)
return
end
- if self.workspace.gitignore(fileName:string()) then
- log.debug('Close ignored file:', fileName:string())
+ if self.workspace.gitignore(path:string()) then
+ log.debug('Close ignored file:', path:string())
self:removeText(uri)
end
end
@@ -237,6 +237,15 @@ function mt:readText(uri, path, buf, compiled)
log.debug('No file: ', path)
return
end
+ if self.workspace then
+ local path = self.workspace:relativePathByUri(uri)
+ if not self.workspace:isLuaFile(path) then
+ return
+ end
+ if self.workspace.gitignore(path:string()) then
+ return
+ end
+ end
local size = #text / 1000.0
if size > config.config.workspace.preloadFileSize then
log.info(('Skip large file, size: %.3f KB: %s'):format(size, uri))