Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
SnapShot
Browse files Browse the repository at this point in the history
  • Loading branch information
DataEraserC committed Feb 11, 2024
1 parent dbf959a commit dacc463
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 357 deletions.
147 changes: 43 additions & 104 deletions home/common/modules/neovim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ For more details, visit the [AstroNvim website](https://astronvim.com/).

This document outlines neovim's configuration structure and various shortcuts/commands for efficient usage.

## Screenshots

![](/_img/astronvim_2023-07-13_00-39.webp)
![](/_img/hyprland_2023-07-29_2.webp)

## Configuration Structure

| Description | Standard Location | My Location |
Expand All @@ -28,32 +33,23 @@ Remove all unused plugins:
:Lazy clean
```

## Screenshots

![](/_img/astronvim_2023-07-13_00-39.webp)
![](/_img/hyprland_2023-07-29_2.webp)
## Testing

## Terminal Related
> via `Justfile` located at the root of this repo.
I used to use Neovim's terminal related shortcuts frequently, but now **I switched my daily terminal environment to zellij**,
which provides a more powerful and stable terminal experience, so I don't use neovim's terminal feature anymore.

So here is zellij's terminal shortcuts I use frequently now:
```bash
# testing
just nvim-test

| Action | Zellij's Shortcut |
| ------------------------- | ------------------ |
| Floating Terminal | `Ctrl + <p> + <w>` |
| Horizontal Split Terminal | `Ctrl + <p> + <d>` |
| Vertical Split Terminal | `Ctrl + <p> + <n>` |
# clear test data
just nvim-clear
```

## Visual Modes
## Cheetsheet

| Action | Shortcut |
| ------------------------ | ---------------------------------------- |
| Toggle visual mode | `v` |
| Toggle visual block mode | `<Ctrl> + v` (select a block vertically) |
Here is the cheetsheet related to my Neovim configs. Please read vim's common cheetsheet at [../README.md](../README.md) before reading the following.

## Incremental Selection
### Incremental Selection

Provided by nvim-treesitter.

Expand All @@ -64,7 +60,7 @@ Provided by nvim-treesitter.
| scope incremental | `<Alt-Space>` |
| node decremental | `Backspace` |

## Search and Jump
### Search and Jump

Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligent search and jump plugin.

Expand All @@ -76,61 +72,34 @@ Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligen
| Treesitter Search | `yR`,`dR`, `cR`, `vR`, `ctrl+v+R`(arround your matches, all the surrounding Treesitter nodes will be labeled) |
| Remote Flash | `yr`, `dr`, `cr`, (arround your matches, all the surrounding Treesitter nodes will be labeled) |

## Text Manipulation

- Add at the end of multiple lines: `:normal A<text>`

- Execublock: `:A<text>`

- visual block mode(ctrl + v)
- Append text at the end of each line in the selected block
- If position exceeds line end, neovim adds spaces automatically

- Delete the last char of multivle lines: `:normal $x`

- Execute `$x` on each line
- visual mode(v)
- `$` moves cursor to the end of line
- `x` deletes the character under the cursor

- Delete the last word of multiple lines: `:normal $bD`
- Execute `$bD` on each line
- visual mode(v)
- `$` moves cursor to the end of line
- `b` moves cursor to the beginning of the last word
- `D` deletes from cursor to the end of line

## Commands & Shortcuts
### Commands & Shortcuts

| Action | Shortcut |
| ----------------------------- | -------------- |
| Learn Neovim's Basics | `:Tutor` |
| Open file explorer | `<Space> + e` |
| Focus Neotree to current file | `<Space> + o` |
| Toggle line wrap | `<Space> + uw` |
| Show line diagnostics | `gl` |
| Show function/variable info | `K` |
| Go to definition | `gd` |
| References of a symbol | `gr` |

## Window Navigation
### Window Navigation

- Switch between windows: `<Ctrl> + h/j/k/l`
- Resize windows: `<Ctrl> + Up/Down/Left/Right`
- Note: On macOS, conflicts with system shortcuts
- Disable in System Preferences -> Keyboard -> Shortcuts -> Mission Control

## Splitting and Buffers
### Splitting and Buffers

| Action | Shortcut |
|
| Action | Shortcut |
| --------------------- | ------------- |
| Horizontal Split | `\` |
| Vertical Split | `\|` |
| Next Buffer (Tab) | `]b` |
| Previous Buffer (Tab) | `[b` |
| Close Buffer | `<Space> + c` |
| Horizontal Split | `\` |
| Vertical Split | `\|` |
| Close Buffer | `<Space> + c` |

## Editing and Formatting
### Editing and Formatting

| Action | Shortcut |
| ----------------------------------------------------- | -------------- |
Expand All @@ -144,7 +113,7 @@ Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligen
| Find files by name (fzf) | `<Space> + ff` |
| Grep string in files (ripgrep) | `<Space> + fw` |

## Sessions
### Sessions

| Action | Shortcut |
| ------------------------------ | -------------- |
Expand All @@ -154,43 +123,24 @@ Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligen
| Search Session | `<Space> + Sf` |
| Load Current Directory Session | `<Space> + S.` |

## Debugging
### Debugging

Press `<Space> + D` to view available bindings and options.

## Find and Replace

| Action | Command |
| ------------------------ | ----------------------------------- |
| Replace in selected area | `:s/old/new/g` |
| Replace in current line | Same as above |
| Replace in whole file | `:% s/old/new/g` |
| Replace with regex | `:% s@\vhttp://(\w+)@https://\1@gc` |

1. `\v` means means that in the regex pattern after it can be used without backslash escaping(similar to python's raw string).
2. `\1` means the first matched group in the pattern.

## Replace in the specific lines

| Action | Command |
| ----------------------------------------- | -------------------------------------- |
| From the 10th line to the end of the file | `:10,$ s/old/new/g` or `:10,$ s@^@#@g` |
| From the 10th line to the 20th line | `:10,20 s/old/new/g` |

The postfix(flags) in the above commands:

1. `g` means replace all the matched strings in the current line/file.
2. `c` means ask for confirmation before replacing.
3. `i` means ignore case.

## Search and Replace Globally
### Search and Replace Globally

| Description | Shortcut |
| ------------------------------------------------------------ | ---------------------------------------------------------------- |
| Open spectre.nvim search and replace panel | `<Space> + ss` |
| Search and replace in command line(need install `sad` first) | `find -name "*.nix" \| sad '<pattern>' '<replacement>' \| delta` |

## Surrounding Characters
Search and replace via cli(fd + sad + delta):

```bash
fd "\\.nix$" . | sad '<pattern>' '<replacement>' | delta
```


### Surrounding Characters

Provided by mini.surround plugin.

Expand All @@ -203,30 +153,19 @@ Provided by mini.surround plugin.
| Replace surrounding characters | `gzr'"` | Replace `'` by `"` around the word under cursor |
| Highlight surrounding | `gzh'` | Highlight `'` around the word under cursor |

## Text Manipulation
### Text Manipulation

| Action | |
| -------------------------------------- | ------------- |
| Join Selection of Lines With Space | `:join` |
| Join without spaces | `:join!` |
| Join with LSP intelligence(treesj) | `<Space> + j` |
| Split Line into Multiple Lines(treesj) | `<Space> + s` |

## Convert Text Case

| Action | |
| -------------------- | --- |
| Toggle text's case | `~` |
| Convert to uppercase | `U` |
| Convert to lowercase | `u` |

## Miscellaneous
### Miscellaneous

| Action | |
| ---------------------------- | -------------------------------------------- |
| Save selected text to a file | `:w filename` (Will show `:'<,'>w filename`) |
| Show all Yank History | `:<Space> + yh` |
| Show undo history | `:<Space> + uh` |
| Action | |
| --------------------- | --------------- |
| Show all Yank History | `:<Space> + yh` |
| Show undo history | `:<Space> + uh` |

## Additional Resources

Expand Down
2 changes: 2 additions & 0 deletions home/common/modules/neovim/astronvim_user/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.clj-kondo/
.nrepl-port
1 change: 1 addition & 0 deletions home/common/modules/neovim/astronvim_user/.nfnl.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:source-file-patterns ["*.fnl" "**/*.fnl"]}
7 changes: 7 additions & 0 deletions home/common/modules/neovim/astronvim_user/.stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
collapse_simple_statement = "Always"
Loading

0 comments on commit dacc463

Please sign in to comment.