Skip to content

Commit

Permalink
feat(core): add icon for completion items
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW committed Aug 10, 2024
1 parent ad6474e commit 81d52ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/core/src/plugins/expression-quick-completions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { definePlugin } from '@shikitor/core'
import type {} from '@shikitor/core/plugins/provide-completions'
import { CompletionItemKind } from '@shikitor/core/plugins/provide-completions'

export default definePlugin({
name: 'expression-quick-completions',
Expand Down Expand Up @@ -32,12 +33,14 @@ export default definePlugin({
return {
suggestions: [
{
kind: CompletionItemKind.Operator,
label: 'par',
detail: '(expr)',
range,
insertText: `(${expressionStr})`
},
{
kind: CompletionItemKind.Operator,
label: 'not',
detail: '!expr',
range,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/plugins/provide-completions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ function completionItemTemplate(
index: number
) {
const { prefix } = completionItemTemplate
const kind = item.kind ? CompletionItemKind[item.kind]?.[0] ?? 'U' : 'U'
return `
<div class="${classnames(prefix, selectedIndex === index && 'selected')}" data-index="${index}">
<div class="${prefix}__kind">${item.kind ? CompletionItemKind[item.kind][0] : 'U'}</div>
<div class="${prefix}__kind">${kind}</div>
<div class="${prefix}__label">${highlightingKeyword(item.label, keywordParts)}</div>
${item.detail ? `<div class="${prefix}__detail">${item.detail}</div>` : ''}
${item.documentation ? `<div class="${prefix}__documentation">${item.documentation}</div>` : ''}
Expand Down

0 comments on commit 81d52ba

Please sign in to comment.