Sublime Forum

Completions from *.sublime-completions files are hidden when using EasyClangComplete plugin

#1

Hi,
I use EasyClangComplete plugin, where, shortly, clang is used as a tool to append any kind of completions while programming with C and C++. Very useful plugin indeed, thanks to the maintainer @niosus for having somewhen started it out
The plugin uses sublime’s python API and in particular the method ‘on_query_completion’ that is called at the time ‘auto_completion’ is requested. As I have understood every listener subscribed on ‘auto_completion’ event by deriving from ‘sublime_plugin.EventListener’ and defining method ‘on_query_completions’ is called successively to append the data in the common popup-window of completion offers
Meanwhile, I have the other plugin that contributes *.sublime-completions files
There is an issue that my completions from *.sublime-completions disappear upon plugin’s EasyClangComplete appending its own
I looked into EasyClangComplete plugin and found out the algorithm of fetching the completions and spreading them:

  1. ‘on_query_completions’ is called
  2. in the handler a new job (a thread) is spawned that is doing fetching the autocompletion list with clang specific API and utilities, it doesn’t matter. Here I like to note that the work is done in a different thread that means that the result will be ready asynchronously. As just the job is created and started working to fill the completions the main thread, which is in ‘on_query_completions’ handler, exits and returns empty list of completions which adds nothing new in the common list of completions. So, I see my default completions as is and don’t see EasyClangComplete completions as they are not ready, no issues, good
  3. The job we created to fill the list completions provided by clang ends its labor and gets the list of completion in the correct format, no issues. Since the main thread has already exited we need to somehow update a completion list with new stuff. So, apparently, there is nothing to do but call auto_completion feature again as though it had been called by a programmer by triggering it. The plugin does it the following way
view.run_command('hide_auto_complete')
        view.run_command('auto_complete', {
            'disable_auto_insert': True,
            'api_completions_only': False,
            'next_competion_if_showing': False})

It, again, queries all the listerners to handle ‘on_query_completions’. The plugin is elaborated so that it immediately returns already formed in the previous round completions in this handler ‘on_query_completions’, not creating any jobs or doing any other stuff. And there it is, this bug. Upon this return I cannot see my default completions from *.sublime-completions files anymore, I see only offers provided by EasyClangComplete plugin and provided my snippets. This circumstance occurs only with *.sublime-completions files as though they are ignored

My questions:

  1. Have you seen this before and have you had any ideas how to avoid or fix that?
  2. Is it legal to invoke a new job in the main thread of processing the query ‘on_query_completions’, return an empty list of completion and then, in the second thread, call ‘auto_completion’ feature from API to append the completions list by this way
view.run_command('hide_auto_complete')
        view.run_command('auto_complete', {
            'disable_auto_insert': True,
            'api_completions_only': False,
            'next_competion_if_showing': False})

?
3) If it is legal does it mean that *.sublime-completions files are ignored when I call the ‘auto_completion’ from API?

My ‘*.sublime-completions’ file look like

{
	"scope": "source.c++",
	"completions": [
		{"trigger": "cout_\tstd::cout statement",                 "contents": "std::cout << "},
		{"trigger": "cerr_\tstd::cerr statement",                 "contents": "std::cerr << "},
		{"trigger": "endl_\tstd::endl statement",                 "contents": "std::endl"},
		{"trigger": "ignunused_\tboost::ignore_unused statement", "contents": "boost::ignore_unused(${1:var});"}
	]
}

Thank you

0 Likes

#2
0 Likes

#3

@kingkeith, thank you
I removed ‘\t’ from from triggers so that the file has appeared

{
	"scope": "source.c++",
	"completions": [
		{"trigger": "cout",      "contents": "std::cout << "},
		{"trigger": "cerr",      "contents": "std::cerr << "},
		{"trigger": "endl",      "contents": "std::endl"},
		{"trigger": "ignunused", "contents": "boost::ignore_unused(${1:var});"}
	]
}

but I still get the same issue

Or should I remove ‘\t’ along the whole list of possible sublime-completions files? It would mean that no hints would be for *.sublime-completions

By the way, if I disable EasyClangComplete, everything works perfectly. Is it somehow related to processing the list of completions when using API in combination with *.sublime-completions files?

0 Likes

#4

maybe I linked the wrong issue, there are a few similar/related ones relating to completions and “special” chars:

hopefully this problem will be addressed in the next dev cycle (I believe Will mentioned he is hoping to look at completions soon), so it may be an option to wait rather than have to remove all hints

1 Like

#5

The last post is exactly what I’m experiencing. I will point out this issue there by providing link
@kingkeith, thank you

0 Likes