diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-06-24 11:08:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-06-24 11:08:46 +0800 |
commit | bc56c859f3f15e4b626d65c317ae077f551288ad (patch) | |
tree | 408285db4002e8c7bdd906299c62e0104921417f /server | |
parent | 8647f7987e30799f8a84b5ed3ae39484ca1c7135 (diff) | |
download | lua-language-server-bc56c859f3f15e4b626d65c317ae077f551288ad.zip |
修正一些bug
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/code_action.lua | 10 | ||||
-rw-r--r-- | server/src/files/files.lua | 4 | ||||
-rw-r--r-- | server/src/method/textDocument/definition.lua | 2 | ||||
-rw-r--r-- | server/src/service.lua | 9 |
4 files changed, 20 insertions, 5 deletions
diff --git a/server/src/core/code_action.lua b/server/src/core/code_action.lua index 21cfeafb..d52749a4 100644 --- a/server/src/core/code_action.lua +++ b/server/src/core/code_action.lua @@ -216,12 +216,16 @@ local function solveSyntaxByAddDoEnd(uri, data, callback) } end +---@param lsp LSP +---@param uri uri +---@param data table +---@param callback function local function solveSyntax(lsp, uri, data, callback) - local obj = lsp:getFile(uri) - if not obj then + local file = lsp:getFile(uri) + if not file then return end - local astErr, lines = obj.astErr, obj.lines + local astErr, lines = file:getAstErr(), file:getLines() if not astErr or not lines then return end diff --git a/server/src/files/files.lua b/server/src/files/files.lua index 4f5b064e..cf619381 100644 --- a/server/src/files/files.lua +++ b/server/src/files/files.lua @@ -91,6 +91,10 @@ function mt:eachOpened() return pairs(self._open) end +function mt:count() + return self._fileCount +end + return function () local self = setmetatable({ _files = {}, diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index 7370a8b7..dbf9e41c 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -55,6 +55,8 @@ end local LastTask +---@param lsp LSP +---@param params table return function (lsp, params) local uri = params.textDocument.uri local vm, lines = lsp:loadVM(uri) diff --git a/server/src/service.lua b/server/src/service.lua index f06473e0..1d60f22d 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -37,6 +37,7 @@ local ErrorCodes = { local CachedVM = setmetatable({}, {__mode = 'kv'}) +---@class LSP local mt = {} mt.__index = mt ---@type files @@ -186,6 +187,9 @@ function mt:isIgnored(uri) if not self.workspace then return true end + if not self.workspace.gitignore then + return true + end local path = self.workspace:relativePathByUri(uri) if self.workspace.gitignore(path:string()) then return true @@ -260,7 +264,7 @@ function mt:removeText(uri) end function mt:getCachedFileCount() - return self._fileCount + return self._files:count() end function mt:reCompile() @@ -322,6 +326,7 @@ function mt:clearAllFiles() self._files:clear() end +---@param uri uri function mt:loadVM(uri) local file = self._files:get(uri) if not file then @@ -341,7 +346,7 @@ function mt:loadVM(uri) if file:getVM() then self._lastLoadedVM = uri end - return file + return file:getVM(), file:getLines() end function mt:_markCompiled(uri, compiled) |