Skip to content

Commit 8b57fe8

Browse files
committed
add settings for file scheme
`workspace.supportScheme`: `["file", "untitled", "git"]` `diagnostics.disableScheme`: `["git"]`
1 parent 8a2de63 commit 8b57fe8

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# changelog
22

33
## 3.2.4
4+
* `NEW` settings:
5+
+ `workspace.supportScheme`: `["file", "untitled", "git"]`
6+
+ `diagnostics.disableScheme`: `["git"]`
47
* `FIX` hover: can not union `table` with other basic types
58
* `FIX` [#1125](https://github.com/sumneko/lua-language-server/issues/1125)
69
* `FIX` [#1131](https://github.com/sumneko/lua-language-server/issues/1131)

script/config/config.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ local Template = {
167167
>> util.deepCopy(define.DiagnosticDefaultSeverity),
168168
['Lua.diagnostics.neededFileStatus'] = Type.Hash(Type.String, Type.String)
169169
>> util.deepCopy(define.DiagnosticDefaultNeededFileStatus),
170+
['Lua.diagnostics.disableScheme'] = Type.Hash(Type.String, Type.Boolean, ';') >> {
171+
['git'] = true,
172+
},
170173
['Lua.diagnostics.workspaceDelay'] = Type.Integer >> 5,
171174
['Lua.diagnostics.workspaceRate'] = Type.Integer >> 100,
172175
['Lua.diagnostics.libraryFiles'] = Type.String >> 'Opened',
@@ -179,6 +182,11 @@ local Template = {
179182
['Lua.workspace.library'] = Type.Hash(Type.String, Type.Boolean, ';'),
180183
['Lua.workspace.checkThirdParty'] = Type.Boolean >> true,
181184
['Lua.workspace.userThirdParty'] = Type.Array(Type.String),
185+
['Lua.workspace.supportScheme'] = Type.Hash(Type.String, Type.Boolean, ';') >> {
186+
['file'] = true,
187+
['untitled'] = true,
188+
['git'] = true,
189+
},
182190
['Lua.completion.enable'] = Type.Boolean >> true,
183191
['Lua.completion.callSnippet'] = Type.String >> 'Disable',
184192
['Lua.completion.keywordSnippet'] = Type.String >> 'Replace',
@@ -213,6 +221,8 @@ local Template = {
213221
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
214222
>> {},
215223
['Lua.telemetry.enable'] = Type.Or(Type.Boolean >> false, Type.Nil) >> nil,
224+
225+
-- VSCode
216226
['files.associations'] = Type.Hash(Type.String, Type.String),
217227
['files.exclude'] = Type.Hash(Type.String, Type.Boolean),
218228
['editor.semanticHighlighting.enabled'] = Type.Or(Type.Boolean, Type.String),

script/provider/diagnostic.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ local loading = require 'workspace.loading'
1414
local scope = require 'workspace.scope'
1515
local time = require 'bee.time'
1616
local ltable = require 'linked-table'
17+
local furi = require 'file-uri'
1718

1819
---@class diagnosticProvider
1920
local m = {}
@@ -217,6 +218,11 @@ function m.doDiagnostic(uri, isScopeDiag)
217218
end
218219
end
219220
end
221+
local scheme = furi.split(uri)
222+
local disableScheme = config.get(uri, 'Lua.diagnostics.disableScheme')
223+
if disableScheme[scheme] then
224+
return
225+
end
220226

221227
await.delay()
222228

script/provider/provider.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ m.register 'workspace/didRenameFiles' {
236236

237237
m.register 'textDocument/didOpen' {
238238
function (params)
239-
local doc = params.textDocument
240-
local scheme = furi.split(doc.uri)
241-
if scheme ~= 'file' and scheme ~= 'untitled' then
239+
local doc = params.textDocument
240+
local scheme = furi.split(doc.uri)
241+
local supports = config.get(doc.uri, 'Lua.workspace.supportScheme')
242+
if not supports[scheme] then
242243
return
243244
end
244245
local uri = files.getRealUri(doc.uri)
@@ -265,9 +266,10 @@ m.register 'textDocument/didClose' {
265266

266267
m.register 'textDocument/didChange' {
267268
function (params)
268-
local doc = params.textDocument
269-
local scheme = furi.split(doc.uri)
270-
if scheme ~= 'file' and scheme ~= 'untitled' then
269+
local doc = params.textDocument
270+
local scheme = furi.split(doc.uri)
271+
local supports = config.get(doc.uri, 'Lua.workspace.supportScheme')
272+
if not supports[scheme] then
271273
return
272274
end
273275
local changes = params.contentChanges

0 commit comments

Comments
 (0)