Skip to content

Instantly share code, notes, and snippets.

@tarruda
tarruda / .README.md
Last active September 27, 2021 13:21
Tmux/Vim integration

Some scripts/configurations that greatly improve tmux/vim workflows. The shell scripts target zsh but should be adaptable without much effort for other unix shells.

Features:

  • Transparently move between tmux panes and vim windows
  • Using the shell, open files in one vim instance per project or directory
  • Fully integrated copy/paste between tmux, vim and x11 using simple keybinds(need to install the xclip program)
  • Easily send text to any tmux pane without breaking your edit workflow(needs slimux

'vim-tmux-move.zsh', '.vimrc' and '.tmux.conf' cooperate so you can move transparently between tmux panes and vim windows using ALT + (arrow keys or jkhl). It was based on this gist

@tarruda
tarruda / .ycm_extra_conf.py
Created January 16, 2014 17:48
YouCompleteMe configuration for vim source code (.ycm_extra_conf.py)
# .ycm_extra_conf.py for vim source code. This should work after running './configure
import os, re
def create_flags():
rv = [
'-Wall',
'-Wextra',
'-std=c89',
'-x',
# .ycm_extra_conf.py for vim source code. This should be used after './configure
import os, re, ycm_core
flags = []
compilation_database_folder = './build'
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
@tarruda
tarruda / .bashrc
Last active August 29, 2015 14:00
Shell functions for working with github pull requests
# Start working on a pull request, this requires a .git/user-repo file
# containing the string "user/repository"
pr() {
if [[ ! -r .git/user-repo ]]; then
echo "Need to setup user/repo" >&2
return 1
fi
local user_repo=$(< .git/user-repo)
local pr_num=$1
if [[ -z $pr_num ]]; then
@tarruda
tarruda / nvim_clipboard.py
Last active April 28, 2023 05:39
Neovim clipboard plugin
import xerox
class NvimClipboard(object):
def __init__(self, vim):
self.provides = ['clipboard']
def clipboard_get(self):
return xerox.paste().split('\n')
def clipboard_set(self, lines):
@tarruda
tarruda / autoload_async.vim
Created July 2, 2014 15:38
Implementing support functions neovim asynchronous services
" create this file at autoload/async.vim
let s:next_completion_id = 1
let s:current_completion_id = 0
function! async#CompletionBegin()
let s:current_completion_id = s:next_completion_id
let s:next_completion_id += 1
@tarruda
tarruda / jobcontrol.vim
Created July 9, 2014 10:49
Neovim job control demo
" Demo of Neovim job control feature.
"
" It starts two netcat processes listening on the same TCP port,
" the second process will exit immediately since the port will be
" unavailable(Used to demonstrate the stderr/exit events)
" To play with this, use two terminals
"
" On terminal 1: `nvim -S jobcontrol.vim`.
" Use `:call jobwrite(v:srv1_id, string) to write
" data to the netcat client
@tarruda
tarruda / gist:08e3a5cb5ebade8acc97
Created August 5, 2014 13:55
libuv terminal emulator support
diff --git a/Makefile.am b/Makefile.am
index 861b632..ffdb4c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -103,6 +103,8 @@ libuv_la_SOURCES += src/unix/async.c \
src/unix/tty.c \
src/unix/udp.c
+libuv_la_LDFLAGS += -lutil
+
@tarruda
tarruda / snake.py
Last active June 11, 2021 00:01
snake.py
# Snake for Neovim! Adapted from https://gist.github.com/sanchitgangwar/2158084
# To install, create a ~/.vim/rplugin/python/snake.py file with this
# code, then run `nvim -c 'UpdateRemotePlugins' -c 'q'` from a shell.
#
# Make sure you have read the internal help explaining how to setup python
# host for external plugins(:help nvim-python)
#
# To start a new game, use the `:SnakeStart` command on an empty buffer(uses 80
# columns and 20 rows)
from threading import Thread, Lock
@tarruda
tarruda / nvim_persistence_service.py
Created September 15, 2014 12:23
Nvim persistence service
import sqlite3, msgpack
class NvimPersistenceService(object):
def __init__(self, vim):
self.connection = sqlite3.connect('.nvim-persisted.db')
with self.connection as c:
c.execute('''
CREATE TABLE IF NOT EXISTS nvim
(
key TEXT PRIMARY KEY,