Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fu! ZOPinit()
- if exists("$ZOPDIRS")
- let files = globpath($ZOPDIRS, "**/*")
- let s:fileList = split(files)
- endif
- endfu
- "call ZOPinit()
- fu! LOCATEIT()
- "treat as a pass through to locate
- let l:index = 1
- let l:numberedMatches = []
- let l:locateinput = input("")
- let l:expressions = split(system('locate '.l:locateinput), '\n')
- for l:expression in l:expressions
- call add(l:numberedMatches, l:index . ". ". l:expression)
- let l:index = l:index + 1
- endfor
- if len(l:numberedMatches) > 0
- let l:index = inputlist(l:numberedMatches)
- if l:index > 0 && l:index <= len(l:numberedMatches)
- let l:index = l:index - 1
- execute "tabnew " . substitute(l:numberedMatches[l:index], "\\(\\d\\+\. \\)","", "")
- endif
- endif
- endfu
- fu! ZOP()
- let index = 1
- let matches = []
- let numberedMatches = []
- let expressions = split(input(""))
- if len(expressions) > 0
- for filePath in s:fileList
- let doContinue = 0
- for expression in expressions
- if filePath !~? expression
- let doContinue = 1
- break
- endif
- endfor
- if doContinue == 0
- call add(matches, filePath)
- call add(numberedMatches, index . ". ". filePath)
- let index = index + 1
- endif
- endfor
- if len(matches) > 0
- let index = inputlist(numberedMatches)
- if index > 0 && index <= len(matches)
- let index = index - 1
- execute "e " . matches[index]
- endif
- endif
- endif
- endfu
- map <leader>op :call LOCATEIT()<enter>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement