title: How to dynamically set language according to file extension in monaco editor?
body: <p>I am working on monaco-editor to show content of local code files, which may be written in various languages, so I am wondering how to dynamically set/change language of monaco editor according to the extension of file, or the first line of file without extension (like #!/usr/bin/env python).</p>
  
  <p>Seems that monaco-editor itself does not come with this feature, but the VSCode does apparently.</p>
  
  <p>I want to define such a method called checkLanguage(file_path), which takes a file path and returns the string that represents the language supported by monaco-editor. If the language cannot be determined, just return plain text.</p>
  
  <pre class="lang-js prettyprint-override"><code>monaco.editor.setModelLanguage(model, checkLanguage(file_path))
  </code></pre>
  
  <p>Supported languages: <a href="https://github.com/microsoft/monaco-languages" rel="noreferrer">https://github.com/microsoft/monaco-languages</a></p>