File tree 4 files changed +17
-15
lines changed
parser/scripts/engines/javascript
4 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ The queue of callbacks resets after this event is triggered.
10
10
11
11
``` lua
12
12
require (' kulala.api' ).on (" after_next_request" , function (data )
13
- vim .print (" Request completed" )
14
- vim .print (" Headers: " .. data .headers )
15
- vim .print (" Body: " .. data .body )
16
- vim .print (" Complete response: " , data .response )
13
+ vim .inspect (" Request completed" )
14
+ vim .inspect (" Headers: " .. data .headers )
15
+ vim .inspect (" Body: " .. data .body )
16
+ vim .inspect (" Complete response: " , data .response )
17
17
end )
18
18
```
19
19
@@ -23,10 +23,10 @@ Triggered after a request has been successfully completed.
23
23
24
24
``` lua
25
25
require (' kulala.api' ).on (" after_request" , function (data )
26
- vim .print (" Request completed" )
27
- vim .print (" Headers: " .. data .headers )
28
- vim .print (" Body: " .. data .body )
29
- vim .print (" Complete response: " , data .response )
26
+ vim .inspect (" Request completed" )
27
+ vim .inspect (" Headers: " .. data .headers )
28
+ vim .inspect (" Body: " .. data .body )
29
+ vim .inspect (" Complete response: " , data .response )
30
30
end )
31
31
```
32
32
Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ local FILE_MAPPING = {
26
26
27
27
local is_uptodate = function ()
28
28
local version = FS .read_file (BASE_FILE_VER ) or 0
29
- return GLOBALS .VERSION == version
29
+ return GLOBALS .VERSION == version and FS . file_exists ( BASE_FILE_PRE ) and FS . file_exists ( BASE_FILE_POST )
30
30
end
31
31
32
32
--- @param wait boolean -- wait to complete
33
33
M .install_dependencies = function (wait )
34
- if FS . file_exists ( BASE_FILE_PRE ) and FS . file_exists ( BASE_FILE_POST ) and is_uptodate () then return true end
34
+ if is_uptodate () then return true end
35
35
36
36
Logger .warn (" Javascript base files not found or are out of date." )
37
37
Logger .info (
Original file line number Diff line number Diff line change 64
64
--- Either returns the absolute path if the path is already absolute or
65
65
--- joins the path with the current buffer directory
66
66
M .get_file_path = function (path )
67
- path = vim .fn .expand (path )
67
+ local ex_path = vim .fn .expand (path , true )
68
+ path = ex_path ~= " " and ex_path or path
68
69
69
70
if M .is_absolute_path (path ) then return path end
70
71
if path :sub (1 , 2 ) == " ./" or path :sub (1 , 2 ) == " .\\ " then path = path :sub (3 ) end
@@ -203,6 +204,7 @@ M.get_plugin_tmp_dir = function()
203
204
local cache = vim .fn .stdpath (" cache" )
204
205
--- @cast cache string
205
206
local dir = M .join_paths (cache , " kulala" )
207
+
206
208
M .ensure_dir_exists (dir )
207
209
return dir
208
210
end
214
216
215
217
M .get_tmp_scripts_build_dir = function ()
216
218
local dir = M .join_paths (M .get_plugin_tmp_dir (), " scripts" , " build" )
217
- M .ensure_dir_exists (dir )
218
-
219
219
return dir
220
220
end
221
221
@@ -325,6 +325,8 @@ M.read_file = function(filename, is_binary)
325
325
if not f then return end
326
326
327
327
local content = f :read (" *a" )
328
+ if not content then return end
329
+
328
330
content = is_binary and content or content :gsub (" \r\n " , " \n " )
329
331
f :close ()
330
332
Original file line number Diff line number Diff line change @@ -497,15 +497,15 @@ describe("UI", function()
497
497
wait_for_requests (1 )
498
498
499
499
local win_config = vim .api .nvim_win_get_config (vim .fn .bufwinid (ui_buf ))
500
- assert .is_same ( " right " , win_config .split )
500
+ assert .is_truthy ( win_config .split )
501
501
end )
502
502
503
503
it (" opens results in float" , function ()
504
504
kulala .run ()
505
505
wait_for_requests (1 )
506
506
507
507
local win_config = vim .api .nvim_win_get_config (vim .fn .bufwinid (ui_buf ))
508
- assert .is_same ( " editor " , win_config .relative )
508
+ assert .is_truthy ( win_config .relative )
509
509
end )
510
510
511
511
it (" closes float and deletes buffer on 'q'" , function ()
You can’t perform that action at this time.
0 commit comments