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

The g:ycm_semantic_triggers doesn't work #1228

Closed
IceNature opened this issue Oct 29, 2014 · 8 comments
Closed

The g:ycm_semantic_triggers doesn't work #1228

IceNature opened this issue Oct 29, 2014 · 8 comments

Comments

@IceNature
Copy link

I wrote this in vimrc:
let g:ycm_semantic_triggers = { 'd': ['.', 're![a-zA-Z]'] }
But in d buffers, semantic completion box shows just when I type '.'.Why the semantic completion box doesn't show when I type any character from a to z?

@vheon
Copy link
Contributor

vheon commented Oct 29, 2014

Can you provide a minimal vimrc and the steps for reproducing the bug? Please see CONTRIBUTING.md. Closing until more info are provided.
Anyway could be related to the semantic engine you use for D.

@vheon vheon closed this as completed Oct 29, 2014
@reinhrst
Copy link

reinhrst commented Nov 3, 2015

For future reference: ycm_semantic_triggers does not work as one might expect. It does not check if the text up to the cursor matches, however it checks if the code up to where the current identifier (as defined by this regex (or one of the language specific regexes)) starts. So to start the semantic checker on every character, do something like:

if !exists('g:ycm_semantic_triggers')
    let g:ycm_semantic_triggers = {}
endif
let g:ycm_semantic_triggers.python = ['re!(?=[a-zA-Z_])']

reinhrst referenced this issue in ycm-core/ycmd Jan 23, 2016
Match triggers until user's caret column solely. Trying to match
triggers with characters after user's caret column doesn't seem
to have any utility.
@reinhrst
Copy link

Note that since ycm-core/ycmd#319, look-ahead as suggested in my previous comment is not needed anymore. It can now simply be: let g:ycm_semantic_triggers.python = ['re![a-zA-Z_]']

My personal line for python is: let g:ycm_semantic_triggers.python = ['re![a-zA-Z_][a-zA-Z_0-9]{2,}'] which will trigger on any python identifier of length 3 or more.

@vheon
Copy link
Contributor

vheon commented Jan 25, 2016

@reinhrst I'm glad that it works easier now but if I can ask: do you really find it necessary to invoke semantic completion after 3 identifiers characters? I mean in that context I usually find the identifier completer good enough; also how's the performance (compared to the size of the project of course)?

@reinhrst
Copy link

I switched off the identifier completer completely. I found it very confusing that it would suggest names that were not in scope; it meant that I needed to type many more characters to uniquely produce the variable name I need. In addition identifier completer wouldn't complete global python variables (e.g. AssertionException) unless I had used them before in the module, jedi completion does. Performance is very good (it's not hard for jedi to figure out which identifiers are in scope; although I should add that I don't do things like from numpy import *, so it only has to inspect the current module). I regularly work on large (2000+ line) modules, in moderate size projects (I would say about 100 modules in the project), however I try to keep my functions relatively short, never having more than 20 or so local variables.

Edit: the above example directly showing my problem; it's actually AssertionError, not AssertionException... Never have to remember that anymore while coding these days.

@vheon
Copy link
Contributor

vheon commented Jan 25, 2016

@reinhrst thanks for the feedback. Assuming the setup you've got wouldn't work, do you think that a ranking of the identifier based on the distance from the cursor would help you with the "scope" problem?

@reinhrst
Copy link

Quite honestly, it's been some months since I stopped using identifier completer, so I can't quite remember in which situations what happened, but I would say that if you're going to sort them on anything, then distance to cursor makes most sense (or perhaps recently used, by which I mean distance from the cursor when only looking up, not down, in the code).

Including all python globals in the identifier completer would also be a step in the right direction (or possibly allow for a configuration setting for identifiers to include). However I would argue that you can never beat a semantic completer, so in case that is too slow, I could imagine that time is better spent on optimising that.

@vheon
Copy link
Contributor

vheon commented Jan 25, 2016

Including all python globals in the identifier completer would also be a step in the right direction

Well that would be really language specific so I see it as a step in the wrong direction.

However I would argue that you can never beat a semantic completer

I could argue, but is really a personal preference: I don't need semantic all the time and the identifier completion is enough for most of my time (at work I don't even set up the semantic completion atm) and I prefer spending my cpu to something useful in each moment.

so in case that is too slow, I could imagine that time is better spent on optimising that.

Well optimising the semantic engine is not really in our hands here 😝

Anyway thanks for the feedback and thoughts!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants