This package implements inline suggestions for the CodeMirror code editor.
npm install codemirror-extension-inline-suggestion --save
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;
MIT