@@ -11,62 +11,62 @@ local bin = { compile = tostring(bin_dir:joinpath("compile")) }
1111local M = {}
1212
1313local p = function (x )
14- io.stdout :write (x .. " \n " )
15- return x
14+ io.stdout :write (x .. " \n " )
15+ return x
1616end
1717
1818function M .compile (source_path , install_path , opts )
19- local do_sync = opts .sync or false
20- local v = Version .get ()
19+ local do_sync = opts .sync or false
20+ local v = Version .get ()
2121
22- local printer = function (err , line )
23- if opts .bufnr then
24- vim .api .nvim_buf_set_lines (opts .bufnr , - 1 , - 1 , false , { line })
25- vim .api .nvim_buf_call (opts .bufnr , function ()
26- vim .api .nvim_command (" normal G" )
27- end )
28- else
29- if err then
30- p (err )
31- else
32- p (line )
33- end
34- end
35- end
22+ local printer = function (err , line )
23+ if opts .bufnr then
24+ vim .api .nvim_buf_set_lines (opts .bufnr , - 1 , - 1 , false , { line })
25+ vim .api .nvim_buf_call (opts .bufnr , function ()
26+ vim .api .nvim_command (" normal G" )
27+ end )
28+ else
29+ if err then
30+ p (err )
31+ else
32+ p (line )
33+ end
34+ end
35+ end
3636
37- local compile = Job :new ( {
38- command = bin .compile ,
39- args = { install_path },
40- cwd = source_path ,
41- on_start = function ()
42- vim .notify (" Compiling ElixirLS..." )
43- end ,
44- on_stdout = do_sync and printer or vim .schedule_wrap (printer ),
45- on_stderr = do_sync and printer or vim .schedule_wrap (printer ),
46- on_exit = vim .schedule_wrap (function (_ , code )
47- if code == 0 then
48- if opts .bufnr then
49- vim .api .nvim_buf_call (opts .bufnr , function ()
50- vim .api .nvim_command (" quit" )
51- end )
52- end
37+ local compile = Job :new {
38+ command = bin .compile ,
39+ args = { install_path },
40+ cwd = source_path ,
41+ on_start = function ()
42+ vim .notify (" Compiling ElixirLS..." )
43+ end ,
44+ on_stdout = do_sync and printer or vim .schedule_wrap (printer ),
45+ on_stderr = do_sync and printer or vim .schedule_wrap (printer ),
46+ on_exit = vim .schedule_wrap (function (_ , code )
47+ if code == 0 then
48+ if opts .bufnr then
49+ vim .api .nvim_buf_call (opts .bufnr , function ()
50+ vim .api .nvim_command (" quit" )
51+ end )
52+ end
5353
54- vim .notify (" Finished compiling ElixirLS!" )
55- vim .notify (" Reloading buffer" )
56- vim .api .nvim_command (" edit" )
57- vim .notify (" Restarting LSP client" )
58- vim .api .nvim_command (" LspRestart" )
59- end
60- end ),
61- })
54+ vim .notify (" Finished compiling ElixirLS!" )
55+ vim .notify (" Reloading buffer" )
56+ vim .api .nvim_command (" edit" )
57+ vim .notify (" Restarting LSP client" )
58+ vim .api .nvim_command (" LspRestart" )
59+ end
60+ end ),
61+ }
6262
63- -- sync is just for testing
64- if do_sync then
65- compile :sync (60000 )
66- else
67- compile :start ()
68- end
63+ -- sync is just for testing
64+ if do_sync then
65+ compile :sync (60000 )
66+ else
67+ compile :start ()
68+ end
6969
70- return compile
70+ return compile
7171end
7272return M
0 commit comments