Monday, June 21, 2021

syntaxcomplete#Complete() and nested filetypes

I would like to use syntaxcomplete#Complete() in a filetype that
includes a nested filetype. The only way I have found so far is to
define my own completion function that checks whether the current
position is within the nested filetype, then calls OmniSyntaxList() with
the appropriate regular expression. Something along these lines:

if synIDattr(...) =~ '^nestedfiletype'
matches = OmniSyntaxList(['^nestedfiletype\w\+'])
else
matches = OmniSyntaxList(['^mainfiletype\w\+'])
endif

This is simple enough, but (1) it does not benefit from
syntaxcomplete#Complete() caching, and (2) it requires my own function.

Perhaps, there is a more canonical way to achieve what I want?

Ideally, I would like to set omnifunc=syntaxcomplete#Complete(), and
have Vim figure out the filetype to use for the current completion.
I see that there are some global variables to tweak the completion
behaviour (g:omni_syntax_group_include, ...), but I have not found how
to use them for the my purpose.

Thanks,
Life.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/sapo54%24bnf%241%40ciao.gmane.io.

No comments: