Move VSCode extension to main repository

This commit is contained in:
Patrick Förster 2022-05-22 15:55:07 +02:00
parent e9f1a827d1
commit 21e453691c
28 changed files with 8400 additions and 0 deletions

9
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"rust-lang.rust-analyzer",
"dbaeumer.vscode-eslint",
"amodio.tsl-problem-matcher"
]
}

31
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,31 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}/editors/code"],
"outFiles": ["${workspaceFolder}/editors/code/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/editors/code",
"--extensionTestsPath=${workspaceFolder}/editors/code/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/editors/code/out/**/*.js",
"${workspaceFolder}/editors/code/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
}

40
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,40 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"],
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": {
"kind": "build",
"isDefault": true
},
"options": { "cwd": "${workspaceFolder}/editors/code" }
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build",
"options": { "cwd": "${workspaceFolder}/editors/code" }
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": [],
"options": { "cwd": "${workspaceFolder}/editors/code" }
}
]
}

View file

@ -0,0 +1,17 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}

274
editors/code/.gitignore vendored Normal file
View file

@ -0,0 +1,274 @@
out/
node_modules/
.vscode-test/
*.vsix
server/*
!server/.gitkeep
### LaTeX ###
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log
*.lot
*.fls
*.out
*.toc
*.fmt
*.fot
*.cb
*.cb2
.*.lb
## Intermediate documents:
*.dvi
*.xdv
*-converted-to.*
# these rules might exclude image files for figures etc.
# *.ps
# *.eps
*.pdf
## Generated if empty string is given at "Please type another file name for output:"
.pdf
## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
*.bcf
*.blg
*-blx.aux
*-blx.bib
*.run.xml
## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync
## Build tool directories for auxiliary files
# latexrun
latex.out/
## Auxiliary and intermediate files from other packages:
# algorithms
*.alg
*.loa
# achemso
acs-*.bib
# amsthm
*.thm
# beamer
*.nav
*.pre
*.snm
*.vrb
# changes
*.soc
# comment
*.cut
# cprotect
*.cpt
# elsarticle (documentclass of Elsevier journals)
*.spl
# endnotes
*.ent
# fixme
*.lox
# feynmf/feynmp
*.mf
*.mp
*.t[1-9]
*.t[1-9][0-9]
*.tfm
#(r)(e)ledmac/(r)(e)ledpar
*.end
*.?end
*.[1-9]
*.[1-9][0-9]
*.[1-9][0-9][0-9]
*.[1-9]R
*.[1-9][0-9]R
*.[1-9][0-9][0-9]R
*.eledsec[1-9]
*.eledsec[1-9]R
*.eledsec[1-9][0-9]
*.eledsec[1-9][0-9]R
*.eledsec[1-9][0-9][0-9]
*.eledsec[1-9][0-9][0-9]R
# glossaries
*.acn
*.acr
*.glg
*.glo
*.gls
*.glsdefs
# gnuplottex
*-gnuplottex-*
# gregoriotex
*.gaux
*.gtex
# htlatex
*.4ct
*.4tc
*.idv
*.lg
*.trc
*.xref
# hyperref
*.brf
# knitr
*-concordance.tex
# TODO Comment the next line if you want to keep your tikz graphics files
*.tikz
*-tikzDictionary
# listings
*.lol
# makeidx
*.idx
*.ilg
*.ind
*.ist
# minitoc
*.maf
*.mlf
*.mlt
*.mtc[0-9]*
*.slf[0-9]*
*.slt[0-9]*
*.stc[0-9]*
# minted
_minted*
*.pyg
# morewrites
*.mw
# nomencl
*.nlg
*.nlo
*.nls
# pax
*.pax
# pdfpcnotes
*.pdfpc
# sagetex
*.sagetex.sage
*.sagetex.py
*.sagetex.scmd
# scrwfile
*.wrt
# sympy
*.sout
*.sympy
sympy-plots-for-*.tex/
# pdfcomment
*.upa
*.upb
# pythontex
*.pytxcode
pythontex-files-*/
# tcolorbox
*.listing
# thmtools
*.loe
# TikZ & PGF
*.dpth
*.md5
*.auxlock
# todonotes
*.tdo
# vhistory
*.hst
*.ver
# easy-todo
*.lod
# xcolor
*.xcp
# xmpincl
*.xmpi
# xindy
*.xdy
# xypic precompiled matrices
*.xyc
# endfloat
*.ttt
*.fff
# Latexian
TSWLatexianTemp*
## Editors:
# WinEdt
*.bak
*.sav
# Texpad
.texpadtmp
# LyX
*.lyx~
# Kile
*.backup
# KBibTeX
*~[0-9]*
# auto folder when using emacs and auctex
./auto/*
*.el
# expex forward references with \gathertags
*-tags.tex
# standalone packages
*.sta
### LaTeX Patch ###
# glossaries
*.glstex
# dist
dist/

5
editors/code/.prettierrc Normal file
View file

@ -0,0 +1,5 @@
{
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all"
}

View file

@ -0,0 +1,13 @@
.vscode/**
.vscode-test/**
out/**
node_modules/**
src/**
.gitignore
.yarnrc
webpack.config.js
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts

206
editors/code/CHANGELOG.md Normal file
View file

@ -0,0 +1,206 @@
# Changelog
All notable changes to this extension will be documented in this file.
The changelog of the TexLab language server can be found [here](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [3.3.2] - 26.02.2022
### Changed
- Update TexLab to [v3.3.2](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#332---26022022)
### Fixed
- Only activate extension after opening a TeX file ([#523](https://github.com/latex-lsp/texlab-vscode/issues/523))
## [3.3.1] - 10.11.2021
### Added
- Add more auto closing pairs for LaTeX ([#478](https://github.com/latex-lsp/texlab-vscode/issues/478))
### Changed
- Update TexLab to [v3.3.1](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#331---10112021)
## [3.2.0] - 12.06.2021
### Changed
- Update TexLab to [v3.2.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#320---12062021)
## [3.1.0] - 03.06.2021
### Changed
- Update TexLab to [v3.1.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#310---03062021)
## [3.0.1] - 22.05.2021
### Changed
- Update TexLab to [v3.0.1](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#301---22052021)
## [3.0.0] - 17.05.2021
### Changed
- BREAKING: Update TexLab to [v3.0.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#300---16052021)
## [2.2.1] - 06.01.2021
### Changed
- Update TexLab to [v2.2.1](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#221---06012021)
## [2.2.0] - 27.05.2020
### Added
- Add `latex.server.trace` and `latex.server.logFile` options
### Changed
- Update TexLab to [v2.2.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#220---27052020)
## [2.1.0] - 10.05.2020
### Changed
- Update TexLab to [v2.1.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#210---10052020)
- Build status is now shown in the status bar (clicking on the icon cancels the build) ([#238](https://github.com/latex-lsp/texlab-vscode/issues/238))
## [2.0.0] - 20.04.2020
### Changed
- Update TexLab to [v2.0.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#200---20042020)
## [1.10.0] - 11.02.2020
### Changed
- Update TexLab to [v1.10.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#1100---11022020)
## [1.9.0] - 30.12.2019
### Changed
- Update TexLab to [v1.9.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#190---30122019)
## [1.8.0] - 01.12.2019
### Changed
- Update TexLab to [v1.8.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#180---01122019)
## [1.7.0] - 20.11.2019
### Changed
- Update TexLab to [v1.7.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#170---20112019)
## [1.6.0] - 29.09.2019
### Changed
- Update TexLab to [v1.6.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#160---29092019)
## [1.5.0] - 27.08.2019
### Changed
- Update TexLab to [v1.5.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#150---27082019)
## [1.4.1] - 22.08.2019
### Changed
- Update TexLab to [v1.4.1](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#141---22082019)
## [1.4.0] - 20.08.2019
### Changed
- Update TexLab to [v1.4.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#140---20082019)
## [1.3.0] - 06.08.2019
### Changed
- Update TexLab to [v1.3.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#130---06082019)
## [1.2.0] - 23.07.2019
### Changed
- Update TexLab to [v1.2.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#120---23072019)
## [1.1.0] - 13.07.2019
### Changed
- Update TexLab to [v1.1.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#110---13072019)
## [1.0.0] - 04.07.2019
### Changed
- Update TexLab to [v1.0.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#100---04072019)
- Reduce extension size
- Download TexLab on first usage instead of bundling it with the extension
## [0.4.2] - 10.04.2019
### Changed
- Update TexLab to [v0.4.2](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#042---10042019)
## [0.4.1] - 30.03.2019
### Changed
- Update TexLab to [v0.4.1](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#041---30032019)
## [0.4.0] - 09.03.2019
### Changed
- Update TexLab to [v0.4.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#040---09032019)
## [0.3.1] - 05.03.2019
### Fixed
- Fix extension bundle
## [0.3.0] - 05.03.2019
### Changed
- Update TexLab to [v0.3.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#030---05032019)
## [0.2.0] - 01.03.2019
### Changed
- Update TexLab to [v0.2.0](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#020---01032019)
## [0.1.2] - 16.02.2019
### Changed
- Update TexLab to [v0.1.2](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#012---16022019)
## [0.1.1] - 15.02.2019
### Changed
- Update TexLab to [v0.1.1](https://github.com/latex-lsp/texlab/blob/master/CHANGELOG.md#011---15022019)
## [0.1.0] - 15.02.2019
- Initial release

21
editors/code/LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Eric Förster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

17
editors/code/README.md Normal file
View file

@ -0,0 +1,17 @@
# TexLab
A [Visual Studio Code](https://code.visualstudio.com) extension that provides rich editing support for the
[LaTeX](https://www.latex-project.org) typesetting system powered by the [TexLab](https://github.com/latex-lsp/texlab) language server.
It aims to produce high quality code completion results by indexing your used packages as you type.
![Demo](images/demo.gif)
Learn more about the project on the [TexLab repository](https://github.com/latex-lsp/texlab).
## Getting Started
A detailed guide can be found on our [documentation page](https://github.com/latex-lsp/texlab).
## Release Notes
See the [Changelog](CHANGELOG.md) for details.

View file

@ -0,0 +1,134 @@
{
"name": "bibtex",
"scopeName": "source.bibtex",
"fileTypes": [""],
"foldingStartMarker": "",
"foldingStopMarker": "",
"patterns": [
{
"include": "#preamble"
},
{
"include": "#string"
},
{
"include": "#entry"
},
{
"include": "#comment"
}
],
"repository": {
"entry": {
"patterns": [
{
"begin": "(@[a-zA-Z]+)\\s*[{\\(]\\s*([a-zA-Z_\\0-9:]+)\\s*,",
"end": "[}\\)]",
"beginCaptures": {
"1": {
"name": "keyword.type.bibtex"
},
"2": {
"name": "variable.parameter.identifier.bibtex"
}
},
"patterns": [
{
"include": "#field"
}
]
}
]
},
"comment": {
"patterns": [
{
"name": "comment.line.bibtex",
"match": ".*"
}
]
},
"field": {
"patterns": [
{
"match": "([a-zA-Z\\-_]+)\\s*(=)",
"captures": {
"1": {
"name": "entity.name.type.key.bibtex"
},
"2": {
"name": "keyword.assignment.bibtex"
}
}
},
{
"include": "#content"
}
]
},
"content": {
"patterns": [
{
"begin": "(\")",
"end": "(\")",
"patterns": [
{
"include": "#content"
}
]
},
{
"begin": "{",
"end": "}",
"patterns": [
{
"include": "#content"
}
]
},
{
"match": "%"
},
{
"include": "source.latex"
}
]
},
"preamble": {
"patterns": [
{
"begin": "(@[pP][rR][eE][aA][mM][bB][lL][eE])\\s*{",
"beginCaptures": {
"1": {
"name": "keyword.type.bibtex"
}
},
"end": "}",
"patterns": [
{
"include": "#content"
}
]
}
]
},
"string": {
"patterns": [
{
"begin": "(@[sS][tT][rR][iI][nN][gG])\\s*{",
"beginCaptures": {
"1": {
"name": "keyword.type.bibtex"
}
},
"end": "}",
"patterns": [
{
"include": "#field"
}
]
}
]
}
}
}

View file

@ -0,0 +1,156 @@
{
"name": "latex",
"scopeName": "source.latex",
"fileTypes": [""],
"foldingStartMarker": "",
"foldingStopMarker": "",
"patterns": [
{
"include": "#comment"
},
{
"include": "#special"
},
{
"include": "#parameter"
},
{
"include": "#command"
},
{
"include": "#math"
}
],
"repository": {
"comment": {
"patterns": [
{
"name": "comment.line.latex",
"match": "%.*$"
}
]
},
"special": {
"patterns": [
{
"name": "keyword.special.latex",
"match": "[&~]"
}
]
},
"parameter": {
"patterns": [
{
"name": "entity.name.type.parameter.latex",
"match": "#[0-9]"
}
]
},
"command": {
"patterns": [
{
"begin": "(\\\\begin)\\{((?:align|alignat|aligned|alignedat|array|Bmatrix|bmatrix|cases|CD|eqnarray|equation|gather|gathered|matrix|multline|pmatrix|smallmatrix|split|subarray|Vmatrix|vmatrix)\\*?)\\}",
"end": "(\\\\end)\\{((?:align|alignat|aligned|alignedat|array|Bmatrix|bmatrix|cases|CD|eqnarray|equation|gather|gathered|matrix|multline|pmatrix|smallmatrix|split|subarray|Vmatrix|vmatrix)\\*?)\\}",
"beginCaptures": {
"1": {
"name": "keyword.command.latex"
},
"2": {
"name": "variable.parameter.identifier.latex"
}
},
"endCaptures": {
"1": {
"name": "keyword.command.latex"
},
"2": {
"name": "variable.parameter.identifier.latex"
}
},
"patterns": [
{
"include": "$self"
},
{
"name": "support.constant.math.latex",
"match": "[^\\$%\\{\\}\\[\\]\\\\\\s]+"
}
]
},
{
"begin": "(\\\\(?:documentclass|usepackage|begin|end))\\[?",
"end": "\\]?(?:\\{([^\\$%\\{\\}\\[\\]\\\\\\s]*)\\})",
"beginCaptures": {
"1": {
"name": "keyword.command.latex"
}
},
"endCaptures": {
"1": {
"name": "variable.parameter.identifier.latex"
}
},
"patterns": [
{
"include": "$self"
},
{
"name": "entity.name.type.options.latex",
"match": "[^\\$%\\{\\}\\[\\]\\\\\\s]+"
}
]
},
{
"begin": "(\\\\(?:chapter|(?:sub){0,2}section|(?:sub)?paragraph)\\*?)\\{",
"end": "\\}",
"beginCaptures": {
"1": {
"name": "keyword.command.latex"
}
},
"patterns": [
{
"include": "$self"
},
{
"name": "entity.name.type.section.latex",
"match": "[^\\$%\\{\\}\\[\\]\\\\\\s]+"
}
]
},
{
"name": "constant.character.escape.latex",
"match": "\\\\[#\\$%&_{}~\\\\, \"`'\\^=\\.]"
},
{
"name": "entity.name.function.command.latex",
"match": "\\\\[a-zA-Z@]+(\\*)?"
}
]
},
"math": {
"patterns": [
{
"name": "support.constant.math.latex",
"begin": "(\\$\\$|\\\\\\[)",
"end": "(\\$\\$|\\\\\\])",
"patterns": [
{
"include": "$self"
}
]
},
{
"name": "support.constant.math.latex",
"begin": "(\\$|\\\\\\()",
"end": "(\\$|\\\\\\))",
"patterns": [
{
"include": "$self"
}
]
}
]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -0,0 +1,24 @@
{
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"],
["$", "$"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["$", "$"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["$", "$"]
]
}

View file

@ -0,0 +1,46 @@
{
"comments": {
"lineComment": "%"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"],
["$", "$"],
["\\[", "\\]"],
["\\(", "\\)"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["`", "'"],
["\\left\\{", "\\right\\}"],
["\\left[", "\\right]"],
["\\left(", "\\right)"],
{
"open": "$",
"close": "$",
"notIn": ["comment"]
},
{
"open": "\\[",
"close": "\\]",
"notIn": ["comment"]
},
{
"open": "\\(",
"close": "\\)",
"notIn": ["comment"]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["$", "$"],
["`", "'"]
]
}

6543
editors/code/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

284
editors/code/package.json Normal file
View file

@ -0,0 +1,284 @@
{
"name": "texlab",
"displayName": "TexLab",
"description": "LaTeX and BibTeX language support for Visual Studio Code",
"version": "3.3.2",
"publisher": "efoerster",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/latex-lsp/texlab"
},
"homepage": "https://github.com/latex-lsp/texlab",
"bugs": {
"url": "https://github.com/latex-lsp/texlab/issues"
},
"engines": {
"vscode": "^1.67.0"
},
"main": "./dist/extension.js",
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"format": "prettier --write \"src/**/*.{ts,json}\" \"{grammars,languages}/**/*.json\" \"*.{ts,json,yml,md}\" ",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.1.1",
"@types/node": "14.x",
"@types/vscode": "^1.67.0",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"@vscode/test-electron": "^2.1.3",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.3.0",
"glob": "^8.0.1",
"mocha": "^9.2.2",
"prettier": "^2.5.1",
"ts-loader": "^9.2.8",
"ts-node": "^10.8.0",
"typescript": "^4.6.4",
"vscode-languageclient": "^8.0.1",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2"
},
"categories": [
"Programming Languages",
"Snippets",
"Other"
],
"keywords": [
"latex",
"tex",
"bibtex"
],
"icon": "images/icon.png",
"galleryBanner": {
"color": "#F5F5F5",
"theme": "light"
},
"preview": true,
"badges": [
{
"url": "https://img.shields.io/github/workflow/status/latex-lsp/texlab/CI.svg?logo=github",
"href": "https://github.com/latex-lsp/texlab/actions",
"description": "CI"
}
],
"activationEvents": [
"onLanguage:latex",
"onLanguage:bibtex"
],
"contributes": {
"configuration": [
{
"title": "TeXLab configuration",
"properties": {
"texlab.rootDirectory": {
"type": [
"string",
"null"
],
"default": null,
"description": "Path to the root directory."
},
"texlab.build.executable": {
"type": "string",
"default": "latexmk",
"description": "Path to a LaTeX build tool."
},
"texlab.build.args": {
"type": "array",
"default": [
"-pdf",
"-interaction=nonstopmode",
"-synctex=1",
"%f"
],
"description": "Additional arguments that are passed to the build tool."
},
"texlab.build.forwardSearchAfter": {
"type": "boolean",
"default": false,
"description": "Execute forward search after building"
},
"texlab.build.onSave": {
"type": "boolean",
"default": false,
"description": "Build after saving a file"
},
"texlab.auxDirectory": {
"type": "string",
"default": ".",
"description": "Directory containing the build artifacts."
},
"texlab.forwardSearch.executable": {
"type": [
"string",
"null"
],
"default": null,
"description": "Path to a PDF previewer that supports SyncTeX."
},
"texlab.forwardSearch.args": {
"type": "array",
"default": [],
"description": "Additional arguments that are passed to the previewer."
},
"texlab.chktex.onOpenAndSave": {
"type": "boolean",
"default": true,
"description": "Lint using chktex after opening and saving a file."
},
"texlab.chktex.onEdit": {
"type": "boolean",
"default": false,
"description": "Lint using chktex after changing a file"
},
"texlab.server.trace": {
"type": "boolean",
"default": false,
"description": "Enable the trace verbosity of the server."
},
"texlab.server.logFile": {
"type": [
"string",
"null"
],
"default": null,
"description": "Path to the server log file."
},
"texlab.bibtexFormatter": {
"type": "string",
"default": "texlab",
"description": "BibTeX formatter to use."
},
"texlab.formatterLineLength": {
"type": "integer",
"default": 80,
"description": "Maximum amount of characters per line (0 = disable)."
},
"texlab.latexFormatter": {
"type": "string",
"default": "latexindent",
"description": "LaTeX formatter to use."
},
"texlab.latexindent.local": {
"type": [
"string",
"null"
],
"default": null,
"description": "Configures the --local flag of latexindent."
},
"texlab.latexindent.modifyLineBreaks": {
"type": "boolean",
"default": false,
"description": "Configures the --modifylinebreaks flag of latexindent."
}
}
}
],
"configurationDefaults": {
"[latex]": {
"editor.wordBasedSuggestions": false,
"editor.suggest.snippetsPreventQuickSuggestions": false
},
"[bibtex]": {
"editor.wordBasedSuggestions": false,
"editor.suggest.snippetsPreventQuickSuggestions": false
}
},
"commands": [
{
"command": "latex.build",
"title": "Build file (latexmk)",
"description": "Builds the current file.",
"category": "LaTeX"
},
{
"command": "latex.forwardSearch",
"title": "Forward Search",
"description": "Performs a forward search from the current file.",
"category": "LaTeX"
}
],
"menus": {
"commandPalette": [
{
"command": "latex.build",
"when": "editorLangId =~ /(latex|bibtex)/"
},
{
"command": "latex.forwardSearch",
"when": "editorLangId == latex"
}
],
"editor/context": [
{
"command": "latex.forwardSearch",
"when": "editorLangId == latex"
}
]
},
"keybindings": [
{
"command": "latex.build",
"key": "f5",
"mac": "f5",
"when": "editorLangId =~ /(latex|bibtex)/"
},
{
"command": "latex.forwardSearch",
"key": "ctrl+alt+f",
"mac": "ctrl+alt+f",
"when": "editorLangId == latex"
}
],
"languages": [
{
"id": "latex",
"aliases": [
"LaTeX",
"latex"
],
"extensions": [
".tex",
".sty",
".cls"
],
"configuration": "./languages/latex.json"
},
{
"id": "bibtex",
"aliases": [
"BibTeX",
"bibtex"
],
"extensions": [
".bib"
],
"configuration": "./languages/bibtex.json"
}
],
"grammars": [
{
"language": "latex",
"scopeName": "source.latex",
"path": "./grammars/latex.tmLanguage.json"
},
{
"language": "bibtex",
"scopeName": "source.bibtex",
"path": "./grammars/bibtex.tmLanguage.json"
}
]
}
}

View file

171
editors/code/src/client.ts Normal file
View file

@ -0,0 +1,171 @@
import * as vscode from 'vscode';
import {
BaseLanguageClient,
ClientCapabilities,
DynamicFeature,
FeatureState,
LanguageClient,
LanguageClientOptions,
RequestType,
ServerOptions,
StaticFeature,
TextDocumentIdentifier,
TextDocumentPositionParams,
WorkDoneProgress,
WorkDoneProgressCreateRequest,
} from 'vscode-languageclient/node';
import { ExtensionState, StatusIcon } from './view';
export enum BuildStatus {
/**
* The build process terminated without any errors.
*/
Success = 0,
/**
* The build process terminated with errors.
*/
Error = 1,
/**
* The build process failed to start or crashed.
*/
Failure = 2,
/**
* The build process was cancelled.
*/
Cancelled = 3,
}
export interface BuildResult {
/**
* The status of the build process.
*/
status: BuildStatus;
}
export enum ForwardSearchStatus {
/**
* The previewer process executed the command without any errors.
*/
Success = 0,
/**
* The previewer process executed the command with errors.
*/
Error = 1,
/**
* The previewer process failed to start or crashed.
*/
Failure = 2,
/**
* The previewer command is not configured.
*/
Unconfigured = 3,
}
export interface ForwardSearchResult {
/**
* The status of the previewer process.
*/
status: ForwardSearchStatus;
}
interface BuildTextDocumentParams {
/**
* The text document to build.
*/
textDocument: TextDocumentIdentifier;
}
abstract class BuildTextDocumentRequest {
public static type = new RequestType<
BuildTextDocumentParams,
BuildResult,
void
>('textDocument/build');
}
abstract class ForwardSearchRequest {
public static type = new RequestType<
TextDocumentPositionParams,
ForwardSearchResult,
void
>('textDocument/forwardSearch');
}
export class CustomProgressFeature implements StaticFeature {
public fillClientCapabilities(capabilities: ClientCapabilities): void {
if (!capabilities.window) {
capabilities.window = {};
}
capabilities.window.workDoneProgress = true;
}
constructor(
private readonly client: BaseLanguageClient,
private readonly icon: StatusIcon,
) {}
public getState(): FeatureState {
return { kind: 'static' };
}
public dispose(): void {
// nothing to dispose here
}
public initialize(): void {
this.client.onRequest(WorkDoneProgressCreateRequest.type, ({ token }) => {
this.icon.update(ExtensionState.Building);
this.client.onProgress(WorkDoneProgress.type, token, (progress) => {
if (progress.kind === 'end') {
this.icon.update(ExtensionState.Running);
}
});
});
}
}
export class LatexLanguageClient extends LanguageClient {
constructor(
name: string,
serverOptions: ServerOptions,
clientOptions: LanguageClientOptions,
icon: StatusIcon,
) {
super(name, serverOptions, clientOptions);
this.registerProposedFeatures();
this.registerFeature(new CustomProgressFeature(this, icon));
}
public registerFeature(
feature: StaticFeature | DynamicFeature<unknown>,
): void {
if (feature.constructor.name !== 'ProgressFeature') {
super.registerFeature(feature);
}
}
public async build(document: vscode.TextDocument): Promise<BuildResult> {
return await this.sendRequest(BuildTextDocumentRequest.type, {
textDocument:
this.code2ProtocolConverter.asTextDocumentIdentifier(document),
});
}
public async forwardSearch(
document: vscode.TextDocument,
position: vscode.Position,
): Promise<ForwardSearchResult> {
const params = this.code2ProtocolConverter.asTextDocumentPositionParams(
document,
position,
);
return this.sendRequest(ForwardSearchRequest.type, params);
}
}

View file

@ -0,0 +1,183 @@
import * as cp from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import { promisify } from 'util';
import * as vscode from 'vscode';
import {
DidChangeConfigurationNotification,
ServerOptions,
State,
} from 'vscode-languageclient/node';
import {
BuildStatus,
ForwardSearchStatus,
LatexLanguageClient,
} from './client';
import {
BIBTEX_FILE,
BIBTEX_UNTITLED,
LATEX_FILE,
LATEX_UNTITLED,
} from './selectors';
import { ExtensionState, Messages, StatusIcon } from './view';
export async function activate(
context: vscode.ExtensionContext,
): Promise<void> {
const serverCommand = await findServer(context);
if (serverCommand === undefined) {
vscode.window.showErrorMessage(
'No pre-built binaries available for your platform. ' +
'Please install the server manually. ' +
'For more information, see https://github.com/latex-lsp/texlab.',
);
return;
}
const serverConfig = vscode.workspace.getConfiguration('texlab.server');
const serverOptions = getServerOptions(serverCommand, serverConfig);
const icon = new StatusIcon();
const client = new LatexLanguageClient(
'texlab',
serverOptions,
{
documentSelector: [
LATEX_FILE,
LATEX_UNTITLED,
BIBTEX_FILE,
BIBTEX_UNTITLED,
],
outputChannelName: 'TexLab Language Server',
uriConverters: {
code2Protocol: (uri) => uri.toString(true),
protocol2Code: (value) => vscode.Uri.parse(value),
},
},
icon,
);
context.subscriptions.push(
vscode.commands.registerTextEditorCommand('latex.build', (editor) =>
build(editor, client),
),
vscode.commands.registerTextEditorCommand('latex.forwardSearch', (editor) =>
forwardSearch(editor, client),
),
client.onDidChangeState(({ newState }) => {
icon.update(
newState === State.Running
? ExtensionState.Running
: ExtensionState.Stopped,
);
}),
vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration('texlab')) {
client.sendNotification(DidChangeConfigurationNotification.type, {
settings: {},
});
}
}),
icon,
);
client.start();
}
async function findServer(
context: vscode.ExtensionContext,
): Promise<string | undefined> {
try {
await promisify(cp.execFile)('texlab', ['--version']);
return 'texlab';
} catch {
const serverName = os.platform() === 'win32' ? 'texlab.exe' : 'texlab';
const serverPath = context.asAbsolutePath(`server/${serverName}`);
return (await promisify(fs.exists)(serverPath)) ? serverPath : undefined;
}
}
function getServerOptions(
serverCommand: string,
serverConfig: vscode.WorkspaceConfiguration,
): ServerOptions {
const trace = serverConfig.get<boolean>('trace');
const logFilePath = serverConfig.get<string | undefined>('logFile');
const args = [];
if (trace) {
args.push('-vvvv');
}
if (logFilePath) {
args.push('--log-file');
args.push(logFilePath);
}
const { ELECTRON_RUN_AS_NODE, ...env } = process.env;
return {
run: {
command: serverCommand,
args,
options: {
env,
},
},
debug: {
command: serverCommand,
args,
options: {
env: {
...env,
RUST_BACKTRACE: '1',
},
},
},
};
}
async function build(
{ document }: vscode.TextEditor,
client: LatexLanguageClient,
): Promise<void> {
if (
vscode.languages.match([LATEX_FILE, BIBTEX_FILE], document) <= 0 ||
(document.isDirty && !(await document.save()))
) {
return;
}
const { status } = await client.build(document);
switch (status) {
case BuildStatus.Success:
break;
case BuildStatus.Cancelled:
break;
case BuildStatus.Error:
vscode.window.showErrorMessage(Messages.BUILD_ERROR);
break;
case BuildStatus.Failure:
vscode.window.showErrorMessage(Messages.BUILD_FAILURE);
break;
}
}
async function forwardSearch(
{ document, selection }: vscode.TextEditor,
client: LatexLanguageClient,
): Promise<void> {
if (vscode.languages.match(LATEX_FILE, document) <= 0) {
return;
}
const { status } = await client.forwardSearch(document, selection.start);
switch (status) {
case ForwardSearchStatus.Success:
break;
case ForwardSearchStatus.Error:
case ForwardSearchStatus.Failure:
vscode.window.showErrorMessage(Messages.SEARCH_FAILURE);
break;
case ForwardSearchStatus.Unconfigured:
vscode.window.showInformationMessage(Messages.SEARCH_UNCONFIGURED);
break;
}
}

View file

@ -0,0 +1,19 @@
export const LATEX_FILE = {
language: 'latex',
scheme: 'file',
};
export const BIBTEX_FILE = {
language: 'bibtex',
scheme: 'file',
};
export const LATEX_UNTITLED = {
language: 'latex',
scheme: 'untitled',
};
export const BIBTEX_UNTITLED = {
language: 'bibtex',
scheme: 'untitled',
};

View file

@ -0,0 +1,23 @@
import * as path from 'path';
import { runTests } from '@vscode/test-electron';
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
main();

View file

@ -0,0 +1,15 @@
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});

View file

@ -0,0 +1,38 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true,
});
const testsRoot = path.resolve(__dirname, '..');
return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
try {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
}

79
editors/code/src/view.ts Normal file
View file

@ -0,0 +1,79 @@
import * as vscode from 'vscode';
export abstract class Messages {
public static SERVER_RUNNING = 'TexLab is running...';
public static SERVER_CANCEL_BUILD = 'Click to cancel the build.';
public static SERVER_STOPPED = 'TexLab has stopped working!';
public static BUILD_ERROR =
'A build error occured. Please check the problems tab \
and the build log for further information.';
public static BUILD_FAILURE =
'An error occured while executing the configured LaTeX build tool.';
public static SEARCH_ERROR =
'An error occured after executing the configured previewer. \
Please see the documentation of your previewer for further information.';
public static SEARCH_FAILURE =
'An error occured while executing the configured PDF viewer. \
Please see the README of this extension and the PDF viewer for further information.';
public static SEARCH_UNCONFIGURED =
'The forward search feature is not configured. Please see the README for instructions.';
public static DOWNLOAD_TITLE = 'Downloading TexLab server';
public static DOWNLOAD_ERROR =
'An error occured while downloading the TexLab language server.';
}
abstract class Colors {
public static NORMAL = new vscode.ThemeColor('statusBar.foreground');
public static ERROR = new vscode.ThemeColor('errorForeground');
}
export enum ExtensionState {
Running,
Building,
Stopped,
}
export class StatusIcon {
private statusBarItem: vscode.StatusBarItem;
constructor() {
this.statusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left,
);
this.statusBarItem.show();
}
public dispose(): void {
this.statusBarItem.dispose();
}
public update(state: ExtensionState): void {
switch (state) {
case ExtensionState.Running:
this.drawIcon(Messages.SERVER_RUNNING, Colors.NORMAL);
break;
case ExtensionState.Building:
this.statusBarItem.text = `$(beaker) Building...`;
this.statusBarItem.color = Colors.NORMAL;
break;
case ExtensionState.Stopped:
this.drawIcon(Messages.SERVER_STOPPED, Colors.ERROR);
break;
}
}
private drawIcon(tooltip: string, color: vscode.ThemeColor): void {
this.statusBarItem.text = `$(beaker)`;
this.statusBarItem.tooltip = tooltip;
this.statusBarItem.color = color;
}
}

View file

@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"lib": ["ES2020"],
"sourceMap": true,
"rootDir": "src",
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true
},
"exclude": ["webpack.config.ts"]
}

View file

@ -0,0 +1,38 @@
import * as path from 'path';
const extensionConfig = {
target: 'node',
mode: 'none',
entry: './src/extension.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
},
externals: {
vscode: 'commonjs vscode',
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
],
},
devtool: 'nosources-source-map',
infrastructureLogging: {
level: 'log',
},
};
module.exports = [extensionConfig];