File: stylua.vim

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (27 lines) | stat: -rw-r--r-- 867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
" Author: Robert Liebowitz <rliebz@gmail.com>
" Description: https://github.com/johnnymorganz/stylua

call ale#Set('lua_stylua_executable', 'stylua')
call ale#Set('lua_stylua_options', '')

function! ale#fixers#stylua#GetCwd(buffer) abort
    for l:possible_configfile in ['stylua.toml', '.stylua.toml']
        let l:config = ale#path#FindNearestFile(a:buffer, l:possible_configfile)

        if !empty(l:config)
            return fnamemodify(l:config, ':h')
        endif
    endfor

    return '%s:h'
endfunction

function! ale#fixers#stylua#Fix(buffer) abort
    let l:executable = ale#Var(a:buffer, 'lua_stylua_executable')
    let l:options = ale#Var(a:buffer, 'lua_stylua_options')

    return {
    \   'cwd': ale#fixers#stylua#GetCwd(a:buffer),
    \   'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' --stdin-filepath %s -',
    \}
endfunction