Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to Volar #2242

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ typings/
.cache

# tdsx
dist
out
*.tsbuildinfo

# VSCode history extension
.history

# syntaxes
postcss.json
svelte.tmLanguage.json
3 changes: 0 additions & 3 deletions packages/language-server/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions packages/language-server/.npmignore

This file was deleted.

13 changes: 8 additions & 5 deletions packages/language-server/bin/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#! /usr/bin/env node

const { startServer } = require('../dist/src/server');

startServer();
#!/usr/bin/env node
if (process.argv.includes('--version')) {
const pkgJSON = require('../package.json');
console.log(`${pkgJSON['version']}`);
}
else {
require('../out/index.js');
}
79 changes: 20 additions & 59 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,29 @@
{
"name": "svelte-language-server",
"version": "0.16.0",
"description": "A language server for Svelte",
"main": "dist/src/index.js",
"typings": "dist/src/index",
"scripts": {
"test": "cross-env TS_NODE_TRANSPILE_ONLY=true mocha --require ts-node/register \"test/**/*.ts\" --exclude \"test/**/*.d.ts\"",
"build": "tsc",
"prepublishOnly": "npm run build",
"watch": "tsc -w"
},
"version": "0.0.0",
"main": "out/index.js",
"license": "MIT",
"files": [
"out/**/*.js",
"out/**/*.d.ts"
],
"bin": {
"svelteserver": "bin/server.js"
"svelte-language-server": "./bin/server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sveltejs/language-tools.git"
},
"keywords": [
"svelte",
"vscode",
"atom",
"editor",
"language-server"
],
"author": "James Birtles <[email protected]> and the Svelte Language Tools contributors",
"license": "MIT",
"bugs": {
"url": "https://github.com/sveltejs/language-tools/issues"
},
"homepage": "https://github.com/sveltejs/language-tools#readme",
"engines": {
"node": ">= 12.0.0"
},
"devDependencies": {
"@types/estree": "^0.0.42",
"@types/lodash": "^4.14.116",
"@types/mocha": "^9.1.0",
"@types/node": "^16.0.0",
"@types/prettier": "^2.2.3",
"@types/sinon": "^7.5.2",
"cross-env": "^7.0.2",
"mocha": "^9.2.0",
"sinon": "^11.0.0",
"ts-node": "^10.0.0"
"url": "https://github.com/johnsoncodehk/volar.git",
"directory": "examples/svelte-language-server"
},
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.17",
"@vscode/emmet-helper": "2.8.4",
"chokidar": "^3.4.1",
"estree-walker": "^2.0.1",
"fast-glob": "^3.2.7",
"lodash": "^4.17.21",
"prettier": "~3.1.0",
"prettier-plugin-svelte": "~3.1.1",
"svelte": "^3.57.0",
"svelte-preprocess": "~5.1.0",
"svelte2tsx": "workspace:~",
"typescript": "^5.3.2",
"vscode-css-languageservice": "~6.2.10",
"vscode-html-languageservice": "~5.1.1",
"vscode-languageserver": "8.0.2",
"vscode-languageserver-protocol": "3.17.2",
"vscode-languageserver-types": "3.17.2",
"vscode-uri": "~3.0.0"
"@jridgewell/sourcemap-codec": "^1.4.15",
"@volar/language-core": "2.0.0-alpha.13",
"@volar/language-server": "2.0.0-alpha.13",
"svelte2tsx": "^0.6.27",
"volar-service-css": "0.0.25",
"volar-service-html": "0.0.25",
"volar-service-typescript": "0.0.25",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-uri": "^3.0.8"
}
}
}
69 changes: 0 additions & 69 deletions packages/language-server/src/importPackage.ts

This file was deleted.

37 changes: 34 additions & 3 deletions packages/language-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
export * from './server';
export { offsetAt } from './lib/documents';
export { SvelteCheck, SvelteCheckOptions, SvelteCheckDiagnosticSource } from './svelte-check';
import { createConnection, createNodeServer, createTypeScriptProjectProvider } from '@volar/language-server/node';
import { create as createCssScriptServicePlugin } from 'volar-service-css';
import { create as createHtmlServicePlugin } from 'volar-service-html';
import { create as createTypeScriptServicePlugin } from 'volar-service-typescript';
import { svelteLanguagePlugin } from './languagePlugin';

const connection = createConnection();
const server = createNodeServer(connection);

connection.listen();

connection.onInitialize(params => {
return server.initialize(params, createTypeScriptProjectProvider, {
watchFileExtensions: ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts', 'jsx', 'tsx', 'json', 'svelte'],
getServicePlugins() {
return [
createCssScriptServicePlugin(),
createHtmlServicePlugin(),
createTypeScriptServicePlugin(server.modules.typescript!),
]
},
getLanguagePlugins() {
return [svelteLanguagePlugin];
},
});
});

connection.onInitialized(() => {
server.initialized();
});

connection.onShutdown(() => {
server.shutdown();
});
Loading