Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ out
node_modules
client/server
.vscode-test
test*/**
sample*/**
*.vsix
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"request": "launch",
"name": "Launch Client",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"${workspaceFolder}/sample"
],
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
"preLaunchTask": {
"type": "npm",
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"vbaLanguageServer.trace.server": "verbose"
"vbaLanguageServer.trace.server": "verbose",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true
}
}
31 changes: 26 additions & 5 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
.vscode/**
**/*.ts
**/*.map
# Project
.gitignore
.eslintignore
.vscode/**
.travis.yml
**/tsconfig.json
**/tsconfig.base.json
contributing.md
.travis.yml

# Development
**/src

# # Typescript
**/*.ts
**/*.map

# Generated
.antlr
*.java
*.interp
*.tokens
*.vsix

# Samples and testing
sample*/**
**/test/**
**/testFixture/**

# Client node modules
client/node_modules/**
!client/node_modules/vscode-jsonrpc/**
!client/node_modules/vscode-languageclient/**
!client/node_modules/vscode-languageserver-protocol/**
!client/node_modules/vscode-languageserver-types/**
!client/node_modules/{minimatch,brace-expansion,concat-map,balanced-match}/**
!client/node_modules/{semver,lru-cache,yallist}/**
!client/node_modules/{semver,lru-cache,yallist}/**
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@

Adds VBA language support to VSCode via LSP compliant Language Server.

![VBA LSP](images/vba-lsp.png)

## Features

* Syntax highlighting (resolved on client)
* Semantic highlighting
* Folding ranges
* Document symbols
* Diagnostics

## Coming Soon

* Hovers
* Diagnostics (info, warnings, and errors)

## Installation

* Through the VBA Marketplace,
* VSCode command palette `ext install sslinky.vba-lsp`, or;
* Download the [visx](/releases/latest).

## Contributing

Contributors welcome! Please see [contributing.md](tbc).
Contributors welcome! Please see [contributing.md](/contributing.md).
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"publisher": "SSlinky",
"repository": {
"type": "git",
"url": "https://github.com/SSlinky/tbc"
"url": "https://github.com/SSlinky/VB-LanguageServer"
},
"engines": {
"vscode": "^1.63.0"
Expand Down
7 changes: 3 additions & 4 deletions client/src/syntaxes/vba.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ repository:
- include: "#mthdSig"
- include: "#variableDeclarations"
- include: "#block"
- include: "#testing"
- include: "#testing"
repository:
moduleLines:
match: "(.*):"
match: '([^\n:]*)?:(?=([^"]*"[^"]*")*[^"]*$)'
captures:
1:
patterns:
Expand Down Expand Up @@ -52,8 +52,7 @@ repository:
repository:
string:
name: string.quoted.double.vba
begin: "\""
end: "\""
match: '"[^\r\n]*"'
boolean:
name: constant.language.boolean.vba
match: "(?i)(true|false)"
Expand Down
35 changes: 35 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributing

## Setup

1. Clone repo
2. Install Java >= 11
3. Install NPM
4. `npm install` to install dependencies.
5. `npm run textMate` first time and every time grammar is changed.
6. `npm run antlr4ts` first time and every time grammar is changed.
7. (Optional) Install [ANTLR4 grammar syntax support](https://marketplace.visualstudio.com/items?itemName=mike-lischke.vscode-antlr4) VSCode extension.

## Debugging Language Server

* Use the Client + Server launch configuration.

## Debugging Antlr Grammar

Requires the ANTLR4 grammar syntax support extension installed. Each time you open the workspace, you'll need to open a grammar file to activate the extension.

Note the grammar file for this project can be found at /server/src/antlr/vba.g4

### Show Parse Tree

* Open the VBA file you want to debug.
* Run `Debug ANTLR4 grammar` from launch configurations.

### Debug Rule

* Open the grammar file.
* Right click a rule and choose an option from the context menu.
* Show Railroad Diagram for Rule
* Show ATN Graph for Rule

The grammar call graph is interesting, but not particularly useful. Generating "valid" input generates garbage.
Binary file added images/vba-lsp-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/vba-lsp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "vba-lsp",
"description": "A language server for VBA",
"displayName": "VBA Pro",
"description": "A VBA extension for VSCode with Language Server support",
"icon": "images/vba-lsp-icon.png",
"author": "SSlinky",
"license": "MIT",
"version": "1.0.0",
"version": "1.1.0",
"repository": {
"type": "git",
"url": "https://github.com/SSlinky/TBC"
"url": "https://github.com/SSlinky/VBA-LanguageServer"
},
"publisher": "SSlinky",
"publisher": "NotisDataAnalytics",
"categories": [
"Programming Languages",
"Snippets",
Expand All @@ -22,14 +24,12 @@
"vscode": "^1.63.0"
},
"main": "./client/out/extension",
"activationEvents": [],
"contributes": {
"languages": [
{
"id": "vba",
"aliases": [
"VBA",
"vba"
],
"aliases": ["VBA"],
"extensions": [
".bas",
".cls",
Expand All @@ -38,6 +38,11 @@
"configuration": "./vba.language-configuration.json"
}
],
"configurationDefaults": {
"[vba]": {
"editor.semanticHighlighting.enabled": true
}
},
"configuration": {
"type": "object",
"title": "Default configuration",
Expand Down
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions server/src/antlr/vba.g4
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ grammar vba;
startRule: module EOF;

module:
WS? (endOfLine | unknownLine)* (moduleHeader endOfLine*)? moduleConfig? endOfLine*
moduleAttributes? endOfLine* moduleDeclarations? endOfLine* moduleBody? endOfLine* WS?;
WS? moduleHeader
moduleBody? endOfLine* WS?;

moduleHeader: VERSION WS DOUBLELITERAL WS CLASS;
moduleHeader:
(endOfLine | unknownLine)*
(moduleVerson endOfLine*)?
moduleConfig? endOfLine*
moduleAttributes? endOfLine*
moduleDeclarations? endOfLine*;

moduleVerson: VERSION WS DOUBLELITERAL WS CLASS;

moduleConfig: BEGIN endOfLine* moduleConfigElement+ END;

Expand All @@ -44,14 +51,8 @@ moduleOption:
moduleDeclarationsElement:
comment
| declareStmt
| enumerationStmt
| eventStmt
| constStmt
| implementsStmt // TODO : not valid in a module!!!
| variableStmt
| implementsStmt
| moduleOption
| typeStmt
| macroStmt
| unknownLine;

macroStmt: macroConstStmt | macroIfThenElseStmt;
Expand All @@ -60,9 +61,14 @@ moduleBody:
moduleBodyElement (endOfLine+ moduleBodyElement)* endOfLine*;

moduleBodyElement:
methodStmt
constStmt
| enumerationStmt
| eventStmt
| macroStmt
| methodStmt
| propertyStmt
| macroStmt;
| typeStmt
| variableStmt;

// block ----------------------------------

Expand Down
6 changes: 6 additions & 0 deletions server/src/capabilities/diagnostics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { TextDocumentClientCapabilities } from 'vscode-languageserver';


function hasDiagnosticRelatedInformationCapability(x: TextDocumentClientCapabilities) {
return !!(x && x.publishDiagnostics && x.publishDiagnostics.relatedInformation);
}
Loading