Skip to content

Commit

Permalink
Add ltex.completionEnabled, disable by default
Browse files Browse the repository at this point in the history
  • Loading branch information
valentjn committed Oct 28, 2021
1 parent 80aaeb1 commit 1b8decf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
5 changes: 4 additions & 1 deletion changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<author>Julian Valentin, LTeX Development Community</author>
</properties>
<body>
<release version="14.1.1" date="upcoming">
<release version="15.0.0" date="upcoming">
<action type="update" issue="#443">
Add [`ltex.completionEnabled`](https://valentjn.github.io/vscode-ltex/docs/settings.html#ltexcompletionenabled) to disable completion by default
</action>
<action type="fix" issue="vscode-ltex#442">
Fix `StringIndexOutOfBoundsException` in `AnnotatedTextFragment.getSubstringOfPlainText`
</action>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.bsplines</groupId>
<artifactId>ltexls</artifactId>
<version>14.1.1-alpha.1.develop</version>
<version>15.0.0-alpha.1.develop</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>LTeX Language Server (LTeX LS): LSP language server for LanguageTool with support for LaTeX, Markdown, and others</description>
<url>https://github.com/valentjn/ltex-ls</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,23 @@ class LtexTextDocumentService(

override fun completion(params: CompletionParams):
CompletableFuture<Either<List<CompletionItem>, CompletionList>> {
val uri: String = params.textDocument?.uri ?:
return if (this.languageServer.settingsManager.settings.completionEnabled) {
val uri: String = params.textDocument?.uri ?: return CompletableFuture.completedFuture(
Either.forLeft(emptyList())
)
val document: LtexTextDocumentItem = getDocument(uri) ?: run {
Logging.logger.warning(I18n.format("couldNotFindDocumentWithUri", uri))
return CompletableFuture.completedFuture(Either.forLeft(emptyList()))
val document: LtexTextDocumentItem = getDocument(uri) ?: run {
Logging.logger.warning(I18n.format("couldNotFindDocumentWithUri", uri))
return CompletableFuture.completedFuture(Either.forLeft(emptyList()))
}
}

return CompletableFuture.completedFuture(
Either.forRight(
languageServer.completionListProvider.createCompletionList(document, params.position)
CompletableFuture.completedFuture(
Either.forRight(
this.languageServer.completionListProvider.createCompletionList(document, params.position)
)
)
)
} else {
CompletableFuture.completedFuture(Either.forLeft(emptyList()))
}
}

override fun resolveCompletionItem(completionItem: CompletionItem):
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ data class Settings(
private val _languageToolOrgApiKey: String? = null,
private val _logLevel: Level? = null,
private val _sentenceCacheSize: Long? = null,
private val _completionEnabled: Boolean? = null,
private val _diagnosticSeverity: Map<String, DiagnosticSeverity>? = null,
private val _checkFrequency: CheckFrequency? = null,
private val _clearDiagnosticsWhenClosingFile: Boolean? = null,
Expand Down Expand Up @@ -80,6 +81,8 @@ data class Settings(
get() = (this._logLevel ?: Level.FINE)
val sentenceCacheSize: Long
get() = (this._sentenceCacheSize ?: DEFAULT_SENTENCE_CACHE_SIZE)
val completionEnabled: Boolean
get() = (this._completionEnabled ?: false)
val diagnosticSeverity: Map<String, DiagnosticSeverity>
get() = (this._diagnosticSeverity ?: DEFAULT_DIAGNOSTIC_SEVERITY)
val checkFrequency: CheckFrequency
Expand Down Expand Up @@ -264,6 +267,8 @@ data class Settings(
),
)
val sentenceCacheSize: Long? = getSettingFromJsonAsLong(jsonSettings, "sentenceCacheSize")
val completionEnabled: Boolean? =
getSettingFromJsonAsBoolean(jsonSettings, "completionEnabled")
val diagnosticSeverity: Map<String, DiagnosticSeverity>? =
getDiagnosticSeverityFromJson(jsonSettings)
val checkFrequency: CheckFrequency? = getSettingFromJsonAsEnum(
Expand Down Expand Up @@ -295,6 +300,7 @@ data class Settings(
languageToolOrgApiKey,
logLevel,
sentenceCacheSize,
completionEnabled,
diagnosticSeverity,
checkFrequency,
clearDiagnosticsWhenClosingFile,
Expand Down

0 comments on commit 1b8decf

Please sign in to comment.