Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: defer import of UltiSnips modules #96

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions python3/ultisnips_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from UltiSnips import UltiSnips_Manager, vim_helper

# Retrieves additional snippet information that is not directly accessible
# using the UltiSnips API functions. Stores a list of dictionaries (one per
# snippet) with the keys "trigger", "description", "options" and "value"
Expand All @@ -10,6 +8,8 @@


def fetch_current_snippets(expandable_only):
from UltiSnips import UltiSnips_Manager, vim_helper

line_until_cursor = vim_helper.buf.line_till_cursor
visual_content = UltiSnips_Manager._visual_content
if expandable_only:
Expand All @@ -25,7 +25,9 @@ def fetch_current_snippets(expandable_only):
if not expandable_only and (is_context_snippet or is_regex_snippet):
continue
# For custom context snippets, always check if the context matches.
if is_context_snippet and not snippet._context_match(visual_content, line_until_cursor):
if is_context_snippet and not snippet._context_match(
visual_content, line_until_cursor
):
continue

snippet_info = {
Expand All @@ -40,6 +42,8 @@ def fetch_current_snippets(expandable_only):


def set_filetype(ft):
from UltiSnips import vim_helper

class CustomVimBuffer(vim_helper.VimBuffer):
@property
def filetypes(self):
Expand All @@ -50,4 +54,6 @@ def filetypes(self):


def reset_filetype():
from UltiSnips import vim_helper

vim_helper.buf = vim_helper._orig_buf
Loading