summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-05-24 18:42:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-05-24 18:42:22 +0800
commit8b57fe8867cf2a82025b8c0b18305ea24b063f4f (patch)
tree51b708ee01e34c67e2c7531f4f8c770071f0bd8b
parent8a2de634b1db860a009dafb5144c0d38eeacc5ad (diff)
downloadlua-language-server-8b57fe8867cf2a82025b8c0b18305ea24b063f4f.zip
add settings for file scheme
`workspace.supportScheme`: `["file", "untitled", "git"]` `diagnostics.disableScheme`: `["git"]`
-rw-r--r--changelog.md3
-rw-r--r--script/config/config.lua10
-rw-r--r--script/provider/diagnostic.lua6
-rw-r--r--script/provider/provider.lua14
4 files changed, 27 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md
index 6f8236d3..4526b750 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,9 @@
# changelog
## 3.2.4
+* `NEW` settings:
+ + `workspace.supportScheme`: `["file", "untitled", "git"]`
+ + `diagnostics.disableScheme`: `["git"]`
* `FIX` hover: can not union `table` with other basic types
* `FIX` [#1125](https://github.com/sumneko/lua-language-server/issues/1125)
* `FIX` [#1131](https://github.com/sumneko/lua-language-server/issues/1131)
diff --git a/script/config/config.lua b/script/config/config.lua
index bde214b0..538b18ab 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -167,6 +167,9 @@ local Template = {
>> util.deepCopy(define.DiagnosticDefaultSeverity),
['Lua.diagnostics.neededFileStatus'] = Type.Hash(Type.String, Type.String)
>> util.deepCopy(define.DiagnosticDefaultNeededFileStatus),
+ ['Lua.diagnostics.disableScheme'] = Type.Hash(Type.String, Type.Boolean, ';') >> {
+ ['git'] = true,
+ },
['Lua.diagnostics.workspaceDelay'] = Type.Integer >> 5,
['Lua.diagnostics.workspaceRate'] = Type.Integer >> 100,
['Lua.diagnostics.libraryFiles'] = Type.String >> 'Opened',
@@ -179,6 +182,11 @@ local Template = {
['Lua.workspace.library'] = Type.Hash(Type.String, Type.Boolean, ';'),
['Lua.workspace.checkThirdParty'] = Type.Boolean >> true,
['Lua.workspace.userThirdParty'] = Type.Array(Type.String),
+ ['Lua.workspace.supportScheme'] = Type.Hash(Type.String, Type.Boolean, ';') >> {
+ ['file'] = true,
+ ['untitled'] = true,
+ ['git'] = true,
+ },
['Lua.completion.enable'] = Type.Boolean >> true,
['Lua.completion.callSnippet'] = Type.String >> 'Disable',
['Lua.completion.keywordSnippet'] = Type.String >> 'Replace',
@@ -213,6 +221,8 @@ local Template = {
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
>> {},
['Lua.telemetry.enable'] = Type.Or(Type.Boolean >> false, Type.Nil) >> nil,
+
+ -- VSCode
['files.associations'] = Type.Hash(Type.String, Type.String),
['files.exclude'] = Type.Hash(Type.String, Type.Boolean),
['editor.semanticHighlighting.enabled'] = Type.Or(Type.Boolean, Type.String),
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 15b08d49..36428b67 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -14,6 +14,7 @@ local loading = require 'workspace.loading'
local scope = require 'workspace.scope'
local time = require 'bee.time'
local ltable = require 'linked-table'
+local furi = require 'file-uri'
---@class diagnosticProvider
local m = {}
@@ -217,6 +218,11 @@ function m.doDiagnostic(uri, isScopeDiag)
end
end
end
+ local scheme = furi.split(uri)
+ local disableScheme = config.get(uri, 'Lua.diagnostics.disableScheme')
+ if disableScheme[scheme] then
+ return
+ end
await.delay()
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index ae99065e..5d803257 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -236,9 +236,10 @@ m.register 'workspace/didRenameFiles' {
m.register 'textDocument/didOpen' {
function (params)
- local doc = params.textDocument
- local scheme = furi.split(doc.uri)
- if scheme ~= 'file' and scheme ~= 'untitled' then
+ local doc = params.textDocument
+ local scheme = furi.split(doc.uri)
+ local supports = config.get(doc.uri, 'Lua.workspace.supportScheme')
+ if not supports[scheme] then
return
end
local uri = files.getRealUri(doc.uri)
@@ -265,9 +266,10 @@ m.register 'textDocument/didClose' {
m.register 'textDocument/didChange' {
function (params)
- local doc = params.textDocument
- local scheme = furi.split(doc.uri)
- if scheme ~= 'file' and scheme ~= 'untitled' then
+ local doc = params.textDocument
+ local scheme = furi.split(doc.uri)
+ local supports = config.get(doc.uri, 'Lua.workspace.supportScheme')
+ if not supports[scheme] then
return
end
local changes = params.contentChanges