How to expand coc.nvim incoming calls - coc.nvim

In Coc.nvim, when I request document.showIncomingCalls, I get the tree with only one successor showing up with a + sign in its left like the following:
- f1
+ f2
How do I expand the + beside f2 to show the caller of f2 as well?

By default <tab> on f2 will open actions menu. You can change it with :h coc-config-tree-key-actions.

Related

vscode navigate search editor using keyboard only

Is there any way to navigate the search editor (whole workspace search) using only cursor keys in vscode ? I'm talking about the whole workspace search and not just the find/replace search.
The new search editor thankfully has ported over most of the shortcut commands you have grown to know, but for brevity, this answer will include only the default keybinds with respective command id.
The when expression most commonly associated with these keybinds, should you want to alter them, are :
inSearchEditor
hasSearchResult
searchInputBoxFocus
Searching
Context Lines
Toggle context lines : toggleSearchEditorContextLines ALT + L
Will show n lines before or after search result, for context
Reduce context line quantity : decreaseSearchEditorContextLines ALT + -
Increase context line quantity : increaseSearchEditorContextLines ALT + =
Query Details
Toggle Query Details : workbench.action.search.toggleQueryDetails
This will toggle the include/exclude file input boxes
Settings
Toggle Match Case : toggleSearchCaseSensitive ALT + C
Toggle Regex : toggleSearchEditorRegex ALT + R
Toggle Word Match : toggleSearchEditorWholeWord ALT + W
Navigation
Luckily, because the search editor is effectively an 'editor', you can continue to use all the keybinds that you are used to. So, in order to jump straight to the editor, you can use whatever your keybind is to jump to an editor group, default is: CTRL + 1 (commandId: workbench.action.focusFirstEditorGroup)
Navigating matches
Go to next match : search.action.focusNextSearchResult F4
Go to previous match : search.action.focusPreviousSearchResult SHIFT + F4
Select all matches : selectAllSearchEditorMatches CTRL + SHIFT + L
Results
Deleting result block : workbench.action.searchEditor.deleteResultBlock CTRL + SHIFT + BACKSPACE
This deletes a block of results from the editor
For example, in the picture below, if my cursor is anywhere in the 'convert.js' result block the entire convert.js matches would be removed. You can undo this with CTRL + Z
Go To Definition (effectively go to file)
You can peek with ALT + F12 when your cursor is anywhere on the file name
You can assign a keyboard shortcut to follow links for the commandId: editor.action.openLink for when your cursor is on the file name
You can go directly to the file & line number of the search result using F12 while your cursor is anywhere on that result
Navigate Back to Input Box
Focus Search Input Box From Results: search.action.focusQueryEditorWidget ESCAPE
Searching within Search Editor
As noted, the search editor is effectively an editor, so you can resume using CTRL + F (find) or CTRL + H (find/replace) to narrow down results even more, and the keybinds set for those are maintained as used elsewhere.
Miscellaneous
Search again: rerunSearchEditorSearch CTRL + SHIFT + R
Perhaps you deleted too many result blocks
Otherwise, while your cursor is actively in the editor (results), you have the freedom to use most of your keybinds per normal, including collapsing/folding, jumping, copying, moving to editor groups etc

vim replace multiple lines by a variable (in register)

I am using Vim and I have ${HOME} saved on a register, which is the fastest way of replacing those ../../.. by ${HOME} ?
LDFLAG = -L../../../libs
-L../../../libs
result
LDFLAG = -L${HOME}/libs
-L${HOME}/libs
If you have ${HOME} in, let sey "u, then press ctrl+v, selected ../../../ , then press s, then ctrl+R (a " should appear) and the letter of your register (u in our example).
Assuming your cursor is on the first . of ../../../ and your text is stored in register a…
With visual-block selection
Press <C-v> to enter visual-block mode,
extend the selection horizontally to the last / of ../../../,
extend the selection vertically,
press "ap to put from register a.
With a repetition
Press v to enter visual mode,
extend the selection horizontally to the last / of ../../../,
press "ap to put from register a,
move the cursor to the next ../../../,
press . to repeat.
With a substitution
Do :,+s#\.\./\{3}#<C-r>e<CR>
I don't know what "I have ${HOME} saved on a register" means but the simplest solution would be
:%s#\M../../..#${HOME}#
It's replacing all of the ../../.. with ${HOME}, or if you really using a register (say #a), then you can use \=#a instead of ${HOME} to replace the match with the contents of register a.
Explanation
:: Open command prompt
%: On the whole buffer...
s: ...replace (substitute) the match...
\M: ...of a non-magic pattern (e.g. a literal string)
#: Used sharp instead of mostly used slash (/) as separator, because the pattern contains slash

SublimeText3 Fold/Unfold all methods

I am using SublimeText3 for C++ and Java. I am wondering if there is a way to fold all of the methods in a file / class, and then unfold them all, regardless of where the caret is. Or is there a way to list all the functions / methods.
Basically I would like to be able to enter a file and see all the methods at one quick glance.
Thanks
Using the Sublime Text 3 menu, you can find EDIT -> Code Folding -> which exposes the folding methods and will helpfully tell you the default keyboard shortcuts they are assigned to.
By default you press Ctrl+K, then Ctrl+1 to fold all subroutines. Then, to unfold all I would press Ctrl+K then Ctrl+J.
If this does not work for your file type / syntax, try Ctrl+K, Ctrl+2 and above to see if another folding level works for you.
Unfortunately for me, the proprietary code I work with required custom syntax and a custom function written in our in-house package to fold all of our functions (a new sublime command written in python and installed as a package).
More simple
Select the code and press:
Ctrl + Shift + [ to fold
Ctrl + Shift + ] to unfold
Updates
You can also select an element. Exemple:
Open the console (View -> Console or Ctrl`) with a source code file focused and enter the following commands at the bottom:
view.run_command("fold_all")
view.run_command("unfold_all")
to see their effect.
These commands can be bound with custom key bindings or put into the Command Palette for easy use.
Mac: Go to Edit/Code Folding as image bellow:
Details image

Sublime code-like method browser in Vim

Sublime code has a shortcut Super-R which opens a method browser listing all methods in current class (Ruby). Is there a plugin to get similar functionality in Vim?
"/def " or "m]" work only if you're familiar with the class and know what method you want to go to, whereas Super+R works for just exploring a class.
The TagList plugin is another (very popular) option. There are a bunch of others.
FYI, /def and m] are not the equivalent of Sublime Text's Ctrl+R. That would be :tag foo which you can tab-complete if you don't know all the names of your methods.
While we are at it, the CtrlP plugin has a feature very similar to Sublime Text's Ctrl+R: :CtrlpBufTag that I use hundreds of times a day.
All of these methods depend on the presence of a tags file generated by Exuberant Ctags or some compatible program. Actually, tags are quite an important part of the Vim experience.
You can use my project https://github.com/fatih/subvim
For cmd+r you can directly jump to any definition on the fly. No need to genarete tags or whatever. Currently any language supported by ctags can use this feature. I've also add languages like Go, Coffeescript, Objective-C,etc... It means just fire it up.
Also it has Sublime-like features backed in (means no plugins necessary). Thus you can use the following shortcuts:
cmd + p -> go to anything
cmd + t -> go to file
cmd + r -> go to symbol
cmd + k -> show side bar
cmd + / -> toggle comment
cmd + [ -> indent
cmd + ] -> unindent
cmd + <number> -> jump to tab 1, tab 2, ...
cmd + alt + left -> move to next tab
cmd + alt + right -> move to previos tab
cmd + z -> undo
cmd + shift + z -> redo
cmd + s -> save file
cmd + w -> close
cmd + f -> search
Also autocompletion, restoring latest session, automatic bracket closing and many minor changes make it really a joy to use.
The tagbar plugin works pretty well with Ruby files. Perhaps its not exactly the same as Sublime Super-R but it does give you a quick and easy way to explore a class.

Enclosing the function call in another function call (retval as parameter)

Having this LOC:
printf("%s (%d)\t(%d)\t%d-%d\t", meta_scanner_token_name($ret['major']), $ret['major'], (string)$ret['dirty'], $ret['start_line'], $ret['minor']);
What is the fastest way in terms of key strokes to enclose the call to meta_scanner_token_name in another function call to foo, yelding:
printf("%s (%d)\t(%d)\t%d-%d\t", foo(meta_scanner_token_name($ret['major'])), $ret['major'], (string)$ret['dirty'], $ret['start_line'], $ret['minor']);
given that
first scenario: my cursor is on 'm' at the beginning of the function?
second scenario: my cursor is somewhere on meta_scanner_token_name?
va)oB would select the entire line, and ys%) would enclose only the m, resulting in:
... (m)eta_sca...
Please answer to both scenarios.
(I am using spf13-vim with default settings except some visual changes, if that has any relevance)
ifoo(<Esc> then f)i)<Esc>
bifoo(<Esc> then f)i)<Esc>
but I'm still a Vim noob
-- EDIT --
I see "Surrounding.vim" is a modified version of "Surround.vim" if it's compatible with Surround you can do:
Scenario 1
vt,sffoo<CR>
vt, to select everything until the first ,
s to launch Surround.vim
f to instruct Surround to input a "function"
foo the identifier
<CR> Enter key.
That's 6 keystrokes not including typing foo which — I think — can't really be avoided.
Scenario 2
bvt,sffoo<CR>
It's the same as scenario 1 except that you type b first to go back to the first letter of meta_scanner_token_name.
Using normal vim you could do this (prefix with b for scenario 2)
`cf)foo()<esc>P`
If your vim plugins add the closing paren for you, you can drop that from the sequence. Depending on where it leaves your cursor, you might need to use p instead of P.

Resources