Skip to content

Commit

Permalink
feat(inlayHint): add inlayHint.position configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es authored Jun 27, 2024
1 parent e4abae7 commit bdfd169
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,13 @@
"scope": "language-overridable",
"description": "Enable inlay hint support"
},
"inlayHint.position": {
"type": "string",
"default": "inline",
"scope": "language-overridable",
"description": "Controls where to show inlay hints: inline in the text, or at the end of the line",
"enum": ["inline", "eol"]
},
"inlayHint.enableParameter": {
"type": "boolean",
"scope": "language-overridable",
Expand Down
10 changes: 10 additions & 0 deletions src/handler/inlayHint/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ import workspace from '../../workspace'

export interface InlayHintConfig {
enable: boolean
position: InlayHintPosition,
display: boolean
filetypes: string[]
refreshOnInsertMode: boolean
enableParameter: boolean
}

export enum InlayHintPosition {
Inline = "inline",
Eol = "eol",
}

let srcId: number | undefined
const debounceInterval = getConditionValue(150, 10)
const requestDelay = getConditionValue(500, 10)
Expand Down Expand Up @@ -70,6 +76,7 @@ export default class InlayHintBuffer implements SyncItem {
let changed = this._config && this._config.enable != config.enable
this._config = {
enable: config.get<boolean>('enable'),
position: config.get<InlayHintPosition>('position'),
display: config.get<boolean>('display', true),
filetypes: config.get<string[]>('filetypes'),
refreshOnInsertMode: config.get<boolean>('refreshOnInsertMode'),
Expand Down Expand Up @@ -205,6 +212,9 @@ export default class InlayHintBuffer implements SyncItem {
if (item.paddingRight) {
chunks.push(nvim.isVim ? [' ', 'Normal'] : [' '])
}
if (this.config.position == InlayHintPosition.Eol) {
col = 0
}
buffer.setVirtualText(srcId, position.line, chunks, { col, hl_mode: 'replace' })
}
nvim.resumeNotification(true, true)
Expand Down

0 comments on commit bdfd169

Please sign in to comment.