Skip to content

Commit

Permalink
refactor(autocomplete): update README
Browse files Browse the repository at this point in the history
  • Loading branch information
baurine committed Jun 29, 2024
1 parent 8e95372 commit 2ec603f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ https://github.com/tidbcloud/tisqleditor/assets/1284531/732b600f-5b4e-45d3-a3d2-
| @tidbcloud/codemirror-extension-sql-parser | parse the editor content to SQL statements |
| @tidbcloud/codemirror-extension-cur-sql | get the selected SQL statements |
| @tidbcloud/codemirror-extension-cur-sql-gutter | show gutter for the selected SQL statements |
| @tidbcloud/codemirror-extension-save-helper | save the editor content if it changes |
| @tidbcloud/codemirror-extension-sql-autocomplete | SQL keyword and database schema autocomplete tips |
| @tidbcloud/codemirror-extension-linters | use db statement, full width chars, and regular expression linters |
| @tidbcloud/codemirror-extension-save-helper | save the editor content if it changes |
| @tidbcloud/codemirror-extension-events | 2 normal kinds of event listener: doc change, selection change |
| @tidbcloud/codemirror-extension-themes | 2 simple builtin themes, `bbedit` for light mode, `oneDark` for dark mode |
| @tidbcloud/codemirror-extension-basic-setup | basic configuration for the CodeMirror6 code editor |
Expand All @@ -49,7 +49,7 @@ import {
useDbLinter,
fullWidthCharLinter
} from '@tidbcloud/codemirror-extension-linters'
import { autoCompletion } from '@tidbcloud/codemirror-extension-sql-autocomplete'
import { sqlAutoCompletion } from '@tidbcloud/codemirror-extension-sql-autocomplete'
import {
aiWidget,
isUnifiedMergeViewActive
Expand All @@ -62,7 +62,7 @@ export function Editor() {
saveFile(activeFile.id, view.state.doc.toString())
}
}),
autoCompletion(),
sqlAutoCompletion(),
curSqlGutter({
whenHide: (view) => {
return isUnifiedMergeViewActive(view.state)
Expand Down
11 changes: 5 additions & 6 deletions packages/extensions/sql-autocomplete/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @tidbcloud/codemirror-extension-sql-autocomplete

This extension implements the SQL autocompletion based @codemirror/autocomplete for the CodeMirror6 editor.
This extension implements the SQL keyword and database schema autocompletion based `@codemirror/autocomplete` for the CodeMirror6 editor, with a customized style.

## Installation

Expand All @@ -19,7 +19,7 @@ npm install @codemirror/view @codemirror/state @codemirror/autocomplete @codemir
```ts
import { EditorView } from '@codemirror/view'
import { EditorState } from '@codemirror/state'
import { autoCompletion, AutoCompletionConfig } from '@tidbcloud/codemirror-extension-sql-autocomplete'
import { sqlAutoCompletion, AutoCompletionConfig } from '@tidbcloud/codemirror-extension-sql-autocomplete'

const autoCompleteConfig = {
acceptKey: 'Tab',
Expand All @@ -30,16 +30,15 @@ const autoCompleteConfig = {
const editorView = new EditorView({
state: EditorState.create({
doc,
extensions: [autoCompletion(autoCompleteConfig)]
extensions: [sqlAutoCompletion(autoCompleteConfig)]
})
})
```

## API

```ts
// DefaultCompletionConfig configs please refer to: https://codemirror.net/docs/ref/#autocomplete.autocompletion

/* DefaultCompletionConfig configs please refer to: https://codemirror.net/docs/ref/#autocomplete.autocompletion */
interface AutoCompletionConfig extends DefaultCompletionConfig {
/**
accept the completion by pressing the key, defult is Tab
Expand All @@ -59,5 +58,5 @@ interface AutoCompletionConfig extends DefaultCompletionConfig {
renderIconMap?: Record<string, string>
}

function autoCompletion(config?: AutoCompletionConfig): Extension
function sqlAutoCompletion(config?: AutoCompletionConfig): Extension
```

0 comments on commit 2ec603f

Please sign in to comment.