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 { parseMixed } from '@lezer/common'
|
||||
import { javascriptLanguage } from '@codemirror/lang-javascript'
|
||||
import { javascriptCompletionSources } from '../javascriptLang'
|
||||
import { javascriptCompletionSupport } from '../javascriptLang'
|
||||
import {
|
||||
xmlLanguage,
|
||||
completeFromSchema,
|
||||
@ -105,8 +105,6 @@ export function fcTemplateLang(options = {}) {
|
||||
)
|
||||
}),
|
||||
autoCloseTags,
|
||||
javascriptLanguage.data.of({
|
||||
autocomplete: javascriptCompletionSources(jsScope)
|
||||
})
|
||||
...javascriptCompletionSupport(jsScope)
|
||||
])
|
||||
}
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
import { completeFromList } from '@codemirror/autocomplete'
|
||||
import {
|
||||
javascript,
|
||||
javascriptLanguage,
|
||||
localCompletionSource,
|
||||
scopeCompletionSource,
|
||||
snippets
|
||||
scopeCompletionSource
|
||||
} from '@codemirror/lang-javascript'
|
||||
import { nodeJsScope } from './nodeScope.js'
|
||||
|
||||
@ -31,14 +28,20 @@ export function nodeScopeCompletionSource(autoCompleteObject) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Completions for mixed languages that mount `javascriptLanguage`
|
||||
* without `javascript()` (snippets + locals + Node globals).
|
||||
* Support extensions for mixed languages that mount
|
||||
* `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 [
|
||||
completeFromList(snippets),
|
||||
localCompletionSource,
|
||||
nodeScopeCompletionSource(autoCompleteObject)
|
||||
javascript().support,
|
||||
javascriptLanguage.data.of({
|
||||
autocomplete: nodeScopeCompletionSource(autoCompleteObject)
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user