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

Names with ' in them are not colored correctly #48

Open
oskarkv opened this issue May 7, 2014 · 1 comment
Open

Names with ' in them are not colored correctly #48

oskarkv opened this issue May 7, 2014 · 1 comment

Comments

@oskarkv
Copy link

oskarkv commented May 7, 2014

Not sure if this is a vim-clojure-static or vim-clojure-highlight issue.

Names that contain ' become clojureSymbol instead of clojureFunc when using vim-clojure-highlight.

Also, another problem with ' is the following:

(defn some-func [args] body)

(defn some-other-func [args]
  (let [some-func' (fn ...)]
    ...))

In this case, the some-func part of the name some-func' becomes clojureFunc while the ' becomes clojureQuote, resulting in a name with two colors in it, which can be confusing. Normally, the name in the let should be a clojureSymbol, but it seems that because some-func is also a function this happens somehow.

@guns
Copy link
Owner

guns commented May 7, 2014

Hi oskarv!

In this case, the some-func part of the name some-func' becomes clojureFunc while the ' becomes clojureQuote, resulting in a name with two colors in it, which can be confusing. Normally, the name in the let should be a clojureSymbol, but it seems that because some-func is also a function this happens somehow.

Yes, this is a problem with the way vim-clojure-static handles single quotes. We use syntax keyword statements to match known symbols, but since we cannot include ' in the iskeywords setting¹, symbols with single quotes are broken in this way.

Now we could avoid this problem by using syntax match instead of syntax keyword, but there is a significant performance hit because while matching syntax keyword is a simple table lookup, matching a syntax match requires a full regexp match.

My benchmarks showed that the performance hit was ~8-10x when translating to simple regexps, while the hit was about ~2x when using frak optimized regexps.

2x is pretty good, but IMO, the Clojure syntax is already a little slow, so I decided against the switch.

Names that contain ' become clojureSymbol instead of clojureFunc when using vim-clojure-highlight.

Now this is a bug! I'll have a look at it today. Thanks!

¹ That would break quoting and the #' reader macro

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

No branches or pull requests

2 participants