Teradata / covalent

Teradata UI Platform built on Angular Material
https://teradata.github.io/covalent/
MIT License
2.23k stars 358 forks source link

auto complete #1619

Open ng2dev opened 5 years ago

ng2dev commented 5 years ago

as the name suggest -

how would it be possible to load custom auto-completions, best at runtime, so depending what ngModel and/or language option of the editor holds. In short, it would be cool to load auto-suggest commands. It bothers a bit that it always show no suggestions. Does anybody have an idea how this might be achieved? Thanks

Kedyn commented 5 years ago

If you are registering custom languages: on your language object, completionItemProvider property you must wrap them inside a suggestions array, example:

var language: any = {
  id: 'myLanguage',
  monarchTokensProvider: [
    ....
  ],
  ...
  completionItemProvider: {
    suggestions: [
      {
        label: 'simpleText',
        kind: 'monaco.languages.CompletionItemKind.Text',
        insertText: 'simpleText'
      },
      ...
    ]
  }
}

I also suggest looking up monaco.languages.Completition.... objects values because we do not have access to monaco instance. For example: instead of kind: 'monaco.languages.CompletionItemKind.Text', should be: kind: 18, kind should take in an integer not a string. see https://microsoft.github.io/monaco-editor/api/enums/monaco.languages.completionitemkind.html#text

hope this helps