@@ -6,15 +6,17 @@ local autocmd = vim.api.nvim_create_autocmd
6
6
local M = {}
7
7
8
8
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
+
9
13
-- Setup options
10
14
local html_output = ctx .html_output
11
15
local hide_toolbar = ctx .hide_toolbar
12
16
local grace_period = ctx .grace_period
13
17
14
18
-- Set default options
15
19
if html_output == nil then
16
- local is_windows = uv .os_uname ().sysname == " Windows"
17
- local is_android = vim .fn .isdirectory (' /system' ) == 1
18
20
if is_windows then -- windows
19
21
html_output = " C:\\ Users\\ <username>\\ AppData\\ Local\\ Temp\\ markmap.html"
20
22
elseif is_android then -- android
@@ -34,6 +36,12 @@ M.setup = function(ctx)
34
36
grace_period = 3600000 -- 60min
35
37
end
36
38
39
+ -- Windows extra fix
40
+ local run_markmap = " markmap"
41
+ if is_windows then
42
+ run_markmap = " markmap.cmd"
43
+ end
44
+
37
45
-- Set a common job for all commands.
38
46
-- This prevents more than one job running at the same time.
39
47
local job = nil
@@ -56,23 +64,23 @@ M.setup = function(ctx)
56
64
reset_arguments ()
57
65
table.insert (arguments , vim .fn .expand " %:p" ) -- current buffer path
58
66
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 )
60
68
end , { desc = " Show a mental map of the current file" })
61
69
62
70
cmd (" MarkmapSave" , function ()
63
71
reset_arguments ()
64
72
table.insert (arguments , " --no-open" ) -- specific to this command
65
73
table.insert (arguments , vim .fn .expand " %:p" ) -- current buffer path
66
74
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 )
68
76
end , { desc = " Save the HTML file without opening the mindmap" })
69
77
70
78
cmd (" MarkmapWatch" , function ()
71
79
reset_arguments ()
72
80
table.insert (arguments , " --watch" ) -- spetific to this command
73
81
table.insert (arguments , vim .fn .expand " %:p" ) -- current buffer path
74
82
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 )
76
84
end ,
77
85
{ desc = " Show a mental map of the current file and watch for changes" }
78
86
)
0 commit comments