Browse Source

Close #1439 - Add an :ALEInfoToFile command

PR/add-argon
w0rp 6 years ago
parent
commit
7cf3ddf6c4
No known key found for this signature in database GPG Key ID: FC1ECAA8C81CD83
5 changed files with 51 additions and 3 deletions
  1. +4
    -3
      .gitignore
  2. +11
    -0
      autoload/ale/debugging.vim
  3. +3
    -0
      doc/ale.txt
  4. +2
    -0
      plugin/ale.vim
  5. +31
    -0
      test/test_ale_info.vader

+ 4
- 3
.gitignore View File

@@ -1,6 +1,7 @@
/init.vim
/doc/tags
.*
!.editorconfig
*.obj
.*
/doc/tags
/init.vim
/test/ale-info-test-file
tags

+ 11
- 0
autoload/ale/debugging.vim View File

@@ -211,3 +211,14 @@ function! ale#debugging#InfoToClipboard() abort

call s:Echo('ALEInfo copied to your clipboard')
endfunction

function! ale#debugging#InfoToFile(filename) abort
let l:expanded_filename = expand(a:filename)

redir => l:output
silent call ale#debugging#Info()
redir END

call writefile(split(l:output, "\n"), l:expanded_filename)
call s:Echo('ALEInfo written to ' . l:expanded_filename)
endfunction

+ 3
- 0
doc/ale.txt View File

@@ -1869,6 +1869,9 @@ ALEInfoToClipboard *ALEInfoToClipboard*
The command `:ALEInfoToClipboard` can be used to output ALEInfo directly to
your clipboard. This might not work on every machine.

`:ALEInfoToFile` will write the ALE runtime information to a given filename.
The filename works just like |:w|.


ALEReset *ALEReset*
ALEResetBuffer *ALEResetBuffer*


+ 2
- 0
plugin/ale.vim View File

@@ -259,6 +259,8 @@ command! -bar ALELint :call ale#Queue(0, 'lint_file')
command! -bar ALEInfo :call ale#debugging#Info()
" The same, but copy output to your clipboard.
command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboard()
" Copy ALE information to a file.
command! -bar -nargs=1 ALEInfoToFile :call ale#debugging#InfoToFile(<f-args>)

" Fix problems in files.
command! -bar ALEFix :call ale#fix#Fix()


+ 31
- 0
test/test_ale_info.vader View File

@@ -105,6 +105,8 @@ Before:
AssertEqual a:expected_list, split(l:output, "\n")
endfunction

call ale#test#SetDirectory('/testplugin/test')

After:
Restore

@@ -123,6 +125,8 @@ After:
unlet! g:ale_testft2_testlinter2_bar
delfunction CheckInfo

call ale#test#RestoreDirectory()

Given nolintersft (Empty buffer with no linters):
Execute (ALEInfo with no linters should return the right output):
call CheckInfo([
@@ -251,6 +255,33 @@ Execute (ALEInfo should return appropriately named global variables):
\ 'let g:ale_testft_testlinter1_foo = ''abc''',
\] + g:globals_lines + g:command_header)

Execute (ALEInfoToFile should write to a file correctly):
if filereadable(g:dir . '/ale-info-test-file')
call delete(g:dir . '/ale-info-test-file')
endif

let g:ale_testft_testlinter1_foo = 'abc'
let g:ale_testft_testlinter1_bar = ['abc']
let g:ale_testft2_testlinter2_foo = 123
let g:ale_testft2_testlinter2_bar = {'x': 'y'}

call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)

execute 'ALEInfoToFile ' . fnameescape(g:dir . '/ale-info-test-file')

AssertEqual [
\ ' Current Filetype: testft.testft2',
\ 'Available Linters: [''testlinter1'', ''testlinter2'']',
\ ' Enabled Linters: [''testlinter1'', ''testlinter2'']',
\ ' Linter Variables:',
\ '',
\ 'let g:ale_testft2_testlinter2_bar = {''x'': ''y''}',
\ 'let g:ale_testft2_testlinter2_foo = 123',
\ 'let g:ale_testft_testlinter1_bar = [''abc'']',
\ 'let g:ale_testft_testlinter1_foo = ''abc''',
\] + g:globals_lines + g:command_header, readfile(g:dir . '/ale-info-test-file')

Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should buffer-local linter variables):
let g:ale_testft2_testlinter2_foo = 123


Loading…
Cancel
Save