Skip to content

Commit c1b5e8e

Browse files
authored
🐛fix(Windows): Requires a different command to run markmap.
1 parent d095f76 commit c1b5e8e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lua/markmap/init.lua

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ local autocmd = vim.api.nvim_create_autocmd
66
local M = {}
77

88
M.setup = function(ctx)
9+
-- Detect OS
10+
local is_windows = uv.os_uname().sysname == "Windows"
11+
local is_android = vim.fn.isdirectory('/system') == 1
12+
913
-- Setup options
1014
local html_output = ctx.html_output
1115
local hide_toolbar = ctx.hide_toolbar
1216
local grace_period = ctx.grace_period
1317

1418
-- Set default options
1519
if html_output == nil then
16-
local is_windows = uv.os_uname().sysname == "Windows"
17-
local is_android = vim.fn.isdirectory('/system') == 1
1820
if is_windows then -- windows
1921
html_output = "C:\\Users\\<username>\\AppData\\Local\\Temp\\markmap.html"
2022
elseif is_android then -- android
@@ -34,6 +36,12 @@ M.setup = function(ctx)
3436
grace_period = 3600000 -- 60min
3537
end
3638

39+
-- Windows extra fix
40+
local run_markmap = "markmap"
41+
if is_windows then
42+
run_markmap = "markmap.cmd"
43+
end
44+
3745
-- Set a common job for all commands.
3846
-- This prevents more than one job running at the same time.
3947
local job = nil
@@ -56,23 +64,23 @@ M.setup = function(ctx)
5664
reset_arguments()
5765
table.insert(arguments, vim.fn.expand "%:p") -- current buffer path
5866
if job ~= nil then uv.process_kill(job, 9) end
59-
job = uv.spawn("markmap", { args = arguments, detached = true }, nil)
67+
job = uv.spawn(run_markmap, { args = arguments, detached = true }, nil)
6068
end, { desc = "Show a mental map of the current file" })
6169

6270
cmd("MarkmapSave", function()
6371
reset_arguments()
6472
table.insert(arguments, "--no-open") -- specific to this command
6573
table.insert(arguments, vim.fn.expand "%:p") -- current buffer path
6674
if job ~= nil then uv.process_kill(job, 9) end -- kill -9 jobs
67-
job = uv.spawn("markmap", { args = arguments, detached = true }, nil)
75+
job = uv.spawn(run_markmap, { args = arguments, detached = true }, nil)
6876
end, { desc = "Save the HTML file without opening the mindmap" })
6977

7078
cmd("MarkmapWatch", function()
7179
reset_arguments()
7280
table.insert(arguments, "--watch") -- spetific to this command
7381
table.insert(arguments, vim.fn.expand "%:p") -- current buffer path
7482
if job ~= nil then uv.process_kill(job, 9) end
75-
job = uv.spawn("markmap", { args = arguments, detached = true }, nil)
83+
job = uv.spawn(run_markmap, { args = arguments, detached = true }, nil)
7684
end,
7785
{ desc = "Show a mental map of the current file and watch for changes" }
7886
)

0 commit comments

Comments
 (0)