8080M .build = function (override )
8181 local file_path = u .current_file_path ()
8282 local parent_dir = vim .fn .fnamemodify (file_path , " :h:h:h:h" )
83- state .settings .bin_path = parent_dir
84- state .settings .bin = parent_dir .. (u .is_windows () and " \\ bin.exe" or " /bin" )
83+
84+ local bin_name = u .is_windows () and " bin.exe" or " bin"
85+ state .settings .root_path = parent_dir
86+ state .settings .bin = parent_dir .. u .path_separator .. " cmd" .. u .path_separator .. bin_name
8587
8688 if not override then
8789 local binary_exists = vim .loop .fs_stat (state .settings .bin )
@@ -90,17 +92,15 @@ M.build = function(override)
9092 end
9193 end
9294
93- local cmd = u .is_windows () and " cd %s\\ cmd && go build -o bin.exe && move bin.exe ..\\ "
94- or " cd %s/cmd && go build -o bin && mv bin ../bin"
95+ local res = vim
96+ .system ({ " go" , " build" , " -o" , bin_name }, { cwd = state .settings .root_path .. u .path_separator .. " cmd" })
97+ :wait ()
9598
96- local command = string.format (cmd , state .settings .bin_path )
97- local null = u .is_windows () and " >NUL" or " > /dev/null"
98- local installCode = os.execute (command .. null )
99- if installCode ~= 0 then
100- u .notify (" Could not install gitlab.nvim!" , vim .log .levels .ERROR )
99+ if res .code ~= 0 then
100+ u .notify (string.format (" Failed to install with status code %d:\n %s" , res .code , res .stderr ), vim .log .levels .ERROR )
101101 return false
102102 end
103- u .notify (" Gitlab.nvim installed successfully!" , vim .log .levels .INFO )
103+ u .notify (" Installed successfully!" , vim .log .levels .INFO )
104104 return true
105105end
106106
0 commit comments