From 8d06a3e475207cb6a3c1237c314874e8c96613dd Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 1 Dec 2017 20:58:46 +0100 Subject: [PATCH] Use user's temp folder for the socket --- SwiftNeoVim/NeoVimAgent.m | 7 ++++++- SwiftNeoVim/NeoVimView.swift | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SwiftNeoVim/NeoVimAgent.m b/SwiftNeoVim/NeoVimAgent.m index c6c97e72..0b4e5526 100644 --- a/SwiftNeoVim/NeoVimAgent.m +++ b/SwiftNeoVim/NeoVimAgent.m @@ -210,8 +210,13 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m _neoVimServerTask.arguments = shellArgs; [_neoVimServerTask launch]; + __auto_type listenAddress = [ + [[NSURL alloc] initFileURLWithPath:NSTemporaryDirectory()] + URLByAppendingPathComponent:[NSString stringWithFormat:@"vimr_%@.sock", _uuid] + ].path; + NSString *cmd = [NSString stringWithFormat:@"NVIM_LISTEN_ADDRESS=%@ exec \"%@\" '%@' '%@'", - [NSString stringWithFormat:@"/tmp/vimr_%@.sock", _uuid], + listenAddress, [self neoVimServerExecutablePath], [self localServerName], [self remoteServerName]]; diff --git a/SwiftNeoVim/NeoVimView.swift b/SwiftNeoVim/NeoVimView.swift index 03b5e852..e0e5a633 100644 --- a/SwiftNeoVim/NeoVimView.swift +++ b/SwiftNeoVim/NeoVimView.swift @@ -152,7 +152,9 @@ public class NeoVimView: NSView, public init(frame rect: NSRect, config: Config) { self.drawer = TextDrawer(font: self._font) self.agent = NeoVimAgent(uuid: self.uuid) - guard let nvim = Nvim(at: "/tmp/vimr_\(self.uuid).sock") else { + + let sockPath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("vimr_\(self.uuid).sock").path + guard let nvim = Nvim(at: sockPath) else { preconditionFailure("Nvim could not be instantiated") }