From 0e15e3a0f28d18d745ae59da065b10f3062c5b93 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 9 Aug 2020 16:54:30 +0900 Subject: [PATCH] Add context filetype support --- autoload/deoppet/util.vim | 5 +++++ rplugin/python3/deoppet/deoppet.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/deoppet/util.vim b/autoload/deoppet/util.vim index 0bf03e2..260e3e5 100644 --- a/autoload/deoppet/util.vim +++ b/autoload/deoppet/util.vim @@ -122,3 +122,8 @@ function! deoppet#util#_indent_snippet(begin, end) abort call setpos('.', pos) endtry endfunction + +function! deoppet#util#_get_context_filetype() abort + return exists('*context_filetype#get_filetype') ? + \ context_filetype#get_filetype() : &filetype +endfunction diff --git a/rplugin/python3/deoppet/deoppet.py b/rplugin/python3/deoppet/deoppet.py index 15bee3e..50dcdfd 100644 --- a/rplugin/python3/deoppet/deoppet.py +++ b/rplugin/python3/deoppet/deoppet.py @@ -49,7 +49,7 @@ def _load_snippets(self) -> None: snippets: typing.Dict[str, Snippet] = {} buf = self._vim.current.buffer filetype: str = self._vim.call( - 'getbufvar', buf.number, '&filetype') + 'deoppet#util#_get_context_filetype') if not filetype: filetype = 'nothing' # debug(self._vim, filetype)