Giter Site home page Giter Site logo

vitality.vim's Introduction

Vitality

(Vit)ality is a plugin that makes (V)im play nicely with (i)Term 2 and (t)mux.

Features

Vitality restores the FocusLost and FocusGained autocommand functionality. Now Vim can save when iTerm 2 loses focus, even if it's inside tmux!

It also handles switching the cursor to a bar shaped one when in insert mode, and restoring it when not.

Pull requests for other helpful behavior are welcome.

Installation and Usage

Use Pathogen to install.

You shouldn't need to do anything else, but you can read :help vitality if you're curious.

Note on later versions of tmux (1.9.x or higher)

If you find that FocusLost events are not working in later versions of tmux try adding the following line to your .tmux.conf.

set -g focus-events on

Don't forget to restart all your tmux sessions for this setting to take effect (or just run the command in tmux itself to avoid having to restart).

License

MIT/X11

vitality.vim's People

Contributors

aaronjensen avatar dmedvinsky avatar gee-forr avatar jtmkrueger avatar lnikkila avatar sjl avatar tangledhelix avatar thaerkh avatar xsimov 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  avatar  avatar  avatar  avatar

vitality.vim's Issues

Cursor fix not working with tmux in iTerm 2 in Vim

Steps to repro:

  1. Open iTerm 2
  2. run tmux
  3. run vim
  4. Enter vim's Insert mode.

Expect:

Bar cursor

Actual:

Block cursor

I am running everything locally on my Mac. I'm not ssh'd into any servers.

Running iTerm 2 Build 1.0.0.20130624 with Tmux 1.8 and vim 7.3:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 20 2013 10:10:22)
MacOS X (unix) version
Included patches: 1-976

:echo g:vitality_fix_cursor == 1

Issue changing tabs in iTerm

When changing tabs in iTerm with the hot keys, I see escape sequences printed into the vim window. ^]]0 and ^]]I, I believe. Since I'm currently using vitality just to fix the cursor, I just changed enable_focus_reporting and disable_focus_reporting to "" in a fork.

I'm using xterm-256color for my terminal, if that makes a difference. I saw that there was a TODO in the code, "Look into how this works with iTerm tabs. Seems a bit wonky."--I'm guessing this is related?

insert mode focus lost/gain prints escape sequences

plugin works almost excellent for me. while in normal and visual mode focus lost causes to save of the file with my autocmd statement in my vimrc file.

but when i make focus lost in insert mode and when focus gained again i see [O[I characers printed to the buffer and buffer not saved.

    vnoremap <silent> <f24> <esc>:silent doautocmd FocusLost %<cr>gv
    vnoremap <silent> <f25> <esc>:silent doautocmd FocusGained %<cr>gv

    inoremap <silent> <f24> <c-o>:silent doautocmd FocusLost %<cr>
    inoremap <silent> <f25> <c-o>:silent doautocmd FocusGained %<cr>

visual mode mapping works but insert mode does not. i tried to put for inoremap but no luck.

"No matching autocommands" error

I see this error on gained-focus. No saving occurs when I lose focus. I'm running on mac with iTerm2, and I'm not running tmux. I have not modified the vitality package.

^[[O and ^[[I being sent to active tmux window, even if not the one with vim running

Say I have 2 tmux windows (0:0 and 0:1) and vim is running in one of them (0:0). I have focused the window that does not have vim running (0:1). If i leave iterm2 the escape sequence ^[[O is sent to window 0:1 and causes a newline to appear after the prompt and rings a bell in iterm2. returning focus to iterm2 also sends the escape sequence ^[[I but no visual disturbance occurs.

Cursor Visual Movement During Replace

I recently switched to using tmux inside iTerm2, and I installed vitality.vim because it was a recommended plugin for this particular trifecta of software. I recently noticed some oddness though- past a certain column, whenever I would hit r to replace a single character, the cursor would visually jump backwards a good bit. It wouldn't affect the replacement but it was still visually jarring. It would jump back even further if I hit ESC instead of doing the replacement. Once again, the cursor didn't actually move, but since I was now in normal mode it was even more off-putting.

(Col 13) r : Cursor changes and stays in place
(Col 14+) r: Cursor changes and visually moves back ~13 columns.

There are two workarounds that I've found:

  • set showcmd - No idea why this works, but my coworker and I worked through his .vimrc to figure out why his didn't exhibit the same behavior. This was the line that fixed it for him.
  • let g:vitality_fix_cursor = 0 - Works as well, though if I want an insert bar it's not a practical solution.

set showcmd works for me in the meantime- just wanted to give you a heads up.

vim - 7.3.462 (same issue with 7.3 and 7.3.333)
tmux - 1.6
iTerm2 - 1.0.0.20120203

FocusGained and FocusLost have stopped working

macOS v10.14.5
iTerm2 v3.3.3
Vim v8.1.1950
Vitality 0f693bf

I recently noticed that FocusGained and FocusLost events don’t seem to be firing. I’m not sure which tool or version caused the breakage. I do know that these events were correctly firing six months ago.

FocusLost not working

I've installed vitality.vim and I can see that it's working as far as the cursor bar is concerned. However the file is not saved when I switch away from my iTerm.

Am I doing something wrong?

Need new entries for :terminal mode

I've been using vim's terminal mode a bit lately and noticed it wasn't getting focus events. Adding these lines fixed it:

    tnoremap <silent> <f24> <c-w>:silent doautocmd FocusLost %<cr>
    tnoremap <silent> <f25> <c-w>:silent doautocmd FocusGained %<cr>

Thanks for the plugin, I love it!

feature request: do FocusLost on tmux pane/window change

This would be fantastic... the dream of autosave fully realised.

I get the impression this is possible (and without requiring entering something in the shell, like https://github.com/pivotal/tmux-config requires), since tmux knows when it switches and it should be possible to attach some extra code at that point (possibly by remapping the original keys to a wrapper function).

For now my workaround is to put things that I want to autosave between in two different iTerm2 windows, and switch between them using the regular OSX shortcut (C-Tilde). Would really be nice to do within one window though.

If I get around to this myself I'll be sure to share it back here.

Support for 'tmux popup'?

Newer versions of tmux introduced popup windows, so it would be great if vitality.vim could handle those, too (like, produce FocusLost if a tmux popup appears, and produce FocusGained when coming back from popup to a tmux pane with Vim).

Lag changing cursor shape

When I enter insert mode, the cursor changes from a block to a bar instantly. But when I return to command mode, it takes a full second for the cursor to change from a bar back into a block.

I'm using iTerm 1.0.0.20140421 on OS X 10.9.2.

Terminal.app

Is there no way to get this awesome plugin working for Terminal.app?

tmux 2.8

Something's happening with vitality.vim under the new tmux v.2.8 -- it seems like some key sequence is being sent to Vim on FocusGain.

The trigger was indeed the upgrade to tmux 2.8 (and this may be related somehow). However, it's exactly vitality.vim, which is affected because switching from vitality to tmux-plugins/vim-tmux-focus-events makes this issue to go away.

Cursor state is messed up when using tmux to switch pane away while in insert mode

If I'm not using FocusLost to stopinsert and I click out of the pane, the cursor isnt being reset to block.

Curiously enough, then when using tmux to switch back to the pane that has the Vim, it will flicker to block, then flicker back to line.

The evidence that I have which indicates this is a vitality problem is that if I actually do this: au FocusLost * stopinsert then the problem goes away! (Click outside of vim while in insert mode, and the cursor properly gets returned to normal).

So I think something is causing vitality to set the cursor back to line when switching out to another tmux pane because it thinks it should be a line because the Vim is still in insert mode.

Modeline is reprocessed on FocusLost/FocusGained

doautocmd re-processes the modeline by default, which annoying things like reset fold level or change other options. I suggest adding <nomodeline> to the doautocmd calls either by default or as an option.

Avoid Bar

Love the plugin! Any way to avoid turning the cursor into a bar?

Idea: support VTE

It'd be great if vitality.vim could support VTE, a terminal widget library that is used a lot in the Linux world.

Just a suggestion.

some vim movements cause strange content shift

one poignant example is doing 'cw'

seems to only effect buffers that represent a file. i can't duplicate this in unnamed buffers (makes sense as there is nothing to autosave, perhaps?)

I'll use JSON.pm (v2.53) as an example:

Starting state (cursor position represented as [X]):

use base qw(Exporter);
@[J]SON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);                                                                                                                                                            

BEGIN {

do a 'cw' to change the word "JSON", i end up in this state:

use base qw(Exporter);
@JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);                                                                                                                                                            
[@]::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);    
BEGIN {

interestingly, if I move around (i.e. PgDn then PgUp) everything appears normal.

also, the behavior does not happen if I defocus/refocus iterm2 prior to the 'cw' command but after opening the file.

at all times, defocusing iterm2 gives the following in the status line "No matching autocommands"

doesn't work in ssh, iterm2

I connect to a ubuntu server using SSH on my mac, I use iterm2 and the cursor didn't change on my remote shell, works on my mac perfectly though.

FocusGained works with Terminal.app (and tmux)

Hi,
it seems I managed to get FocusGained work by using this plugin and tmux. Steps for this are below and I'm still a bit fuzzy *why* this works.

Tools:

  • OS X 10.10.1, Terminal.app (iTerm will work just fine, but we already knew it works)
  • tmux 1.9a
  • terminal vim (neovim works too)

How to enable FocusGained for terminal vim with the above tools:

  • make sure tmux has the focus-events option on: tmux set -g focus-events on
  • install the vitality.vim plugin
  • set this option: let g:vitality_always_assume_iterm = 1

That's it! FocusGained should now work. I've tested it with vim by setting the following autocommand:

au FocusGained * echom 'focus gained!'

A couple observations:

  • FocusLost does not work for some reason
  • this does not work outside tmux (plain Terminal.app + vim)

If this plugin is still maintained, do you think we could add these instructions somewhere (wiki maybe) so people know this is possible? Also, how about enabling the plugin when vim is running inside tmux so that let g:vitality_always_assume_iterm = 1 is not required?

Cursor fix just plain not working

I get no change in the cursor when I install Vitality. I even went to this extent to test it without my config being in the way:

mv .vimrc .vimrc.old
mv .vim .vim.old
mkdir .vim ; cd .vim
git clone https://github.com/sjl/vitality.vim
mv vitality.vim/{doc,plugin} .
rm -rf vitality.vim

And... nothing. So it's presumably not something in my Vim config, which I temporarily erased… any ideas? I am not spotting any problems in Vitality, and I know the cursor can work (outside tmux) because my configs change the cursor.

Note: Vitality is not fixing the cursor for me even without tmux in use.

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.