Commits

Meikel Brandmeyer committed 400eb3f

^ in Repl moves after prompt, not BOL (suggested by A. Bonnaire-Sergeant)

Comments (0)

Files changed (3)

vim/autoload/vimclojure.vim

 	if !hasmapto("<Plug>ClojureReplEvaluate")
 		imap <buffer> <silent> <C-CR> <Plug>ClojureReplEvaluate
 	endif
+	if !hasmapto("<Plug>ClojureReplHatHook")
+		nmap <buffer> <silent> ^ <Plug>ClojureReplHatHook
+	endif
 	if !hasmapto("<Plug>ClojureReplUpHistory")
 		imap <buffer> <silent> <C-Up> <Plug>ClojureReplUpHistory
 	endif
 	endif
 endfunction
 
+function! vimclojure#Repl.hatHook() dict
+	let l = getline(".")
+
+	if l =~ "^" . self._prompt
+		let [buf, line, col, off] = getpos(".")
+		call setpos(".", [buf, line, len(self._prompt) + 2, off])
+	else
+		normal! ^
+	endif
+endfunction
+
 function! vimclojure#Repl.upHistory() dict
 	let histLen = len(self._history)
 	let histDepth = self._historyDepth

vim/doc/clojure.txt

 entry. So playing back with <C-Up> will again send all of the contained
 expressions.
 
+If the current line starts with a repl prompt, the *^* command moves to
+the end of the prompt and to the beginning of the line.
+
 The Plugs are:
  - <Plug>ClojureReplEnterHook for the enter key
  - <Plug>ClojureReplEvaluate for immediate evaluation (<C-CR>)
+ - <Plug>ClojureReplHatHook for ^ navigation
  - <Plug>ClojureReplUpHistory for going backwards in history (<C-Up>)
  - <Plug>ClojureReplDownHistory for going forwards in history (<C-Down>)
 

vim/plugin/clojure.vim

 
 inoremap <Plug>ClojureReplEnterHook <Esc>:call b:vimclojure_repl.enterHook()<CR>
 imap <Plug>ClojureReplEvaluate <Esc>GA<CR>
+nnoremap <Plug>ClojureReplHatHook :call b:vimclojure_repl.hatHook()<CR>
 inoremap <Plug>ClojureReplUpHistory <C-O>:call b:vimclojure_repl.upHistory()<CR>
 inoremap <Plug>ClojureReplDownHistory <C-O>:call b:vimclojure_repl.downHistory()<CR>