Skip to content

feat: add g:dpp#hook_result for hook return values#43

Merged
Shougo merged 1 commit into
mainfrom
copilot/fix-hook-return-value
Jun 15, 2026
Merged

feat: add g:dpp#hook_result for hook return values#43
Shougo merged 1 commit into
mainfrom
copilot/fix-hook-return-value

Conversation

Copilot AI commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Hooks are executed via execute() which cannot return values, making it impossible for hook code to communicate results back to the caller — particularly when hooks are defined as plain strings in TOML.

Introduces a convention using g:dpp#hook_result: the variable is reset to v:null before each hook execution, and the hook can assign any value to it.

Changes

  • autoload/dpp/util.vim: Reset g:dpp#hook_result = v:null at the top of dpp#util#_execute_hook() before running hook code
  • doc/dpp.txt: New VARIABLES section documenting g:dpp#hook_result; usage note added to the HOOKS section

Usage (TOML-compatible)

hook_source = '''
  let g:dpp#hook_result = s:my_setup()
'''

Read g:dpp#hook_result immediately after the hook of interest — it is overwritten on each subsequent hook execution.

Copilot AI changed the title feat: add g:dpp#hook_result to allow hooks to return values feat: add g:dpp#hook_result for hook return values Jun 15, 2026
Copilot AI requested a review from Shougo June 15, 2026 08:02
@Shougo Shougo marked this pull request as ready for review June 15, 2026 08:04
@Shougo Shougo merged commit 946156e into main Jun 15, 2026
3 checks passed
@Shougo Shougo deleted the copilot/fix-hook-return-value branch June 15, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants