The g:ycm_semantic_triggers doesn't work
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?
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.
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_])']
Note that since Valloric/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.
@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)?
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.
@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?
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.
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 :stuck_out_tongue_closed_eyes:
Anyway thanks for the feedback and thoughts!