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

[READY] Do not depend on UltiSnips internals to fetch snippets #2321

Merged
merged 1 commit into from
Sep 11, 2016

Conversation

micbou
Copy link
Collaborator

@micbou micbou commented Sep 8, 2016

Use the UltiSnips#SnippetsInCurrentScope public function instead of the UltiSnips_Manager internal object to fetch snippets. Fixes #2320.

Give a workaround in the FAQ for snippets not suggested as candidates if added with the :UltiSnipsAddFiletypes command.


This change is Reviewable

@vheon
Copy link
Contributor

vheon commented Sep 8, 2016

I think that unless we provide an API that allow to add additional identifier like snippets, hence delegating the "when to do it" to the external source, the FAQ is the best way. This way we cover the majority of the cases anyway. :lgtm:


Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@puremourning
Copy link
Member

Reviewed 2 of 3 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


python/ycm/youcompleteme.py, line 689 [r1] (raw file):
According to the docs:

This function simply returns a vim dictionary with the snippets whose trigger
matches the current word. If you need all snippets information of current
buffer, you can simply pass 1 (which means all) as first argument of this
function, and use a global variable g:current_ulti_dict_info to get the
result (see example below).

It's the last bit that I'm surprised by. It says to use g:current_ulti_dict_info not the return value

the example in question:

function! GetAllSnippets()
  call UltiSnips#SnippetsInCurrentScope(1)
  let list = []
  for [key, info] in items(g:current_ulti_dict_info)
...

Comments from Reviewable

@puremourning
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


python/ycm/youcompleteme.py, line 689 [r1] (raw file):

Previously, puremourning (Ben Jackson) wrote…

According to the docs:

This function simply returns a vim dictionary with the snippets whose trigger
matches the current word. If you need all snippets information of current
buffer, you can simply pass 1 (which means all) as first argument of this
function, and use a global variable g:current_ulti_dict_info to get the
result (see example below).

It's the last bit that I'm surprised by. It says to use g:current_ulti_dict_info not the return value

the example in question:

function! GetAllSnippets()
  call UltiSnips#SnippetsInCurrentScope(1)
  let list = []
  for [key, info] in items(g:current_ulti_dict_info)
...
Additionally, won't this break if the user doesn't have UltiSnips installed? We used to detect it by catching the import exception.

Comments from Reviewable

@micbou
Copy link
Collaborator Author

micbou commented Sep 8, 2016

Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


python/ycm/youcompleteme.py, line 689 [r1] (raw file):

It's the last bit that I'm surprised by. It says to use g:current_ulti_dict_info not the return value

This function also returns the g:current_ulti_dict variable, which contains what we want.

Additionally, won't this break if the user doesn't have UltiSnips installed? We used to detect it by catching the import exception.

This is what the try/except block is for. In fact, it is better this way because it supports lazy-loading of UltiSnips.


Comments from Reviewable

@puremourning
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


python/ycm/youcompleteme.py, line 689 [r1] (raw file):

This function also returns the g:current_ulti_dict variable, which contains what we want.

OK makes sense, but feels a tad like relying on undocumented (and thus unstable) behaviour.

This is what the try/except block is for. In fact, it is better this way because it supports lazy-loading of UltiSnips

OK sure. Thanks makes sense


Comments from Reviewable

@micbou micbou force-pushed the improve-ultisnips-support branch from 11782b8 to 355f07f Compare September 8, 2016 23:02
@micbou
Copy link
Collaborator Author

micbou commented Sep 8, 2016

Review status: 2 of 3 files reviewed at latest revision, 1 unresolved discussion.


python/ycm/youcompleteme.py, line 689 [r1] (raw file):

OK makes sense, but feels a tad like relying on undocumented (and thus unstable) behaviour.

Good point. I've decided to follow the documentation.


Comments from Reviewable

@kal444
Copy link

kal444 commented Sep 9, 2016

Does the try/except block inform the user in anyway? (I don't know enough about python/vim interaction to know if vim.error is reported regardless. If not, would be a good idea to do a vimsupport.PostVimMessage().

When I was debugging this, it took a while to track down the issue, an error at the status line would have helped.

Thanks for the quick fix!

@micbou
Copy link
Collaborator Author

micbou commented Sep 9, 2016

Does the try/except block inform the user in anyway? (I don't know enough about python/vim interaction to know if vim.error is reported regardless. If not, would be a good idea to do a vimsupport.PostVimMessage().

Printing a message on the status line would be annoying for those that don't use UltiSnips. This is where a logfile would be useful.


Reviewed 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@puremourning
Copy link
Member

:lgtm:


Reviewed 1 of 3 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@puremourning
Copy link
Member

Reviewed 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@budi
Copy link

budi commented Sep 10, 2016

:lgtm:


Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@homu
Copy link
Contributor

homu commented Sep 11, 2016

☔ The latest upstream changes (presumably #2324) made this pull request unmergeable. Please resolve the merge conflicts.

@micbou micbou force-pushed the improve-ultisnips-support branch 3 times, most recently from 6d1864f to 882f4ec Compare September 11, 2016 15:11
Use UltiSnips#SnippetsInCurrentScope to fetch snippets.
Add an entry in the FAQ about the :UltiSnipsAddFiletypes command.
@micbou micbou force-pushed the improve-ultisnips-support branch from 882f4ec to 5dca552 Compare September 11, 2016 15:11
@micbou
Copy link
Collaborator Author

micbou commented Sep 11, 2016

PR rebased.

A lot of users seem to be affected by this so let's merge the PR.

@homu r+


Reviewed 2 of 2 files at r3.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@homu
Copy link
Contributor

homu commented Sep 11, 2016

📌 Commit 5dca552 has been approved by micbou

@homu homu merged commit 5dca552 into ycm-core:master Sep 11, 2016
@homu
Copy link
Contributor

homu commented Sep 11, 2016

⚡ Test exempted - status

homu added a commit that referenced this pull request Sep 11, 2016
[READY] Do not depend on UltiSnips internals to fetch snippets

Use the `UltiSnips#SnippetsInCurrentScope` public function instead of the `UltiSnips_Manager` internal object to fetch snippets. Fixes #2320.

Give a workaround in the FAQ for snippets not suggested as candidates if added with the `:UltiSnipsAddFiletypes` command.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2321)
<!-- Reviewable:end -->
@micbou micbou deleted the improve-ultisnips-support branch October 1, 2016 14:57
@vheon vheon mentioned this pull request Dec 2, 2016
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants