Skip to content

Commit 25f96af

Browse files
committed
feat:
- add useCommand to extensionScope
1 parent a035f0e commit 25f96af

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { defineExtension, useDisposable } from 'reactive-vscode'
1+
import { defineExtension, useDisposable,useCommand } from 'reactive-vscode'
22
import { extensions, window } from 'vscode'
3-
import { registerCommands } from './commands'
3+
// import { registerCommands } from './commands'
4+
import { currentMode } from "./neovimModeManager"
45
import { setupNeovimModeManager } from './neovimModeManager'
56
import { setupThemeManager } from './themeManager'
67
import { logger } from './utils'
@@ -29,6 +30,8 @@ const { activate, deactivate } = defineExtension(async () => {
2930
return
3031
}
3132
}
33+
34+
3235
// Set up the mode manager
3336
const modeManager = setupNeovimModeManager()
3437
useDisposable({ dispose: modeManager })
@@ -38,7 +41,24 @@ const { activate, deactivate } = defineExtension(async () => {
3841
useDisposable({ dispose: themeManager })
3942

4043
// Register command to update mode from Neovim
41-
registerCommands()
44+
// registerCommands()
45+
//
46+
// Register a command to receive mode updates from Neovim
47+
useCommand('nvim-ui-plus.setMode', (args: { mode: string }) => {
48+
if (!args || typeof args.mode !== 'string') {
49+
logger.warn(`Received invalid args:`, args)
50+
return false
51+
}
52+
53+
logger.info(`Mode changed to: ${args.mode} (via Neovim autocommand)`)
54+
currentMode.value = args.mode
55+
return true
56+
})
57+
58+
// Add a command to check the current mode
59+
useCommand('nvim-ui-plus.showCurrentMode', () => {
60+
window.showInformationMessage(`Current Neovim mode: ${currentMode.value}`)
61+
})
4262
})
4363

4464
export { activate, deactivate }

0 commit comments

Comments
 (0)