Skip to content

Commit

Permalink
Added autocompletion for filetypes with !
Browse files Browse the repository at this point in the history
Now, :Neoformat! will complete available filetypes
And :Neoformat will still complete available formatters
  • Loading branch information
sbdchd committed Jan 10, 2017
1 parent 4c454b3 commit fe6ef62
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions autoload/neoformat.vim
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ function! s:deletelines(start, end) abort
endfunction

function! neoformat#CompleteFormatters(ArgLead, CmdLine, CursorPos) abort
if a:CmdLine =~ '!'
" https://github.com/junegunn/fzf.vim/pull/110
" 1. globpath (find) all filetype files in neoformat
" 2. split at new lines
" 3. map ~/.config/nvim/plugged/neoformat/autoload/neoformat/formatters/xml.vim --> xml
" 4. sort & uniq to eliminate dupes
" 5. filter for input
return filter(uniq(sort(map(split(globpath(&runtimepath,
\ 'plugged/neoformat/autoload/neoformat/formatters/*.vim'), '\n'),
\ "fnamemodify(v:val, ':t:r')"))),
\ "v:val =~? '^" . a:ArgLead . "'")
endif
if a:ArgLead =~ '[^A-Za-z0-9]'
return []
endif
Expand Down

0 comments on commit fe6ef62

Please sign in to comment.