From fe6ef62dda0118a98bebb7a6c576e9b23b8a701b Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Mon, 9 Jan 2017 23:39:02 -0500 Subject: [PATCH] Added autocompletion for filetypes with ! Now, :Neoformat! will complete available filetypes And :Neoformat will still complete available formatters --- autoload/neoformat.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/autoload/neoformat.vim b/autoload/neoformat.vim index 5aacd484..5c7077f1 100644 --- a/autoload/neoformat.vim +++ b/autoload/neoformat.vim @@ -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