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

configure cursor shape #7151

Closed
Zaechus opened this issue Nov 16, 2022 · 21 comments
Closed

configure cursor shape #7151

Zaechus opened this issue Nov 16, 2022 · 21 comments
Labels
question the issue author asks something

Comments

@Zaechus
Copy link

Zaechus commented Nov 16, 2022

Question

It looks like the new appearance for the cursor in vi_mode is a vertical line for insert mode and a block for normal mode. Is there a configuration option to revert to a block for all modes?

Additional context and details

nu --version
0.71.0
@Zaechus Zaechus added the question the issue author asks something label Nov 16, 2022
@fdncred
Copy link
Collaborator

fdncred commented Nov 16, 2022

There is no config option yet, but it's planned. Planned, meaning that no one has done it yet but we want it.

@KSXGitHub
Copy link

At least exiting nu should revert the cursor to normal. But if nu can't know what the original cursor is, then I think this behavior should be disabled by default.

@fdncred
Copy link
Collaborator

fdncred commented Nov 29, 2022

FWIW, a PR has been started to make this configurable. nushell/reedline#515

@AmionSky
Copy link

The nushell/reedline#515 PR has been merged but I still couldn't find a way to configure it from nushell.
Also I strongly think by default nu shouldn't change the cursor set by the terminal.

@fdncred
Copy link
Collaborator

fdncred commented Jan 15, 2023

If you're on the latest main branch, you can configure it by adding this to your config.nu.

  cursor_shape: {
    vi_insert: underscore
    vi_normal: block
    emacs: line
  }

IIRC, I believe it will overwrite the terminal setting with or without setting this information. Maybe someone should look at that in the future. I'm just glad to get rid of the friggin block finally.

@warpdesign
Copy link

Just stumbled upon this issue: I'm not sure where to add the cursor_shape config? config.nu is huge and there are lots of entries. I tried pasting this at the end of the file but this resulted in an error.

@warpdesign
Copy link

Btw why doesn't nu use the shape defined by the terminal app and overwrites it?

@fdncred
Copy link
Collaborator

fdncred commented Jan 19, 2023

This change, I mentioned above, could go anywhere within the config section of the config.nu. You can identify this part of the config by finding let-env config = {. Anywhere before the last } would work.

So, you'd want something like, if you wanted it as the first thing in your config.nu.

let-env config = {
  cursor_shape: {
    vi_insert: underscore
    vi_normal: block
    emacs: line
  }
... all the rest of your config
}

You could also look at the default_config.nu in the repo, which shows where it goes.

But why doesn't ...

It probably should but it doesn't yet. Of course, this gives you a different option too. With this config option, you can different cursors depending on editing mode. Since that mode is specific to nushell, I doubt any terminal configuration would recognize it.

@ahirner
Copy link

ahirner commented Apr 7, 2023

Btw why doesn't nu use the shape defined by the terminal app and overwrites it?

Reedline supports not modifying the cursor:

If any of the fields is None, the cursor won’t get changed by Reedline for that mode.

I guess nushell should allow null in addition to 'line', 'block', or 'underscore'.

@tomboland
Copy link

tomboland commented Jun 22, 2023

Hi, I have this in the default, generated config:

  cursor_shape: {
    emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default)
    vi_insert: block # block, underscore, line , blink_block, blink_underscore, blink_line (block is the default)
    vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default)
  }

In vim, my cursor is a very fine line, and it's very difficult for me to see. I'm using version 0.81.0, installed with homebrew on MacOS.

@amtoine
Copy link
Member

amtoine commented Jun 22, 2023

  cursor_shape: {
    emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default)
    vi_insert: block # block, underscore, line , blink_block, blink_underscore, blink_line (block is the default)
    vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default)
  }

yes this is available now, i think we can close this issue as the question has been answered with time 😌

In vim, my cursor is a very fine line, and it's very difficult for me to see. I'm using version 0.81.0, installed with homebrew on MacOS.

this might have to do with your font? 🤔
my underscore is quite big enough!

@amtoine amtoine closed this as completed Jun 22, 2023
@tomboland
Copy link

Hi,

Should I raise a new issue? Using the same terminal emulator, but with bash, I see a large, bold, black cursor block, instead of this very thin vertical line. See my screenshot; can you see the cursor at a glance? It's on the vi_insert line:
image

@amtoine
Copy link
Member

amtoine commented Jun 22, 2023

@tomboland
mm i'd say this is a Vim issue 🤔

when i run Neovim i have a completely different cursor, it's not even switching from large to thin underscore, but rather between a vertical bar in Nushell and a block in NORMAL mode in Neovim 😕

@amtoine
Copy link
Member

amtoine commented Jun 22, 2023

what's strange is that Nushell should not have anything to do with the cursor inside either Vim or Neovim, which is what i see on my side...

@mb21
Copy link

mb21 commented Aug 31, 2023

@tomboland @amtoine I have the same and opened an issue: #10169

fdncred pushed a commit that referenced this issue Sep 9, 2023
# Description
There are several cursor shape related issues #7151 #9243 #7271 #8452
#10169, you can't disable the cursor shape feature even if you comment
out the entire `cursor_shape` block in the config.nu, and even worse,
when nushell exits with an error, the cursor shape can't be restored,
that is annoying.

This PR provides an opportunity to disable setting the cursor shape.

# User-Facing Changes
If you use the default config.nu, nothing changes, but if you comment
out `cursor_shape` block or set them to `inherit`, related cursor shape
will not be set.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
@nazmulidris
Copy link

On Windows, w/ nu v0.84.0, I had to add the following to my config.nu file

export-env { load-env {

    # https://github.com/nushell/nushell/issues/7151
    config: ($env.config? | default {} | merge {
        render_right_prompt_on_last_line: true,
        cursor_shape: {
            vi_insert: block
            vi_normal: block
            emacs: block
        }
    })

}}

@dedguy21
Copy link

I see that there are the two vi_insert & vi_normal. Is there also an option for vi_visual & vi_replace. I don't see it on the documentation.

@mb21
Copy link

mb21 commented Oct 17, 2023

@dedguy21 the cursor_shape vi_insert and vi_normal configs are not for inside vi/vim. They are for when nushell's prompt itself is set up to be in vim-like-mode (edit_mode: vi) – and that doesn't have visual or replace mode AFAIK.

@dedguy21
Copy link

@mb21 too bad, I was hoping it would be more like zsh/bash where the vi mode has VISUAL and REPLACE modes as well.

@mb21
Copy link

mb21 commented Oct 17, 2023

Yeah, you can like the upstream issue: kkawakam/rustyline#335

@fdncred
Copy link
Collaborator

fdncred commented Oct 17, 2023

We don't use rustyline anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question the issue author asks something
Projects
None yet
Development

No branches or pull requests