Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niuiic/cp-image.nvim
Quickly insert image in neovim
https://github.com/niuiic/cp-image.nvim
neovim plugin
Last synced: 14 days ago
JSON representation
Quickly insert image in neovim
- Host: GitHub
- URL: https://github.com/niuiic/cp-image.nvim
- Owner: niuiic
- License: mit
- Created: 2023-01-05T13:22:18.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-11T04:35:59.000Z (6 months ago)
- Last Synced: 2024-07-31T20:49:55.459Z (3 months ago)
- Topics: neovim, plugin
- Language: Lua
- Homepage:
- Size: 15.6 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - niuiic/cp-image.nvim - Paste image from clipboard and insert the reference code. (Media / Cursorline)
README
# cp-image.nvim
Paste the image from the clipboard and insert the reference code.
[More neovim plugins](https://github.com/niuiic/awesome-neovim-plugins)
## Usage
1. Take a screenshot or copy a image.
2. Run `:PasteImage`.
3. Input full path.
4. Confirm.
5. Done.## Dependencies
- [niuiic/core.nvim](https://github.com/niuiic/core.nvim)
## Config
```lua
require("cp-image").setup(
-- default config
{
-- how to generate the image from clipboard and place it
-- image_type is the suffix of file name
cmd = function(path, image_type)
return string.format("xclip -selection clipboard -t image/%s -o > %s", image_type, path)
end,
---@diagnostic disable-next-line:unused-local
-- text to insert
-- relative_path is relative to the root path of the project
text = function(relative_path, file_name, file_type, full_path)
return string.format("![%s](%s)", file_name, relative_path)
end,
-- default directory path to store image
path = function(project_root)
return project_root
end,
-- used to search root path of the project
-- if .git does not exist, current directory path would be used
root_pattern = ".git",
}
)
```