Search code examples
pythonautocompletecodemirror

Autocomplete for Python in Codemirror?


I am trying to set up an autocomplete feature for Codemirror for the Python language. Unfortunately, it seems that Codemirror only includes the files necessary for Javascript key term completion.

Has anyone built Python hint file for CodeMirror similar to the JavaScript Version?

(Edit for future reference: link to similar question on CodeMirror Google Group)


Solution

  • I start the python autocomplete with a js based on pig-hint from codemirror 3.

    You can get the python-hint.js from here.

    to work, you need in your html:

    1. include simple-hint,js and python-hint.js, simple-hint.css plus codemirror.js

    2. add this script:

      <script>
      CodeMirror.commands.autocomplete = function(cm) {
           CodeMirror.simpleHint(cm, CodeMirror.pythonHint);
         }
      </script>
      

    python-hint.js is a basic js I have created today and not reviewed in depth.