mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-01 01:32:04 +03:00
GH-251, GH-258 Show a warning when there was an error during the initialization of init.vim
This commit is contained in:
parent
fb86c67c73
commit
762c1e7267
@ -597,11 +597,8 @@ void server_start_neovim() {
|
|||||||
|
|
||||||
_backspace = [[NSString alloc] initWithString:@"<BS>"];
|
_backspace = [[NSString alloc] initWithString:@"<BS>"];
|
||||||
|
|
||||||
NSData *data = nil;
|
bool value = msg_didany > 0;
|
||||||
if (msg_didany > 0) {
|
NSData *data = [[NSData alloc] initWithBytes:&value length:sizeof(bool)];
|
||||||
bool value = true;
|
|
||||||
data = [[NSData alloc] initWithBytes:&value length:sizeof(bool)];
|
|
||||||
}
|
|
||||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdNeoVimReady data:data];
|
[_neovim_server sendMessageWithId:NeoVimServerMsgIdNeoVimReady data:data];
|
||||||
[data release];
|
[data release];
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (instancetype)initWithUuid:(NSString *)uuid;
|
- (instancetype)initWithUuid:(NSString *)uuid;
|
||||||
- (void)quit;
|
- (void)quit;
|
||||||
|
|
||||||
- (void)runLocalServerAndNeoVimWithPath:(NSString *)path;
|
- (bool)runLocalServerAndNeoVimWithPath:(NSString *)path;
|
||||||
|
|
||||||
- (void)vimCommand:(NSString *)string;
|
- (void)vimCommand:(NSString *)string;
|
||||||
|
|
||||||
|
@ -52,7 +52,9 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
CFRunLoopRef _localServerRunLoop;
|
CFRunLoopRef _localServerRunLoop;
|
||||||
|
|
||||||
NSTask *_neoVimServerTask;
|
NSTask *_neoVimServerTask;
|
||||||
|
|
||||||
bool _neoVimIsReady;
|
bool _neoVimIsReady;
|
||||||
|
bool _isInitErrorPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithUuid:(NSString *)uuid {
|
- (instancetype)initWithUuid:(NSString *)uuid {
|
||||||
@ -63,6 +65,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
|
|
||||||
_uuid = uuid;
|
_uuid = uuid;
|
||||||
_neoVimIsReady = NO;
|
_neoVimIsReady = NO;
|
||||||
|
_isInitErrorPresent = NO;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -85,7 +88,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
[_localServerThread cancel];
|
[_localServerThread cancel];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)runLocalServerAndNeoVimWithPath:(NSString *)path {
|
- (bool)runLocalServerAndNeoVimWithPath:(NSString *)path {
|
||||||
_localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil];
|
_localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil];
|
||||||
[_localServerThread start];
|
[_localServerThread start];
|
||||||
|
|
||||||
@ -103,6 +106,8 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
// Wait until neovim is ready.
|
// Wait until neovim is ready.
|
||||||
while (!_neoVimIsReady
|
while (!_neoVimIsReady
|
||||||
&& [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
|
&& [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
|
||||||
|
|
||||||
|
return !_isInitErrorPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)vimCommand:(NSString *)string {
|
- (void)vimCommand:(NSString *)string {
|
||||||
@ -250,11 +255,10 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case NeoVimServerMsgIdNeoVimReady: {
|
case NeoVimServerMsgIdNeoVimReady: {
|
||||||
_neoVimIsReady = YES;
|
bool *value = data_to_bool_array(data, 1);
|
||||||
|
_isInitErrorPresent = value[0];
|
||||||
|
|
||||||
if (data.length > 0) {
|
_neoVimIsReady = YES;
|
||||||
log4Warn("There was an error during the initialization of NeoVim. Use :messages to view the error messages.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,19 @@ public class NeoVimView: NSView, NSUserInterfaceValidations {
|
|||||||
|
|
||||||
// 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.agent.bridge = self
|
self.agent.bridge = self
|
||||||
self.agent.runLocalServerAndNeoVimWithPath(ShellUtils.pathForUserShell())
|
let noErrorDuringInitialization = self.agent.runLocalServerAndNeoVimWithPath(ShellUtils.pathForUserShell())
|
||||||
|
|
||||||
// Neovim is ready now: resize neovim to bounds.
|
// Neovim is ready now: resize neovim to bounds.
|
||||||
DispatchUtils.gui {
|
DispatchUtils.gui {
|
||||||
|
if noErrorDuringInitialization == false {
|
||||||
|
let alert = NSAlert()
|
||||||
|
alert.alertStyle = .WarningAlertStyle
|
||||||
|
alert.messageText = "Error during initialization"
|
||||||
|
alert.informativeText = "There was an error during the initialization of NeoVim. "
|
||||||
|
+ "Use :messages to view the error messages."
|
||||||
|
alert.runModal()
|
||||||
|
}
|
||||||
|
|
||||||
self.resizeNeoVimUiTo(size: self.bounds.size)
|
self.resizeNeoVimUiTo(size: self.bounds.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user