[Update] add keymappings examples & add lua version commands

pull/89/head
The Mist 2024-04-23 00:18:45 +08:00 committed by GitHub
parent ac73f9e543
commit 2ff1247b2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 0 deletions

View File

@ -85,6 +85,24 @@ sudo dnf install libuv libuv-devel # On RHEL based systems
sudo apt-get install libtool libuv1-dev # On Debian based systems sudo apt-get install libtool libuv1-dev # On Debian based systems
``` ```
### Keymappings
If you use `Lazy.nvim` as your package manager, here are some examples show you how to configure keymappings for CodeSnap:
```lua
{
"mistricky/codesnap.nvim",
build = "make build_generator",
keys = {
{ "<leader>cc", "<cmd>CodeSnap<cr>", mode = "x", desc = "Save selected code snapshot into clipboard" },
{ "<leader>cs", "<cmd>CodeSnapSave<cr>", mode = "x", desc = "Save selected code snapshot in ~/Pictures" },
},
opts = {
save_path = "~/Pictures",
has_breadcrumbs = true,
bg_theme = "bamboo",
},
}
```
## Usage ## Usage
`CodeSnap.nvim` provides the following two ways to take snapshots of currently selected code `CodeSnap.nvim` provides the following two ways to take snapshots of currently selected code
@ -236,6 +254,16 @@ CodeSnap # Take a snapshot of the currently selected code and copy the snapshot
CodeSnapSave # Save the snapshot of the currently selected code and save it on the disk CodeSnapSave # Save the snapshot of the currently selected code and save it on the disk
``` ```
**Lua**
```lua
local codesnap <const> = require("codesnap")
-- Take a snapshot of the currently selected code and copy the snapshot into the clipboard
codesnap.copy_into_clipboard()
-- Save the snapshot of the currently selected code and save it on the disk
codesnap.save_snapshot()
```
## Configuration ## Configuration
Define your custom config using `setup` function Define your custom config using `setup` function