Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Structural editing #50

Open
tapegram opened this issue Feb 2, 2022 · 2 comments
Open

[Request] Structural editing #50

tapegram opened this issue Feb 2, 2022 · 2 comments

Comments

@tapegram
Copy link
Contributor

tapegram commented Feb 2, 2022

Hello! I'm really enjoying this project and depend on it for all my kotlin dev. However, I am increasingly missing the structural editing slurp and barf keys from spacemacs.

I was looking around the intellij plugin ecosystem and it looks like the Cursive is the best bet there -- but structural editing is just a small part of that plugin being for clojure language support, which seems like more than I want. And I'm not sure how to map the keys to my preferred spacemacs bindings.

Is there any chance of this possibly eventually making it into intellimacs, or is that beyond the scope of this project? Thanks!

@marcoieni
Copy link
Owner

Hi tapegram! First of all, thanks for your kind words.
I don't use this feature and I don't have time to work on it.
If you want you can develop this feature by yourself by adding source path/to/structural_editing.vim to your .ideavimrc.

After that, you can submit a Pull Request and we merge your effort if you want 👍

@JAremko
Copy link

JAremko commented Nov 15, 2024

You can call :actionlist to get the list of all Cursive actions available:

Cursive actions
:cursive.actions.paredit/backward                  <C-Left>
:cursive.actions.paredit/backward-down
:cursive.actions.paredit/backward-up
:cursive.actions.paredit/barf-backwards            <A-C-K>
:cursive.actions.paredit/barf-forwards             <A-S-J>
:cursive.actions.paredit/clojure-edit-group
:cursive.actions.paredit/clojure-navigate-group
:cursive.actions.paredit/close-curly-and-newline   <C-S-]>
:cursive.actions.paredit/close-paren-and-newline   <C-S-0>
:cursive.actions.paredit/close-square-and-newline  <C-]>
:cursive.actions.paredit/copy-as-kill              <A-S-D>
:cursive.actions.paredit/cycle-collection-type
:cursive.actions.paredit/forward                   <C-Right>
:cursive.actions.paredit/forward-down
:cursive.actions.paredit/forward-up
:cursive.actions.paredit/join                      <C-S-S>
:cursive.actions.paredit/kill                      <A-D>
:cursive.actions.paredit/kill-sexp                 <A-C-D>
:cursive.actions.paredit/move-form-down            <C-S-Down>
:cursive.actions.paredit/move-form-up              <C-S-Up>
:cursive.actions.paredit/raise                     <A-R>
:cursive.actions.paredit/slurp-backwards           <A-C-J>
:cursive.actions.paredit/slurp-forwards            <A-S-K>
:cursive.actions.paredit/splice                    <A-S>
:cursive.actions.paredit/splice-killing-backwards
:cursive.actions.paredit/splice-killing-forwards
:cursive.actions.paredit/split                     <A-S-S>
:cursive.actions.paredit/thread-form               <A-C-,>
:cursive.actions.paredit/toggle
:cursive.actions.paredit/unthread-form             <A-C-.>
:cursive.actions.paredit/wrap-curly                <C-S-[>
:cursive.actions.paredit/wrap-paren                <C-S-9>
:cursive.actions.paredit/wrap-quotes               <C-S-Þ>
:cursive.actions.paredit/wrap-square               <C-[>
:cursive.repl.actions/clear-repl
:cursive.repl.actions/clojure-repl-commands-group
:cursive.repl.actions/clojure-repl-group
:cursive.repl.actions/close
:cursive.repl.actions/execute                      <C-CR>
:cursive.repl.actions/execute-bookmark
:cursive.repl.actions/interrupt
:cursive.repl.actions/jump-to-output
:cursive.repl.actions/jump-to-repl                 <C-\>
:cursive.repl.actions/language
:cursive.repl.actions/load-file                    <A-S-L>
:cursive.repl.actions/macroexpansion               <C-S-\>
:cursive.repl.actions/next-history-item
:cursive.repl.actions/prev-history-item
:cursive.repl.actions/print-exception
:cursive.repl.actions/reconnect
:cursive.repl.actions/run-last-sexp
:cursive.repl.actions/run-top-sexp                 <A-S-P>
:cursive.repl.actions/search-history               <A-C-E>
:cursive.repl.actions/stop
:cursive.repl.actions/switch-namespace             <A-S-R>
:cursive.repl.actions/sync-files                   <A-S-M>
:cursive.repl.actions/toggle-auto-scroll
:cursive.repl.actions/toggle-locals-clearing
:cursive.repl.actions/toggle-repl-editor-type
:cursive.repl.actions/toggle-soft-wrap
:cursive.testing.actions/remove-test-markers
:cursive.testing.actions/rerun-last-test
:cursive.testing.actions/run-ns-tests
:cursive.testing.actions/run-single-test

So I fed Spacemacs docs to Claude and asked to extract bindings. Then I combined the list above with the bindings
and used intellimacs as example.

And I have this config so far:

hallucination galore
" ============================================================================
" WhichKey Descriptions
" ============================================================================

" Top-level menus
let g:WhichKeyDesc_Major = "<leader>m +major-mode"
let g:WhichKeyDesc_Structural = "<leader>k +structural"

" --- Eval and REPL ---
let g:WhichKeyDesc_Major_Eval = "<leader>me +eval"
let g:WhichKeyDesc_Major_Eval_LastSexp = "<leader>mee run-last-sexp"
let g:WhichKeyDesc_Major_Eval_TopLevel = "<leader>mep run-top-sexp"
let g:WhichKeyDesc_Major_Eval_Buffer = "<leader>meb load-file"

let g:WhichKeyDesc_Major_REPL = "<leader>ms +repl"
let g:WhichKeyDesc_Major_REPL_Clear = "<leader>msc clear-repl"
let g:WhichKeyDesc_Major_REPL_Quit = "<leader>msq close-repl"
let g:WhichKeyDesc_Major_REPL_SwitchNS = "<leader>msr switch-namespace"
let g:WhichKeyDesc_Major_REPL_Switch = "<leader>mss jump-to-repl"
let g:WhichKeyDesc_Major_REPL_Output = "<leader>mso jump-to-output"
let g:WhichKeyDesc_Major_REPL_Macroexpand = "<leader>msm macroexpansion"
let g:WhichKeyDesc_Major_REPL_Execute = "<leader>mse execute"
let g:WhichKeyDesc_Major_REPL_History = "<leader>msh search-history"
let g:WhichKeyDesc_Major_REPL_HistoryNext = "<leader>msn next-history"
let g:WhichKeyDesc_Major_REPL_HistoryPrev = "<leader>msp prev-history"
let g:WhichKeyDesc_Major_REPL_Stop = "<leader>msx stop"
let g:WhichKeyDesc_Major_REPL_Interrupt = "<leader>msi interrupt"
let g:WhichKeyDesc_Major_REPL_Sync = "<leader>msy sync-files"
let g:WhichKeyDesc_Major_REPL_Exception = "<leader>msE print-exception"
let g:WhichKeyDesc_Major_REPL_Reconnect = "<leader>msR reconnect"

" --- Testing ---
let g:WhichKeyDesc_Major_Test = "<leader>mt +test"
let g:WhichKeyDesc_Major_Test_All = "<leader>mta run-ns-tests"
let g:WhichKeyDesc_Major_Test_Single = "<leader>mtt run-single-test"
let g:WhichKeyDesc_Major_Test_Rerun = "<leader>mtr rerun-last-test"
let g:WhichKeyDesc_Major_Test_Clear = "<leader>mtc remove-test-markers"

" --- Settings ---
let g:WhichKeyDesc_Major_Settings = "<leader>mR +settings"
let g:WhichKeyDesc_Major_Settings_AutoScroll = "<leader>mRa toggle-auto-scroll"
let g:WhichKeyDesc_Major_Settings_Locals = "<leader>mRl toggle-locals"
let g:WhichKeyDesc_Major_Settings_Type = "<leader>mRt toggle-repl-editor-type"
let g:WhichKeyDesc_Major_Settings_Wrap = "<leader>mRw toggle-soft-wrap"

" --- Structural Editing ---
" Navigation
let g:WhichKeyDesc_Structural_Forward = "<leader>kj next-sexp"
let g:WhichKeyDesc_Structural_Backward = "<leader>kk prev-sexp"
let g:WhichKeyDesc_Structural_ForwardDown = "<leader>kl forward-down"
let g:WhichKeyDesc_Structural_BackwardUp = "<leader>kh backward-up"
let g:WhichKeyDesc_Structural_BackwardDown = "<leader>kL backward-down"
let g:WhichKeyDesc_Structural_ForwardUp = "<leader>kH forward-up"
let g:WhichKeyDesc_Structural_MoveUp = "<leader>kK move-form-up"
let g:WhichKeyDesc_Structural_MoveDown = "<leader>kJ move-form-down"

" Manipulation
let g:WhichKeyDesc_Structural_Slurp = "<leader>ks slurp-forwards"
let g:WhichKeyDesc_Structural_SlurpBack = "<leader>kS slurp-backwards"
let g:WhichKeyDesc_Structural_Barf = "<leader>kb barf-forwards"
let g:WhichKeyDesc_Structural_BarfBack = "<leader>kB barf-backwards"
let g:WhichKeyDesc_Structural_Splice = "<leader>kw splice"
let g:WhichKeyDesc_Structural_SpliceKillForward = "<leader>ke splice-killing-forwards"
let g:WhichKeyDesc_Structural_SpliceKillBackward = "<leader>kE splice-killing-backwards"
let g:WhichKeyDesc_Structural_Join = "<leader>kj join"
let g:WhichKeyDesc_Structural_Split = "<leader>k<Space> split"
let g:WhichKeyDesc_Structural_Raise = "<leader>kr raise"
let g:WhichKeyDesc_Structural_CycleCollection = "<leader>kc cycle-collection"
let g:WhichKeyDesc_Structural_Kill = "<leader>kd kill"
let g:WhichKeyDesc_Structural_KillSexp = "<leader>kD kill-sexp"
let g:WhichKeyDesc_Structural_CopyKill = "<leader>ky copy-as-kill"
let g:WhichKeyDesc_Structural_Toggle = "<leader>kt toggle"

" Threading
let g:WhichKeyDesc_Structural_Thread = "<leader>k> thread-form"
let g:WhichKeyDesc_Structural_Unthread = "<leader>k< unthread-form"

" Wrapping
let g:WhichKeyDesc_Structural_WrapRound = "<leader>k( wrap-paren"
let g:WhichKeyDesc_Structural_WrapSquare = "<leader>k[ wrap-square"
let g:WhichKeyDesc_Structural_WrapCurly = "<leader>k{ wrap-curly"
let g:WhichKeyDesc_Structural_WrapQuote = "<leader>k\" wrap-quotes"
let g:WhichKeyDesc_Structural_CloseParenNewline = "<leader>k) close-paren-newline"
let g:WhichKeyDesc_Structural_CloseSquareNewline = "<leader>k] close-square-newline"
let g:WhichKeyDesc_Structural_CloseCurlyNewline = "<leader>k} close-curly-newline"

" ============================================================================
" Mappings
" ============================================================================

" --- Structural Editing ---
" Navigation
nnoremap <leader>kj :action :cursive.actions.paredit/forward<CR>
vnoremap <leader>kj <Esc>:action :cursive.actions.paredit/forward<CR>

nnoremap <leader>kk :action :cursive.actions.paredit/backward<CR>
vnoremap <leader>kk <Esc>:action :cursive.actions.paredit/backward<CR>

nnoremap <leader>kl :action :cursive.actions.paredit/forward-down<CR>
vnoremap <leader>kl <Esc>:action :cursive.actions.paredit/forward-down<CR>

nnoremap <leader>kh :action :cursive.actions.paredit/backward-up<CR>
vnoremap <leader>kh <Esc>:action :cursive.actions.paredit/backward-up<CR>

nnoremap <leader>kL :action :cursive.actions.paredit/backward-down<CR>
vnoremap <leader>kL <Esc>:action :cursive.actions.paredit/backward-down<CR>

nnoremap <leader>kH :action :cursive.actions.paredit/forward-up<CR>
vnoremap <leader>kH <Esc>:action :cursive.actions.paredit/forward-up<CR>

nnoremap <leader>kK :action :cursive.actions.paredit/move-form-up<CR>
vnoremap <leader>kK <Esc>:action :cursive.actions.paredit/move-form-up<CR>

nnoremap <leader>kJ :action :cursive.actions.paredit/move-form-down<CR>
vnoremap <leader>kJ <Esc>:action :cursive.actions.paredit/move-form-down<CR>

" Slurp & Barf
nnoremap <leader>ks :action :cursive.actions.paredit/slurp-forwards<CR>
vnoremap <leader>ks <Esc>:action :cursive.actions.paredit/slurp-forwards<CR>

nnoremap <leader>kS :action :cursive.actions.paredit/slurp-backwards<CR>
vnoremap <leader>kS <Esc>:action :cursive.actions.paredit/slurp-backwards<CR>

nnoremap <leader>kb :action :cursive.actions.paredit/barf-forwards<CR>
vnoremap <leader>kb <Esc>:action :cursive.actions.paredit/barf-forwards<CR>

nnoremap <leader>kB :action :cursive.actions.paredit/barf-backwards<CR>
vnoremap <leader>kB <Esc>:action :cursive.actions.paredit/barf-backwards<CR>

" Splice operations
nnoremap <leader>kw :action :cursive.actions.paredit/splice<CR>
vnoremap <leader>kw <Esc>:action :cursive.actions.paredit/splice<CR>

nnoremap <leader>ke :action :cursive.actions.paredit/splice-killing-forwards<CR>
vnoremap <leader>ke <Esc>:action :cursive.actions.paredit/splice-killing-forwards<CR>

nnoremap <leader>kE :action :cursive.actions.paredit/splice-killing-backwards<CR>
vnoremap <leader>kE <Esc>:action :cursive.actions.paredit/splice-killing-backwards<CR>

" Kill operations
nnoremap <leader>kd :action :cursive.actions.paredit/kill<CR>
vnoremap <leader>kd <Esc>:action :cursive.actions.paredit/kill<CR>

nnoremap <leader>kD :action :cursive.actions.paredit/kill-sexp<CR>
vnoremap <leader>kD <Esc>:action :cursive.actions.paredit/kill-sexp<CR>

nnoremap <leader>ky :action :cursive.actions.paredit/copy-as-kill<CR>
vnoremap <leader>ky <Esc>:action :cursive.actions.paredit/copy-as-kill<CR>

" Split & Join
nnoremap <leader>k<Space> :action :cursive.actions.paredit/split<CR>
vnoremap <leader>k<Space> <Esc>:action :cursive.actions.paredit/split<CR>

nnoremap <leader>kj :action :cursive.actions.paredit/join<CR>
vnoremap <leader>kj <Esc>:action :cursive.actions.paredit/join<CR>

" Collection operations
nnoremap <leader>kc :action :cursive.actions.paredit/cycle-collection-type<CR>
vnoremap <leader>kc <Esc>:action :cursive.actions.paredit/cycle-collection-type<CR>

" Threading
nnoremap <leader>k> :action :cursive.actions.paredit/thread-form<CR>
vnoremap <leader>k> <Esc>:action :cursive.actions.paredit/thread-form<CR>

nnoremap <leader>k< :action :cursive.actions.paredit/unthread-form<CR>
vnoremap <leader>k< <Esc>:action :cursive.actions.paredit/unthread-form<CR>

" Wrapping
nnoremap <leader>k( :action :cursive.actions.paredit/wrap-paren<CR>
vnoremap <leader>k( <Esc>:action :cursive.actions.paredit/wrap-paren<CR>

nnoremap <leader>k[ :action :cursive.actions.paredit/wrap-square<CR>
vnoremap <leader>k[ <Esc>:action :cursive.actions.paredit/wrap-square<CR>

nnoremap <leader>k{ :action :cursive.actions.paredit/wrap-curly<CR>
vnoremap <leader>k{ <Esc>:action :cursive.actions.paredit/wrap-curly<CR>

nnoremap <leader>k" :action :cursive.actions.paredit/wrap-quotes<CR>
vnoremap <leader>k" <Esc>:action :cursive.actions.paredit/wrap-quotes<CR>

" Close and newline
nnoremap <leader>k) :action :cursive.actions.paredit/close-paren-and-newline<CR>
vnoremap <leader>k) <Esc>:action :cursive.actions.paredit/close-paren-and-newline<CR>

nnoremap <leader>k] :action :cursive.actions.paredit/close-square-and-newline<CR>
vnoremap <leader>k] <Esc>:action :cursive.actions.paredit/close-square-and-newline<CR>

nnoremap <leader>k} :action :cursive.actions.paredit/close-curly-and-newline<CR>
vnoremap <leader>k} <Esc>:action :cursive.actions.paredit/close-curly-and-newline<CR>

" Toggle paredit
nnoremap <leader>kt :action :cursive.actions.paredit/toggle<CR>
vnoremap <leader>kt <Esc>:action :cursive.actions.paredit/toggle<CR>

" --- REPL Mappings ---
nnoremap <leader>mee :action :cursive.repl.actions/run-last-sexp<CR>
vnoremap <leader>mee <Esc>:action :cursive.repl.actions/run-last-sexp<CR>

nnoremap <leader>mep :action :cursive.repl.actions/run-top-sexp<CR>
vnoremap <leader>mep <Esc>:action :cursive.repl.actions/run-top-sexp<CR>

nnoremap <leader>meb :action :cursive.repl.actions/load-file<CR>
vnoremap <leader>meb <Esc>:action :cursive.repl.actions/load-file<CR>

nnoremap <leader>msc :action :cursive.repl.actions/clear-repl<CR>
vnoremap <leader>msc <Esc>:action :cursive.repl.actions/clear-repl<CR>

nnoremap <leader>msq :action :cursive.repl.actions/close<CR>
vnoremap <leader>msq <Esc>:action :cursive.repl.actions/close<CR>

nnoremap <leader>msr :action :cursive.repl.actions/switch-namespace<CR>
vnoremap <leader>msr <Esc>:action :cursive.repl.actions/switch-namespace<CR>

nnoremap <leader>mss :action :cursive.repl.actions/jump-to-repl<CR>
vnoremap <leader>mss <Esc>:action :cursive.repl.actions/jump-to-repl<CR>

nnoremap <leader>mso :action :cursive.repl.actions/jump-to-output<CR>
vnoremap <leader>mso <Esc>:action :cursive.repl.actions/jump-to-output<CR>

nnoremap <leader>msm :action :cursive.repl.actions/macroexpansion<CR>
vnoremap <leader>msm <Esc>:action :cursive.repl.actions/macroexpansion<CR>

nnoremap <leader>mse :action :cursive.repl.actions/execute<CR>
vnoremap <leader>mse <Esc>:action :cursive.repl.actions/execute<CR>

nnoremap <leader>msh :action :cursive.repl.actions/search-history<CR>
vnoremap <leader>msh <Esc>:action :cursive.repl.actions/search-history<CR>

nnoremap <leader>msn :action :cursive.repl.actions/next-history-item<CR>
vnoremap <leader>msn <Esc>:action :cursive.repl.actions/next-history-item<CR>

nnoremap <leader>msp :action :cursive.repl.actions/prev-history-item<CR>
vnoremap <leader>msp <Esc>:action :cursive.repl.actions/prev-history-item<CR>

nnoremap <leader>msx :action :cursive.repl.actions/stop<CR>
vnoremap <leader>msx <Esc>:action :cursive.repl.actions/stop<CR>

nnoremap <leader>msi :action :cursive.repl.actions/interrupt<CR>
vnoremap <leader>msi <Esc>:action :cursive.repl.actions/interrupt<CR>

nnoremap <leader>msy :action :cursive.repl.actions/sync-files<CR>
vnoremap <leader>msy <Esc>:action :cursive.repl.actions/sync-files<CR>

nnoremap <leader>msE :action :cursive.repl.actions/print-exception<CR>
vnoremap <leader>msE <Esc>:action :cursive.repl.actions/print-exception<CR>

nnoremap <leader>msR :action :cursive.repl.actions/reconnect<CR>
vnoremap <leader>msR <Esc>:action :cursive.repl.actions/reconnect<CR>

" Settings mappings
nnoremap <leader>mRa :action :cursive.repl.actions/toggle-auto-scroll<CR>
vnoremap <leader>mRa <Esc>:action :cursive.repl.actions/toggle-auto-scroll<CR>

nnoremap <leader>mRl :action :cursive.repl.actions/toggle-locals-clearing<CR>
vnoremap <leader>mRl <Esc>:action :cursive.repl.actions/toggle-locals-clearing<CR>

nnoremap <leader>mRt :action :cursive.repl.actions/toggle-repl-editor-type<CR>
vnoremap <leader>mRt <Esc>:action :cursive.repl.actions/toggle-repl-editor-type<CR>

nnoremap <leader>mRw :action :cursive.repl.actions/toggle-soft-wrap<CR>
vnoremap <leader>mRw <Esc>:action :cursive.repl.actions/toggle-soft-wrap<CR>

" Testing mappings
nnoremap <leader>mta :action :cursive.testing.actions/run-ns-tests<CR>
vnoremap <leader>mta <Esc>:action :cursive.testing.actions/run-ns-tests<CR>

nnoremap <leader>mtt :action :cursive.testing.actions/run-single-test<CR>
vnoremap <leader>mtt <Esc>:action :cursive.testing.actions/run-single-test<CR>

nnoremap <leader>mtr :action :cursive.testing.actions/rerun-last-test<CR>
vnoremap <leader>mtr <Esc>:action :cursive.testing.actions/rerun-last-test<CR>

nnoremap <leader>mtc :action :cursive.testing.actions/remove-test-markers<CR>
vnoremap <leader>mtc <Esc>:action :cursive.testing.actions/remove-test-markers<CR>

" Raise operation
nnoremap <leader>kr :action :cursive.actions.paredit/raise<CR>
vnoremap <leader>kr <Esc>:action :cursive.actions.paredit/raise<CR>

" Toggle
nnoremap <leader>kt :action :cursive.actions.paredit/toggle<CR>
vnoremap <leader>kt <Esc>:action :cursive.actions.paredit/toggle<CR>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants