diff --git a/NeoVimServer/NeoVimMsgIds.h b/NeoVimServer/NeoVimMsgIds.h index 13cfba28..43534b45 100644 --- a/NeoVimServer/NeoVimMsgIds.h +++ b/NeoVimServer/NeoVimMsgIds.h @@ -47,8 +47,6 @@ typedef NS_ENUM(NSInteger, NeoVimServerMsgId) { typedef NS_ENUM(NSInteger, NeoVimAgentMsgId) { NeoVimAgentMsgIdAgentReady = 0, - NeoVimAgentMsgIdCommand, - NeoVimAgentMsgIdCommandOutput, NeoVimAgentMsgIdInput, NeoVimAgentMsgIdInputMarked, NeoVimAgentMsgIdDelete, diff --git a/NeoVimServer/NeoVimServer.m b/NeoVimServer/NeoVimServer.m index ece63717..228cd292 100644 --- a/NeoVimServer/NeoVimServer.m +++ b/NeoVimServer/NeoVimServer.m @@ -66,8 +66,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD return NULL; } - case NeoVimAgentMsgIdCommandOutput: return data_sync(data, outputCondition, neovim_vim_command_output); - case NeoVimAgentMsgIdSelectWindow: return data_sync(data, outputCondition, neovim_select_window); case NeoVimAgentMsgIdScroll: return data_sync(data, outputCondition, neovim_scroll); @@ -76,8 +74,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD case NeoVimAgentMsgIdResize: return data_sync(data, outputCondition, neovim_resize); - case NeoVimAgentMsgIdCommand: return data_sync(data, outputCondition, neovim_vim_command); - case NeoVimAgentMsgIdInput: return data_sync(data, outputCondition, neovim_vim_input); case NeoVimAgentMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text); diff --git a/NeoVimServer/server_globals.h b/NeoVimServer/server_globals.h index 3235f105..bf328380 100644 --- a/NeoVimServer/server_globals.h +++ b/NeoVimServer/server_globals.h @@ -15,10 +15,8 @@ extern void start_neovim(NSInteger width, NSInteger height, NSArray extern void neovim_select_window(void **argv); extern void neovim_scroll(void **argv); -extern void neovim_vim_command_output(void **argv); extern void neovim_escaped_filenames(void **argv); extern void neovim_resize(void **argv); -extern void neovim_vim_command(void **argv); extern void neovim_vim_input(void **argv); extern void neovim_vim_input_marked_text(void **argv); diff --git a/NeoVimServer/server_ui.m b/NeoVimServer/server_ui.m index ffea0a19..83b44782 100644 --- a/NeoVimServer/server_ui.m +++ b/NeoVimServer/server_ui.m @@ -744,34 +744,6 @@ void neovim_select_window(void **argv) { }); } -void neovim_vim_command_output(void **argv) { - work_and_write_data_sync(argv, ^NSData *(NSData *data) { - NSString *input = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - - Error err = ERROR_INIT; - String commandOutput = nvim_command_output(vim_string_from(input), &err); - char_u *output = (char_u *) commandOutput.data; - - // FIXME: handle err.set == true - NSString *result = nil; - if (output == NULL) { - WLOG("vim command output is null"); - } else if (ERROR_SET(&err)) { - WLOG("vim command output for '%s' was not successful: %s", input.cstr, err.msg); - } else { - result = [[NSString alloc] initWithCString:(const char *) output - encoding:NSUTF8StringEncoding]; - } - - NSData *resultData = result == nil ? nil : [NSKeyedArchiver archivedDataWithRootObject:result]; - - [result release]; - [input release]; - - return resultData; - }); -} - void neovim_escaped_filenames(void **argv) { work_and_write_data_sync(argv, ^NSData *(NSData *data) { NSArray *fileNames = [NSKeyedUnarchiver unarchiveObjectWithData:data]; @@ -798,23 +770,6 @@ void neovim_resize(void **argv) { }); } -void neovim_vim_command(void **argv) { - work_and_write_data_sync(argv, ^NSData *(NSData *data) { - NSString *input = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - - Error err = ERROR_INIT; - nvim_command(vim_string_from(input), &err); - - if (ERROR_SET(&err)) { - WLOG("ERROR while executing command %s: %s", input.cstr, err.msg); - } - - [input release]; - - return nil; - }); -} - void neovim_vim_input(void **argv) { work_and_write_data_sync(argv, ^NSData *(NSData *data) { NSString *input = [[[NSString alloc] initWithData:data diff --git a/SwiftNeoVim/NeoVimAgent.h b/SwiftNeoVim/NeoVimAgent.h index a39c90c2..d662de24 100644 --- a/SwiftNeoVim/NeoVimAgent.h +++ b/SwiftNeoVim/NeoVimAgent.h @@ -37,7 +37,6 @@ NS_ASSUME_NONNULL_BEGIN - (bool)runLocalServerAndNeoVimWithWidth:(NSInteger)width height:(NSInteger)height; - (NSURL *)pwd; -- (void)vimCommand:(NSString *)string; - (void)vimInput:(NSString *)string; - (void)vimInputMarkedText:(NSString *)markedText; @@ -52,9 +51,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)scrollHorizontal:(NSInteger)horiz vertical:(NSInteger)vert at:(Position)position; - (void)selectWindow:(NeoVimWindow *)window; -// WAITS -- (NSString * _Nullable)vimCommandOutput:(NSString *)string; - - (void)focusGained:(bool)gained; @end diff --git a/SwiftNeoVim/NeoVimAgent.m b/SwiftNeoVim/NeoVimAgent.m index 950f9eea..66afd063 100644 --- a/SwiftNeoVim/NeoVimAgent.m +++ b/SwiftNeoVim/NeoVimAgent.m @@ -268,24 +268,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m return pwd; } -- (void)vimCommand:(NSString *)string { - NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; - [self sendMessageWithId:NeoVimAgentMsgIdCommand data:data expectsReply:NO]; -} - -- (NSString *)vimCommandOutput:(NSString *)string { - NSData *data = [self sendMessageWithId:NeoVimAgentMsgIdCommandOutput - data:[string dataUsingEncoding:NSUTF8StringEncoding] - expectsReply:YES]; - - if (data == nil) { - return nil; - } - - NSString *result = [NSKeyedUnarchiver unarchiveObjectWithData:data]; - return [result stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; -} - - (void)vimInput:(NSString *)string { NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; [self sendMessageWithId:NeoVimAgentMsgIdInput data:data expectsReply:NO]; diff --git a/SwiftNeoVim/NeoVimView+Api.swift b/SwiftNeoVim/NeoVimView+Api.swift index b8afbe9b..87d5f1c1 100644 --- a/SwiftNeoVim/NeoVimView+Api.swift +++ b/SwiftNeoVim/NeoVimView+Api.swift @@ -133,7 +133,7 @@ extension NeoVimView { } public func vimOutput(of command: String) -> String { - return self.agent.vimCommandOutput(command) ?? "" + return self.nvim.commandOutput(str: command) ?? "" } public func cursorGo(to position: Position) { diff --git a/SwiftNeoVim/NeoVimView+Resize.swift b/SwiftNeoVim/NeoVimView+Resize.swift index 582fe43f..56945b60 100644 --- a/SwiftNeoVim/NeoVimView+Resize.swift +++ b/SwiftNeoVim/NeoVimView+Resize.swift @@ -59,9 +59,9 @@ extension NeoVimView { self.nvim.connect() - self.agent.vimCommand("set mouse=a") - self.agent.vimCommand("set title") - self.agent.vimCommand("set termguicolors") + self.nvim.setOption(name: "mouse", value: .string("a")) + self.nvim.setOption(name: "title", value: .bool(true)) + self.nvim.setOption(name: "termguicolors", value: .bool(true)) if noErrorDuringInitialization == false { self.logger.fault("There was an error launching neovim.") diff --git a/SwiftNeoVim/NeoVimView.swift b/SwiftNeoVim/NeoVimView.swift index 247846f4..03b5e852 100644 --- a/SwiftNeoVim/NeoVimView.swift +++ b/SwiftNeoVim/NeoVimView.swift @@ -139,7 +139,7 @@ public class NeoVimView: NSView, return } - self.agent.vimCommandOutput("cd \(escapedCwd)") + self.nvim.command(command: "cd \(escapedCwd)") } }