-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: new cmdline (local to editor view) #57
Conversation
Thanks! I tried it on my machine and it looks very nice, but I need more time to review the code.
Externalizing UI has improved a lot these years, if we drop neovim-qt and upgrade to the latest API we should be able to drop lots of hacks we currently have in the codebase and drop the complexity and improve the stability for a wide range of use cases. Using ext_windows and ext_multigrid for example should resolve issues with splits, etc.
I think we better stick to Neovim behavior whenever possible. Generally speaking people using this plugin probably are satisfied with Neovim user experience and are used to it and prefer to stick with it whenever possible. |
I figured out a way to block the editors interaction with the mouse during command line editing, but I am not sure if it is possible to let the user select text in the buffer. Futhermore, the user can still open a file/split using GUI, which you could not do in Neovim. Should we block this functionality as well? |
I see, that in the code, we already pass an ext_multigrid option and neovim-qt sends us a multigrid events such as If I am not mistaken, |
I don't think we should block anything (even mouse interaction) I just think it would be better to stick with Neovim user experience. If we accidentally get extra features it's good. So I think it's good that interacting with mouse doesn't discard cmdline (Neovim behavior kept, so users will feel at home), I'm also happy interacting with mouse is possible (extra features, if someone accidentally interacts with the mouse and copies some text from the buffer by mouse, good for them.) Regarding opening a file/split using GUI, I think it's ok, we don't need to block or manipulate anything. Ideally we should just report it to Neovim and let Neovim instance decide what to do in this situation. If Neovim ignores it or if it opens the window/split while keeping the user in cmdline or if Neovim opens the window/split and discards cmdline, it's all good. If Neovim crashes, then it's bad and we will report a bug in Neovim repository. I say let the Neovim team think about such issues, as they are designing the external user interface and its behavior, if something goes wrong we fix it in Neovim, not in qnvim. The thing is clicking on "new window"/"new split" button in an IDE/editor while editing cmdline is not something special with qnvim, it can happen in VSCode, JetBrains, Sublime or any other IDE/editor, so for the sake of consistency and avoiding duplications we better decide about it in Neovim. Sorry for the long post, I tried to explain how I understand this issue. |
Sorry, I forgot we already use My knowledge about new Neovim api is poor, so I can't brainstorm with you about it. I'm willing to learn about it once libnvim is out and stable and we can easily and directly communicate with Neovim instance with a third party library. It's beyond the scope of this pull request anyway. I think the user experience of cmdline in this pull request is already very good. |
Relevant: neovim/neovim#21693 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review, I added some comments.
*/ | ||
template <typename K, typename V> | ||
requires (QObjectBasedPointer<K> || QObjectBasedPointer<V>) | ||
class AutoMap : public AutoMapBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to learn a bit about its mission and the rational behind implementing it.
It seems to me that this data-structure has two missions:
- Act as a map.
- Help with garbage collection.
If that's correct then it may be an anti-pattern regarding Single Responsibility Principle and may make the maintenance of the code hard over time.
An alternative would be to implement a list of pairs for this purpose instead of a map and keep the lookup feature for a simple Qt or std map?
Also I'm under the impression that it will delete the key if the value is deleted and also deletes the value if the key is deleted. So if the cmdline is somehow deleted it deletes the editor and the editorview, right? Is it intentional?
Also in this project we have avoided standard library and sticked with Qt data structures (like using QMap instead of std::map). What do you think about keep this pattern for the sake of consistency?
@@ -148,13 +137,12 @@ autocmd VimEnter * let $MYQVIMRC=substitute($MYVIMRC, 'init.vim$', 'qnvim.vim', | |||
mNVim->api2()->nvim_subscribe("Gui"); | |||
mNVim->api2()->nvim_subscribe("api-buffer-updates"); | |||
}); | |||
|
|||
m_cmdLine = std::make_unique<CmdLine>(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a QObject, Isn't new CmdLine(this)
enough to take care of garbage collection? I know using new
is not preferred in C++ but last time I checked (I may not be updated) for QObjects you usually don't need to take care of garbage collection and passing this
as the parent in the constructor is enough for Qt to take care of the rest.
I don't have a strong opinion about this, if you are confident this is better we can go with it, I'd be thankful if you provide me a resource so that I can learn more about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just trying to avoid standard library in parallel with Qt, my understanding is that Qt already has whatever standard library can provide for general use cases and having both work in parallel may cause some compatibility issues.
|
||
QTimer::singleShot(100, this, [=]() { fixSize(editor); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to call fixSize in the initialization, previously we used to call it on initialization as well as whenever Resize
event was triggered.
@@ -0,0 +1,47 @@ | |||
// SPDX-FileCopyrightText: 2023 Mikhail Zolotukhin <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of correctness I think the copyright header for the newly created files that are mostly based on the old code should be probably like this:
// SPDX-FileCopyrightText: 2023 Mikhail Zolotukhin <[email protected]> | |
// SPDX-FileCopyrightText: 2023 Mikhail Zolotukhin <[email protected]> | |
// SPDX-FileCopyrightText: 2018-2019 Sassan Haradji <[email protected]> |
Sorry, this PR got closed automatically when I merged qtc-6 to master, kindly reopen it when you got the time. |
Summary
This creates Neovim command line inside the editor, instead of occupying Qt Creator search bar. This is an enhancement, because:
Notes
Test Plan
:
,/
or?
and try to use some neovim command. It should work.:history
orecho "something\n\n\n\n\nsomething"
.Closes #56