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

How to have intellisense for a language ? (in Nextjs) #560

Closed
dev265545 opened this issue Nov 27, 2023 · 2 comments
Closed

How to have intellisense for a language ? (in Nextjs) #560

dev265545 opened this issue Nov 27, 2023 · 2 comments

Comments

@dev265545
Copy link

No description provided.

@suren-atoyan
Copy link
Owner

You have IntelliSense for the following languages out of the box:

  • TypeScript
  • JavaScript
  • CSS
  • LESS
  • SCSS
  • JSON
  • HTML

For all other supported languages, you have only syntax highlighting, so you have to implement IntelliSense by yourself by using an appropriate LSP or doing it manually by using a completion provider

@ansh
Copy link

ansh commented Aug 14, 2024

How do I integrate Shiki highlighter? @suren-atoyan

I'm currently doing it in handleEditorWillMount like this:

  const handleEditorWillMount: BeforeMount = async (monaco) => {
    // SETUP SHIKI HIGHLIGHTER
    // Create the highlighter, it can be reused
    const highlighter = await createHighlighter({
      themes: ["slack-dark", "vitesse-dark", "vitesse-light"],
      langs: ["javascript", "typescript", "css", "html", "json"],
    })
    // Register the languageIds first. Only registered languages will be highlighted.
    monaco.languages.register({ id: "typescript" })
    monaco.languages.register({ id: "javascript" })
    monaco.languages.register({ id: "css" })
    monaco.languages.register({ id: "html" })
    monaco.languages.register({ id: "json" })
    // Register the themes from Shiki, and provide syntax highlighting for Monaco.
    shikiToMonaco(highlighter, monaco)

    monaco.editor.addKeybindingRules([
      {
        keybinding: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyG,
        command: "null",
      },
    ])
  }

But this has a delay so it doesn't work properly. If I save highlighter into a state variable, then it doesn't work either.

Any workarounds since createHighlighter is async?

I opened a new issue for it here: #641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants