From b25b08fd5f1ac067d43192426b55cebe91ad109a Mon Sep 17 00:00:00 2001 From: Chiel92 Date: Mon, 12 Jan 2015 14:17:27 +0100 Subject: [PATCH] Add support for composite filetypes. Fix #37. --- README.md | 2 ++ plugin/autoformat.vim | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index c213966..6984550 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ For the default formatprogram definitions, the options `expandtab`, `shiftwidth` This means that the formatting style will match your current vim settings as much as possible. For the exact default definitions, have a look in `vim-autoformat/plugin/defaults.vim`. +If you have a composite filetype with dots (like `django.python` or `php.wordpress`), vim-autoformat internally replaces the dots with underscores so you can define formatters through `g:formatprg_django_python` and so on. + Things that are not (yet) implemented ---------------------------------------------------------- diff --git a/plugin/autoformat.vim b/plugin/autoformat.vim index f5d182e..2067148 100644 --- a/plugin/autoformat.vim +++ b/plugin/autoformat.vim @@ -1,6 +1,8 @@ "Function for finding and setting the formatter with the given name function! s:set_formatprg(...) let type = a:0 ? a:1 : &filetype + "Support composite filetypes by replacing dots with underscores + let type = substitute(type, "[.]", "_", "g") "Get formatprg config let s:formatprg_var = "g:formatprg_".type