vim-sexp
vim-sexp copied to clipboard
Incompatibility with tree-sitter
Hey there! Love the plugin, it makes working in Clojure a breeze.
I've run into a small problem where if I use nvim-treesitter and leave additional_vim_regex_highlighting = false
(meaning all syntax highlighting is provided by TS), then the "
insert maps don't work correctly anymore, as s:syntax_match can't find any highlighting under the cursor.
Would it be feasible to add some awareness of TS and use that when appropriate?
I know than a solution is to set additional_vim_regex_highlighting = true
, but it's not ideal because the two highlights clash and don't look great together.
+1 on this. A note for others finding this, you can also set additional_vim_regex_highlighting
to a list of languages e.g. additional_vim_regex_highlighting = {"clojure" "racket" "fennel" "janet"}
, although I agree it would be much nicer if this were not necessary.
Another workaround is to disable the insert mapping using let g:sexp_enable_insert_mode_mappings = 0
and to use another plugin like nvim-autopairs
.
My workaround:
highlight = {
enable = true,
disable = { 'clojure' },
},
Using jiangmiao/auto-pairs
, without setting additional_vim_regex_highlighting
.
Disabling highlighting suits me fine, since TS-based highlighting doesn't highlight keywords for some reason.
Another way I test for this issue, is to add a string like (def "foobar")
, move the cursor to the position between "foo" and "bar", insert (
(autopairs adds closing )
), press enter (with the cursor between the parens), and end up with this:
(def "foo(
)bar")
Another consequence of the broken string handling: The paren inside the string in (def s "a)b")
gets pair matched to the opening (
. This has all kinds of detrimental effects on editing, like d%
at the start of that form leaving you with b")
, and the def
's closing paren being interpreted as the closing paren for def
's parent form.
See https://github.com/nvim-treesitter/nvim-treesitter/issues/2966 for some additional context.