Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
"typescript": "*",
"vscode-css-languageservice": "4.2.0",
"vscode-emmet-helper": "1.2.17",
"vscode-html-languageservice": "3.0.4-next.15",
"vscode-html-languageservice": "3.1.4",
"vscode-languageserver": "6.1.1",
"vscode-languageserver-types": "3.15.1",
"vscode-uri": "2.1.2"
},
"resolutions": {
"vscode-languageserver-types": "3.15.1"
}
}
37 changes: 33 additions & 4 deletions packages/language-server/src/plugins/html/HTMLPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { EmmetConfiguration, getEmmetCompletionParticipants } from 'vscode-emmet-helper';
import { getLanguageService, HTMLDocument } from 'vscode-html-languageservice';
import {
getLanguageService,
HTMLDocument,
CompletionItem as HtmlCompletionItem
} from 'vscode-html-languageservice';
import {
CompletionList,
Hover,
Position,
SymbolInformation,
CompletionItem,
CompletionItemKind
CompletionItemKind,
TextEdit
} from 'vscode-languageserver';
import {
DocumentManager,
Expand All @@ -20,7 +25,10 @@ import { HoverProvider, CompletionsProvider } from '../interfaces';

export class HTMLPlugin implements HoverProvider, CompletionsProvider {
private configManager: LSConfigManager;
private lang = getLanguageService({ customDataProviders: [svelteHtmlDataProvider] });
private lang = getLanguageService({
customDataProviders: [svelteHtmlDataProvider],
useDefaultDataProvider: false
});
private documents = new WeakMap<Document, HTMLDocument>();
private styleScriptTemplate = new Set(['template', 'style', 'script']);

Expand Down Expand Up @@ -84,13 +92,34 @@ export class HTMLPlugin implements HoverProvider, CompletionsProvider {
// Other attributes/events would be false positives.
CompletionList.create([])
: this.lang.doComplete(document, position, html);
const items = this.toCompletionItems(results.items);
return CompletionList.create(
[...results.items, ...this.getLangCompletions(results.items), ...emmetResults.items],
[
...this.toCompletionItems(items),
...this.getLangCompletions(items),
...emmetResults.items
],
// Emmet completions change on every keystroke, so they are never complete
emmetResults.items.length > 0
);
}

/**
* The HTML language service uses newer types which clash
* without the stable ones. Transform to the stable types.
*/
private toCompletionItems(items: HtmlCompletionItem[]): CompletionItem[] {
return items.map((item) => {
if (!item.textEdit || TextEdit.is(item.textEdit)) {
return <CompletionItem>item;
}
return {
...item,
textEdit: TextEdit.replace(item.textEdit.replace, item.textEdit.newText)
};
});
}

private isInComponentTag(html: HTMLDocument, document: Document, position: Position) {
return !!getNodeIfIsInComponentStartTag(html, document.offsetAt(position));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('HTML Plugin', () => {
contents: {
kind: 'markdown',
value:
'```html\n<h1>\n```\nThe h1 element represents a section heading.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/HTML/Element/Heading_Elements)'
'The h1 element represents a section heading.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/HTML/Element/Heading_Elements)'
},

range: Range.create(0, 1, 0, 3)
Expand Down
40 changes: 20 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2652,15 +2652,15 @@ vscode-emmet-helper@1.2.17:
jsonc-parser "^1.0.0"
vscode-languageserver-types "^3.6.0-next.1"

vscode-html-languageservice@3.0.4-next.15:
version "3.0.4-next.15"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.0.4-next.15.tgz#7214ccd9b4a06cf138b5945d9fd88285a0add490"
integrity sha512-UmUm3A1ZTj+BloVIyel+5pK/nfsqRfPLXzl8BA9O7v5Cj64vivddABvNf/rW1US8fzdikFNZNloC/4ooqxB2kw==
vscode-html-languageservice@3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.1.4.tgz#0316dff77ee38dc176f40560cbf55e4f64f4f433"
integrity sha512-3M+bm+hNvwQcScVe5/ok9BXvctOiGJ4nlOkkFf+WKSDrYNkarZ/RByKOa1/iylbvZxJUPzbeziembWPe/dMvhw==
dependencies:
vscode-languageserver-textdocument "^1.0.1-next.1"
vscode-languageserver-types "^3.15.1"
vscode-nls "^4.1.1"
vscode-uri "^2.1.1"
vscode-languageserver-textdocument "^1.0.1"
vscode-languageserver-types "3.16.0-next.2"
vscode-nls "^5.0.0"
vscode-uri "^2.1.2"

vscode-jsonrpc@^5.0.1:
version "5.0.1"
Expand All @@ -2683,7 +2683,7 @@ vscode-languageserver-protocol@3.15.3, vscode-languageserver-protocol@^3.15.3:
vscode-jsonrpc "^5.0.1"
vscode-languageserver-types "3.15.1"

vscode-languageserver-textdocument@^1.0.1, vscode-languageserver-textdocument@^1.0.1-next.1:
vscode-languageserver-textdocument@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.1.tgz#178168e87efad6171b372add1dea34f53e5d330f"
integrity sha512-UIcJDjX7IFkck7cSkNNyzIz5FyvpQfY7sdzVy+wkKN/BLaD4DQ0ppXQrKePomCxTS7RrolK1I0pey0bG9eh8dA==
Expand All @@ -2693,33 +2693,33 @@ vscode-languageserver-types@3.15.1, vscode-languageserver-types@^3.15.1, vscode-
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.15.1.tgz#17be71d78d2f6236d414f0001ce1ef4d23e6b6de"
integrity sha512-+a9MPUQrNGRrGU630OGbYVQ+11iOIovjCkqxajPa9w57Sd5ruK8WQNsslzpa0x/QJqC8kRc2DUxWjIFwoNm4ZQ==

vscode-languageserver-types@3.16.0-next.2:
version "3.16.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0-next.2.tgz#940bd15c992295a65eae8ab6b8568a1e8daa3083"
integrity sha512-QjXB7CKIfFzKbiCJC4OWC8xUncLsxo19FzGVp/ADFvvi87PlmBSCAtZI5xwGjF5qE0xkLf0jjKUn3DzmpDP52Q==

vscode-languageserver@6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-6.1.1.tgz#d76afc68172c27d4327ee74332b468fbc740d762"
integrity sha512-DueEpkUAkD5XTR4MLYNr6bQIp/UFR0/IPApgXU3YfCBCB08u2sm9hRCs6DxYZELkk++STPjpcjksR2H8qI3cDQ==
dependencies:
vscode-languageserver-protocol "^3.15.3"

vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==

vscode-nls@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==

vscode-uri@2.1.2:
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==

vscode-uri@2.1.2, vscode-uri@^2.1.1, vscode-uri@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.1.2.tgz#c8d40de93eb57af31f3c715dd650e2ca2c096f1c"
integrity sha512-8TEXQxlldWAuIODdukIb+TR5s+9Ds40eSJrw+1iDDA9IFORPjMELarNQE3myz5XIkWWpdprmJjm1/SxMlWOC8A==

vscode-uri@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.1.1.tgz#5aa1803391b6ebdd17d047f51365cf62c38f6e90"
integrity sha512-eY9jmGoEnVf8VE8xr5znSah7Qt1P/xsCdErz+g8HYZtJ7bZqKH5E3d+6oVNm1AC/c6IHUDokbmVXKOi4qPAC9A==

which-module@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
Expand Down