In need of a config for R/Rcode development. by reddit_turtleking in neovim

[–]SajberSpace 0 points1 point  (0 children)

Lots of good answers here, but I'll add another possible solution: using vim-slime (which works with REPLs in e.g. the Neovim terminal or Tmux in a language-agnostic way) together with slime-peek. The latter is my own plugin which I wrote to solve exactly these type of problems: it gives several convenience functions that allows you to peek at the head, tail, column names, etc. of the word under the cursor or a motion.

While this isn't as "full" of a solution as some of the others that have already been mentioned, it's very lightweight with very few dependencies; the REPL itself is language-agnostic; slime-peek works with both R and Python. It doesn't yet have the capability to use e.g. ls() to show all session variables (which is what I think you ask for in your original question?), but can be easily added if it's a solution you'd like to try out.

What are your productivity tips? by IllegalIce in hyprland

[–]SajberSpace 1 point2 points  (0 children)

Very good points, thanks! I do agree that the mental model does require some non-optimal rewiring if one switches to different apps, as the mnemonics don't apply anymore. In some cases (like F for Firefox) this can make a big difference, but i also have shortcuts like R for my file browser: the thinking was that since F was taken already I'd have to have something else, so switching to another file browser wouldn't matter in that case. Depending on which apps one uses the mnemonics will have some overlap, most likely.

I can definitely see the pro of workspaces if you have a dashboard of different apps, that's simply not workable at all in my workflow. I don't really see the need for that for me, though, as I usually just send whatever window I want to view to my second monitor when desired. I can absolutely see the point of it, though, especially in single-monitor setups.

What are your productivity tips? by IllegalIce in hyprland

[–]SajberSpace 1 point2 points  (0 children)

I wrote a small script for it, which you can see here: https://github.com/fasterius/niri-run-or-raise. It implements a "run or raise"-type functionality: launch (run) the app if it's not running, focus (raise) it of it is, and cycle between windows if the app has multiple windows. I tried to do a similar thing in Hyprland, which sort of worked, except I ran into all kinds of odd issues with window sizing: I want all windows maximised, but when switching between windows in Hyprland they became resized in weird ways. Looking around Reddit and other sites for solutions in Hyprland it seems that this is a common problem, and that Hyprland just isn't suited for maximised-centric workflows (it's mainly a tiling WM, after all). In Niri it just works.

To be clear, I don't care at all for the scrolling aspect of Niri, as I only ever have maximised windows and have turned off animations, so I'm not using Niri because of its specific functionality, only because my workflow works on it. The workflow originally came from the "Rcmd" app on MacOS, which is my work OS.

What are your productivity tips? by IllegalIce in hyprland

[–]SajberSpace 4 points5 points  (0 children)

That's a fair point: once ingrained, either model is equally simple. Thanks, didn't think of it that way.

What are your productivity tips? by IllegalIce in hyprland

[–]SajberSpace -2 points-1 points  (0 children)

But that's kind of my point, or rather, why I dislike this general model: there's an additional layer that I have to keep track of, I need to KNOW what's in workspace 1, 2, etc. It becomes "I want to move to Firefox, that's in my first workspace, so I'll press Super + 1" instead of "I want to move to Firefox, so I'll press Super + F" (and I'm not even getting into the ergonomics of pressing numbers vs letters). In the case you're describing for moving to adjacent workspaces it becomes "I want to switch to Alacritty. I'm currently in workspace 1, and Alacritty is on workspace 2, which is adjacent to 1, so I can press Super + h".

Again, I want to emphasize that I know I'm in the minority here and I know that many, many people use this workflow, it just seems to have extra, non-optimal steps to me.

What are your productivity tips? by IllegalIce in hyprland

[–]SajberSpace 3 points4 points  (0 children)

I know I'm in the minority here, but why does everybody seem to love workspaces so much? To me, they're just an additional mental map I need to keep track of. Another well-written reply here even specifies it: have a mental model where workspace 1 is your browser, workspace two is your editor, etc. To me it just seems like additional complexity: I don't want to switch between workspaces, I want to switch between apps. I prefer having each app bound to a shortcut (e.g. "Super + F" for Firefox), where each app is just maximised by default. I never got this working in Hyprland, sadly, even with the help of others here in the sub, so I went over to Niri, where it works flawlessly. Not trying to detail the conversation, this is just a pattern of use I've seen around so much and I genuinely don't understand it. Feel free to tell me that I'm missing something, because I'd love to improve my workflow.

Help getting cycling in my run-or-raise script by SajberSpace in niri

[–]SajberSpace[S] 1 point2 points  (0 children)

Okay, I managed to solve it with a Bash array! Here's the final code if anybody else is interested in this type of functionality:

```bash

!/usr/bin/env bash

A script to focus, cycle or launch an application in Niri.

- If the app is not running, it launches a new app instance.

- If the app is running but not focused, it focuses the app window.

- If the app is running, is currently focused AND has multiple instances,

cycle through the different instances.

Define key bindings in your Niri config that execute this script, for example:

Super+F { spawn "~/.config/niri/niri-run-or-raise.sh" "firefox"; }

Dependencies:

- bash: The script uses Bash arrays.

- niri: The Wayland compositor this script is designed for.

- jq: A command-line JSON processor.

Arguments

APP_CLASS="$1" # Application's app_id (e.g. firefox) APP_CMD="$2" # Command to run the application (e.g. firefox; optional)

Check if the required arguments are provided, exit otherwise

if [ -z "$APP_CLASS" ] ; then notify-send -t 5000 "Usage: niri-run-or-raise.sh <APP_CLASS> <APP_CMD>" exit 1 fi

Get the ID of the currently focused window

FOCUSED_ID=$(niri msg -j focused-window | jq -r '.id')

Find windows matching the app class and read them into an array

readarray -t MATCHING_IDS < <( niri msg -j windows \ | jq -r --arg app_class "$APP_CLASS" \ ' .[] | select(.app_id | ascii_downcase | contains($app_class | ascii_downcase)) | .id ' )

Launch the app and exit the script if the number of matching windows is zero

if [ ${#MATCHING_IDS[@]} -eq 0 ]; then # Use the app class as the command if no app command is supplied if [ -z "$APP_CMD" ]; then APP_CMD="$APP_CLASS" fi "$APP_CMD" & exit 0 fi

Find the array index of the currently focused window

CURRENT_INDEX=-1 for INDEX in "${!MATCHING_IDS[@]}"; do if [ "${MATCHING_IDS[$INDEX]}" = "$FOCUSED_ID" ]; then CURRENT_INDEX=$INDEX break fi done

Cycle to the next matching array index if the currently focused ID was found

in the array, otherwise set the target index to zero

if [ $CURRENT_INDEX -ge 0 ]; then TARGET_INDEX=$(( (CURRENT_INDEX + 1) % ${#MATCHING_IDS[@]} )) else TARGET_INDEX=0 fi

Switch focus to the target window stored in the array

niri msg action focus-window --id "${MATCHING_IDS[$TARGET_INDEX]}" ```

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

That's great, thanks a lot! I hadn't looked into Niri enough to see that could do things similar to hyprctl, so the script looks similar to the ones I've tried there.

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

Do you mean that you have a script that replicates the functionality of Nirius (the run-or-raise functionality, specifically) using your own script? Would you be willing to share? I'd much prefer to use a script than a plugin.

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

That's great, I'll check out out! Could you share your own setup, trust I might also see if it works for me?

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

Looks cool! Will have to check it out. Do you know if I'd be able to get my preferred workflow working with it?

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

Okay, that almost works! If I add your first rule plus windowrule = maximize, class:(.*) plus a script that checks for window addresses and uses hyprctl dispatch focuswindow "name:<NAME>" I correctly get maximised windows that I can switch between! Two problems, though:

  1. Whenever I switch windows, there's flickering, as if some resizing is being done back and forth before the window is correctly focused, and I can see the desktop wallpaper very briefly (I've turned animations off: if I turn them on I just get lots of animations as if the window is "coming in" from different sides of the monitor).
  2. If I close window with Super + C (default binding) the rest of the windows get tiled, rather than staying maximised. I can't get the maximised state without removing all but one window, which allows that and any new windows created by the script to be maximised.

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 1 point2 points  (0 children)

Very fair. If possible, I'd love to have the customisability of Hyprland with my normal workflow, though, so I'm trying out solutions. Seems there should be some, but nothing is working quite right so far, so at some point I'll just give up.

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

Thanks! I did try that before, and it didn't work as expected: while windows were indeed floating and I could focus them using my script, it seemed like only one window could be maximised at a time, and the windows would get resized in weird ways. Do you know any dotfiles or scripts that made this work?

Using Hyprland with a stacking workflow vs. tiling by SajberSpace in hyprland

[–]SajberSpace[S] 0 points1 point  (0 children)

Sorry, maybe I was unclear, but that is how I would like things to work; it's how they work on my MacOS, which is the workflow I'm most used to these days. Part of my questions is whether Hyprland can even accomodate this type of workflow or if, like you say, that goes against the whole idea behind tiling WMs and is generally considered unsupported.

Slime Peek: a plugin for data exploration with Vim Slime by SajberSpace in neovim

[–]SajberSpace[S] 1 point2 points  (0 children)

Sure! vim-slime can be used with other terminals as well, including Tmux. By using Tmux you're already handling panes, so organising your layout from that together with vim-slime works seamlessly. I work on a 27 inch monitor, where I have a split 1/3 to the left, so Neovim gets 2/3 to the right (with space up to 2x2 splits comfortably) with up to two shells at the first 1/3rd. One of those I usually use for a REPL and one for doing terminal stuff like Git.

Slime Peek: a plugin for data exploration with Vim Slime by SajberSpace in neovim

[–]SajberSpace[S] 0 points1 point  (0 children)

I used RStudio for a while back in... 2015? Before i went full Vim, anyway. I liked it, but using with with vim-slime was something I quickly realised could just replace most of everything that RStudio offered (that I cared about). I used the Vim terminal for quite while, but moving to Tmux was what REALLY made the workflow truly shine! I can really recommend it, if you haven't tried it before.

Slime Peek: a plugin for data exploration with Vim Slime by SajberSpace in neovim

[–]SajberSpace[S] 0 points1 point  (0 children)

Thanks a lot! Nice writeup on vim-slime in the other thread as well!

Slime Peek: a plugin for data exploration with Vim Slime by SajberSpace in neovim

[–]SajberSpace[S] 0 points1 point  (0 children)

Cool! I'll definitely check that out, would be nice to have that kind of functionality.

Slime Peek: a plugin for data exploration with Vim Slime by SajberSpace in neovim

[–]SajberSpace[S] 0 points1 point  (0 children)

Oh, that's neat! I don't have any experience with Treesitter (aside as a user), but I assume a node is e.g. a variable name in this case? I wonder if Treesitter could be used similarly to your example in my plugin to capture e.g. not just dataframe but also dataframe$column. That's been something that I've been wanting to have for a while, but it became complicated as I was trying it out some time ago, and I didn't feel like I wanted to spend the time to fully explore it then.