/codemirror-extension-inline-suggestion

A CodeMirror extension to display inline suggestions

Primary LanguageTypeScriptMIT LicenseMIT

codemirror-extension-inline-suggestion

This package implements inline suggestions for the CodeMirror code editor.

Screenshot

Install

npm install codemirror-extension-inline-suggestion --save

Usage

Edit codemirror-extension-inline-suggestion

import CodeMirror from '@uiw/react-codemirror';
import { inlineSuggestion } from 'codemirror-extension-inline-suggestion';

const fetchSuggestion = async (state) => {
  // or make an async API call here based on editor state
  return 'hello';
};

function App() {
  return (
    <CodeMirror
      value=""
      height="200px"
      extensions={[
        inlineSuggestion({
          fetchFn: fetchSuggestion,
          delay: 1000,
        }),
      ]}
    />
  );
}

export default App;

License

MIT