]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/fixers/erlang_mode.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / fixers / erlang_mode.vim
1 " Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
2 " Description: Indent with the Erlang mode for Emacs
3
4 call ale#Set('erlang_erlang_mode_emacs_executable', 'emacs')
5 call ale#Set('erlang_erlang_mode_indent_level', 4)
6 call ale#Set('erlang_erlang_mode_icr_indent', 'nil')
7 call ale#Set('erlang_erlang_mode_indent_guard', 2)
8 call ale#Set('erlang_erlang_mode_argument_indent', 2)
9 call ale#Set('erlang_erlang_mode_indent_tabs_mode', 'nil')
10
11 let s:variables = {
12 \   'erlang-indent-level': 'erlang_erlang_mode_indent_level',
13 \   'erlang-icr-indent': 'erlang_erlang_mode_icr_indent',
14 \   'erlang-indent-guard': 'erlang_erlang_mode_indent_guard',
15 \   'erlang-argument-indent': 'erlang_erlang_mode_argument_indent',
16 \   'indent-tabs-mode': 'erlang_erlang_mode_indent_tabs_mode',
17 \}
18
19 function! ale#fixers#erlang_mode#Fix(buffer) abort
20     let l:emacs_executable =
21     \   ale#Var(a:buffer, 'erlang_erlang_mode_emacs_executable')
22
23     let l:exprs = [
24     \   '(setq enable-local-variables :safe)',
25     \   s:SetqDefault(a:buffer, s:variables),
26     \   '(erlang-mode)',
27     \   '(font-lock-fontify-region (point-min) (point-max))',
28     \   '(indent-region (point-min) (point-max))',
29     \   '(funcall (if indent-tabs-mode ''tabify ''untabify)'
30     \         . ' (point-min) (point-max))',
31     \   '(save-buffer 0)',
32     \]
33
34     let l:command = ale#Escape(l:emacs_executable)
35     \   . ' --batch'
36     \   . ' --find-file=%t'
37     \   . join(map(l:exprs, '" --eval=" . ale#Escape(v:val)'), '')
38
39     return {'command': l:command, 'read_temporary_file': 1}
40 endfunction
41
42 function! s:SetqDefault(buffer, variables) abort
43     let l:args = []
44
45     for [l:emacs_name, l:ale_name] in items(a:variables)
46         let l:args += [l:emacs_name, ale#Var(a:buffer, l:ale_name)]
47     endfor
48
49     return '(setq-default ' . join(l:args) . ')'
50 endfunction