codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.94k stars 376 forks source link

Is it possible to have both JavaScript syntax auto-completion and custom auto-completion? #1437

Closed qzd1989 closed 2 months ago

qzd1989 commented 2 months ago

Describe the issue

I use "import { javascript } from @codemirror/lang-javascript" for JavaScript syntax autocompletion, it works well:

image

I also use "import { snippetCompletion } from @codemirror/autocomplete" for Diy function autocompletion, it works well too:

image
//my code is like this :
const snippets = [
  snippetCompletion('logError("${message}");${}', {
    label: 'logError(message: String);',
    type: 'function',
  })
];
const extensions = [
  autocompletion({
    tooltipClass: (state) => {
      return 'custom-tooltip';
    },
  }),
  javascript(),
  javascriptLanguage.data.of({
    autocomplete: snippets,
  }),
  lintGutter(),
  linter(esLint(new eslint.Linter(), eslintConfig)),
  oneDark,
];

And now I also want to have enum hints and autocompletion, I don't know how to get it:

image

thank you, sir.

Browser and platform

No response

Reproduction link

No response

marijnh commented 2 months ago

This is an issue tracker, and not a place for asking questions. You can try the forum. But at a glance, I don't see why completeFromList wouldn't work for those completions.