Skip to content

Instantly share code, notes, and snippets.

@mutewinter
Last active January 15, 2017 14:39
Show Gist options
  • Save mutewinter/7186595 to your computer and use it in GitHub Desktop.
Save mutewinter/7186595 to your computer and use it in GitHub Desktop.
Add dash and underscore completion for the YouCompleteMe Vim plugin.
diff --git a/ycmd/identifier_utils.py b/ycmd/identifier_utils.py
index 4217fdef..ac91c97b 100644
--- a/ycmd/identifier_utils.py
+++ b/ycmd/identifier_utils.py
@@ -102,6 +102,7 @@ FILETYPE_TO_IDENTIFIER_REGEX = {
}
FILETYPE_TO_IDENTIFIER_REGEX[ 'scss' ] = FILETYPE_TO_IDENTIFIER_REGEX[ 'css' ]
+FILETYPE_TO_IDENTIFIER_REGEX[ 'javascript' ] = FILETYPE_TO_IDENTIFIER_REGEX[ 'css' ]
FILETYPE_TO_IDENTIFIER_REGEX[ 'sass' ] = FILETYPE_TO_IDENTIFIER_REGEX[ 'css' ]
FILETYPE_TO_IDENTIFIER_REGEX[ 'less' ] = FILETYPE_TO_IDENTIFIER_REGEX[ 'css' ]
FILETYPE_TO_IDENTIFIER_REGEX[ 'elisp' ] = (
@boschni
Copy link

boschni commented Oct 27, 2013

Thanks, works fine!

@miickel
Copy link

miickel commented Oct 28, 2013

Thanks! Had to apply using --reject and --whitespace=fix.

Also added $-sign (useful when writing AngularJs)...

 return char.isalnum() or char in ['_', '-', '$']
const char *IDENTIFIER_REGEX = "[\\$_a-zA-Z][\\w_-]*";

@snikch
Copy link

snikch commented Feb 25, 2014

👍

Adding the $ sign also helps with sass variables too. Cheers.

@blueyed
Copy link

blueyed commented Mar 14, 2014

You might want to use the following instead to only match $ at the beginning:

const char *IDENTIFIER_REGEX = "\\$?[_a-zA-Z][\\w_-]*";

(also in my fork, together with handling identifiers from strings and comments)

@mutewinter
Copy link
Author

Updated for ycmd.

@djtango
Copy link

djtango commented May 12, 2016

Does this still work? I can't find any reference to:

def IsIdentifierChar( char ): return char.isalnum() or char == '_'

to change in my local source code .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment