context_filetype.vim 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "=============================================================================
  2. " FILE: context_filetype.vim
  3. " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
  4. " License: MIT license {{{
  5. " Permission is hereby granted, free of charge, to any person obtaining
  6. " a copy of this software and associated documentation files (the
  7. " "Software"), to deal in the Software without restriction, including
  8. " without limitation the rights to use, copy, modify, merge, publish,
  9. " distribute, sublicense, and/or sell copies of the Software, and to
  10. " permit persons to whom the Software is furnished to do so, subject to
  11. " the following conditions:
  12. "
  13. " The above copyright notice and this permission notice shall be included
  14. " in all copies or substantial portions of the Software.
  15. "
  16. " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17. " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  19. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  20. " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21. " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  22. " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. " }}}
  24. "=============================================================================
  25. let s:save_cpo = &cpo
  26. set cpo&vim
  27. " context_filetype.vim installation check.
  28. if !exists('s:exists_context_filetype')
  29. silent! call context_filetype#version()
  30. let s:exists_context_filetype = exists('*context_filetype#version')
  31. endif
  32. function! neocomplete#context_filetype#set() abort "{{{
  33. let neocomplete = neocomplete#get_current_neocomplete()
  34. let context_filetype =
  35. \ s:exists_context_filetype ?
  36. \ context_filetype#get_filetype() : &filetype
  37. if context_filetype == ''
  38. let context_filetype = 'nothing'
  39. endif
  40. let neocomplete.context_filetype = context_filetype
  41. let neocomplete.context_filetypes = s:exists_context_filetype ?
  42. \ context_filetype#get_filetypes(context_filetype) :
  43. \ [context_filetype] + split(context_filetype, '\.')
  44. return neocomplete.context_filetype
  45. endfunction"}}}
  46. function! neocomplete#context_filetype#get(filetype) abort "{{{
  47. let context_filetype =
  48. \ s:exists_context_filetype ?
  49. \ context_filetype#get_filetype(a:filetype) : a:filetype
  50. if context_filetype == ''
  51. let context_filetype = 'nothing'
  52. endif
  53. return context_filetype
  54. endfunction"}}}
  55. function! neocomplete#context_filetype#filetypes() abort "{{{
  56. return copy(neocomplete#get_current_neocomplete().context_filetypes)
  57. endfunction"}}}
  58. let &cpo = s:save_cpo
  59. unlet s:save_cpo
  60. " vim: foldmethod=marker