File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
quick-lint-js.vim/autoload Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 5
5
" https://github.com/dense-analysis/ale
6
6
7
7
function ! quick_lint_js_ale#get_command (buffer_number) abort
8
- return ' %e --output-format=vim-qflist-json --vim-file-bufnr ' .string (a: buffer_number ).' --path-for-config-search=%s %t'
8
+ let l: extra_options = ' '
9
+ if quick_lint_js_ale#is_buffer_associated_with_file (a: buffer_number )
10
+ let l: extra_options .= ' --path-for-config-search=%s'
11
+ endif
12
+ return ' %e --output-format=vim-qflist-json --vim-file-bufnr ' .string (a: buffer_number ).l: extra_options .' %t'
9
13
endfunction
10
14
11
15
function ! quick_lint_js_ale#get_executable (buffer_number) abort
@@ -36,6 +40,11 @@ function! quick_lint_js_ale#get_lsp_project_root(_buffer_number) abort
36
40
return ' /'
37
41
endfunction
38
42
43
+ function ! quick_lint_js_ale#is_buffer_associated_with_file (buffer_number) abort
44
+ return bufname (a: buffer_number ) !=# ' '
45
+ \ && getbufvar (a: buffer_number , ' &buftype' ) == # ' '
46
+ endfunction
47
+
39
48
" quick-lint-js finds bugs in JavaScript programs.
40
49
" Copyright (C) 2020 Matthew "strager" Glazar
41
50
"
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ function! s:main() abort
15
15
endfunction
16
16
17
17
function ! s: test_all () abort
18
+ call s: test_parse_command_output ()
19
+ call s: test_buffer_is_associated_with_file ()
20
+ endfunction
21
+
22
+ function ! s: test_parse_command_output () abort
18
23
let l: qflist = s: parse ([' ' ])
19
24
call assert_equal ([], l: qflist )
20
25
@@ -72,6 +77,33 @@ function! s:parse(lines) abort
72
77
return quick_lint_js_ale#parse_command_output (0 , a: lines )
73
78
endfunction
74
79
80
+ function ! s: test_buffer_is_associated_with_file () abort
81
+ % bwipeout !
82
+ call assert_false (quick_lint_js_ale#is_buffer_associated_with_file (bufnr (' %' )))
83
+
84
+ % bwipeout !
85
+ silent edit file - name.txt
86
+ call assert_true (quick_lint_js_ale#is_buffer_associated_with_file (bufnr (' %' )))
87
+
88
+ % bwipeout !
89
+ silent edit file - name.txt
90
+ set buftype = nofile
91
+ call assert_false (quick_lint_js_ale#is_buffer_associated_with_file (bufnr (' %' )))
92
+
93
+ % bwipeout !
94
+ help
95
+ set filetype = javascript
96
+ call assert_false (quick_lint_js_ale#is_buffer_associated_with_file (bufnr (' %' )))
97
+
98
+ " Check a buffer different from the current buffer:
99
+ % bwipeout !
100
+ silent edit file .txt
101
+ let l: file_buffer_number = bufnr (' %' )
102
+ new
103
+ call assert_false (quick_lint_js_ale#is_buffer_associated_with_file (bufnr (' %' )))
104
+ call assert_true (quick_lint_js_ale#is_buffer_associated_with_file (l: file_buffer_number ))
105
+ endfunction
106
+
75
107
function ! s: check_for_errors () abort
76
108
if len (v: errors ) > 0
77
109
for l: error in v: errors
You can’t perform that action at this time.
0 commit comments