Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows named pipe #50

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions lua/fzfx/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ function RpcRegistry:new(callback, user_context)
end

--- @return string|nil
local function get_pipe_name()
if constants.is_windows then
local result = vim.fn.trim(
string.format(
[[ \\.\pipe\nvim-pipe-%d-%d ]],
vim.fn.getpid(),
os.time()
)
)
log.debug(
"|fzfx.server - make_windows_pipe_name| result:%s",
vim.inspect(result)
local function get_windows_pipe_name()
log.ensure(
constants.is_windows,
"|fzfx.server - get_windows_pipe_name| error! must use this function in Windows!"
)
local result = vim.fn.trim(
string.format(
[[ \\.\pipe\nvim-pipe-%d-%d ]],
vim.fn.getpid(),
os.time()
)
return result
else
return nil
end
)
log.debug(
"|fzfx.server - make_windows_pipe_name| result:%s",
vim.inspect(result)
)
return result
end

--- @class RpcServer
Expand All @@ -64,7 +64,9 @@ local RpcServer = {
--- @return RpcServer
function RpcServer:new()
--- @type string
local address = vim.fn.serverstart(get_pipe_name()) --[[@as string]]
local address = constants.is_windows
and vim.fn.serverstart(get_windows_pipe_name())
or vim.fn.serverstart() --[[@as string]]
log.debug(
"|fzfx.server - RpcServer:new| start server on socket address:%s",
vim.inspect(address)
Expand Down