Skip to content

Commit

Permalink
Better elisp support for identifier completer
Browse files Browse the repository at this point in the history
Elisp is a lisp, so it supports all kinds of crazy identifiers. AFAIR
using the same regexes as Clojure should work more than well enough
because Clojure is too a Lisp descendent.
  • Loading branch information
Valloric committed May 29, 2016
1 parent 22f229c commit f2696ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ycmd/identifier_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
FILETYPE_TO_IDENTIFIER_REGEX[ 'scss' ] = 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' ] = (
FILETYPE_TO_IDENTIFIER_REGEX[ 'clojure' ] )
FILETYPE_TO_IDENTIFIER_REGEX[ 'lisp' ] = (
FILETYPE_TO_IDENTIFIER_REGEX[ 'clojure' ] )


def IdentifierRegexForFiletype( filetype ):
Expand Down
14 changes: 14 additions & 0 deletions ycmd/tests/identifier_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ def IsIdentifier_Clojure_test():
ok_( not iu.IsIdentifier( '' , 'clojure' ) )


def IsIdentifier_Elisp_test():
# elisp is using the clojure regexes, so we're testing this more lightly
ok_( iu.IsIdentifier( 'foo' , 'elisp' ) )
ok_( iu.IsIdentifier( 'f9' , 'elisp' ) )
ok_( iu.IsIdentifier( 'a.b.c', 'elisp' ) )
ok_( iu.IsIdentifier( 'a/c' , 'elisp' ) )

ok_( not iu.IsIdentifier( '9f' , 'elisp' ) )
ok_( not iu.IsIdentifier( '9' , 'elisp' ) )
ok_( not iu.IsIdentifier( 'a/b/c', 'elisp' ) )
ok_( not iu.IsIdentifier( '(a)' , 'elisp' ) )
ok_( not iu.IsIdentifier( '' , 'elisp' ) )


def IsIdentifier_Haskell_test():
ok_( iu.IsIdentifier( 'foo' , 'haskell' ) )
ok_( iu.IsIdentifier( "foo'", 'haskell' ) )
Expand Down

0 comments on commit f2696ef

Please sign in to comment.