Fork me on GitHub
Andrew Berrien19:07:02

Hello, I am having trouble getting syntax highlighting for function calls in Neovim. Any functions I defined myself, or imported (like string/split), do not get highlighted, even though they are the first item after an open parens.

Andrew Berrien19:07:36

First I tried everything according to this article: and still didn't get full highlighting, so then I tried fireplace + vim-clojure-highlight, but still the same problem persists. My current init.vim is here:

Noah Bogart20:07:27

inline function calls are missing from the current vim-clojure-highlight, and i haven’t tried to upstream my changes:

syntax keyword clojureSpecial clojure.core/fn fn nextgroup=clojureFunction skipwhite
syntax keyword clojureDefine clojure.core/defn clojure.core/defn- defn defn- nextgroup=clojureFunction skipwhite
syntax match clojureFunction "\%(\%(defn\|defn-\|fn\)\s*\)\@<=\h\k\+" contained
syntax match clojureInlineFunction "\v\(@<=%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!#$%&*_+=|'<.>/?-]|[^\x00-\x7F]))*[#:]@1<!"

syntax cluster clojureTop remove=clojureDefine,clojureFunction,clojureSpecial
syntax cluster clojureTop add=clojureDefine,clojureFunction,clojureInlineFunction,clojureSpecial

highlight default link clojureFunction                  Function
highlight default link clojureInlineFunction            Function
highlight default link clojureFunc                      Type

Noah Bogart20:07:16

i put that in ~/.vim/after/syntax/clojure.vim , so regardless of what other plugins i have set up, it’ll do that last

Noah Bogart20:07:46

now, that changes the color of built-in/standard library functions to something else, so if you don’t want that, remove the last line lol

🙏 2

Also since youre on Neovim 0.5+, might be worth to look into treesitter and lua based config and highlighting. Here is my lua based config using conjure, treesitter and LSP: These give you much nicer, more semantic highlights. Also the LSP would give you the IDE like abilities too

🙏 4

Just in case you weren't ware, you can also turn on treesitter support for Conjure evals. It's experimental and I'm looking for testers! Have a search through :h conjure for treesitter, it should select the right code (with a LOT LOT LOT less CPU cycles) and eval it as you'd expect when enabled.

Noah Bogart20:07:03

yeah, the semantic highlighting from clojure-lsp is very nice too

👍 2