Skip to content

Commit 3611dd0

Browse files
committed
feat: enhance command execution by capturing output and handling errors in NeovimManager
1 parent f202d58 commit 3611dd0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/neovim.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,19 @@ export class NeovimManager {
103103

104104
// For regular Vim commands
105105
await nvim.setVvar('errmsg', '');
106-
await nvim.command(normalizedCommand);
107-
106+
107+
// Execute the command and capture its output using the execute() function
108+
const output = await nvim.call('execute', [normalizedCommand]);
109+
110+
// Check for errors
108111
const vimerr = await nvim.getVvar('errmsg');
109112
if (vimerr) {
110113
console.error('Vim error:', vimerr);
111114
return `Error executing command: ${vimerr}`;
112115
}
113116

114-
return 'Command executed';
117+
// Return the actual command output if any
118+
return output ? String(output).trim() : 'Command executed (no output)';
115119
} catch (error) {
116120
console.error('Error sending command:', error);
117121
return 'Error executing command';

0 commit comments

Comments
 (0)