Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inlayHint): add inlayHint.position configuration #5060

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading