Monday, June 21, 2021

Re: syntaxcomplete#Complete() and nested filetypes

Life, 

I am not sure I quite understand your use case for the plugin.

:h ft-syntax-omni

In the example I provide there, I am editing a PHP file, which has embedded HTML and JavaScript.
So I need syntaxComplete to also provide JavaScript functions, not just PHP functions.

That examples demonstrates how to use the syntaxcomplete variables like:
    let g:omni_syntax_group_include_php = 'php\w\+,javaScript\w\+,html\w\+'

I can help if you give me a bit more to go on with a concrete example of commands and what you expected / want to see.

David


On Mon, Jun 21, 2021 at 6:23 AM Lifepillar <lifepillar@lifepillar.me> wrote:
On 2021-06-21, Lifepillar <lifepillar@lifepillar.me> wrote:
> I would like to use syntaxcomplete#Complete() in a filetype that
> includes a nested filetype.

This is what I have so far, which appears to be working in filetype
`foobar` with nested filetype `xyz`:

    def foobarcomplete#Complete(findstart: number, base: string): any
      if findstart == 1
        syntaxcomplete#OmniSyntaxClearCache()

        if len(synstack(line("."), 1)) > 0 &&
          synIDattr(synstack(line("."), 1)[0], "name") ==# '^xyz'
          g:omni_syntax_group_include_foobar = 'xyz\w\+'
        else
          unlet! g:omni_syntax_group_include_foobar
        endif
      endif

        return syntaxcomplete#Complete(findstart, base)
    enddef

If you have better ideas, let me know! I especially do not like that
I have to clear the cache.

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/sappac%243eh%242%40ciao.gmane.io.

--
--
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/CAJ_EjQgRzQYoShaRyeOcUve8V5052LdP%2BvW5GCFLV444mF7_0A%40mail.gmail.com.

No comments:

Post a Comment