guns / vim-sexp

Precision Editing for S-expressions
MIT License
612 stars 33 forks source link

Incompatibility with tree-sitter #31

Open NoahTheDuke opened 2 years ago

NoahTheDuke commented 2 years ago

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.

Grazfather commented 1 year ago

+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.

nbardiuk commented 1 year ago

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.

walterl commented 1 year ago

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")
walterl commented 1 year ago

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.

sheluchin commented 1 year ago

See https://github.com/nvim-treesitter/nvim-treesitter/issues/2966 for some additional context.