Skip to content

Commit

Permalink
feat: sql suggestions in query editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Aug 21, 2020
1 parent 256ec76 commit 8dc74ef
Show file tree
Hide file tree
Showing 8 changed files with 6,153 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/renderer/components/QueryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@
<script>
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { completionItemProvider } from '@/suggestions/sql';
monaco.languages.registerCompletionItemProvider('sql', {
provideCompletionItems: () => {
const suggestions = [// TODO: complete in a separate file
{
label: 'SELECT',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: 'SELECT'
}
];
return { suggestions };
}
});
monaco.languages.registerCompletionItemProvider('sql', completionItemProvider(monaco));
export default {
name: 'QueryEditor',
Expand All @@ -42,9 +31,9 @@ export default {
enabled: false
},
contextmenu: false,
wordBasedSuggestions: true,
acceptSuggestionOnEnter: 'smart',
quickSuggestions: true,
wordBasedSuggestions: true
quickSuggestions: true
});
this.editor.onDidChangeModelContent(e => {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/scss/_data-types.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"blob": darkorchid,
"mediumblob": darkorchid,
"longblob": darkorchid,
"enum": gold,
"set": gold,
"unknown": gray,
)
);
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ body {

.tab {
border-color: #272727;

.tab-item {
.btn-clear {
margin-top: -0.1rem;
font-size: 0.6rem;
}
}
}

.panel {
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/suggestions/sql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { functions } from '@/suggestions/sql/sql-functions';
import { keywords } from '@/suggestions/sql/sql-keywords';
import { operators } from '@/suggestions/sql/sql-operators';
import { variables } from '@/suggestions/sql/sql-variables';

export const completionItemProvider = (monaco) => {
return {
provideCompletionItems () {
return { suggestions: [...functions(monaco), ...keywords(monaco), ...operators(monaco), ...variables(monaco)] };
}
};
};
Loading

0 comments on commit 8dc74ef

Please sign in to comment.