lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.08k stars 101 forks source link

Context not working for Clojure #387

Closed jcpsantiago closed 2 years ago

jcpsantiago commented 2 years ago

I'm using Neovim (this is my config https://github.com/jcpsantiago/nvim-fennel-lsp-conjure-as-clojure-ide) and blankline works for all the languages I've tested it with (R, Fennel, JS, Python) but not with Clojure. I have all parsers installed.

In Clojure, with https://github.com/jcpsantiago/nvim-fennel-lsp-conjure-as-clojure-ide/blob/3fef0f52e0512069cd505738c2cb2aba14bb73cc/.config/nvim/fnl/config/plugin/blankline.fnl#L4 :

(indent_blankline.setup {:show_current_context true})

I see the vertical lines, but the context is not highlighted, which rather works in the other languages I cited above.

This could be an issue with https://github.com/sogaiu/tree-sitter-clojure, but wanted to check here first how I could debug it further to understand the source.

lukas-reineke commented 2 years ago

The current context patterns probably doesn't include something that matches for clojure. I don't use clojure myself, can you share some code that you would expect to work?

jcpsantiago commented 2 years ago

https://github.com/jcpsantiago/controltower/blob/3a26dc6114e1e301c403d776099a93ccc3ff758a/src/controltower/core.clj#L147

(defn onair-flights
  [flight-data]
  (let [ks (into []
                 (keep (fn [[k v]]
                         (when (and (= (:onground v) 0)
                                    (> (:altitude v) 150)
                                    (seq (:start v)
                                    (seq (:end v))
                                    (seq (:flight v)))
                           k))
                       flight-data))]
    (if (empty? ks)
      (do (timbre/info "No flights in the air, returning empty map.") {})
      (do (timbre/info "Returning" (count ks) "flights found in the air")
          (select-keys flight-data ks)))))

None of the above shows any context highlighting, but it's valid, working Clojure code.

lukas-reineke commented 2 years ago

Try to add lit$ to the indent_blankline_context_patterns. Does that give you the expected result?

jcpsantiago commented 2 years ago

Yes, that works thanks! Could you explain/point me to the docs explaining what lit$ is?

lukas-reineke commented 2 years ago

Context works by comparing the treesitter tree against the list of lua patterns in indent_blankline_context_patterns.

You can see how the treesitter tree looks like with :TSPlayground. For example, here is the one for clojure Screen Capture_select-area_20220401161926

lit$ just matches everything that ends with lit.

The default patterns should cover most languages, I'll add the one for clojure as well.

jcpsantiago commented 2 years ago

ah I see! thanks for the explanation 👍