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: add initial intellisense #226

Merged
merged 88 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
c359e8d
feat: add initial intellisense
remcohaszing Aug 26, 2022
665ac34
chore(monaco): replace Vite with Webpack
remcohaszing Sep 15, 2022
e2dae5d
feat: add TypeScript based hovers
remcohaszing Sep 22, 2022
471109d
feat: enhance TypeScript integration
remcohaszing Sep 30, 2022
adbbf39
feat: implement more intellisense features
remcohaszing Oct 9, 2022
a907d6d
feat: support diagnostics
remcohaszing Oct 10, 2022
bdcf240
feat: restore support for markdown link definition
remcohaszing Oct 11, 2022
da93ff1
fix: fix LSP definitions
remcohaszing Oct 11, 2022
14481ca
chore: some cleanups
remcohaszing Oct 11, 2022
a18dcde
feat: provide completions
remcohaszing Oct 12, 2022
73bee60
chore: move convert functions into separate modules
remcohaszing Oct 12, 2022
44024c0
chore: move processor into language service
remcohaszing Oct 12, 2022
682256f
feat: support completion in the language server
remcohaszing Oct 13, 2022
b00be7f
chore: support references in language server
remcohaszing Oct 14, 2022
ae30c6d
feat: support diagnosics in language server
remcohaszing Oct 14, 2022
7dcc219
fix: fix language service management
remcohaszing Oct 15, 2022
c94b3a6
refactor: use TypeScript’s builtin displayPartsToString
remcohaszing Oct 15, 2022
2990c31
refactor: remove console.log
remcohaszing Oct 15, 2022
7b8eec5
fix: display location links for unopened files
remcohaszing Oct 16, 2022
91c4856
refactor: use helper function to create internal host
remcohaszing Oct 18, 2022
1f113ae
chore: update yarn.lock
remcohaszing Oct 19, 2022
01f9ee7
fix: fix module resolution and caching issues
remcohaszing Oct 21, 2022
ef57e01
refactor: remove useless function body
remcohaszing Oct 21, 2022
8ad411c
fix: fix for Monaco editor
remcohaszing Oct 21, 2022
04769a0
fix: handle parsing errors
remcohaszing Oct 24, 2022
a799ce6
docs: add readmes, licenses, and package metadata
remcohaszing Oct 25, 2022
0250ef6
chore: enable v8 --nolazy when debuggin
remcohaszing Oct 27, 2022
503c1e1
fix: add MDX snapshot caching
remcohaszing Nov 8, 2022
57de2ae
fix: fix position mapping
remcohaszing Nov 10, 2022
1704c32
feat: support renaming symbols
remcohaszing Nov 10, 2022
fa783d7
Merge branch 'master' into intellisense
remcohaszing Nov 10, 2022
5ce1c3a
feat: support type definitions
remcohaszing Nov 11, 2022
7a86603
feat: implement folding ranges
remcohaszing Nov 11, 2022
a30983a
Update packages/monaco/README.md
remcohaszing Nov 17, 2022
4e8fae8
feat: support based markdown code folding
remcohaszing Nov 11, 2022
d744406
feat: provide document outline based on TypeScript
remcohaszing Nov 11, 2022
a641641
chore: remove unnecessary CSS unit
remcohaszing Nov 17, 2022
505bd53
test: add initial language server tests
remcohaszing Nov 24, 2022
65a38b9
fix: filter MDXContent from document symbols
remcohaszing Nov 24, 2022
c3c5c64
chore: update @types/node
remcohaszing Nov 24, 2022
bbf2ab9
chore: update is-core-module
remcohaszing Nov 24, 2022
39088e2
test: add tests for prepare-rename-request
remcohaszing Nov 25, 2022
90d11ff
test: add test for rename request
remcohaszing Nov 25, 2022
88fe16b
fix: fix resolving JSX runtimes
remcohaszing Dec 1, 2022
82a2996
fix: fix React types in the Monaco demo
remcohaszing Dec 2, 2022
98b71b1
chore: move demo and test fixtures into shared directory
remcohaszing Dec 8, 2022
16e1bb0
chore: fix debug launch script
remcohaszing Dec 8, 2022
331760a
chore: fix packaging quirks
remcohaszing Dec 22, 2022
9f185d7
Merge branch 'master' into intellisense
remcohaszing Dec 22, 2022
2b30787
Merge branch 'master' into intellisense
remcohaszing Dec 22, 2022
586c8fd
Merge branch 'master' into intellisense
remcohaszing Dec 23, 2022
b30846e
Refactor Monaco integration and add tests
remcohaszing Dec 23, 2022
9b1979a
Merge branch 'master' into intellisense
remcohaszing Dec 29, 2022
8fa2b0c
Fix tests
remcohaszing Dec 29, 2022
4ff0cc9
Merge branch 'main' into intellisense
remcohaszing Dec 29, 2022
cb19bff
Fix broken test
remcohaszing Dec 29, 2022
380afa8
Fix playwright install in CI
remcohaszing Dec 29, 2022
63d331e
Make language server opt-in
remcohaszing Dec 29, 2022
12a7a1c
Disable macos tests
remcohaszing Dec 29, 2022
c95ea7a
Disable Windows in CI
remcohaszing Dec 30, 2022
c1d2a04
Increase language server test timeout
remcohaszing Dec 30, 2022
e3739bb
Update README.md
remcohaszing Dec 30, 2022
2862a05
Change casing of MDX in function names
remcohaszing Dec 30, 2022
095bc46
Remove commented code
remcohaszing Dec 30, 2022
fbdda07
Update packages/language-server/README.md
remcohaszing Dec 30, 2022
faaf0e4
Apply suggestions from code review
remcohaszing Dec 30, 2022
45d01a7
Include specific extensions in demo
remcohaszing Dec 30, 2022
fdf784b
Fix IntelliSense casing
remcohaszing Dec 30, 2022
5c2dcd8
Use strict assertion mode
remcohaszing Dec 30, 2022
80ed300
Update packages/language-service/README.md
remcohaszing Dec 30, 2022
6c1a8f2
Update packages/language-service/lib/utils.js
remcohaszing Dec 30, 2022
cac60c4
Reduce boilerplate for unimplemented code
remcohaszing Dec 30, 2022
8e86b1a
Include TypeScript in the extension bundle
remcohaszing Dec 30, 2022
7f373b6
Fix some type issues
remcohaszing Jan 5, 2023
f9e8dc4
Update jsdoc
remcohaszing Jan 6, 2023
40fffdc
Fix spacing issue
remcohaszing Jan 6, 2023
7ffbaf9
Add changeset for IntelliSense
remcohaszing Jan 6, 2023
b8ef978
Set language server process title
remcohaszing Jan 6, 2023
f5cf2aa
Omit source map from production build
remcohaszing Jan 6, 2023
77d95d5
Fix IntelliSense casing
remcohaszing Jan 6, 2023
d8e8e5e
Explain MDX/TypeScript snapshot synchronization
remcohaszing Jan 6, 2023
3ff1e0c
Add readme and license to demo
remcohaszing Jan 6, 2023
0c0c981
Explain why Windows tests are disabled
remcohaszing Jan 6, 2023
c076303
Explain how one can verity MDX intellisense is working
remcohaszing Jan 6, 2023
5af2c05
Add explanations to the Monaco editor demo
remcohaszing Jan 12, 2023
23a22e2
Configure xo env
remcohaszing Jan 12, 2023
87ebb52
Include builtin TypeScript libs in VSCode bundle
remcohaszing Jan 12, 2023
ad45694
Fix .vscodeignore
remcohaszing Jan 12, 2023
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
10 changes: 10 additions & 0 deletions .changeset/intellisense.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'vscode-mdx': minor
---

Add experimental IntelliSense

To enable IntelliSense, set `mdx.experimentalLanguageServer` to `true` in your
VSCode settings.
remcohaszing marked this conversation as resolved.
Show resolved Hide resolved
You can verify it’s enabled by interacting with the JavaScript parts on an MDX
document, for example by hovering an import or variable
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx playwright install --with-deps
- run: npm test
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
remcohaszing marked this conversation as resolved.
Show resolved Hide resolved
# We should test on Windows, because the language server deals with
# the file system.
# Currently blocked by https://github.com/remcohaszing/playwright-monaco/issues/1
# - windows-latest
node:
- 18
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
*.tsbuildinfo
*.vsix
.vscode-test/
dist/
node_modules/
out/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
out/
*.md
*.mdx
27 changes: 26 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,32 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
"args": [
"--profile-temp",
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/fixtures/fixtures.code-workspace"
],
"presentation": {
"hidden": true
}
},
{
"name": "Debug language server",
"type": "node",
"request": "attach",
"port": 6009,
"presentation": {
"hidden": true
},
"skipFiles": ["<node_internals>/**", "**/node_modules/vscode-*/**"]
}
],
"compounds": [
{
"preLaunchTask": "build",
"name": "Extension + Language server",
"configurations": ["Run Extension", "Debug language server"],
"stopAll": true
}
]
}
19 changes: 19 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "npm",
"args": ["run", "build", "--", "--sourcemap"],
"label": "build",
"presentation": {
"clear": true,
"echo": true
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Adds language support for [MDX][].

You can install this extension from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx).

## Settings

This extension provides the following settings:

* `mdx.experimentalLanguageServer`: Enable experimental IntelliSense support
for MDX files. (`boolean`, default: false)

## Integration With [VS Code ESLint](https://github.com/microsoft/vscode-eslint)

1. First of all, you need to enable [eslint-plugin-mdx][] which makes it
Expand Down
21 changes: 21 additions & 0 deletions demo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Remco Haszing <remcohaszing@gmail.com>

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.
52 changes: 52 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Demo of `@mdx-js/monaco`

## What is this?

This is a project to demo the `@mdx-js/monaco` package using [webpack][].
When started, this starts a webserver that serves Monaco editor and a file tree.
The contents of the `fixtures/demo` directory are loaded into [Monaco editor][].

## When should I use this?

You can use this demo to troubleshoot issues related to `@mdx-js/monaco`, or to
see how it can be integrated in your own project.

## Use

Clone and install this repository.

```sh
git clone https://github.com/mdx-js/vscode-mdx.git
cd vscode-mdx
npm install
```

Now start it.

```sh
npm start
```

This will serve the demo on <http://localhost:8080>.

## Compatibility

This demo is compatible with evergreen browsers.

## Security

The demo only uses local content.
No external resources are loaded.
It’s safe to run and open.

## License

[MIT][] © [Remco Haszing][author]

[author]: https://github.com/remcohaszing

[mit]: LICENSE

[monaco editor]: https://github.com/microsoft/monaco-editor

[webpack]: https://webpack.js.org
21 changes: 21 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
remcohaszing marked this conversation as resolved.
Show resolved Hide resolved
"name": "@mdx-js/monaco-demo",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"build": "tsc",
"start": "webpack serve --mode development"
},
"dependencies": {
"@mdx-js/monaco": "*",
ChristianMurphy marked this conversation as resolved.
Show resolved Hide resolved
"@types/webpack-env": "^1.0.0",
"css-loader": "^6.0.0",
"html-webpack-plugin": "^5.0.0",
"mini-css-extract-plugin": "^2.0.0",
"monaco-editor": "^0.34.0",
"webpack": "^5.0.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.0.0"
}
}
160 changes: 160 additions & 0 deletions demo/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
:root {
--background-color: hsl(0, 0%, 96%);
--editor-background: hsl(60, 100%, 100%);
--error-color: hsl(0, 85%, 62%);
--foreground-color: hsl(0, 0%, 0%);
--primary-color: hsl(189, 100%, 63%);
--shadow-color: hsla(0, 0%, 27%, 0.239);
--scrollbar-color: hsla(0, 0%, 47%, 0.4);
--warning-color: hsl(49, 100%, 40%);
}

@media (prefers-color-scheme: dark) {
:root {
--background-color: hsl(0, 0%, 23%);
--editor-background: hsl(0, 0%, 12%);
--foreground-color: hsl(0, 0%, 100%);
--shadow-color: hsl(0, 0%, 43%);
}
}

body {
background: var(--background-color);
display: flex;
flex-flow: column;
font-family: sans-serif;
height: 100vh;
margin: 0;
}

h1 {
margin: 0 auto 0 1rem;
}

.navbar {
align-items: center;
background: var(--primary-color);
box-shadow: 0 5px 5px var(--shadow-color);
display: flex;
flex: 0 0 auto;
height: 3rem;
justify-content: space-between;
}

.nav-icon {
margin-right: 1rem;
text-decoration: none;
}

.nav-icon > img {
vertical-align: middle;
}

main {
background: var(--editor-background);
box-shadow: 0 0 10px var(--shadow-color);
display: flex;
flex: 1 1 auto;
margin: 1.5rem;
}

#files {
border-right: 1px solid var(--shadow-color);
color: var(--foreground-color);
list-style: none;
margin: 0;
padding: 2rem 0;
}

#files a {
color: var(--foreground-color);
display: block;
padding: 0.25rem 1rem 0.25rem 0.5rem;
text-decoration: none;
}

#files a:hover,
#files a:target {
background: var(--shadow-color);
}

.wrapper {
display: flex;
flex: 1 1 auto;
flex-flow: column;
}

#schema-selection {
background-color: var(--editor-background);
border: none;
border-bottom: 1px solid var(--shadow-color);
color: var(--foreground-color);
width: 100%;
}

#breadcrumbs {
border-bottom: 1px solid var(--shadow-color);
color: var(--foreground-color);
flex: 0 0 1rem;
}

.breadcrumb {
cursor: pointer;
}

#breadcrumbs::before,
.breadcrumb:not(:last-child)::after {
content: '›';
margin: 0 0.2rem;
}

.breadcrumb.array::before {
content: '[]';
}

.breadcrumb.object::before {
content: '{}';
}

#editor {
flex: 1 1 auto;
}

#problems {
border-top: 1px solid var(--shadow-color);
flex: 0 0 20vh;
color: var(--foreground-color);
overflow-y: scroll;
}

.problem {
align-items: center;
cursor: pointer;
display: flex;
padding: 0.25rem;
}

.problem:hover {
background-color: var(--shadow-color);
}

.problem-text {
margin-left: 0.5rem;
}

.problem .codicon-warning {
color: var(--warning-color);
}

.problem .codicon-error {
color: var(--error-color);
}

*::-webkit-scrollbar {
box-shadow: 1px 0 0 0 var(--scrollbar-color) inset;
width: 14px;
}

*::-webkit-scrollbar-thumb {
background: var(--scrollbar-color);
}
28 changes: 28 additions & 0 deletions demo/src/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Monaco MDX</title>
<meta
name="description"
content="MDX support for Monaco editor"
/>
<meta
name="theme-color"
content="#42e3ff"
/>
</head>
<body>
<nav class="navbar">
<h1>Monaco MDX</h1>
</nav>
<main>
<nav id="files"></nav>
<div class="wrapper">
<div id="breadcrumbs"></div>
<div id="editor"></div>
<div id="problems"></div>
</div>
</main>
</body>
</html>
Loading