简体   繁体   中英

Add ale fixer for a specific file name?

I would like to define a fixer for tox.ini files that invokes tox-ini-fmt , but when defining my fixer mapping, doing the naïve thing of specifying "tox.ini" doesn't work:

let g:ale_fixers = {"tox.ini": "tox-ini-fmt"}

I have worked around this by defining a custom file type toxini , but I'm wondering if there's a more direct way to do this, since I'm not sure I need to maintain a custom file type just for this.

How about something like this in vimrc or (probably better) after/filetype.vim ?

au BufNewFile,BufRead tox.ini let b:ale_fixers = ["tox-ini-fmt"]

Whenever you create a new file or read an existing file called tox.ini, that will set the buffer-local variable b:ale_fixers to ["tox-ini-fmt"]

References:

:help :autocmd
:help BufNewFile
:help BufRead
:help buffer-variable

and

https://github.com/dense-analysis/ale#2ii-fixing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM