From 8b57fe8867cf2a82025b8c0b18305ea24b063f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 24 May 2022 18:42:22 +0800 Subject: add settings for file scheme `workspace.supportScheme`: `["file", "untitled", "git"]` `diagnostics.disableScheme`: `["git"]` --- changelog.md | 3 +++ script/config/config.lua | 10 ++++++++++ script/provider/diagnostic.lua | 6 ++++++ script/provider/provider.lua | 14 ++++++++------ 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 -- cgit v1.2.3