Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions autoload/ale/fix/registry.vim
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['kt'],
\ 'description': 'Fix Kotlin files with ktlint.',
\ },
\ 'latexindent': {
\ 'function': 'ale#fixers#latexindent#Fix',
\ 'suggested_filetypes': ['tex'],
\ 'description' : 'Indent code within environments, commands, after headings and within special code blocks.',
\ },
\}

" Reset the function registry to the default entries.
Expand Down
18 changes: 18 additions & 0 deletions autoload/ale/fixers/latexindent.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
" Author: riley-martine <[email protected]>
" Description: Integration of latexindent with ALE.

call ale#Set('tex_latexindent_executable', 'latexindent')
call ale#Set('tex_latexindent_options', '')

function! ale#fixers#latexindent#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'tex_latexindent_executable')
let l:options = ale#Var(a:buffer, 'tex_latexindent_options')

return {
\ 'command': ale#Escape(l:executable)
\ . ' -l -w'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction
21 changes: 21 additions & 0 deletions doc/ale-tex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,26 @@ g:ale_lacheck_executable *g:ale_lacheck_executable*
This variable can be changed to change the path to lacheck.



===============================================================================
latexindent *ale-tex-latexindent*

g:ale_tex_latexindent_executable *g:ale_tex_latexindent_executable*
*b:ale_tex_latexindent_executable*
Type: |String|
Default: `'latexindent'`

This variable can be changed to change the path to latexindent.


g:ale_tex_latexindent_options *g:ale_tex_latexindent_options*
*b:ale_tex_latexindent_options*
Type: |String|
Default: `''`

This variable can be changed to modify flags given to latexindent.



===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
1 change: 1 addition & 0 deletions doc/ale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,7 @@ documented in additional help files.
tex.....................................|ale-tex-options|
chktex................................|ale-tex-chktex|
lacheck...............................|ale-tex-lacheck|
latexindent...........................|ale-tex-latexindent|
texinfo.................................|ale-texinfo-options|
write-good............................|ale-texinfo-write-good|
text....................................|ale-text-options|
Expand Down
40 changes: 40 additions & 0 deletions test/fixers/test_latexindent_fixer_callback.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Before:
Save g:ale_tex_latexindent_executable
Save g:ale_tex_latexindent_options

" Use an invalid global executable, so we don't match it.
let g:ale_tex_latexindent_executable = 'xxxinvalid'
let g:ale_tex_latexindent_options = ''

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

After:
Restore

call ale#test#RestoreDirectory()

Execute(The latexindent callback should return the correct default values):
call ale#test#SetFilename('../tex_files/testfile.tex')

AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -l -w'
\ . ' %t',
\ },
\ ale#fixers#latexindent#Fix(bufnr(''))

Execute(The latexindent callback should include custom gofmt options):
let g:ale_tex_latexindent_options = "-l '~/.indentconfig.yaml'"
call ale#test#SetFilename('../tex_files/testfile.tex')

AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -l -w'
\ . ' ' . g:ale_tex_latexindent_options
\ . ' %t',
\ },
\ ale#fixers#latexindent#Fix(bufnr(''))
Empty file added test/tex_files/testfile.tex
Empty file.