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(model): resolve languageID for spring-boot #5226

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions src/__tests__/modules/document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ describe('Document', () => {
await nvim.command(`edit +setl\\ filetype=txt.vim foo`)
let doc = await workspace.document
expect(doc.languageId).toBe('txt')

await nvim.command(`edit +setl\\ filetype=jproperties application.properties`)
doc = await workspace.document
expect(doc.languageId).toBe('spring-boot-properties')

await nvim.command(`edit +setl\\ filetype=jproperties bootstrap.test.properties`)
doc = await workspace.document
expect(doc.languageId).toBe('spring-boot-properties')

await nvim.command(`edit +setl\\ filetype=yaml application.yml`)
doc = await workspace.document
expect(doc.languageId).toBe('spring-boot-properties-yaml')

await nvim.command(`edit +setl\\ filetype=yaml application.test.yaml`)
doc = await workspace.document
expect(doc.languageId).toBe('spring-boot-properties-yaml')
})

it('should parse iskeyword of character range', async () => {
Expand Down
11 changes: 10 additions & 1 deletion src/model/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,16 @@ export default class Document {
*/
public get languageId(): string {
let { _filetype } = this
return _filetype.includes('.') ? _filetype.match(/(.*?)\./)[1] : _filetype
const ft = _filetype.includes('.') ? _filetype.match(/(.*?)\./)[1] : _filetype

if (ft === 'jproperties' && /(application|bootstrap).*\.properties$/.test(this._bufname)) {
return 'spring-boot-properties'
}
if (ft === 'yaml' && /(application|bootstrap).*\.ya?ml$/.test(this._bufname)) {
return 'spring-boot-properties-yaml'
}

return ft
}

/**
Expand Down
Loading