diff --git a/plugin/UltiSnips.vim b/plugin/UltiSnips.vim index 99e0338..bf94a74 100644 --- a/plugin/UltiSnips.vim +++ b/plugin/UltiSnips.vim @@ -77,7 +77,7 @@ if !exists("g:UltiSnipsSnippetDirectories") endif " }}} -"" Global Commands {{{ +" Global Commands {{{ function! UltiSnipsEdit(...) if a:0 == 1 && a:1 != '' let type = a:1 @@ -101,7 +101,7 @@ endfunction command! -nargs=? UltiSnipsEdit :call UltiSnipsEdit() "" }}} -"" FUNCTIONS {{{ +" FUNCTIONS {{{ function! CompensateForPUM() """ The CursorMovedI event is not triggered while the popup-menu is visible, """ and it's by this event that UltiSnips updates its vim-state. The fix is @@ -144,6 +144,11 @@ function! UltiSnips_JumpForwards() return "" endfunction +function! UltiSnips_FileTypeChanged() + exec g:_uspy "UltiSnips_Manager.ensure_snippets_loaded()" + return "" +endfunction + function! UltiSnips_AddSnippet(trigger, value, descr, options, ...) " Takes the same arguments as SnippetManager.add_snippet: " (trigger, value, descr, options, ft = "all", globals = None) @@ -210,6 +215,7 @@ exec g:_uspy "UltiSnips_Manager.backward_trigger = vim.eval('g:UltiSnipsJumpBack au CursorMovedI * call UltiSnips_CursorMoved() au CursorMoved * call UltiSnips_CursorMoved() au WinLeave * call UltiSnips_LeavingWindow() +au FileType * call UltiSnips_FileTypeChanged() call UltiSnips_MapKeys() diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index 9f91e23..b67a15c 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -780,7 +780,7 @@ class SnippetManager(object): before the cursor. If possible is True, then get all possible matches. """ - filetypes = self._ensure_snippets_loaded() + filetypes = self.ensure_snippets_loaded() found_snippets = [] for ft in filetypes: @@ -1027,7 +1027,7 @@ class SnippetManager(object): self._ensure_loaded(parent, checked) - def _ensure_snippets_loaded(self): + def ensure_snippets_loaded(self): """ Checks for changes in the list of snippet files or the contents of the snippet files and reloads them if necessary. """