Skip to content

Commit

Permalink
feat(inlayHint): add afterText option to move hints after text
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es committed Jun 27, 2024
1 parent e4abae7 commit 12dfe6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,12 @@
"scope": "language-overridable",
"description": "Enable inlay hint support"
},
"inlayHint.afterText": {
"type": "boolean",
"default": false,
"scope": "language-overridable",
"description": "Show inlay hints at the end of a line instead of in between text"
},
"inlayHint.enableParameter": {
"type": "boolean",
"scope": "language-overridable",
Expand Down
5 changes: 5 additions & 0 deletions src/handler/inlayHint/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import workspace from '../../workspace'

export interface InlayHintConfig {
enable: boolean
afterText: boolean,
display: boolean
filetypes: string[]
refreshOnInsertMode: boolean
Expand Down Expand Up @@ -70,6 +71,7 @@ export default class InlayHintBuffer implements SyncItem {
let changed = this._config && this._config.enable != config.enable
this._config = {
enable: config.get<boolean>('enable'),
afterText: config.get<boolean>('afterText'),
display: config.get<boolean>('display', true),
filetypes: config.get<string[]>('filetypes'),
refreshOnInsertMode: config.get<boolean>('refreshOnInsertMode'),
Expand Down Expand Up @@ -205,6 +207,9 @@ export default class InlayHintBuffer implements SyncItem {
if (item.paddingRight) {
chunks.push(nvim.isVim ? [' ', 'Normal'] : [' '])
}
if (this._config.afterText) {
col = 0
}
buffer.setVirtualText(srcId, position.line, chunks, { col, hl_mode: 'replace' })
}
nvim.resumeNotification(true, true)
Expand Down

0 comments on commit 12dfe6c

Please sign in to comment.