Skip to content
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

FEATURE: Put cursor in the beginning of line in normal mode #1371

Closed
1 task done
luthfielaroeha opened this issue Mar 2, 2024 · 17 comments
Closed
1 task done

FEATURE: Put cursor in the beginning of line in normal mode #1371

luthfielaroeha opened this issue Mar 2, 2024 · 17 comments
Labels
enhancement New feature or request

Comments

@luthfielaroeha
Copy link

Did you check the docs?

  • I have read all the docs.

Is your feature request related to a problem? Please describe.

Most of the time, when renaming a file I just want to rename the filename without changing the extension. Currently the cursor placed in the end of line.

Describe the solution you'd like.

I think it would be better to put the cursor in the beginning of the line so we can just use cw or ct. to change the filename.

Describe alternatives you've considered.

No response

Additional Context

No response

@luthfielaroeha luthfielaroeha added the enhancement New feature or request label Mar 2, 2024
@pysan3
Copy link
Collaborator

pysan3 commented Mar 2, 2024

#602

@pysan3 pysan3 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2024
@luthfielaroeha
Copy link
Author

Sorry probably I'm missing something.
I'm aware that the normal mode exists, but when I want to rename the file, the cursor started in the end of the line.
Is there any other config to make the cursor in the beginning of the line instead?

image

@pysan3
Copy link
Collaborator

pysan3 commented Mar 2, 2024

Oh I'm sorry.

@pysan3 pysan3 reopened this Mar 2, 2024
@bwpge
Copy link
Contributor

bwpge commented Mar 2, 2024

Just adding info for anyone looking to pick this up: you might have success getting the nui input/popup window ID (split.winid) and setting the cursor with vim.api.nvim_win_set_cursor().

@pysan3
Copy link
Collaborator

pysan3 commented Mar 12, 2024

neo_tree_popup_input_ready event has been added with #1372.

Please read :h neo-tree-events for more information.

@pysan3 pysan3 closed this as completed Mar 12, 2024
@uthmanmoh
Copy link

Not sure if this is the right place to ask this, but does anyone know if there's a way to control what happens based on the different input popups?
I want to be able to customize what happens when the input box for the move operation opens, and a different action when the input box for add opens

@uthmanmoh
Copy link

Also with this new suggested event:

{
  event = "neo_tree_popup_input_ready",
  ---@param input NuiInput
  handler = function(input)
    vim.cmd("stopinsert") -- Enter normal mode
  end,
}

I am unable to enter normal mode after manually entering insert mode with i, since pressing esc even in insert mode just closes the input. Is there a way to make it so that I need to press esc from within normal mode only to exit the input box, as I believe it used to be before?

@cseickel
Copy link
Contributor

cseickel commented Mar 15, 2024

@uthmanmoh

Not sure if this is the right place to ask this, but does anyone know if there's a way to control what happens based on the different input popups? I want to be able to customize what happens when the input box for the move operation opens, and a different action when the input box for add opens

There's no simple way to do this, but it would be a nice feature. Someone could probably come up with a code snippet to inspect the title displayed in the wrapper window.

I am unable to enter normal mode after manually entering insert mode with i, since pressing esc even in insert mode just closes the input.

That's a bug, or at least an oversight. I made a separate issue out of that.

@pysan3
Copy link
Collaborator

pysan3 commented Mar 15, 2024

Isn't it just up to the user to remap using input:map inside the event by themselves if they want this feature?

@cseickel
Copy link
Contributor

Isn't it just up to the user to remap using input:map inside the event by themselves if they want this feature?

Maybe, but we make the mapping with Nui so I'm not sure how easy it is to unmap from the event.

@pysan3
Copy link
Collaborator

pysan3 commented Mar 15, 2024

Wdym? There's input:unmap or do you mean something else?

@cseickel
Copy link
Contributor

Wdym? There's input:unmap or do you mean something else?

input is a Nui object that is not available in the event and also not standard nvim api so I'm not sure its the best user experience even if we could provide a reference to that object.

@pysan3
Copy link
Collaborator

pysan3 commented Mar 15, 2024

I'm sorry, I even put it in the docs but I forgot to pass input as an argument to fire_event. This is more of a bug I'd say.

I think we should pass it as either input or { input = input }.

Which one would you prefer? I'll make a PR later today.

@pysan3
Copy link
Collaborator

pysan3 commented Mar 15, 2024

@uthmanmoh

I've created #1398. Do you think this method works for you?

It was my mistake in the previous PR. Thanks for pointing out.

@uthmanmoh
Copy link

uthmanmoh commented Mar 15, 2024

Yup being able to control the mappings seems good. Thanks for the fix.

Although im thinking now with the complexity of this event handler increasing, it might have been a good idea to keep the boolean option enable_normal_mode_for_inputs which if set to 'true' would just create this handler. That makes sense as its own option since thats a basic functionality imo, and then the event handler would be there to customize the behaviour more.

Let me know if this makes sense, maybe I can create a separate ticket for it

@pysan3
Copy link
Collaborator

pysan3 commented Mar 15, 2024

This is my opinion on that #1372 (comment)

I understand that it is complicated but I've seen many FR that are slightly different for everybody (normal by default, put cursor before extension but in insert mode, put cursor at front, ...) and it is hard to distinguish where we officially support and not.

Therefore imo I think it's better to say that we support one and only one feature (insert + maps for <esc>, q) and everyone that don't like this behavior, they can edit whatever they want.
If we go this route, users can share their handler in the wiki and everybody who copy that code will work because everybody is on the same starting point, regardless of any other config option.

@uthmanmoh
Copy link

That sounds alright to me. Thanks for clarifying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants