Commit 476167c2 authored by Marco Kellershoff's avatar Marco Kellershoff 🤸

Initial import

parents
MIT License
Copyright (c) 2018 Super Evil Mega Co
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Screenshot.nvim
===============
A Vim/Neovim plugin to run take Screenshots of the current window.
It utilizes the [scrot](https://en.wikipedia.org/wiki/Scrot) binary,
so you'd have to make sure that `scrot` is installed.
## Usage
`:Screenshot` to take a screenshot.
The screenshot is placed in `~/Pictures/Screenshot.nvim-YYYYMMDD-HHMMSS.png`.
It also takes into account the existence of
[XDG user directories][xdg_user_dirs].
That means, that if you have set a custom pictures like so:
```
XDG_PICTURES_DIR="$HOME/MyAwesomePictures"
```
It'll write the Screenshots to this directory instead of the default
`$HOME/Pictures`.
[xdg_user_dirs]: https://wiki.archlinux.org/index.php/XDG_user_directories
*Screenshot.txt* A Vim/Neovim plugin to take Screenshots.
Author: Marco Kellershoff <https://gorilla.moe/>
License: MIT License (see |license|)
INTRODUCTION *Screenshot*
This plugin's main purpose is to take a Screenshot of the current window.
It utilizes the [scrot](https://en.wikipedia.org/wiki/Scrot) binary,
so you'd have to make sure that `scrot` is installed.
COMMANDS *Screenshot-commands*
Screenshot *:Screenshot*
Takes a screenshot.
The screenshot is placed in
`$HOME/Pictures/Screenshot.nvim-YYYYMMDD-HHMMSS.png`.
It also takes into account the existence of
XDG user directories.
That means, that if you have set a custom pictures like so:
`XDG_PICTURES_DIR="$HOME/Pictures"`
It'll write the Screenshots to this directory
instead of the default `$HOME/Pictures`.
MAPPINGS *Screenshot-mappings*
There are no mappings registered by the plugin.
You need to map it according to your preference.
ABOUT *Screenshot-about*
Grab the latest version or report a bug:
http://git.superevilmegaco.com/superevilmegaco/Neovim/Screenshot.nvim
vim:tw=78:et:ft=help:norl:
if exists("g:loaded_Screenshot")
finish
endif
let g:loaded_Screenshot = 1
let s:PluginName = "Screenshot.nvim"
function! s:FileExists(filepath)
if filereadable(a:filepath)
return 1
else
return 0
endif
endfunction
function! Screenshot#GetPicturesDir()
if !empty($XDG_PICTURES_DIR)
return "$XDG_PICTURES_DIR"
else
return "$HOME/Pictures/"
endif
endfunction
function! Screenshot#Window()
let dir = Screenshot#GetPicturesDir()
let cmd = 'scrot --focused ' . dir . 'Screenshot.nvim-%Y%m%d_%H%M%S.png'
call s:ExecExternalCommand(cmd)
endfunction
function! s:OnJobEventHandler(job_id, data, event) dict
if a:event == 'stdout'
let str = self.shell.' stdout: '.join(a:data)
elseif a:event == 'stderr'
let str = self.shell.' stderr: '.join(a:data)
else
let str = self.shell.' finished'
endif
echom str
endfunction
let s:jobEventCallbacks = {
\ 'on_stdout': function('s:OnJobEventHandler'),
\ 'on_stderr': function('s:OnJobEventHandler'),
\ 'on_exit': function('s:OnJobEventHandler')
\ }
function! s:ExecExternalCommand(command)
if has("nvim") == 1
call jobstart(["bash", "-c", a:command])
elseif v:version >= 800
call job_start("bash -c " . a:command)
else
silent execute "!" . a:command
endif
endfunction
command! Screenshot call Screenshot#Window()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment