rksm / paredit.js

Generic reader and editor for s-expressions.
MIT License
107 stars 21 forks source link

Navigate to end or beginning of current list/vector/map (and string would be nice too) #18

Closed PEZ closed 6 years ago

PEZ commented 6 years ago

I would like to be able to navigate to the beginning or end of the ”current” list, wether it is denoted with parens, brackets or curlies.

For instance in this Clojure snippet, the cursor is between r and s in :css-dirs.

(def figwheel-options
  {:figwheel-options (merge nrepl-options
                            {:css-dir|s ["resources/public/css"]})
   :all-builds       [{:id           "dev"
                       :figwheel     {:on-jsload "app.main/on-js-reload"}
                       :source-paths [source-dir "dev"]
                       :compiler     dev-config}]})

I would like commands to navigate to:

                            {:css-dirs ["resources/public/css"]|})

and

                            {|:css-dirs ["resources/public/css"]})

There is a closeList command that seems to be able to do almost this, but I need to tell it what kind of bracket the ”current” one is and also it moves after the closing bracket, I want it to move to before.

I hope this makes sense. And I am also willing to try add these movement commands myself if you think it is something that should be added.

rksm commented 6 years ago

Navigation to the inner beginning and end of a s-expression can be done by combining existing commands, backwardUpSexp + right and backwardUpSexp + forwardSexp + left. I would really like to avoid adding redundant commands.

PEZ commented 6 years ago

Fair enough. The reason I want it is that it would make it easier for me to implement kill/copy-to-closing/opening bracket commands in Calva Paredit (a VS Code extension). I shall ponder if I can utilise a combination of existing commands for this somehow.