GithubHelp home page GithubHelp logo

animate.vim's Introduction

 █████╗ ███╗   ██╗██╗███╗   ███╗ █████╗ ████████╗███████╗  ██╗   ██╗██╗███╗   ███╗
██╔══██╗████╗  ██║██║████╗ ████║██╔══██╗╚══██╔══╝██╔════╝  ██║   ██║██║████╗ ████║
███████║██╔██╗ ██║██║██╔████╔██║███████║   ██║   █████╗    ██║   ██║██║██╔████╔██║
██╔══██║██║╚██╗██║██║██║╚██╔╝██║██╔══██║   ██║   ██╔══╝    ╚██╗ ██╔╝██║██║╚██╔╝██║
██║  ██║██║ ╚████║██║██║ ╚═╝ ██║██║  ██║   ██║   ███████╗██╗╚████╔╝ ██║██║ ╚═╝ ██║
╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝ ╚═══╝  ╚═╝╚═╝     ╚═╝

Animate.vim

A Vim Window Animation Library

Animate.vim is a general window animation library for Vim, it provides the ability to animate window height and width via:

  • delta from current size
  • percent of screen
  • absolute size

Installation

To install Animate.vim, use your plugin manager of choice, e.g:

Plug 'camspiers/animate.vim'

Usage

Given the general purpose nature of resizing windows Animate.vim can be used in many contexts.

The following gives and example of using animate to more smoothly change window size using the directional keys:

Example: Animated Directional Keys

nnoremap <silent> <Up>    :call animate#window_delta_height(10)<CR>
nnoremap <silent> <Down>  :call animate#window_delta_height(-10)<CR>
nnoremap <silent> <Left>  :call animate#window_delta_width(10)<CR>
nnoremap <silent> <Right> :call animate#window_delta_width(-10)<CR>

Animate-Resize

Example: Animated FZF Bottom Drawer

Here is an example that integrates Animate.vim with Fuzzy Finder (FZF) to animate its opening:

let g:fzf_layout = {
 \ 'window': 'new | wincmd J | resize 1 | call animate#window_percent_height(0.5)'
\ }

Animate-FZF

Example: Animated Neovim Terminal Drawers

function! OpenAnimatedHtop() abort
  " Open a htop in terminal
  new term://htop
  " Send window to bottom and start with small height
  wincmd J | resize 1
  " Animate height to 66%
  call animate#window_percent_height(0.66)
endfunction

Animate-Htop

Animate-LazyGit

Options

Distribute Space

By default Animate.vim distributes space of non-animating windows while resizing this can be destructive to intended window sizes when those sizes aren't fixed. To disable:

let g:animate#distribute_space = 0

Duration

Animation duration in milliseconds can be controlled via a global flag:

let g:animate#duration = 300.0

Easing

Animation easing can be controlled via a global flag:

let g:animate#easing_func = 'animate#ease_linear'

Easing Options

Currently there are 3 easing options available:

  • animate#ease_linear
  • animate#ease_out_quad
  • animate#ease_out_cubic
  • animate#ease_in_out_sine (default)

To set a custom easing function:

let g:animate#easing_func = 'animate#ease_out_cubic'

You can also set your own easing function using the following signature:

function! MyEasingFunction(elapsed, initial, delta, duration) abort
  " return value
endfunction

let g:animate#easing_func = 'MyEasingFunction'

API

Delta Functions

Animate current window by delta:

animate#window_delta(width_delta, height_delta)

Animate current window by width delta:

animate#window_delta_width(delta)

Animate current window by height delta:

animate#window_delta_height(delta)

Percent Functions

Animate current window by percent of screen:

animate#window_percent(width_percent, height_percent)

Animate current window by percent of screen width:

animate#window_percent_width(percent)

Animate current window by percent of screen height:

animate#window_percent_height(percent)

Absolute Functions

Animate current window to absolute size:

animate#window_absolute(width, height)

Animate current window by absolute width:

animate#window_absolute_width(width)

Animate current window by absolute height:

animate#window_absolute_height(height)

Helper Functions

Focus window:

function! animate#window_focus(target_window) abort

Determines with target window is animating:

function! animate#window_is_animating(target_window) abort

Get the current time as a float in milliseconds:

animate#time()

Get the available height factoring in cmdheight and status line:

animate#get_available_height()

Linear easing function:

animate#ease_linear(elapsed, initial, delta, duration)

Out quad easing function:

animate#ease_out_quad(elapsed, initial, delta, duration)

Out cubic easing function:

animate#ease_out_cubic(elapsed, initial, delta, duration)

In out sine easing function:

animate#ease_in_out_sine(elapsed, initial, delta, duration)

animate.vim's People

Contributors

3coma3 avatar camspiers avatar tadaa avatar vimpostor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

animate.vim's Issues

Mouse scrolling now changes window size

Hey, I know that this is blasphemous but if I'm away from my keyboard I do use the mouse for scrolling (only for scrolling, I promise!). Problem is there is some setting that is interfering with that and now mouse scrolling makes the horizontal window go up and down, I would like to disable this.

Invalid in command-line window .... noautocmd windo if ! &winfixwidth | let nowinfixwidths[winnr()] = 1 | set winfixwidth | endif

Hi, when I open the history editing with q: I receive this message:

Invalid in command-line window; executes, CTRL-C quits:
noautocmd windo if ! &winfixwidth | let nowinfixwidths[winnr()] = 1 | set winfixwidth | endif

I've just grepped the string on all my vim configuration and found it on:
plugins/animate.vim/plugin/animate.vim:109: noautocmd windo if ! &winfixwidth | let nowinfixwidths[winnr()] = 1 | set winfixwidth | endif

Is this something easily solvable, can others reproduce?

Intercepts movement in vim-fugitive

This is a wonderful addition to my vim setup, but it introduces one subtle annoyance when used with vim-fugitive.

From the vim-fugitive window, I press cc create a new commit. vim-fugitive opens a new buffer for me to populate the git commit message.

Without this plugin (or with g:lens#animate=0), the new buffer is automatically focused.

With this plugin active, the new buffer window opens, but I must manually focus it.

Support for Neovide cursor animations

Hi there!

I was wondering if it would be possible to use the same mechanism (with some modifications) we use here for animating windows to replicate Neovide's GUI-only cursor animations.

I'd love to talk more on this here and contribute towards making this possible, thanks!

Drawer gets stuck open when using suggested fzf command

With NVIM v0.8.0-dev-1039-gf32fd19f1, using:

vim.g.fzf_layout = {
    window = 'new | wincmd J | resize 1 | call animate#window_percent_height(0.5)'
}

in my ~/.vim/init.lua leads to my fzf drawer being stuck open (the "command" window takes up my entire screen).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.