@@ -68,6 +68,10 @@ function! VIntSearch#SearchCursor(cmd, vimmode, action)
6868 return
6969 endif
7070
71+ if a: cmd== #' find'
72+ let keyword = ' *' .keyword .' *'
73+ endif
74+
7175 if a: action== #' j'
7276 let jump_to_firstitem = 1
7377 let open_result_win = 0
@@ -93,6 +97,8 @@ function! s:Search(keyword, cmd, options, jump_to_firstitem, open_result_win)
9397 let qflist = s: GetGrepQFList (real_keyword, a: options , 1 )
9498 elseif a: cmd== #' cfgrep'
9599 let qflist = s: GetGrepQFList (real_keyword, a: options , 1 , expand (' %:p' ))
100+ elseif a: cmd== #' find'
101+ let qflist = s: GetFindQFList (real_keyword, a: options )
96102 else
97103 echo ' VIntSearch: ' .a: cmd .' : Unsupported command.'
98104 return
@@ -370,10 +376,12 @@ function! s:MakeFindOpt()
370376 if i <len (g: :vintsearch_search_exclude_patterns)-1
371377 \o r (i == len (g: :vintsearch_search_exclude_patterns)-1 and len (g: vintsearch_search_include_patterns )>0 )
372378 let findopt = findopt." -o "
379+ endif
373380 endfor
374381 for i in range (len (g: vintsearch_search_include_patterns ))
375382 let pattern = g: vintsearch_search_include_patterns [i ]
376- let findopt = findopt." -ipath \' " .pattern." \' -print"
383+ " let findopt = findopt."-ipath \'".pattern."\' -print"
384+ let findopt = findopt." -ipath \' " .pattern." \' "
377385 if i <len (g: vintsearch_search_include_patterns )-1
378386 let findopt = findopt." -o "
379387 endif
@@ -570,6 +578,48 @@ function! s:GetGrepQFList(keyword, options, use_quickfix, ...)
570578 return qflist
571579endfunction
572580
581+ function ! s: GetFindQFList (keyword , options )
582+ let prevdir = getcwd ()
583+ let searchpath = s: GetSearchPath (g: vintsearch_searchpathmode )
584+ if searchpath== #' '
585+ return
586+ endif
587+ execute ' cd' searchpath
588+
589+ let findopt = s: MakeFindOpt ()
590+ let keyword_option = ' -path'
591+ if a: options = ~ ' -i'
592+ let keyword_option = ' -ipath'
593+ endif
594+
595+ " update later with find . and grep
596+ " http://stackoverflow.com/questions/13073731/linux-find-on-multiple-patterns
597+ let pathListStr = system (" find \\ ( " .findopt." \\ ) -a " .keyword_option." " .a: keyword )
598+ let pathList = split (pathListStr, ' \n' )
599+
600+ execute ' cd' prevdir
601+
602+ let qflist = []
603+ for path in pathList
604+ " getqflist()
605+ " [{'lnum': 124, 'bufnr': 59, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1,
606+ " 'type': '', 'pattern': '', 'text': 'FindTags generateClassificationBind()
607+ " '},
608+ " {'lnum': 193, 'bufnr': 59, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1,
609+ " 'type': '', 'pattern': '', 'text': ' generateClassificationBind()
610+ " '}]
611+
612+ let qfitem = {
613+ \ ' filename' : path ,
614+ \ ' lnum' : 0 ,
615+ \ ' text' : ' ' ,
616+ \ }
617+ call add (qflist, qfitem)
618+ endfor
619+
620+ return qflist
621+ endfunction
622+
573623" ctags list to quickfix
574624" http://andrewradev.com/2011/06/08/vim-and-ctags/
575625" http://andrewradev.com/2011/10/15/vim-and-ctags-finding-tag-definitions/
687737 return qflist
688738endfunction
689739
740+ " """"""""""""""""""""""""""""""""""""""""""""
741+ " utility function
742+
743+ " thanks for xolox!
744+ function ! s: get_visual_selection ()
745+ " Why is this not a built-in Vim script function?!
746+ let [lnum1, col1] = getpos (" '<" )[1 :2 ]
747+ let [lnum2, col2] = getpos (" '>" )[1 :2 ]
748+ let lines = getline (lnum1, lnum2)
749+ let lines [-1 ] = lines [-1 ][: col2 - (&selection == ' inclusive' ? 1 : 2 )]
750+ let lines [0 ] = lines [0 ][col1 - 1 :]
751+ let str = join (lines , " \n " )
752+ let str = substitute (str, ' "' , ' \\"' , ' g' )
753+ return str
754+ endfunction
690755
691756" """"""""""""""""
692757" deprecated search commands
0 commit comments