Skip to content

Commit

Permalink
Renaming extension: Language Server Modelica
Browse files Browse the repository at this point in the history
  - Adding CI for server
  • Loading branch information
AnHeuermann committed Dec 7, 2023
1 parent a135fea commit aa3e113
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 22 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test Modelica Language Server

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup npm
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Install the dependencies
run: npm clean-install && npm run postinstall

- name: Build package
run: npm run compile

- name: Test language server
run: npm run test:server
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# LSP Example
# VS Code Modelica Language Server

Heavily documented sample code for https://code.visualstudio.com/api/language-extensions/language-server-extension-guide

## Functionality

This Language Server works for plain text file. It has the following language features:
- Completions
- Diagnostics regenerated on each file change or configuration change
This Language Server works for Modelica files. It has the following language features:
- None

It also includes an End-to-End test.

Expand All @@ -24,14 +23,16 @@ It also includes an End-to-End test.
└── server.ts // Language Server entry point
```

## Running the Sample

- Run `npm install` in this folder. This installs all necessary npm modules in both the client and server folder
- Open VS Code on this folder.
- Press Ctrl+Shift+B to start compiling the client and server in [watch mode](https://code.visualstudio.com/docs/editor/tasks#:~:text=The%20first%20entry%20executes,the%20HelloWorld.js%20file.).
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
- Select `Launch Client` from the drop down (if it is not already).
- Press ▷ to run the launch config (F5).
- In the [Extension Development Host](https://code.visualstudio.com/api/get-started/your-first-extension#:~:text=Then%2C%20inside%20the%20editor%2C%20press%20F5.%20This%20will%20compile%20and%20run%20the%20extension%20in%20a%20new%20Extension%20Development%20Host%20window.) instance of VSCode, open a document in 'plain text' language mode.
- Type `j` or `t` to see `Javascript` and `TypeScript` completion.
- Enter text content such as `AAA aaa BBB`. The extension will emit diagnostics for all words in all-uppercase.
## Running the Language Server

- Run `npm install` in this folder. This installs all necessary npm modules in both the
client and server folder
- Open VS Code on this folder.
- Press Ctrl+Shift+B to start compiling the client and server in
[watch mode](https://code.visualstudio.com/docs/editor/tasks#:~:text=The%20first%20entry%20executes,the%20HelloWorld.js%20file.).
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
- Select `Launch Client` from the drop down (if it is not already).
- Press ▷ to run the launch config (F5).
- In the [Extension Development Host](https://code.visualstudio.com/api/get-started/your-first-extension#:~:text=Then%2C%20inside%20the%20editor%2C%20press%20F5.%20This%20will%20compile%20and%20run%20the%20extension%20in%20a%20new%20Extension%20Development%20Host%20window.)
instance of VSCode, open a document in 'modelica' language mode.
- Check the console output of `Language Server Modelica` to see the parsed tree of the opened file.
4 changes: 2 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export function activate(context: ExtensionContext) {

// Create the language client and start the client.
client = new LanguageClient(
'languageServerExample',
'Language Server Example',
'languageServerModelica',
'Language Server Modelica',
serverOptions,
clientOptions
);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lsp-sample",
"description": "A language server example",
"description": "A language server Modelica",
"author": "Microsoft Corporation",
"license": "MIT",
"version": "1.0.0",
Expand All @@ -25,13 +25,13 @@
"type": "object",
"title": "Example configuration",
"properties": {
"languageServerExample.maxNumberOfProblems": {
"languageServerModelica.maxNumberOfProblems": {
"scope": "resource",
"type": "number",
"default": 100,
"description": "Controls the maximum number of problems produced by the server."
},
"languageServerExample.trace.server": {
"languageServerModelica.trace.server": {
"scope": "window",
"type": "string",
"enum": [
Expand Down
4 changes: 2 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ connection.onDidChangeConfiguration(change => {
documentSettings.clear();
} else {
globalSettings = <ExampleSettings>(
(change.settings.languageServerExample || defaultSettings)
(change.settings.languageServerModelica || defaultSettings)
);
}

Expand All @@ -125,7 +125,7 @@ function getDocumentSettings(resource: string): Thenable<ExampleSettings> {
if (!result) {
result = connection.workspace.getConfiguration({
scopeUri: resource,
section: 'languageServerExample'
section: 'languageServerModelica'
});
documentSettings.set(resource, result);
}
Expand Down

0 comments on commit aa3e113

Please sign in to comment.