1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 14:52:19 +03:00

Merge remote-tracking branch 'origin/develop' into update-neovim

This commit is contained in:
Tae Won Ha 2018-01-25 23:12:57 +01:00
commit 60615aa245
25 changed files with 281 additions and 248 deletions

4
.gitignore vendored
View File

@ -177,8 +177,4 @@ Network Trash Folder
Temporary Items Temporary Items
.apdisk .apdisk
# -------------------------------------------
*.generated.h
*.generated.m
.deps .deps

View File

@ -6,3 +6,5 @@ brew 'cmake'
brew 'pkg-config' brew 'pkg-config'
brew 'gettext' brew 'gettext'
brew 'ninja' brew 'ninja'
brew 'python3'

View File

@ -218,7 +218,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -278,7 +278,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -308,7 +308,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 257; DYLIB_CURRENT_VERSION = 258;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
INFOPLIST_FILE = MsgPackRpc/Info.plist; INFOPLIST_FILE = MsgPackRpc/Info.plist;
@ -331,7 +331,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 257; DYLIB_CURRENT_VERSION = 258;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
INFOPLIST_FILE = MsgPackRpc/Info.plist; INFOPLIST_FILE = MsgPackRpc/Info.plist;

View File

@ -15,9 +15,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-257</string> <string>SNAPSHOT-258</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>257</string> <string>258</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Tae Won Ha. All rights reserved.</string> <string>Copyright © 2017 Tae Won Ha. All rights reserved.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>

View File

@ -10,7 +10,7 @@
4B9E33711FCB475600E0C4BC /* NvimMsgPack.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9E336F1FCB475600E0C4BC /* NvimMsgPack.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B9E33711FCB475600E0C4BC /* NvimMsgPack.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9E336F1FCB475600E0C4BC /* NvimMsgPack.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B9E33781FCB476D00E0C4BC /* MsgPackRpc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9E33791FCB476D00E0C4BC /* MsgPackRpc.framework */; }; 4B9E33781FCB476D00E0C4BC /* MsgPackRpc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9E33791FCB476D00E0C4BC /* MsgPackRpc.framework */; };
4B9E337C1FCB47B300E0C4BC /* NvimApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9E337A1FCB47B300E0C4BC /* NvimApi.swift */; }; 4B9E337C1FCB47B300E0C4BC /* NvimApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9E337A1FCB47B300E0C4BC /* NvimApi.swift */; };
4B9E337D1FCB47B300E0C4BC /* NvimApiMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9E337B1FCB47B300E0C4BC /* NvimApiMethods.swift */; }; 4B9E337D1FCB47B300E0C4BC /* NvimApiMethods.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9E337B1FCB47B300E0C4BC /* NvimApiMethods.generated.swift */; };
4B9E33831FCB47F900E0C4BC /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4B9E337F1FCB47F900E0C4BC /* Info.plist */; }; 4B9E33831FCB47F900E0C4BC /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4B9E337F1FCB47F900E0C4BC /* Info.plist */; };
4B9E33841FCB47F900E0C4BC /* Result.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9E33801FCB47F900E0C4BC /* Result.h */; }; 4B9E33841FCB47F900E0C4BC /* Result.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9E33801FCB47F900E0C4BC /* Result.h */; };
4B9E33851FCB47F900E0C4BC /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9E33811FCB47F900E0C4BC /* Result.swift */; }; 4B9E33851FCB47F900E0C4BC /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9E33811FCB47F900E0C4BC /* Result.swift */; };
@ -23,7 +23,7 @@
4B9E33701FCB475600E0C4BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 4B9E33701FCB475600E0C4BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4B9E33791FCB476D00E0C4BC /* MsgPackRpc.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MsgPackRpc.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4B9E33791FCB476D00E0C4BC /* MsgPackRpc.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MsgPackRpc.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4B9E337A1FCB47B300E0C4BC /* NvimApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NvimApi.swift; sourceTree = "<group>"; }; 4B9E337A1FCB47B300E0C4BC /* NvimApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NvimApi.swift; sourceTree = "<group>"; };
4B9E337B1FCB47B300E0C4BC /* NvimApiMethods.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NvimApiMethods.swift; sourceTree = "<group>"; }; 4B9E337B1FCB47B300E0C4BC /* NvimApiMethods.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NvimApiMethods.generated.swift; sourceTree = "<group>"; };
4B9E337F1FCB47F900E0C4BC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 4B9E337F1FCB47F900E0C4BC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4B9E33801FCB47F900E0C4BC /* Result.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Result.h; sourceTree = "<group>"; }; 4B9E33801FCB47F900E0C4BC /* Result.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Result.h; sourceTree = "<group>"; };
4B9E33811FCB47F900E0C4BC /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; }; 4B9E33811FCB47F900E0C4BC /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
@ -66,7 +66,7 @@
children = ( children = (
4B9E336F1FCB475600E0C4BC /* NvimMsgPack.h */, 4B9E336F1FCB475600E0C4BC /* NvimMsgPack.h */,
4B9E337A1FCB47B300E0C4BC /* NvimApi.swift */, 4B9E337A1FCB47B300E0C4BC /* NvimApi.swift */,
4B9E337B1FCB47B300E0C4BC /* NvimApiMethods.swift */, 4B9E337B1FCB47B300E0C4BC /* NvimApiMethods.generated.swift */,
4B9E337E1FCB47F900E0C4BC /* Result */, 4B9E337E1FCB47F900E0C4BC /* Result */,
4B9E33701FCB475600E0C4BC /* Info.plist */, 4B9E33701FCB475600E0C4BC /* Info.plist */,
); );
@ -112,6 +112,7 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 4B9E33741FCB475600E0C4BC /* Build configuration list for PBXNativeTarget "NvimMsgPack" */; buildConfigurationList = 4B9E33741FCB475600E0C4BC /* Build configuration list for PBXNativeTarget "NvimMsgPack" */;
buildPhases = ( buildPhases = (
4BA60C2220172D8F002DBFB7 /* ShellScript */,
4B9E33671FCB475600E0C4BC /* Sources */, 4B9E33671FCB475600E0C4BC /* Sources */,
4B9E33681FCB475600E0C4BC /* Frameworks */, 4B9E33681FCB475600E0C4BC /* Frameworks */,
4B9E33691FCB475600E0C4BC /* Headers */, 4B9E33691FCB475600E0C4BC /* Headers */,
@ -172,6 +173,22 @@
}; };
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
4BA60C2220172D8F002DBFB7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ../bin/generate_api_methods.py;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
4B9E33671FCB475600E0C4BC /* Sources */ = { 4B9E33671FCB475600E0C4BC /* Sources */ = {
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
@ -179,7 +196,7 @@
files = ( files = (
4B9E33861FCB47F900E0C4BC /* ResultProtocol.swift in Sources */, 4B9E33861FCB47F900E0C4BC /* ResultProtocol.swift in Sources */,
4B9E33851FCB47F900E0C4BC /* Result.swift in Sources */, 4B9E33851FCB47F900E0C4BC /* Result.swift in Sources */,
4B9E337D1FCB47B300E0C4BC /* NvimApiMethods.swift in Sources */, 4B9E337D1FCB47B300E0C4BC /* NvimApiMethods.generated.swift in Sources */,
4B9E337C1FCB47B300E0C4BC /* NvimApi.swift in Sources */, 4B9E337C1FCB47B300E0C4BC /* NvimApi.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -218,7 +235,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -278,7 +295,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -308,7 +325,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 257; DYLIB_CURRENT_VERSION = 258;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
INFOPLIST_FILE = NvimMsgPack/Info.plist; INFOPLIST_FILE = NvimMsgPack/Info.plist;
@ -331,7 +348,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 257; DYLIB_CURRENT_VERSION = 258;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
INFOPLIST_FILE = NvimMsgPack/Info.plist; INFOPLIST_FILE = NvimMsgPack/Info.plist;

View File

@ -15,9 +15,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-257</string> <string>SNAPSHOT-258</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>257</string> <string>258</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Tae Won Ha. All rights reserved.</string> <string>Copyright © 2017 Tae Won Ha. All rights reserved.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>

View File

@ -2825,4 +2825,3 @@ extension Dictionary {
return result return result
} }
} }

View File

@ -14,8 +14,8 @@
remoteServerName:(NSString *)remoteServerName remoteServerName:(NSString *)remoteServerName
nvimArgs:(NSArray<NSString *> *)nvimArgs; nvimArgs:(NSArray<NSString *> *)nvimArgs;
- (void)sendMessageWithId:(NeoVimServerMsgId)msgid; - (void)sendMessageWithId:(NvimServerMsgId)msgid;
- (void)sendMessageWithId:(NeoVimServerMsgId)msgid data:(NSData *)data; - (void)sendMessageWithId:(NvimServerMsgId)msgid data:(NSData *)data;
- (void)notifyReadiness; - (void)notifyReadiness;
@end @end

View File

@ -59,25 +59,25 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
switch (msgid) { switch (msgid) {
case NeoVimAgentMsgIdAgentReady: { case NvimBridgeMsgIdAgentReady: {
NSInteger *values = (NSInteger *) CFDataGetBytePtr(data); NSInteger *values = (NSInteger *) CFDataGetBytePtr(data);
start_neovim(values[0], values[1], neoVimServer.nvimArgs); start_neovim(values[0], values[1], neoVimServer.nvimArgs);
return NULL; return NULL;
} }
case NeoVimAgentMsgIdScroll: return data_sync(data, outputCondition, neovim_scroll); case NvimBridgeMsgIdScroll: return data_sync(data, outputCondition, neovim_scroll);
case NeoVimAgentMsgIdGetEscapeFileNames: return data_sync(data, outputCondition, neovim_escaped_filenames); case NvimBridgeMsgIdGetEscapeFileNames: return data_sync(data, outputCondition, neovim_escaped_filenames);
case NeoVimAgentMsgIdResize: return data_sync(data, outputCondition, neovim_resize); case NvimBridgeMsgIdResize: return data_sync(data, outputCondition, neovim_resize);
case NeoVimAgentMsgIdInput: return data_sync(data, outputCondition, neovim_vim_input); case NvimBridgeMsgIdInput: return data_sync(data, outputCondition, neovim_vim_input);
case NeoVimAgentMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text); case NvimBridgeMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text);
case NeoVimAgentMsgIdDelete: return data_sync(data, outputCondition, neovim_delete); case NvimBridgeMsgIdDelete: return data_sync(data, outputCondition, neovim_delete);
case NeoVimAgentMsgIdFocusGained: return data_sync(data, outputCondition, neovim_focus_gained); case NvimBridgeMsgIdFocusGained: return data_sync(data, outputCondition, neovim_focus_gained);
default: return NULL; default: return NULL;
@ -183,11 +183,11 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
CFRunLoopRun(); CFRunLoopRun();
} }
- (void)sendMessageWithId:(NeoVimServerMsgId)msgid { - (void)sendMessageWithId:(NvimServerMsgId)msgid {
[self sendMessageWithId:msgid data:nil]; [self sendMessageWithId:msgid data:nil];
} }
- (void)sendMessageWithId:(NeoVimServerMsgId)msgid data:(NSData *)data { - (void)sendMessageWithId:(NvimServerMsgId)msgid data:(NSData *)data {
#ifdef DEBUG_NEOVIM_SERVER_STANDALONE #ifdef DEBUG_NEOVIM_SERVER_STANDALONE
return; return;
#endif #endif
@ -210,7 +210,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
- (void)notifyReadiness { - (void)notifyReadiness {
#ifndef DEBUG_NEOVIM_SERVER_STANDALONE #ifndef DEBUG_NEOVIM_SERVER_STANDALONE
[self sendMessageWithId:NeoVimServerMsgIdServerReady data:nil]; [self sendMessageWithId:NvimServerMsgIdServerReady data:nil];
#endif #endif
} }

View File

@ -114,7 +114,7 @@ static void send_dirty_status() {
_dirty = new_dirty_status; _dirty = new_dirty_status;
DLOG("sending dirty status: %d", _dirty); DLOG("sending dirty status: %d", _dirty);
NSData *data = [[NSData alloc] initWithBytes:&_dirty length:sizeof(bool)]; NSData *data = [[NSData alloc] initWithBytes:&_dirty length:sizeof(bool)];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdDirtyStatusChanged data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdDirtyStatusChanged data:data];
[data release]; [data release];
} }
@ -122,14 +122,14 @@ static void send_cwd() {
char_u *temp = xmalloc(MAXPATHL); char_u *temp = xmalloc(MAXPATHL);
if (os_dirname(temp, MAXPATHL) == FAIL) { if (os_dirname(temp, MAXPATHL) == FAIL) {
xfree(temp); xfree(temp);
[_neovim_server sendMessageWithId:NeoVimServerMsgIdCwdChanged]; [_neovim_server sendMessageWithId:NvimServerMsgIdCwdChanged];
} }
NSString *pwd = [NSString stringWithCString:(const char *) temp encoding:NSUTF8StringEncoding]; NSString *pwd = [NSString stringWithCString:(const char *) temp encoding:NSUTF8StringEncoding];
xfree(temp); xfree(temp);
NSData *resultData = [pwd dataUsingEncoding:NSUTF8StringEncoding]; NSData *resultData = [pwd dataUsingEncoding:NSUTF8StringEncoding];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdCwdChanged data:resultData]; [_neovim_server sendMessageWithId:NvimServerMsgIdCwdChanged data:resultData];
} }
static HlAttrs HlAttrsFromAttrCode(int attr_code) { static HlAttrs HlAttrsFromAttrCode(int attr_code) {
@ -180,7 +180,7 @@ static void send_colorscheme() {
}; };
NSData *resultData = [NSData dataWithBytes:values length:5 * sizeof(NSInteger)]; NSData *resultData = [NSData dataWithBytes:values length:5 * sizeof(NSInteger)];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdColorSchemeChanged data:resultData]; [_neovim_server sendMessageWithId:NvimServerMsgIdColorSchemeChanged data:resultData];
} }
static void insert_marked_text(NSString *markedText) { static void insert_marked_text(NSString *markedText) {
@ -278,7 +278,7 @@ static void server_ui_flush(UI *ui __unused) {
return; return;
} }
[_neovim_server sendMessageWithId:NeoVimServerMsgIdFlush [_neovim_server sendMessageWithId:NvimServerMsgIdFlush
data:[NSKeyedArchiver archivedDataWithRootObject:render_data]]; data:[NSKeyedArchiver archivedDataWithRootObject:render_data]];
[render_data removeAllObjects]; [render_data removeAllObjects];
} }
@ -290,7 +290,7 @@ static void server_ui_resize(UI *ui __unused, Integer width, Integer height) {
NSInteger values[] = {width, height}; NSInteger values[] = {width, height};
NSData *data = [[NSData alloc] initWithBytes:values length:(2 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:values length:(2 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdResize data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdResize data:data];
[data release]; [data release];
} }
} }
@ -300,7 +300,7 @@ static void server_ui_clear(UI *ui __unused) {
server_ui_flush(NULL); server_ui_flush(NULL);
} }
[_neovim_server sendMessageWithId:NeoVimServerMsgIdClear]; [_neovim_server sendMessageWithId:NvimServerMsgIdClear];
} }
static void server_ui_eol_clear(UI *ui __unused) { static void server_ui_eol_clear(UI *ui __unused) {
@ -308,7 +308,7 @@ static void server_ui_eol_clear(UI *ui __unused) {
server_ui_flush(NULL); server_ui_flush(NULL);
} }
[_neovim_server sendMessageWithId:NeoVimServerMsgIdEolClear]; [_neovim_server sendMessageWithId:NvimServerMsgIdEolClear];
} }
static void server_ui_cursor_goto(UI *ui __unused, Integer row, Integer col) { static void server_ui_cursor_goto(UI *ui __unused, Integer row, Integer col) {
@ -330,23 +330,23 @@ static void server_ui_cursor_goto(UI *ui __unused, Integer row, Integer col) {
} }
static void server_ui_update_menu(UI *ui __unused) { static void server_ui_update_menu(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetMenu]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetMenu];
} }
static void server_ui_busy_start(UI *ui __unused) { static void server_ui_busy_start(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdBusyStart]; [_neovim_server sendMessageWithId:NvimServerMsgIdBusyStart];
} }
static void server_ui_busy_stop(UI *ui __unused) { static void server_ui_busy_stop(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdBusyStop]; [_neovim_server sendMessageWithId:NvimServerMsgIdBusyStop];
} }
static void server_ui_mouse_on(UI *ui __unused) { static void server_ui_mouse_on(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdMouseOn]; [_neovim_server sendMessageWithId:NvimServerMsgIdMouseOn];
} }
static void server_ui_mouse_off(UI *ui __unused) { static void server_ui_mouse_off(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdMouseOff]; [_neovim_server sendMessageWithId:NvimServerMsgIdMouseOff];
} }
static void server_ui_mode_info_set(UI *ui __unused, Boolean enabled __unused, static void server_ui_mode_info_set(UI *ui __unused, Boolean enabled __unused,
@ -358,7 +358,7 @@ static void server_ui_mode_change(UI *ui __unused, String mode_str __unused, Int
@autoreleasepool { @autoreleasepool {
NSInteger value = mode; NSInteger value = mode;
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdModeChange data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdModeChange data:data];
[data release]; [data release];
} }
} }
@ -371,7 +371,7 @@ static void server_ui_set_scroll_region(UI *ui __unused, Integer top, Integer bo
NSInteger values[] = {top, bot, left, right}; NSInteger values[] = {top, bot, left, right};
NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetScrollRegion data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetScrollRegion data:data];
[data release]; [data release];
} }
} }
@ -382,7 +382,7 @@ static void server_ui_scroll(UI *ui __unused, Integer count) {
NSInteger value = count; NSInteger value = count;
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdScroll data:data];
[data release]; [data release];
} }
} }
@ -454,11 +454,11 @@ static void server_ui_put(UI *ui __unused, String str) {
} }
static void server_ui_bell(UI *ui __unused) { static void server_ui_bell(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdBell]; [_neovim_server sendMessageWithId:NvimServerMsgIdBell];
} }
static void server_ui_visual_bell(UI *ui __unused) { static void server_ui_visual_bell(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdVisualBell]; [_neovim_server sendMessageWithId:NvimServerMsgIdVisualBell];
} }
static void server_ui_update_fg(UI *ui __unused, Integer fg) { static void server_ui_update_fg(UI *ui __unused, Integer fg) {
@ -468,7 +468,7 @@ static void server_ui_update_fg(UI *ui __unused, Integer fg) {
if (fg == -1) { if (fg == -1) {
value[0] = _default_foreground; value[0] = _default_foreground;
NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetForeground data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetForeground data:data];
[data release]; [data release];
return; return;
@ -478,7 +478,7 @@ static void server_ui_update_fg(UI *ui __unused, Integer fg) {
value[0] = fg; value[0] = fg;
NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetForeground data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetForeground data:data];
[data release]; [data release];
} }
} }
@ -490,7 +490,7 @@ static void server_ui_update_bg(UI *ui __unused, Integer bg) {
if (bg == -1) { if (bg == -1) {
value[0] = _default_background; value[0] = _default_background;
NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetBackground data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetBackground data:data];
[data release]; [data release];
return; return;
@ -499,7 +499,7 @@ static void server_ui_update_bg(UI *ui __unused, Integer bg) {
_default_background = bg; _default_background = bg;
value[0] = bg; value[0] = bg;
NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetBackground data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetBackground data:data];
[data release]; [data release];
} }
} }
@ -511,7 +511,7 @@ static void server_ui_update_sp(UI *ui __unused, Integer sp) {
if (sp == -1) { if (sp == -1) {
value[0] = _default_special; value[0] = _default_special;
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetSpecial data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetSpecial data:data];
[data release]; [data release];
return; return;
@ -520,7 +520,7 @@ static void server_ui_update_sp(UI *ui __unused, Integer sp) {
_default_special = sp; _default_special = sp;
value[0] = sp; value[0] = sp;
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))]; NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetSpecial data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdSetSpecial data:data];
[data release]; [data release];
} }
} }
@ -532,7 +532,7 @@ static void server_ui_set_title(UI *ui __unused, String title) {
} }
NSString *string = [[NSString alloc] initWithCString:title.data encoding:NSUTF8StringEncoding]; NSString *string = [[NSString alloc] initWithCString:title.data encoding:NSUTF8StringEncoding];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetTitle [_neovim_server sendMessageWithId:NvimServerMsgIdSetTitle
data:[string dataUsingEncoding:NSUTF8StringEncoding]]; data:[string dataUsingEncoding:NSUTF8StringEncoding]];
[string release]; [string release];
} }
@ -545,7 +545,7 @@ static void server_ui_set_icon(UI *ui __unused, String icon) {
} }
NSString *string = [[NSString alloc] initWithCString:icon.data encoding:NSUTF8StringEncoding]; NSString *string = [[NSString alloc] initWithCString:icon.data encoding:NSUTF8StringEncoding];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetIcon [_neovim_server sendMessageWithId:NvimServerMsgIdSetIcon
data:[string dataUsingEncoding:NSUTF8StringEncoding]]; data:[string dataUsingEncoding:NSUTF8StringEncoding]];
[string release]; [string release];
} }
@ -557,7 +557,7 @@ static void server_ui_option_set(UI *ui __unused, String name, Object value) {
} }
static void server_ui_stop(UI *ui __unused) { static void server_ui_stop(UI *ui __unused) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdStop]; [_neovim_server sendMessageWithId:NvimServerMsgIdStop];
ServerUiData *data = (ServerUiData *) ui->data; ServerUiData *data = (ServerUiData *) ui->data;
data->stop = true; data->stop = true;
@ -649,7 +649,7 @@ void custom_ui_autocmds_groups(
[data appendBytes:&bufHandle length:sizeof(NSInteger)]; [data appendBytes:&bufHandle length:sizeof(NSInteger)];
} }
[_neovim_server sendMessageWithId:NeoVimServerMsgIdAutoCommandEvent data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdAutoCommandEvent data:data];
[data release]; [data release];
} }
@ -690,7 +690,7 @@ void start_neovim(NSInteger width, NSInteger height, NSArray<NSString *> *args)
bool value = msg_didany > 0; bool value = msg_didany > 0;
NSData *data = [[NSData alloc] initWithBytes:&value length:sizeof(bool)]; NSData *data = [[NSData alloc] initWithBytes:&value length:sizeof(bool)];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdNeoVimReady data:data]; [_neovim_server sendMessageWithId:NvimServerMsgIdNvimReady data:data];
[data release]; [data release];
} }
@ -817,7 +817,7 @@ void neovim_vim_input(void **argv) {
NSInteger values[] = {_put_row, MAX(_put_column - i, 0)}; NSInteger values[] = {_put_row, MAX(_put_column - i, 0)};
NSData *unmarkData = [[NSData alloc] initWithBytes:values length:(2 * sizeof(NSInteger))]; NSData *unmarkData = [[NSData alloc] initWithBytes:values length:(2 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdUnmark data:unmarkData]; [_neovim_server sendMessageWithId:NvimServerMsgIdUnmark data:unmarkData];
[unmarkData release]; [unmarkData release];
} }
} }

View File

@ -275,6 +275,7 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 4B90F00C1FD2AF59008A39E0 /* Build configuration list for PBXNativeTarget "NvimView" */; buildConfigurationList = 4B90F00C1FD2AF59008A39E0 /* Build configuration list for PBXNativeTarget "NvimView" */;
buildPhases = ( buildPhases = (
4BA60C2120172AB8002DBFB7 /* ShellScript */,
4B90EFFF1FD2AF59008A39E0 /* Sources */, 4B90EFFF1FD2AF59008A39E0 /* Sources */,
4B90F0001FD2AF59008A39E0 /* Frameworks */, 4B90F0001FD2AF59008A39E0 /* Frameworks */,
4B90F0011FD2AF59008A39E0 /* Headers */, 4B90F0011FD2AF59008A39E0 /* Headers */,
@ -297,7 +298,6 @@
buildConfigurationList = 4B90F0531FD2AFD3008A39E0 /* Build configuration list for PBXNativeTarget "NvimServer" */; buildConfigurationList = 4B90F0531FD2AFD3008A39E0 /* Build configuration list for PBXNativeTarget "NvimServer" */;
buildPhases = ( buildPhases = (
4BE45C091FD2D92D005C0A95 /* ShellScript */, 4BE45C091FD2D92D005C0A95 /* ShellScript */,
4BE45C0A1FD2D941005C0A95 /* ShellScript */,
4B90F04B1FD2AFD3008A39E0 /* Sources */, 4B90F04B1FD2AFD3008A39E0 /* Sources */,
4B90F04C1FD2AFD3008A39E0 /* Frameworks */, 4B90F04C1FD2AFD3008A39E0 /* Frameworks */,
4B90F04D1FD2AFD3008A39E0 /* CopyFiles */, 4B90F04D1FD2AFD3008A39E0 /* CopyFiles */,
@ -359,6 +359,19 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
4BA60C2120172AB8002DBFB7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ../bin/generate_source.py;
};
4BE45C091FD2D92D005C0A95 /* ShellScript */ = { 4BE45C091FD2D92D005C0A95 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -372,19 +385,6 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "pushd neovim\n../../bin/build_libnvim.sh\npopd"; shellScript = "pushd neovim\n../../bin/build_libnvim.sh\npopd";
}; };
4BE45C0A1FD2D941005C0A95 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ../bin/generate_source.py;
};
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
@ -472,7 +472,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -530,7 +530,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -557,7 +557,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 257; DYLIB_CURRENT_VERSION = 258;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
@ -579,7 +579,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 257; DYLIB_CURRENT_VERSION = 258;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;

View File

@ -15,9 +15,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-257</string> <string>SNAPSHOT-258</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>257</string> <string>258</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Tae Won Ha. All rights reserved.</string> <string>Copyright © 2017 Tae Won Ha. All rights reserved.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>

View File

@ -1,3 +1,5 @@
// Auto generated for nvim version 0.2.2.
// See bin/generate_source.py
enum NvimAutoCommandEvent: Int { enum NvimAutoCommandEvent: Int {
case bufadd = 0 case bufadd = 0

View File

@ -179,27 +179,24 @@ extension NvimView {
/// Closes the current window. /// Closes the current window.
public func closeCurrentTab() { public func closeCurrentTab() {
// We don't have to wait here even when neovim quits since we wait in gui.async() block in neoVimStopped(). self.nvim.command(command: "q", expectsReturnValue: true)
self.nvim.command(command: "q", expectsReturnValue: false)
} }
public func saveCurrentTab() { public func saveCurrentTab() {
self.nvim.command(command: "w", expectsReturnValue: false) self.nvim.command(command: "w", expectsReturnValue: true)
} }
public func saveCurrentTab(url: URL) { public func saveCurrentTab(url: URL) {
self.nvim.command(command: "w \(url.path)", expectsReturnValue: false) self.nvim.command(command: "w \(url.path)", expectsReturnValue: true)
} }
public func closeCurrentTabWithoutSaving() { public func closeCurrentTabWithoutSaving() {
self.nvim.command(command: "q!", expectsReturnValue: false) self.nvim.command(command: "q!", expectsReturnValue: true)
} }
public func quitNeoVimWithoutSaving() { public func quitNeoVimWithoutSaving() {
self.nvim.command(command: "qa!", expectsReturnValue: false) self.bridgeLogger.mark()
self.eventsSubject.onNext(.neoVimStopped) self.nvim.command(command: "qa!", expectsReturnValue: true)
self.eventsSubject.onCompleted()
self.waitForNeoVimToQuit()
} }
public func vimOutput(of command: String) -> String { public func vimOutput(of command: String) -> String {

View File

@ -39,7 +39,6 @@ extension NvimView {
let dirtyRects = self.rectsBeingDrawn() let dirtyRects = self.rectsBeingDrawn()
self.drawBaseBackground(rects: dirtyRects, in: context)
self.rowRunIntersecting(rects: dirtyRects).forEach { self.draw(rowRun: $0, in: context) } self.rowRunIntersecting(rects: dirtyRects).forEach { self.draw(rowRun: $0, in: context) }
self.drawCursor(context: context) self.drawCursor(context: context)
} }
@ -127,14 +126,6 @@ extension NvimView {
self.shouldDrawCursor = false self.shouldDrawCursor = false
} }
private func drawBaseBackground(rects: [CGRect], in context: CGContext) {
context.saveGState()
defer { context.restoreGState() }
context.setFillColor(ColorUtils.cgColorIgnoringAlpha(self.grid.background))
context.fill(rects)
}
private func drawBackground(rowRun: RowRun, in context: CGContext) { private func drawBackground(rowRun: RowRun, in context: CGContext) {
if rowRun.attrs.background == self.grid.background { if rowRun.attrs.background == self.grid.background {
return return
@ -212,7 +203,7 @@ extension NvimView {
} }
private func rowRunsFor(rowRange: CountableClosedRange<Int>, private func rowRunsFor(rowRange: CountableClosedRange<Int>,
columnRange: CountableClosedRange<Int>) -> [RowRun] { columnRange: CountableClosedRange<Int>) -> [RowRun] {
return rowRange return rowRange
.map { (row) -> [RowRun] in .map { (row) -> [RowRun] in
@ -318,7 +309,8 @@ extension NvimView {
} }
} }
private let emojiAttrs = [ NSAttributedStringKey.font: NSFont(name: "AppleColorEmoji", size: 72)! ] private let emojiAttrs = [NSAttributedStringKey.font: NSFont(name: "AppleColorEmoji", size: 72)!]
private let resizeTextAttrs = [ private let resizeTextAttrs = [
NSAttributedStringKey.font: NSFont.systemFont(ofSize: 18), NSAttributedStringKey.font: NSFont.systemFont(ofSize: 18),
NSAttributedStringKey.foregroundColor: NSColor.darkGray NSAttributedStringKey.foregroundColor: NSColor.darkGray

View File

@ -9,28 +9,28 @@ import RxSwift
extension NvimView { extension NvimView {
func resize(width width: Int, height: Int) { func resize(width: Int, height: Int) {
gui.async { self.bridgeLogger.debug("\(width) x \(height)")
self.bridgeLogger.debug("\(width) x \(height)")
gui.async {
self.grid.resize(Size(width: width, height: height)) self.grid.resize(Size(width: width, height: height))
self.markForRenderWholeView() self.markForRenderWholeView()
} }
} }
func clear() { func clear() {
gui.async { self.bridgeLogger.mark()
self.bridgeLogger.mark()
gui.async {
self.grid.clear() self.grid.clear()
self.markForRenderWholeView() self.markForRenderWholeView()
} }
} }
func eolClear() { func eolClear() {
gui.async { self.bridgeLogger.mark()
self.bridgeLogger.mark()
gui.async {
self.grid.eolClear() self.grid.eolClear()
let putPosition = self.grid.position let putPosition = self.grid.position
@ -43,25 +43,26 @@ extension NvimView {
} }
func modeChange(_ mode: CursorModeShape) { func modeChange(_ mode: CursorModeShape) {
self.bridgeLogger.debug(name(of: mode))
gui.async { gui.async {
self.bridgeLogger.debug(name(of: mode))
self.mode = mode self.mode = mode
} }
} }
func setScrollRegion(top: Int, bottom: Int, left: Int, right: Int) { func setScrollRegion(top: Int, bottom: Int, left: Int, right: Int) {
gui.async { self.bridgeLogger.debug("\(top):\(bottom):\(left):\(right)")
self.bridgeLogger.debug("\(top):\(bottom):\(left):\(right)")
gui.async {
let region = Region(top: top, bottom: bottom, left: left, right: right) let region = Region(top: top, bottom: bottom, left: left, right: right)
self.grid.setScrollRegion(region) self.grid.setScrollRegion(region)
} }
} }
func scroll(_ count: Int) { func scroll(_ count: Int) {
gui.async { self.bridgeLogger.debug(count)
self.bridgeLogger.debug(count)
gui.async {
self.grid.scroll(count) self.grid.scroll(count)
self.markForRender(region: self.grid.region) self.markForRender(region: self.grid.region)
// Do not send msgs to agent -> neovim in the delegate method. It causes spinning // Do not send msgs to agent -> neovim in the delegate method. It causes spinning
@ -71,9 +72,9 @@ extension NvimView {
} }
func unmark(row: Int, column: Int) { func unmark(row: Int, column: Int) {
gui.async { self.bridgeLogger.debug("\(row):\(column)")
self.bridgeLogger.debug("\(row):\(column)")
gui.async {
let position = Position(row: row, column: column) let position = Position(row: row, column: column)
self.grid.unmarkCell(position) self.grid.unmarkCell(position)
@ -82,9 +83,9 @@ extension NvimView {
} }
func flush(_ renderData: [Data]) { func flush(_ renderData: [Data]) {
gui.async { self.bridgeLogger.hr()
self.bridgeLogger.hr()
gui.async {
renderData.forEach { data in renderData.forEach { data in
data.withUnsafeBytes { (pointer: UnsafePointer<RenderDataType>) in data.withUnsafeBytes { (pointer: UnsafePointer<RenderDataType>) in
let sizeOfType = MemoryLayout<RenderDataType>.size let sizeOfType = MemoryLayout<RenderDataType>.size
@ -135,24 +136,26 @@ extension NvimView {
} }
func update(foreground fg: Int) { func update(foreground fg: Int) {
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(fg))
gui.async { gui.async {
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(fg))
self.grid.foreground = fg self.grid.foreground = fg
} }
} }
func update(background bg: Int) { func update(background bg: Int) {
gui.async { self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(bg))
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(bg))
gui.async {
self.grid.background = bg self.grid.background = bg
self.layer?.backgroundColor = ColorUtils.colorIgnoringAlpha(self.grid.background).cgColor self.layer?.backgroundColor = ColorUtils.colorIgnoringAlpha(self.grid.background).cgColor
} }
} }
func update(special sp: Int) { func update(special sp: Int) {
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(sp))
gui.async { gui.async {
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(sp))
self.grid.special = sp self.grid.special = sp
} }
} }
@ -196,10 +199,10 @@ extension NvimView {
} }
func ipcBecameInvalid(_ reason: String) { func ipcBecameInvalid(_ reason: String) {
gui.async { self.bridgeLogger.debug(reason)
self.bridgeLogger.debug(reason)
if self.uiBridge.isNvimQuitting == 1 || self.uiBridge.isNvimQuit { gui.async {
if self.uiBridge.isNvimQuitting || self.uiBridge.isNvimQuit {
return return
} }
@ -274,10 +277,10 @@ extension NvimView {
self.eventsSubject.onNext(.cwdChanged) self.eventsSubject.onNext(.cwdChanged)
} }
func colorSchemeChanged(_ values: [Int]) { func colorSchemeChanged(_ values: [Int]) {
gui.async { let theme = Theme(values)
let theme = Theme(values) self.bridgeLogger.debug(theme)
self.bridgeLogger.debug(theme)
gui.async {
self.theme = theme self.theme = theme
self.eventsSubject.onNext(.colorschemeChanged(theme)) self.eventsSubject.onNext(.colorschemeChanged(theme))
} }

View File

@ -174,7 +174,7 @@ public class NvimView: NSView,
public init(frame rect: NSRect, config: Config) { public init(frame rect: NSRect, config: Config) {
self.drawer = TextDrawer(font: self._font) self.drawer = TextDrawer(font: self._font)
self.uiBridge = UiBridge(uuid: self.uuid) self.uiBridge = UiBridge(uuid: self.uuid, config: config)
let sockPath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("vimr_\(self.uuid).sock").path let sockPath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("vimr_\(self.uuid).sock").path
guard let nvim = NvimApi(at: sockPath) else { guard let nvim = NvimApi(at: sockPath) else {
@ -193,9 +193,6 @@ public class NvimView: NSView,
// We cannot set bridge in init since self is not available before super.init()... // We cannot set bridge in init since self is not available before super.init()...
self.uiBridge.nvimView = self self.uiBridge.nvimView = self
self.uiBridge.useInteractiveZsh = config.useInteractiveZsh
self.uiBridge.cwd = config.cwd
self.uiBridge.nvimArgs = config.nvimArgs ?? []
} }
convenience override public init(frame rect: NSRect) { convenience override public init(frame rect: NSRect) {

View File

@ -9,19 +9,19 @@ class UiBridge {
weak var nvimView: NvimView? weak var nvimView: NvimView?
var isNvimQuitting = UInt32(0)
var isNvimQuit = false
let nvimQuitCondition = NSCondition() let nvimQuitCondition = NSCondition()
var useInteractiveZsh = false private(set) var isNvimQuitting = false
private(set) var isNvimQuit = false
var cwd = URL(fileURLWithPath: NSHomeDirectory()) init(uuid: String, config: NvimView.Config) {
var nvimArgs = [String]()
init(uuid: String) {
self.uuid = uuid self.uuid = uuid
self.messageHandler = MessageHandler() self.messageHandler = MessageHandler()
self.useInteractiveZsh = config.useInteractiveZsh
self.nvimArgs = config.nvimArgs ?? []
self.cwd = config.cwd
self.messageHandler.bridge = self self.messageHandler.bridge = self
} }
@ -67,7 +67,7 @@ class UiBridge {
} }
func quit() { func quit() {
OSAtomicOr32Barrier(1, &self.isNvimQuitting) self.isNvimQuitting = true
self.closePorts() self.closePorts()
@ -86,7 +86,7 @@ class UiBridge {
func forceQuit() { func forceQuit() {
self.logger.info("Force-exiting NvimServer \(self.uuid).") self.logger.info("Force-exiting NvimServer \(self.uuid).")
OSAtomicOr32Barrier(1, &self.isNvimQuitting) self.isNvimQuitting = true
self.closePorts() self.closePorts()
self.forceExitNvimServer() self.forceExitNvimServer()
@ -106,7 +106,7 @@ class UiBridge {
} }
fileprivate func handleMessage(msgId: Int32, data: Data?) { fileprivate func handleMessage(msgId: Int32, data: Data?) {
guard let msg = NeoVimServerMsgId(rawValue: Int(msgId)) else { guard let msg = NvimServerMsgId(rawValue: Int(msgId)) else {
return return
} }
@ -115,7 +115,7 @@ class UiBridge {
case .serverReady: case .serverReady:
self.establishNvimConnection() self.establishNvimConnection()
case .neoVimReady: case .nvimReady:
self.isInitErrorPresent = data?.asArray(ofType: Bool.self, count: 1)?[0] ?? false self.isInitErrorPresent = data?.asArray(ofType: Bool.self, count: 1)?[0] ?? false
self.nvimReadyCondition.lock() self.nvimReadyCondition.lock()
self.isNvimReady = true self.isNvimReady = true
@ -131,7 +131,6 @@ class UiBridge {
self.nvimView?.resize(width: values[0], height: values[1]) self.nvimView?.resize(width: values[0], height: values[1])
case .clear: case .clear:
self.nvimView?.clear() self.nvimView?.clear()
@ -296,13 +295,13 @@ class UiBridge {
} }
private func establishNvimConnection() { private func establishNvimConnection() {
self.remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, self.remoteServerName.CFStr) self.remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, self.remoteServerName.cfStr)
self.sendMessage(msgId: .agentReady, data: [self.initialWidth, self.initialHeight].data()) self.sendMessage(msgId: .agentReady, data: [self.initialWidth, self.initialHeight].data())
} }
/// Does not wait for reply. /// Does not wait for reply.
private func sendMessage(msgId: NeoVimAgentMsgId, data: Data?) { private func sendMessage(msgId: NvimBridgeMsgId, data: Data?) {
if self.isNvimQuitting == 1 { if self.isNvimQuitting {
self.logger.info("NvimServer is quitting, but trying to send msg: \(msgId).") self.logger.info("NvimServer is quitting, but trying to send msg: \(msgId).")
return return
} }
@ -320,7 +319,7 @@ class UiBridge {
nil, nil,
nil) nil)
if self.isNvimQuitting == 1 { if self.isNvimQuitting {
return return
} }
@ -328,7 +327,7 @@ class UiBridge {
let msg = "Remote server responded with \(name(of: responseCode)) for msg \(msgId)." let msg = "Remote server responded with \(name(of: responseCode)) for msg \(msgId)."
self.logger.error(msg) self.logger.error(msg)
if self.isNvimQuitting == 0 { if !self.isNvimQuitting {
self.nvimView?.ipcBecameInvalid(msg) self.nvimView?.ipcBecameInvalid(msg)
} }
} }
@ -353,23 +352,26 @@ class UiBridge {
shellArgs.append("-i") shellArgs.append("-i")
} }
let inputPipe = Pipe()
self.nvimServerProc = Process()
let listenAddress = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("vimr_\(self.uuid).sock") let listenAddress = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("vimr_\(self.uuid).sock")
var env = selfEnv var env = selfEnv
env["NVIM_LISTEN_ADDRESS"] = listenAddress.path env["NVIM_LISTEN_ADDRESS"] = listenAddress.path
self.nvimServerProc?.environment = env let inputPipe = Pipe()
self.nvimServerProc?.standardInput = inputPipe let process = Process()
self.nvimServerProc?.currentDirectoryPath = self.cwd.path process.environment = env
self.nvimServerProc?.launchPath = shellPath.path process.standardInput = inputPipe
self.nvimServerProc?.arguments = shellArgs process.currentDirectoryPath = self.cwd.path
self.nvimServerProc?.launch() process.launchPath = shellPath.path
process.arguments = shellArgs
process.launch()
self.nvimServerProc = process
nvimArgs.append("--headless") nvimArgs.append("--headless")
let cmd = "exec '\(self.nvimServerExecutablePath())' '\(self.localServerName)' '\(self.remoteServerName)' " let cmd = "exec '\(self.nvimServerExecutablePath())' '\(self.localServerName)' '\(self.remoteServerName)' "
.appending(self.nvimArgs.map { "\($0)" }.joined(separator: " ")) .appending(self.nvimArgs.map { "'\($0)'" }.joined(separator: " "))
self.logger.debug(cmd)
let writeHandle = inputPipe.fileHandleForWriting let writeHandle = inputPipe.fileHandleForWriting
guard let cmdData = cmd.data(using: .utf8) else { guard let cmdData = cmd.data(using: .utf8) else {
@ -396,7 +398,7 @@ class UiBridge {
self.localServerPort = CFMessagePortCreateLocal( self.localServerPort = CFMessagePortCreateLocal(
kCFAllocatorDefault, kCFAllocatorDefault,
self.localServerName.CFStr, self.localServerName.cfStr,
{ _, msgid, data, info in { _, msgid, data, info in
return info? return info?
.load(as: MessageHandler.self) .load(as: MessageHandler.self)
@ -416,6 +418,10 @@ class UiBridge {
private let uuid: String private let uuid: String
private let useInteractiveZsh: Bool
private let cwd: URL
private var nvimArgs: [String]
private var remoteServerPort: CFMessagePort? private var remoteServerPort: CFMessagePort?
private var localServerPort: CFMessagePort? private var localServerPort: CFMessagePort?
@ -463,7 +469,7 @@ private extension CFData {
private extension String { private extension String {
var CFStr: CFString { var cfStr: CFString {
return self as NSString return self as NSString
} }
} }

View File

@ -56,50 +56,50 @@ typedef NS_ENUM(NSInteger, RenderDataType) {
RenderDataTypeHighlight RenderDataTypeHighlight
}; };
typedef NS_ENUM(NSInteger, NeoVimServerMsgId) { typedef NS_ENUM(NSInteger, NvimServerMsgId) {
NeoVimServerMsgIdServerReady = 0, NvimServerMsgIdServerReady = 0,
NeoVimServerMsgIdNeoVimReady, NvimServerMsgIdNvimReady,
NeoVimServerMsgIdResize, NvimServerMsgIdResize,
NeoVimServerMsgIdClear, NvimServerMsgIdClear,
NeoVimServerMsgIdEolClear, NvimServerMsgIdEolClear,
NeoVimServerMsgIdSetMenu, NvimServerMsgIdSetMenu,
NeoVimServerMsgIdBusyStart, NvimServerMsgIdBusyStart,
NeoVimServerMsgIdBusyStop, NvimServerMsgIdBusyStop,
NeoVimServerMsgIdMouseOn, NvimServerMsgIdMouseOn,
NeoVimServerMsgIdMouseOff, NvimServerMsgIdMouseOff,
NeoVimServerMsgIdModeChange, NvimServerMsgIdModeChange,
NeoVimServerMsgIdSetScrollRegion, NvimServerMsgIdSetScrollRegion,
NeoVimServerMsgIdScroll, NvimServerMsgIdScroll,
NeoVimServerMsgIdUnmark, NvimServerMsgIdUnmark,
NeoVimServerMsgIdBell, NvimServerMsgIdBell,
NeoVimServerMsgIdVisualBell, NvimServerMsgIdVisualBell,
NeoVimServerMsgIdFlush, NvimServerMsgIdFlush,
NeoVimServerMsgIdSetForeground, NvimServerMsgIdSetForeground,
NeoVimServerMsgIdSetBackground, NvimServerMsgIdSetBackground,
NeoVimServerMsgIdSetSpecial, NvimServerMsgIdSetSpecial,
NeoVimServerMsgIdSetTitle, NvimServerMsgIdSetTitle,
NeoVimServerMsgIdSetIcon, NvimServerMsgIdSetIcon,
NeoVimServerMsgIdStop, NvimServerMsgIdStop,
NeoVimServerMsgIdDirtyStatusChanged, NvimServerMsgIdDirtyStatusChanged,
NeoVimServerMsgIdCwdChanged, NvimServerMsgIdCwdChanged,
NeoVimServerMsgIdColorSchemeChanged, NvimServerMsgIdColorSchemeChanged,
NeoVimServerMsgIdAutoCommandEvent, NvimServerMsgIdAutoCommandEvent,
NeoVimServerMsgIdDebug1, NvimServerMsgIdDebug1,
}; };
typedef NS_ENUM(NSInteger, NeoVimAgentMsgId) { typedef NS_ENUM(NSInteger, NvimBridgeMsgId) {
NeoVimAgentMsgIdAgentReady = 0, NvimBridgeMsgIdAgentReady = 0,
NeoVimAgentMsgIdInput, NvimBridgeMsgIdInput,
NeoVimAgentMsgIdInputMarked, NvimBridgeMsgIdInputMarked,
NeoVimAgentMsgIdDelete, NvimBridgeMsgIdDelete,
NeoVimAgentMsgIdResize, NvimBridgeMsgIdResize,
NeoVimAgentMsgIdScroll, NvimBridgeMsgIdScroll,
NeoVimAgentMsgIdGetEscapeFileNames, NvimBridgeMsgIdGetEscapeFileNames,
NeoVimAgentMsgIdFocusGained, NvimBridgeMsgIdFocusGained,
NeoVimAgentMsgIdDebug1, NvimBridgeMsgIdDebug1,
}; };

View File

@ -1032,7 +1032,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -1087,7 +1087,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 257; CURRENT_PROJECT_VERSION = 258;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;

View File

@ -32,7 +32,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-257</string> <string>SNAPSHOT-258</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
@ -49,7 +49,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>257</string> <string>258</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string> <string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>BNDL</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-257</string> <string>SNAPSHOT-258</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>257</string> <string>258</string>
</dict> </dict>
</plist> </plist>

View File

@ -7,30 +7,24 @@
<description>Most recent changes with links to updates for VimR.</description> <description>Most recent changes with links to updates for VimR.</description>
<language>en</language> <language>en</language>
<item> <item>
<title>SNAPSHOT-257</title> <title>SNAPSHOT-258</title>
<description><![CDATA[ <description><![CDATA[
<ul> <ul>
<li><em>WARNING</em>: This snapshot may be unstable.</li> <li><em>WARNING</em>: This snapshot may be unstable.</li>
<li>Migrate one of the few Objective-C parts to Swift.</li> <li>GH-605: Further (slightly) improved scrolling. </li>
<li>GH-605: Slightly improve scroll performance.</li> <li>Bugfix: Quote <code>--nvim</code> arguments correctly (this was introduced in the last snapshot).</li>
<li>Dependencies updates:<ul>
<li>ReactiveX/RxSwift@4.1.1</li>
<li>sindresorhus/github-markdown-css@2.10.0</li>
<li>Quick/Nimble@7.0.3</li>
</ul>
</li>
</ul> </ul>
]]></description> ]]></description>
<releaseNotesLink> <releaseNotesLink>
https://github.com/qvacua/vimr/releases/tag/snapshot/257 https://github.com/qvacua/vimr/releases/tag/snapshot/258
</releaseNotesLink> </releaseNotesLink>
<pubDate>2018-01-22T19:35:09.975390</pubDate> <pubDate>2018-01-25T23:12:29.260007</pubDate>
<minimumSystemVersion>10.10.0</minimumSystemVersion> <minimumSystemVersion>10.10.0</minimumSystemVersion>
<enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/257/VimR-SNAPSHOT-257.tar.bz2" <enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/258/VimR-SNAPSHOT-258.tar.bz2"
sparkle:version="257" sparkle:version="258"
sparkle:shortVersionString="SNAPSHOT-257" sparkle:shortVersionString="SNAPSHOT-258"
sparkle:dsaSignature="MC4CFQDU5plbXXSLDfjxHdaa8BVIDSczLAIVAOSMo+hC92C07HMViUu9iOMjlBVN" sparkle:dsaSignature="MC4CFQDrjPqwMEh8UK9jjMNs2G1AUgxdhgIVAMdfOHH+FUcBdsYepmZGvVFhl/O5"
length="11921363" length="11919728"
type="application/octet-stream"/> type="application/octet-stream"/>
</item> </item>
</channel> </channel>

View File

@ -7,6 +7,7 @@ from string import Template
import re import re
import textwrap import textwrap
import os import os
import io
void_func_template = Template('''\ void_func_template = Template('''\
@ -396,14 +397,31 @@ def parse_version(version):
def parse_error_types(error_types): def parse_error_types(error_types):
return textwrap.indent('\n'.join([f'private static let {t.lower()}RawValue = UInt64({v["id"]})' for t, v in error_types.items()]), ' ').lstrip() return textwrap.indent(
'\n'.join(
[f'private static let {t.lower()}RawValue = UInt64({v["id"]})' for t, v in error_types.items()]
),
' '
).lstrip()
def parse_error_cases(error_types): def parse_error_cases(error_types):
return textwrap.indent('\n'.join([f'case Error.{t.lower()}RawValue: self = .{t.lower()}(message: message)' for t, v in error_types.items()]), ' ').lstrip() return textwrap.indent(
'\n'.join(
[f'case Error.{t.lower()}RawValue: self = .{t.lower()}(message: message)' for t, v in error_types.items()]
),
' '
).lstrip()
if __name__ == '__main__': if __name__ == '__main__':
result_file_path = './NvimMsgPack/NvimApiMethods.generated.swift'
if 'CONFIGURATION' in os.environ and os.environ['CONFIGURATION'] == 'Debug':
if os.path.isfile(result_file_path):
print("Files already there and DEBUG, exiting...")
exit(0)
nvim_path = os.environ['NVIM_PATH'] if 'NVIM_PATH' in os.environ else 'nvim' nvim_path = os.environ['NVIM_PATH'] if 'NVIM_PATH' in os.environ else 'nvim'
nvim_output = subprocess.run([nvim_path, '--api-info'], stdout=subprocess.PIPE) nvim_output = subprocess.run([nvim_path, '--api-info'], stdout=subprocess.PIPE)
@ -413,7 +431,7 @@ if __name__ == '__main__':
functions = [f for f in api['functions'] if 'deprecated_since' not in f] functions = [f for f in api['functions'] if 'deprecated_since' not in f]
body = '\n'.join([parse_function(f) for f in functions]) body = '\n'.join([parse_function(f) for f in functions])
print(extension_template.substitute( result = extension_template.substitute(
body=body, body=body,
version=version, version=version,
error_types=parse_error_types(api['error_types']), error_types=parse_error_types(api['error_types']),
@ -421,4 +439,7 @@ if __name__ == '__main__':
buffer_type=api['types']['Buffer']['id'], buffer_type=api['types']['Buffer']['id'],
window_type=api['types']['Window']['id'], window_type=api['types']['Window']['id'],
tabpage_type=api['types']['Tabpage']['id'] tabpage_type=api['types']['Tabpage']['id']
)) )
with io.open(result_file_path, 'w') as api_methods_file:
api_methods_file.write(result)

View File

@ -5,34 +5,41 @@ import io
import re import re
from string import Template from string import Template
print(os.getcwd())
if 'CONFIGURATION' in os.environ and os.environ['CONFIGURATION'] == 'Debug':
if os.path.isfile('./NvimView/NvimAutoCommandEvent.generated.swift'):
print("Files already there, exiting...")
exit(0)
with io.open('./neovim/build/include/auevents_enum.generated.h', 'r') as auto_cmds_file:
raw_auto_cmds = [line.strip() for line in auto_cmds_file.readlines() if re.match(r'^EVENT_', line.strip())]
def convert(line): def convert(line):
result = re.match(r'^EVENT_(.*) = (.*)', line.replace(',', '')) result = re.match(r'^EVENT_(.*) = (.*)', line.replace(',', ''))
return result.group(1), result.group(2) return result.group(1), result.group(2)
auto_cmds = [convert(line) for line in raw_auto_cmds] def swift_auto_cmds():
auto_cmds_template = Template( with io.open('./neovim/build/include/auevents_enum.generated.h', 'r') as auto_cmds_file:
''' raw_auto_cmds = [line.strip() for line in auto_cmds_file.readlines() if re.match(r'^EVENT_', line.strip())]
auto_cmds = [convert(line) for line in raw_auto_cmds]
auto_cmds_template = Template(
'''// Auto generated for nvim version 0.2.2.
// See bin/generate_source.py
enum NvimAutoCommandEvent: Int { enum NvimAutoCommandEvent: Int {
${event_cases} ${event_cases}
} }
''' '''
) )
header = auto_cmds_template.substitute( return auto_cmds_template.substitute(
event_cases='\n'.join( event_cases='\n'.join(
[' case {} = {}'.format(event[0].lower(), event[1]) for event in auto_cmds] [' case {} = {}'.format(event[0].lower(), event[1]) for event in auto_cmds]
), ),
) )
with io.open('./NvimView/NvimAutoCommandEvent.generated.swift', 'w') as auto_cmds_header_file:
auto_cmds_header_file.write(header)
if __name__ == '__main__':
result_file_path = './NvimView/NvimAutoCommandEvent.generated.swift'
if 'CONFIGURATION' in os.environ and os.environ['CONFIGURATION'] == 'Debug':
if os.path.isfile(result_file_path):
print("Files already there, exiting...")
exit(0)
with io.open(result_file_path, 'w') as auto_cmds_header_file:
auto_cmds_header_file.write(swift_auto_cmds())