-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: changeset * nit: add a warning message when failing to load the config * nit: also log it to the console * chore: changeset
- Loading branch information
1 parent
97c422b
commit c1fa115
Showing
12 changed files
with
153 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@astrojs/language-server": patch | ||
"astro-vscode": patch | ||
--- | ||
|
||
Fixes `.prettierignore` and `.editorconfig` not working correctly. This update also improves the error logging around Prettier, the LSP will now warn when it failed to load the Prettier config. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = false | ||
|
||
[{.*,*.md,*.json,*.toml,*.yml,*.yaml}] | ||
indent_style = space | ||
# https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = false | ||
|
||
[{.*,*.md,*.json,*.toml,*.yml,*.yaml}] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dontFormat.astro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
--- | ||
|
||
<div> | ||
|
||
|
||
Hello</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
<div></div> | ||
</div> |
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/language-server/test/misc/prettier-format.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as path from 'node:path'; | ||
import { Range } from '@volar/language-server'; | ||
import { expect } from 'chai'; | ||
import { describe } from 'mocha'; | ||
import { type LanguageServer, getLanguageServer } from '../server.js'; | ||
|
||
describe('Formatting - Prettier', () => { | ||
let languageServer: LanguageServer; | ||
|
||
before(async () => (languageServer = await getLanguageServer())); | ||
|
||
it('Can format document', async () => { | ||
const document = await languageServer.openFakeDocument(`---\n\n\n---`, 'astro'); | ||
const formatEdits = await languageServer.handle.sendDocumentFormattingRequest(document.uri, { | ||
tabSize: 2, | ||
insertSpaces: true, | ||
}); | ||
|
||
expect(formatEdits).to.deep.equal([ | ||
{ | ||
range: Range.create(0, 0, 3, 3), | ||
newText: '---\n\n---\n', | ||
}, | ||
]); | ||
}); | ||
|
||
it('Can ignore documents correctly', async () => { | ||
const document = await languageServer.handle.openTextDocument(path.resolve(__dirname, '..', 'fixture', 'dontFormat.astro'), 'astro'); | ||
const formatEdits = await languageServer.handle.sendDocumentFormattingRequest(document.uri, { | ||
tabSize: 2, | ||
insertSpaces: true, | ||
}); | ||
|
||
expect(formatEdits).to.deep.equal(null); | ||
}); | ||
|
||
it('Respect .editorconfig', async () => { | ||
const document = await languageServer.handle.openTextDocument(path.resolve(__dirname, '..', 'fixture', 'editorConfig.astro'), 'astro'); | ||
const formatEdits = await languageServer.handle.sendDocumentFormattingRequest(document.uri, { | ||
tabSize: 2, | ||
insertSpaces: true, | ||
}); | ||
|
||
expect(formatEdits).to.deep.equal([ | ||
{ | ||
range: Range.create(0, 0, 3, 0), | ||
newText: '<div>\r\n\t<div></div>\r\n</div>\r\n' | ||
} | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as path from 'path'; | ||
import * as path from 'node:path'; | ||
import { | ||
type Diagnostic, | ||
DiagnosticSeverity, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.