mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-12-23 09:19:21 +00:00
Add option to build on save
This commit is contained in:
parent
3811bdfd8b
commit
bc74bca9ea
3 changed files with 12 additions and 1 deletions
|
|
@ -38,6 +38,7 @@ class LanguageServerImpl : LanguageServer {
|
|||
val capabilities = ServerCapabilities().apply {
|
||||
val syncOptions = TextDocumentSyncOptions().apply {
|
||||
openClose = true
|
||||
save = SaveOptions(false)
|
||||
change = TextDocumentSyncKind.Full
|
||||
}
|
||||
textDocumentSync = Either.forRight(syncOptions)
|
||||
|
|
|
|||
|
|
@ -174,6 +174,15 @@ class TextDocumentServiceImpl(private val workspace: Workspace) : CustomTextDocu
|
|||
}
|
||||
|
||||
override fun didSave(params: DidSaveTextDocumentParams) {
|
||||
CompletableFuture.supplyAsync {
|
||||
val uri = URIHelper.parse(params.textDocument.uri)
|
||||
val config = client.configuration<BuildConfig>("latex.build", uri)
|
||||
if (config.onSave) {
|
||||
val document = workspace.findParent(uri)
|
||||
val identifier = TextDocumentIdentifier(document.uri.toString())
|
||||
build(BuildParams(identifier)).get()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun didClose(params: DidCloseTextDocumentParams) {
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ package texlab.build
|
|||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class BuildConfig(@SerializedName("executable") val executable: String,
|
||||
@SerializedName("args") val args: List<String>)
|
||||
@SerializedName("args") val args: List<String>,
|
||||
@SerializedName("onSave") val onSave: Boolean)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue