-
Notifications
You must be signed in to change notification settings - Fork 214
Peek
The basic use of lsp-bridge-peek
is to read the definition and the references of a symbol, without leaving current buffer. This is often helpful when reading and writing code.
Type M-x lsp-bridge-peek
on a symbol to peek its definition and references. A peek window will be opened under current line, and it follows the cursor. You can use these keybindings to browse in the peek window:
-
M-n
,M-p
: Next/prev line. -
M-N
,M-P
: Next/prev definition or reference. -
M-l j
: Jump to the definition or reference. -
M-l b
: Jump back to the position beforelsp-bridge-peek-jump
. -
C-g
: Close the peek window.
These keys are defined in lsp-bridge-peek-keymap
, and can be customized.
When reading a definition or reference, we often find it calls another function, and we are interested in the definition and references of that function too. Use a traditional code reading tools to do this, and we'll soon get lost in a lot of buffers.
Not a problem in lsp-bridge-peek
. In a peek session, just type M-x lsp-bridge-peek-through
(It can be bound to any key you like), than an ace string will be attached to each symbol in the peek window, and you know what to do now :) Just type it to see the definition and the references of that symbol, in the same peek window.
Do this several times, and the history is shown in the bottom of the peek window, like this:
func1 -> func2 -> [func3]
You can type <left>
and <right>
to move in the history. Now move back to func2
, it becomes:
func1 -> [func2] -> func3
At this point you can browse the definition and references of func2
again.
If now we peek through func4
, the history will become:
func1 -> func2 < [func4]
The < means you created a branch here. The current branch goes to func4, and the other one goes to func3. You can type / to switch between the branches. Congratulations! You just learned the most effective way to browse in a tree-like code reading history.