Closed hongxuchen closed 1 year ago
Thanks a lot for your work on this, the implementation is otherwise nice
I pushed to your branch, I hope you don't mind
I pushed to your branch, I hope you don't mind
That's all right to me.
But to be honest, I prefer to keep vim.bo.bufhidden = "hide"
for the created buffer for reuse purpose. When vim.bo.bufhidden = "wipe"
, the buffer will no longer be available whenever jumped to other buffers; and if we'd like to see another parent/child type, we have to invoke ClangdTypeHierarchy
once more, which is somewhat annoying. Is it possible to provide a setup option for this?
we have to invoke ClangdTypeHierarchy once more,
You can bind it to a key if you use it frequently (maybe in on_attach
so it only works in clangd-attached buffers)
If you want to keep the buffer then you need to use another window for the gd
buffer (making it three windows) because we change the window options for the type hierarchy window
we have to invoke ClangdTypeHierarchy once more,
You can bind it to a key if you use it frequently (maybe in
on_attach
so it only works in clangd-attached buffers)
I have a keymap for ClangdTypeHierarchy. But I think this is still a bit inconvenient with.
hide
, when we jump back it returned to the created ClangdTypeHierarchy buffer and the previous position is kept; therefore we can just select other items which are likely around the cursor.wipe
, when we jump back it returned to previous cpp buffer; we press the bound keys, cursor switches to start of ClangdTypeHierarchy buffer, and we navigate to the new child/parent items. This involves many more keystrokes.If you want to keep the buffer then you need to use another window for the
gd
buffer (making it three windows) because we change the window options for the type hierarchy window
Oh, I realized that window options were not correctly restored in my commit.
Hmm ok, but what about the multiple windows problem?
What if we reuse the source code window from which :ClangdTypeHierarchy
was invoked?
I installed vscode to see what they do, they keep the type hierarchy window open and open another "tab" (like vim buffers) so I guess doing the above is fine?
This way we can keep bufhidden=wipe
because the type hierarchy window stays
Can you try the latest commit I pushed?
This way we can keep
bufhidden=wipe
because the type hierarchy window staysCan you try the latest commit I pushed?
Yes, your solution is elegant!
Ok, I'll squash and merge. Thanks for your contribution!
Manually rebased main on top of this branch
One more thing I'm not quite sure, do we need to clean up _G.type_pos_mappings? If many different ClangdTypeHierarchy buffers have been opened, whether or not they are wiped out, this may cause memory bloat. This is an extreme case though.
Previously I was trying buffer-local variables, but it was not updated when passed as a function parameter.
Can you also add a demo to the readme?
Can you also add a demo to the readme?
I'd like to but I think it may not be a good choice since I use different colorscheme and font from yours, which may bring surprise. BTW, I guess llvm-project may be used for demo since there are many complicated inheritances.
@p00f I noticed that there is an issue with current implementation: when the original window is closed (Ctrl-W_c for example), and the navigation from inside type hierarchy window with gd
will report an invalid window id error like below:
E5108: Error executing lua: ...extensions.nvim/lua/clangd_extensions/type_hierarchy.lua:109: Invalid window id: 1365
stack traceback:
[C]: in function 'nvim_set_current_win'
...extensions.nvim/lua/clangd_extensions/type_hierarchy.lua:109: in function <...extensions.nvim/lua/clangd_extensions/type_hierarchy.lua:104>
Another issue is that it will report Buffer is not 'modifiable'
when we repeatedly :ClangdTypeHierarchy
on a Class/Struct (since the corresponding type hierarchy buffer is set unmodifiable).
This commit adds the localization functionality for the items of
ClangdTypeHierarchy
created buffer. Major changes:An implementation for https://github.com/p00f/clangd_extensions.nvim/issues/36