Refactor JavaScript Completion Support for Enhanced Autocomplete Functionality
- Renamed the javascriptCompletionSources function to javascriptCompletionSupport for clarity. - Updated the implementation to utilize CodeMirror's built-in support for JavaScript, improving the handling of autocomplete sources. - Streamlined the integration of completion sources for mixed languages, ensuring better performance and user experience.
This commit is contained in:
parent
56b9ad9e1a
commit
699e178fa1
@ -9,7 +9,7 @@ import {
|
|||||||
import { styleTags, tags as t } from '@lezer/highlight'
|
import { styleTags, tags as t } from '@lezer/highlight'
|
||||||
import { parseMixed } from '@lezer/common'
|
import { parseMixed } from '@lezer/common'
|
||||||
import { javascriptLanguage } from '@codemirror/lang-javascript'
|
import { javascriptLanguage } from '@codemirror/lang-javascript'
|
||||||
import { javascriptCompletionSources } from '../javascriptLang'
|
import { javascriptCompletionSupport } from '../javascriptLang'
|
||||||
import {
|
import {
|
||||||
xmlLanguage,
|
xmlLanguage,
|
||||||
completeFromSchema,
|
completeFromSchema,
|
||||||
@ -105,8 +105,6 @@ export function fcTemplateLang(options = {}) {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
autoCloseTags,
|
autoCloseTags,
|
||||||
javascriptLanguage.data.of({
|
...javascriptCompletionSupport(jsScope)
|
||||||
autocomplete: javascriptCompletionSources(jsScope)
|
|
||||||
})
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
import { completeFromList } from '@codemirror/autocomplete'
|
|
||||||
import {
|
import {
|
||||||
javascript,
|
javascript,
|
||||||
javascriptLanguage,
|
javascriptLanguage,
|
||||||
localCompletionSource,
|
scopeCompletionSource
|
||||||
scopeCompletionSource,
|
|
||||||
snippets
|
|
||||||
} from '@codemirror/lang-javascript'
|
} from '@codemirror/lang-javascript'
|
||||||
import { nodeJsScope } from './nodeScope.js'
|
import { nodeJsScope } from './nodeScope.js'
|
||||||
|
|
||||||
@ -31,14 +28,20 @@ export function nodeScopeCompletionSource(autoCompleteObject) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completions for mixed languages that mount `javascriptLanguage`
|
* Support extensions for mixed languages that mount
|
||||||
* without `javascript()` (snippets + locals + Node globals).
|
* `javascriptLanguage` without `javascript()` itself (snippets,
|
||||||
|
* keywords, locals, and Node globals).
|
||||||
|
*
|
||||||
|
* Each source must be a separate `languageData` entry. CodeMirror
|
||||||
|
* treats an `autocomplete` *array* as `completeFromList` options, not
|
||||||
|
* as multiple completion sources.
|
||||||
*/
|
*/
|
||||||
export function javascriptCompletionSources(autoCompleteObject) {
|
export function javascriptCompletionSupport(autoCompleteObject) {
|
||||||
return [
|
return [
|
||||||
completeFromList(snippets),
|
javascript().support,
|
||||||
localCompletionSource,
|
javascriptLanguage.data.of({
|
||||||
nodeScopeCompletionSource(autoCompleteObject)
|
autocomplete: nodeScopeCompletionSource(autoCompleteObject)
|
||||||
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user