@@ -12,9 +12,10 @@ function! neoformat#Neoformat(user_formatter) abort
1212 if ! empty (a: user_formatter )
1313 let formatter = a: user_formatter
1414 else
15- let formatters = s: get_enabled_formatters (&filetype )
15+ let filetype = s: split_filetypes (&filetype )
16+ let formatters = s: get_enabled_formatters (filetype )
1617 if formatters == []
17- call neoformat#utils#msg (' formatter not defined for ' . & filetype . ' filetype' )
18+ call neoformat#utils#msg (' formatter not defined for ' . filetype . ' filetype' )
1819 return neoformat#format#BasicFormat ()
1920 endif
2021
@@ -26,10 +27,10 @@ function! neoformat#Neoformat(user_formatter) abort
2627 let formatter = formatters[s: current_formatter_index ]
2728 endif
2829
29- if exists (' g:neoformat_' . & filetype . ' _' . formatter)
30- let definition = g: neoformat_ {& filetype }_{formatter}
31- elseif s: autoload_func_exists (' neoformat#formatters#' . & filetype . ' #' . formatter)
32- let definition = neoformat#formatters#{& filetype }#{formatter}()
30+ if exists (' g:neoformat_' . filetype . ' _' . formatter)
31+ let definition = g: neoformat_ {filetype }_{formatter}
32+ elseif s: autoload_func_exists (' neoformat#formatters#' . filetype . ' #' . formatter)
33+ let definition = neoformat#formatters#{filetype }#{formatter}()
3334 else
3435 call neoformat#utils#log (' definition not found for formatter: ' . formatter)
3536 if ! empty (a: user_formatter )
@@ -39,7 +40,7 @@ function! neoformat#Neoformat(user_formatter) abort
3940 return neoformat#NextNeoformat ()
4041 endif
4142
42- let cmd = neoformat#cmd#generate (definition)
43+ let cmd = neoformat#cmd#generate (definition, filetype )
4344 if cmd == {}
4445 if ! empty (a: user_formatter )
4546 return neoformat#utils#log (' user specified formatter failed' )
@@ -63,7 +64,8 @@ function! neoformat#CompleteFormatters(ArgLead, CmdLine, CursorPos)
6364 if a: ArgLead = ~ ' [^A-Za-z0-9]'
6465 return []
6566 endif
66- return filter (s: get_enabled_formatters (&filetype ),
67+ let filetype = s: split_filetypes (&filetype )
68+ return filter (s: get_enabled_formatters (filetype ),
6769 \ " v:val =~? '^" . a: ArgLead ." '" )
6870endfunction
6971
@@ -81,3 +83,7 @@ function! s:autoload_func_exists(func_name)
8183 endtry
8284 return 1
8385endfunction
86+
87+ function ! s: split_filetypes (filetype )
88+ return split (a: filetype , ' \.' )[0 ]
89+ endfunction
0 commit comments