Start adding LSP implementation
This commit is contained in:
		
							parent
							
								
									c262418f88
								
							
						
					
					
						commit
						bc59b6f575
					
				
							
								
								
									
										937
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										937
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,5 +1,6 @@ | ||||
| [workspace] | ||||
| members = [ | ||||
|     "reid", | ||||
|     "reid-llvm-lib" | ||||
| ] | ||||
|     "reid-llvm-lib",  | ||||
|     "reid-lsp" | ||||
| ] | ||||
|  | ||||
							
								
								
									
										6
									
								
								reid-lsp/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								reid-lsp/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| .vscode | ||||
| node_modules | ||||
| dist | ||||
| package-lock.json | ||||
| pnpm-lock.yaml | ||||
| tsconfig.tsbuildinfo | ||||
							
								
								
									
										1
									
								
								reid-lsp/.npmrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								reid-lsp/.npmrc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| enable-pre-post-scripts = true | ||||
							
								
								
									
										5
									
								
								reid-lsp/.vscode-test.mjs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								reid-lsp/.vscode-test.mjs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| import { defineConfig } from '@vscode/test-cli'; | ||||
| 
 | ||||
| export default defineConfig({ | ||||
| 	files: 'out/test/**/*.test.js', | ||||
| }); | ||||
							
								
								
									
										15
									
								
								reid-lsp/.vscodeignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								reid-lsp/.vscodeignore
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| .vscode/** | ||||
| .vscode-test/** | ||||
| out/** | ||||
| node_modules/** | ||||
| src/** | ||||
| client/** | ||||
| .gitignore | ||||
| .yarnrc | ||||
| webpack.config.js | ||||
| vsc-extension-quickstart.md | ||||
| **/tsconfig.json | ||||
| **/eslint.config.mjs | ||||
| **/*.map | ||||
| **/*.ts | ||||
| **/.vscode-test.* | ||||
							
								
								
									
										9
									
								
								reid-lsp/CHANGELOG.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								reid-lsp/CHANGELOG.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| # Change Log | ||||
| 
 | ||||
| All notable changes to the "reid-lsp" extension will be documented in this file. | ||||
| 
 | ||||
| Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. | ||||
| 
 | ||||
| ## [Unreleased] | ||||
| 
 | ||||
| - Initial release | ||||
							
								
								
									
										9
									
								
								reid-lsp/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								reid-lsp/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| [package] | ||||
| name = "reid-lsp" | ||||
| version = "0.1.0" | ||||
| edition = "2024" | ||||
| 
 | ||||
| [dependencies] | ||||
| socket = "0.0.7" | ||||
| tokio = { version = "1.47.0", features = ["full"] } | ||||
| tower-lsp = "0.20.0" | ||||
							
								
								
									
										71
									
								
								reid-lsp/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								reid-lsp/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | ||||
| # reid-lsp README | ||||
| 
 | ||||
| This is the README for your extension "reid-lsp". After writing up a brief description, we recommend including the following sections. | ||||
| 
 | ||||
| ## Features | ||||
| 
 | ||||
| Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. | ||||
| 
 | ||||
| For example if there is an image subfolder under your extension project workspace: | ||||
| 
 | ||||
| \!\[feature X\]\(images/feature-x.png\) | ||||
| 
 | ||||
| > Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. | ||||
| 
 | ||||
| ## Requirements | ||||
| 
 | ||||
| If you have any requirements or dependencies, add a section describing those and how to install and configure them. | ||||
| 
 | ||||
| ## Extension Settings | ||||
| 
 | ||||
| Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. | ||||
| 
 | ||||
| For example: | ||||
| 
 | ||||
| This extension contributes the following settings: | ||||
| 
 | ||||
| * `myExtension.enable`: Enable/disable this extension. | ||||
| * `myExtension.thing`: Set to `blah` to do something. | ||||
| 
 | ||||
| ## Known Issues | ||||
| 
 | ||||
| Calling out known issues can help limit users opening duplicate issues against your extension. | ||||
| 
 | ||||
| ## Release Notes | ||||
| 
 | ||||
| Users appreciate release notes as you update your extension. | ||||
| 
 | ||||
| ### 1.0.0 | ||||
| 
 | ||||
| Initial release of ... | ||||
| 
 | ||||
| ### 1.0.1 | ||||
| 
 | ||||
| Fixed issue #. | ||||
| 
 | ||||
| ### 1.1.0 | ||||
| 
 | ||||
| Added features X, Y, and Z. | ||||
| 
 | ||||
| --- | ||||
| 
 | ||||
| ## Following extension guidelines | ||||
| 
 | ||||
| Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension. | ||||
| 
 | ||||
| * [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) | ||||
| 
 | ||||
| ## Working with Markdown | ||||
| 
 | ||||
| You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: | ||||
| 
 | ||||
| * Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). | ||||
| * Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). | ||||
| * Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. | ||||
| 
 | ||||
| ## For more information | ||||
| 
 | ||||
| * [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) | ||||
| * [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) | ||||
| 
 | ||||
| **Enjoy!** | ||||
							
								
								
									
										27
									
								
								reid-lsp/client/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								reid-lsp/client/package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| { | ||||
|   "name": "reid-lsp", | ||||
|   "displayName": "Reid Language Server", | ||||
|   "description": "Language Server Extension for Reid", | ||||
|   "version": "0.0.1", | ||||
|   "engines": { | ||||
|     "vscode": "^1.102.0" | ||||
|   }, | ||||
|   "main": "../out/extension.js", | ||||
|   "devDependencies": { | ||||
|     "@types/mocha": "^10.0.10", | ||||
|     "@types/node": "20.x", | ||||
|     "@types/vscode": "^1.102.0", | ||||
|     "@typescript-eslint/eslint-plugin": "^8.31.1", | ||||
|     "@typescript-eslint/parser": "^8.31.1", | ||||
|     "@vscode/test-cli": "^0.0.11", | ||||
|     "@vscode/test-electron": "^2.5.2", | ||||
|     "eslint": "^9.25.1", | ||||
|     "ts-loader": "^9.5.2", | ||||
|     "typescript": "^5.8.3", | ||||
|     "webpack": "^5.99.7", | ||||
|     "webpack-cli": "^6.0.1" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "vscode-languageclient": "^9.0.1" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										69
									
								
								reid-lsp/client/src/extension.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								reid-lsp/client/src/extension.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,69 @@ | ||||
| /* -------------------------------------------------------------------------------------------- | ||||
|  * Copyright (c) Microsoft Corporation. All rights reserved. | ||||
|  * Licensed under the MIT License. See License.txt in the project root for license information. | ||||
|  * ------------------------------------------------------------------------------------------ */ | ||||
| 
 | ||||
| import * as path from 'path'; | ||||
| import { workspace, ExtensionContext, window } from 'vscode'; | ||||
| 
 | ||||
| import { | ||||
| 	Executable, | ||||
| 	LanguageClient, | ||||
| 	LanguageClientOptions, | ||||
| 	ServerOptions, | ||||
| 	TransportKind | ||||
| } from 'vscode-languageclient/node'; | ||||
| 
 | ||||
| 
 | ||||
| let client: LanguageClient; | ||||
| 
 | ||||
| export function activate(context: ExtensionContext) { | ||||
| 	const traceOutputChannel = window.createOutputChannel("Reid Language Server trace"); | ||||
| 	const command = process.env.SERVER_PATH || "reid-language-server"; | ||||
| 
 | ||||
| 
 | ||||
| 	const run: Executable = { | ||||
| 		command, | ||||
| 		options: { | ||||
| 			env: { | ||||
| 				...process.env, | ||||
| 				RUST_LOG: "debug", | ||||
| 			} | ||||
| 		} | ||||
| 	}; | ||||
| 
 | ||||
| 	const serverOptions: ServerOptions = { | ||||
| 		run, | ||||
| 		debug: run, | ||||
| 	}; | ||||
| 
 | ||||
| 	// Options to control the language client
 | ||||
| 	const clientOptions: LanguageClientOptions = { | ||||
| 		// Register the server for plain text documents
 | ||||
| 		documentSelector: [{ scheme: 'file', language: 'reid' }], | ||||
| 		synchronize: { | ||||
| 			// Notify the server about file changes to '.clientrc files contained in the workspace
 | ||||
| 			fileEvents: workspace.createFileSystemWatcher('**/.clientrc') | ||||
| 		} | ||||
| 	}; | ||||
| 
 | ||||
| 	// Create the language client and start the client.
 | ||||
| 	client = new LanguageClient( | ||||
| 		'reid-lsp', | ||||
| 		'Reid Language Server', | ||||
| 		serverOptions, | ||||
| 		clientOptions | ||||
| 	); | ||||
| 
 | ||||
| 	client.info("hello"); | ||||
| 
 | ||||
| 	// Start the client. This will also launch the server
 | ||||
| 	client.start(); | ||||
| } | ||||
| 
 | ||||
| export function deactivate(): Thenable<void> | undefined { | ||||
| 	if (!client) { | ||||
| 		return undefined; | ||||
| 	} | ||||
| 	return client.stop(); | ||||
| } | ||||
							
								
								
									
										15
									
								
								reid-lsp/client/src/test/extension.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								reid-lsp/client/src/test/extension.test.ts
									
									
									
									
									
										Normal 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)); | ||||
| 	}); | ||||
| }); | ||||
							
								
								
									
										24
									
								
								reid-lsp/client/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								reid-lsp/client/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| { | ||||
| 	"compilerOptions": { | ||||
| 		"module": "Node16", | ||||
| 		"target": "ES2022", | ||||
| 		"lib": [ | ||||
| 			"ES2022" | ||||
| 		], | ||||
| 		"sourceMap": true, | ||||
| 		"rootDir": "src", | ||||
| 		"outDir": "../dist", | ||||
| 		"strict": true /* enable all strict type-checking options */ | ||||
| 		/* Additional Checks */ | ||||
| 		// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||||
| 		// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||||
| 		// "noUnusedParameters": true,  /* Report errors on unused parameters. */ | ||||
| 	}, | ||||
| 	"include": [ | ||||
| 		"src" | ||||
| 	], | ||||
| 	"exclude": [ | ||||
| 		"node_modules", | ||||
| 		".vscode-test" | ||||
| 	] | ||||
| } | ||||
							
								
								
									
										28
									
								
								reid-lsp/eslint.config.mjs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								reid-lsp/eslint.config.mjs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| import typescriptEslint from "@typescript-eslint/eslint-plugin"; | ||||
| import tsParser from "@typescript-eslint/parser"; | ||||
| 
 | ||||
| export default [{ | ||||
|     files: ["**/*.ts"], | ||||
| }, { | ||||
|     plugins: { | ||||
|         "@typescript-eslint": typescriptEslint, | ||||
|     }, | ||||
| 
 | ||||
|     languageOptions: { | ||||
|         parser: tsParser, | ||||
|         ecmaVersion: 2022, | ||||
|         sourceType: "module", | ||||
|     }, | ||||
| 
 | ||||
|     rules: { | ||||
|         "@typescript-eslint/naming-convention": ["warn", { | ||||
|             selector: "import", | ||||
|             format: ["camelCase", "PascalCase"], | ||||
|         }], | ||||
| 
 | ||||
|         curly: "warn", | ||||
|         eqeqeq: "warn", | ||||
|         "no-throw-literal": "warn", | ||||
|         semi: "warn", | ||||
|     }, | ||||
| }]; | ||||
							
								
								
									
										76
									
								
								reid-lsp/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								reid-lsp/package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,76 @@ | ||||
| { | ||||
|   "name": "reid-lsp", | ||||
|   "displayName": "Reid Language Server", | ||||
|   "description": "Language Server Extension for Reid", | ||||
|   "version": "0.0.1", | ||||
|   "engines": { | ||||
|     "vscode": "^1.102.0" | ||||
|   }, | ||||
|   "categories": [ | ||||
|     "Other" | ||||
|   ], | ||||
|   "activationEvents": [ | ||||
|     "onLanguage:reid" | ||||
|   ], | ||||
|   "main": "./dist/extension.js", | ||||
|   "contributes": { | ||||
|     "languages": [ | ||||
|       { | ||||
|         "id": "reid", | ||||
|         "extensions": [ | ||||
|           ".reid" | ||||
|         ] | ||||
|       } | ||||
|     ], | ||||
|     "configuration": { | ||||
|       "type": "object", | ||||
|       "title": "reid-language-server", | ||||
|       "properties": { | ||||
|         "nrs-language-server.trace.server": { | ||||
|           "type": "string", | ||||
|           "scope": "window", | ||||
|           "enum": [ | ||||
|             "off", | ||||
|             "messages", | ||||
|             "verbose" | ||||
|           ], | ||||
|           "enumDescriptions": [ | ||||
|             "No traces", | ||||
|             "Error only", | ||||
|             "Full log" | ||||
|           ], | ||||
|           "default": "off", | ||||
|           "description": "Traces the communication between VS Code and the language server." | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "vscode:prepublish": "pnpm 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": "pnpm run compile-tests && pnpm run compile && pnpm run lint", | ||||
|     "lint": "eslint src", | ||||
|     "test": "vscode-test" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/mocha": "^10.0.10", | ||||
|     "@types/node": "20.x", | ||||
|     "@types/vscode": "^1.102.0", | ||||
|     "@typescript-eslint/eslint-plugin": "^8.31.1", | ||||
|     "@typescript-eslint/parser": "^8.31.1", | ||||
|     "@vscode/test-cli": "^0.0.11", | ||||
|     "@vscode/test-electron": "^2.5.2", | ||||
|     "eslint": "^9.25.1", | ||||
|     "ts-loader": "^9.5.2", | ||||
|     "typescript": "^5.8.3", | ||||
|     "webpack": "^5.99.7", | ||||
|     "webpack-cli": "^6.0.1" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "vscode-languageclient": "^9.0.1" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										41
									
								
								reid-lsp/src/main.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								reid-lsp/src/main.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| use tower_lsp::jsonrpc::Result; | ||||
| use tower_lsp::lsp_types::*; | ||||
| use tower_lsp::{Client, LanguageServer, LspService, Server}; | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| struct Backend { | ||||
|     client: Client, | ||||
| } | ||||
| 
 | ||||
| #[tower_lsp::async_trait] | ||||
| impl LanguageServer for Backend { | ||||
|     async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> { | ||||
|         Ok(InitializeResult { | ||||
|             capabilities: ServerCapabilities { | ||||
|                 hover_provider: Some(HoverProviderCapability::Simple(true)), | ||||
|                 completion_provider: Some(CompletionOptions::default()), | ||||
|                 ..Default::default() | ||||
|             }, | ||||
|             ..Default::default() | ||||
|         }) | ||||
|     } | ||||
| 
 | ||||
|     async fn initialized(&self, _: InitializedParams) { | ||||
|         self.client | ||||
|             .log_message(MessageType::INFO, "Reid Language Server initialized!") | ||||
|             .await; | ||||
|     } | ||||
| 
 | ||||
|     async fn shutdown(&self) -> Result<()> { | ||||
|         Ok(()) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[tokio::main] | ||||
| async fn main() { | ||||
|     let stdin = tokio::io::stdin(); | ||||
|     let stdout = tokio::io::stdout(); | ||||
| 
 | ||||
|     let (service, socket) = LspService::new(|client| Backend { client }); | ||||
|     Server::new(stdin, stdout, socket).serve(service).await; | ||||
| } | ||||
							
								
								
									
										29
									
								
								reid-lsp/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								reid-lsp/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| { | ||||
| 	"compilerOptions": { | ||||
| 		"module": "Node16", | ||||
| 		"target": "ES2022", | ||||
| 		"lib": [ | ||||
| 			"ES2022" | ||||
| 		], | ||||
| 		"sourceMap": true, | ||||
| 		"rootDir": "src", | ||||
| 		"outDir": "out", | ||||
| 		"strict": true /* enable all strict type-checking options */ | ||||
| 		/* Additional Checks */ | ||||
| 		// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||||
| 		// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||||
| 		// "noUnusedParameters": true,  /* Report errors on unused parameters. */ | ||||
| 	}, | ||||
| 	"include": [ | ||||
| 		"src" | ||||
| 	], | ||||
| 	"exclude": [ | ||||
| 		"node_modules", | ||||
| 		".vscode-test" | ||||
| 	], | ||||
| 	"references": [ | ||||
| 		{ | ||||
| 			"path": "./client/" | ||||
| 		}, | ||||
| 	] | ||||
| } | ||||
							
								
								
									
										48
									
								
								reid-lsp/vsc-extension-quickstart.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								reid-lsp/vsc-extension-quickstart.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| # Welcome to your VS Code Extension | ||||
| 
 | ||||
| ## What's in the folder | ||||
| 
 | ||||
| * This folder contains all of the files necessary for your extension. | ||||
| * `package.json` - this is the manifest file in which you declare your extension and command. | ||||
|   * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. | ||||
| * `src/extension.ts` - this is the main file where you will provide the implementation of your command. | ||||
|   * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. | ||||
|   * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. | ||||
| 
 | ||||
| ## Setup | ||||
| 
 | ||||
| * install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint) | ||||
| 
 | ||||
| 
 | ||||
| ## Get up and running straight away | ||||
| 
 | ||||
| * Press `F5` to open a new window with your extension loaded. | ||||
| * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. | ||||
| * Set breakpoints in your code inside `src/extension.ts` to debug your extension. | ||||
| * Find output from your extension in the debug console. | ||||
| 
 | ||||
| ## Make changes | ||||
| 
 | ||||
| * You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. | ||||
| * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. | ||||
| 
 | ||||
| 
 | ||||
| ## Explore the API | ||||
| 
 | ||||
| * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. | ||||
| 
 | ||||
| ## Run tests | ||||
| 
 | ||||
| * Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner) | ||||
| * Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered. | ||||
| * Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A` | ||||
| * See the output of the test result in the Test Results view. | ||||
| * Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder. | ||||
|   * The provided test runner will only consider files matching the name pattern `**.test.ts`. | ||||
|   * You can create folders inside the `test` folder to structure your tests any way you want. | ||||
| 
 | ||||
| ## Go further | ||||
| 
 | ||||
| * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). | ||||
| * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace. | ||||
| * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). | ||||
							
								
								
									
										48
									
								
								reid-lsp/webpack.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								reid-lsp/webpack.config.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| //@ts-check
 | ||||
| 
 | ||||
| 'use strict'; | ||||
| 
 | ||||
| const path = require('path'); | ||||
| 
 | ||||
| //@ts-check
 | ||||
| /** @typedef {import('webpack').Configuration} WebpackConfig **/ | ||||
| 
 | ||||
| /** @type WebpackConfig */ | ||||
| const extensionConfig = { | ||||
|   target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
 | ||||
|   mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
 | ||||
| 
 | ||||
|   entry: './client/src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
 | ||||
|   output: { | ||||
|     // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
 | ||||
|     path: path.resolve(__dirname, 'dist'), | ||||
|     filename: 'extension.js', | ||||
|     libraryTarget: 'commonjs2' | ||||
|   }, | ||||
|   externals: { | ||||
|     vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
 | ||||
|     // modules added here also need to be added in the .vscodeignore file
 | ||||
|   }, | ||||
|   resolve: { | ||||
|     // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
 | ||||
|     extensions: ['.ts', '.js'] | ||||
|   }, | ||||
|   module: { | ||||
|     rules: [ | ||||
|       { | ||||
|         test: /\.ts$/, | ||||
|         exclude: /node_modules/, | ||||
|         use: [ | ||||
|           { | ||||
|             loader: 'ts-loader' | ||||
|           } | ||||
|         ] | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
|   devtool: 'nosources-source-map', | ||||
|   infrastructureLogging: { | ||||
|     level: "log", // enables logging required for problem matchers
 | ||||
|   }, | ||||
| }; | ||||
| module.exports = [extensionConfig]; | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user