-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5e1bf0d
Showing
9 changed files
with
3,827 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib | ||
node_modules/ | ||
server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
src | ||
node_modules | ||
tsconfig.json | ||
*.map | ||
.tags | ||
webpack.config.js | ||
yarn.lock | ||
server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Heyward Fann | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# coc-texlab | ||
|
||
> fork of [texlab-vscode](https://github.com/latex-lsp/texlab-vscode), provides editing support for LaTeX documents, powered by the [TexLab](https://github.com/latex-lsp/texlab) language server. | ||
## Install | ||
|
||
`:CocInstall coc-texlab` | ||
|
||
## Requirements | ||
|
||
- A [TeX distribution](https://www.latex-project.org/get/#tex-distributions). All distributions that are based on [TeX Live](https://www.tug.org/texlive/) or [MikTeX](https://miktex.org/) are supported. | ||
- The Node.js runtime. This is an optional dependency used for the citation rendering feature. | ||
- On Windows, you will need to install [Microsoft Visual C++ Redistributable for Visual Studio 2015](https://aka.ms/vs/16/release/vc_redist.x64.exe). | ||
|
||
More info in [TexLab Docs](https://texlab.netlify.com/docs) | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "coc-texlab", | ||
"version": "1.0.0", | ||
"description": "TexLab extension for coc.nvim", | ||
"main": "lib/index.js", | ||
"author": "Heyward Fann <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"watch": "webpack --watch", | ||
"build": "webpack", | ||
"prepare": "npx npm-run-all clean build" | ||
}, | ||
"keywords": [ | ||
"coc.nvim", | ||
"latex", | ||
"texlab" | ||
], | ||
"engines": { | ||
"coc": "^0.0.70" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^12.0.4", | ||
"@types/request": "^2.48.1", | ||
"@types/tar": "^4.0.2", | ||
"@types/unzipper": "^0.9.2", | ||
"axios": "^0.19.0", | ||
"coc.nvim": "^0.0.71", | ||
"request": "^2.88.0", | ||
"rimraf": "^2.6.3", | ||
"tar": "^4.4.10", | ||
"ts-loader": "^6.0.4", | ||
"typescript": "^3.5.2", | ||
"unzipper": "^0.10.1", | ||
"webpack": "^4.35.0", | ||
"webpack-cli": "^3.3.5" | ||
}, | ||
"dependencies": {}, | ||
"prettier": { | ||
"printWidth": 160, | ||
"singleQuote": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import fs from 'fs'; | ||
import os from 'os'; | ||
import tar from 'tar'; | ||
import unzipper from 'unzipper'; | ||
import request from 'request'; | ||
|
||
import { ServerOptions, services, ExtensionContext, workspace, LanguageClientOptions, LanguageClient } from 'coc.nvim'; | ||
|
||
export async function activate(context: ExtensionContext): Promise<void> { | ||
const serverPath = getServerPath(context); | ||
if (!fs.existsSync(serverPath)) { | ||
workspace.showMessage(`TexLab Server is not found, downloading...`); | ||
try { | ||
await downloadServer(context); | ||
} catch (_e) { | ||
workspace.showMessage(`Download TexLab failed`); | ||
return; | ||
} | ||
} | ||
|
||
const serverOptions = getServerOptions(serverPath); | ||
const clientOptions: LanguageClientOptions = { | ||
documentSelector: ['tex', 'latex', 'bib', 'bibtex'], | ||
outputChannelName: 'LaTeX' | ||
}; | ||
|
||
const client = new LanguageClient('TexLab', serverOptions, clientOptions); | ||
context.subscriptions.push(services.registLanguageClient(client)); | ||
|
||
client.onReady().then(() => { | ||
workspace.showMessage(`TexLab Server Started`); | ||
}); | ||
} | ||
|
||
function getServerPath(context: ExtensionContext): string { | ||
const name = os.platform() === 'win32' ? 'texlab.exe' : 'texlab'; | ||
return context.asAbsolutePath(`./server/${name}`); | ||
} | ||
|
||
function getServerOptions(serverPath: string): ServerOptions { | ||
const { ELECTRON_RUN_AS_NODE, ...env } = process.env; | ||
return { | ||
run: { | ||
command: serverPath, | ||
options: { | ||
env | ||
} | ||
}, | ||
debug: { | ||
command: serverPath, | ||
args: ['-vvvv'], | ||
options: { | ||
env: { | ||
...env, | ||
RUST_BACKTRACE: '1' | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
async function downloadServer(context: ExtensionContext): Promise<void> { | ||
const urls = { | ||
win32: 'https://github.com/latex-lsp/texlab/releases/download/v1.0.0/texlab-x86_64-windows.zip', | ||
linux: 'https://github.com/latex-lsp/texlab/releases/download/v1.0.0/texlab-x86_64-linux.tar.gz', | ||
darwin: 'https://github.com/latex-lsp/texlab/releases/download/v1.0.0/texlab-x86_64-macos.tar.gz' | ||
}; | ||
|
||
const url = urls[os.platform()]; | ||
const path = context.asAbsolutePath('server'); | ||
const extract = os.platform() === 'win32' ? () => unzipper.Extract({ path }) : () => tar.x({ C: path }); | ||
|
||
let statusItem = workspace.createStatusBarItem(0, { progress: true }); | ||
statusItem.text = 'Downloading TexLab Server'; | ||
statusItem.show(); | ||
|
||
return new Promise((resolve, reject) => { | ||
request(url) | ||
.pipe(extract()) | ||
.on('close', () => { | ||
resolve(); | ||
statusItem.dispose(); | ||
}) | ||
.on('error', e => { | ||
reject(e); | ||
}); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2017", | ||
"lib": ["es2017", "es2018"], | ||
"module": "commonjs", | ||
"declaration": false, | ||
"sourceMap": true, | ||
"outDir": "lib", | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"noImplicitAny": false, | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
entry: './src/index.ts', | ||
target: 'node', | ||
mode: 'none', | ||
resolve: { | ||
mainFields: ['module', 'main'], | ||
extensions: ['.js', '.ts'] | ||
}, | ||
externals: { | ||
'coc.nvim': 'commonjs coc.nvim' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'ts-loader', | ||
options: { | ||
compilerOptions: { | ||
sourceMap: true | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'lib'), | ||
filename: 'index.js', | ||
libraryTarget: 'commonjs' | ||
}, | ||
plugins: [], | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
} | ||
}; |
Oops, something went wrong.