All Projects → martingms → Vipsql

martingms / Vipsql

A vim-frontend for interacting with psql

Projects that are alternatives of or similar to Vipsql

Pg qualstats
A PostgreSQL extension for collecting statistics about predicates, helping find what indices are missing
Stars: ✭ 150 (-6.83%)
Mutual labels:  postgresql
Knests
Full-stack boilerplate (project/hackathon starter) with Docker/NodeJS/Typescript/GraphQL/React/Material-UI
Stars: ✭ 156 (-3.11%)
Mutual labels:  postgresql
Sqorn
A Javascript library for building SQL queries
Stars: ✭ 1,871 (+1062.11%)
Mutual labels:  postgresql
Serendipity
A PHP blog software
Stars: ✭ 151 (-6.21%)
Mutual labels:  postgresql
Taopq
C++ client library for PostgreSQL
Stars: ✭ 153 (-4.97%)
Mutual labels:  postgresql
Ihp
🔥 The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness
Stars: ✭ 2,746 (+1605.59%)
Mutual labels:  postgresql
Libzbxpgsql
Monitor PostgreSQL with Zabbix
Stars: ✭ 150 (-6.83%)
Mutual labels:  postgresql
Targets.vim
Vim plugin that provides additional text objects
Stars: ✭ 2,114 (+1213.04%)
Mutual labels:  vim-plugin
Psql2csv
Run a query in psql and output the result as CSV.
Stars: ✭ 153 (-4.97%)
Mutual labels:  postgresql
Database To Plantuml
Compile PostgreSQL and MySQL table information into a PlantUML description.
Stars: ✭ 157 (-2.48%)
Mutual labels:  postgresql
Jsonschema2db
Generate tables dynamically from a JSON Schema and insert data
Stars: ✭ 152 (-5.59%)
Mutual labels:  postgresql
Web Budget
Sistema web para controle financeiro pessoal ou de pequenas empresas
Stars: ✭ 152 (-5.59%)
Mutual labels:  postgresql
Yuniql
Free and open source schema versioning and database migration made natively with .NET Core.
Stars: ✭ 156 (-3.11%)
Mutual labels:  postgresql
Rust Webapp Starter
Rust single page webapp written in actix-web with vuejs.
Stars: ✭ 151 (-6.21%)
Mutual labels:  postgresql
Nodebb
Node.js based forum software built for the modern web
Stars: ✭ 12,303 (+7541.61%)
Mutual labels:  postgresql
Pos
Stars: ✭ 150 (-6.83%)
Mutual labels:  postgresql
Vimux
easily interact with tmux from vim
Stars: ✭ 1,980 (+1129.81%)
Mutual labels:  vim-plugin
Github Complete.vim
Vim input completion for GitHub
Stars: ✭ 161 (+0%)
Mutual labels:  vim-plugin
Vim Markbar
Display all accessible marks and their surrounding lines in a collapsible sidebar.
Stars: ✭ 159 (-1.24%)
Mutual labels:  vim-plugin
Netflix Clone
Netflix like full-stack application with SPA client and backend implemented in service oriented architecture
Stars: ✭ 156 (-3.11%)
Mutual labels:  postgresql

vipsql

A vim-plugin for interacting with psql

Demo

asciicast demo

Install

With Pathogen

$ cd ~/.vim/bundle && git clone https://github.com/martingms/vipsql

As a terminal command

To use vipsql in a manner similar to psql, add something like this to your .bashrc or similar:

vipsql() {
    vim -c 'setlocal buftype=nofile | setlocal ft=sql | VipsqlOpenSession '"$*"
}

Or, if you'd prefer that every session gets its own tmp-file:

vipsql() {
    vim -c 'setlocal ft=sql | VipsqlOpenSession '"$*" $(mktemp -t vipsql.XXXXX)
}

Or perhaps always using the same file for the same provided args, so you can reuse queries from previous sessions:

vipsql() {
    local dir=${XDG_DATA_HOME:-"$HOME/.local/share"}"/vipsql/"
    local file=$(echo "$*" | tr -dc "[:alpha:]-=")".sql"
    mkdir -p "$dir"
    vim -c 'setlocal ft=sql | VipsqlOpenSession '"$*" "$dir$file"
}

For all of these, args are redirected to the underlying psql session, so e.g.

$ vipsql -d test

will start vim with vipsql already connected to the database test.

Notes

Note that vipsql uses the vim channels feature, so your vim must be at least version 8, and compiled with +channel. To test whether you're compatible, run:

$ vim --version | grep -o +channel

If the output is +channel you should be good to go.

Please also note that sending an interrupt (SIGINT) to psql (for example to cancel a long running query) results in killing the channel in versions of vim older than 8.0.0588 due to a bug.

Neovim should be supported, but I have not had the chance to test it, so please let me know if you are a neovim user and can confirm. One thing that definitely does not work for neovim is to send SIGINT, as there doesn't seem to be any support for sending arbitrary signals through neovim's job api yet.

Configure

Bindings

Put the following in your .vimrc (and customize bindings to your liking):

" Starts an async psql job, prompting for the psql arguments.
" Also opens a scratch buffer where output from psql is directed.
noremap <leader>po :VipsqlOpenSession<CR>

" Terminates psql (happens automatically if the output buffer is closed).
noremap <silent> <leader>pk :VipsqlCloseSession<CR>

" In normal-mode, prompts for input to psql directly.
nnoremap <leader>ps :VipsqlShell<CR>

" In visual-mode, sends the selected text to psql.
vnoremap <leader>ps :VipsqlSendSelection<CR>

" Sends the selected _range_ to psql.
noremap <leader>pr :VipsqlSendRange<CR>

" Sends the current line to psql.
noremap <leader>pl :VipsqlSendCurrentLine<CR>

" Sends the entire current buffer to psql.
noremap <leader>pb :VipsqlSendBuffer<CR>

" Sends `SIGINT` (C-c) to the psql process.
noremap <leader>pc :VipsqlSendInterrupt<CR>

Options

Configuration options (and their defaults) are:

" Which command to run to get psql. Should be simply `psql` for most.
let g:vipsql_psql_cmd = "psql"

" The prompt to show when running `:VipsqlShell`
let g:vipsql_shell_prompt = "> "

" What `vim` command to use when opening the output buffer
let g:vipsql_new_buffer_cmd = "rightbelow split"

" Commands executed after opening the output buffer
" Chain multiple commands together with `|` like so:
" "setlocal buftype=nofile | setlocal nowrap"
let g:vipsql_new_buffer_config = 'setlocal buftype=nofile'

" Whether or not to clear the output buffer on each send.
let g:vipsql_auto_clear_enabled = 0

" Whether or not to print a separator in the output buffer when sending a new
" command/query to psql. Has no effect if g:vipsql_auto_clear_enabled = 1.
let g:vipsql_separator_enabled = 0

" What that separator should look like.
let g:vipsql_separator = '────────────────────'

License

Copyright (c) Martin Gammelsæter. Distributed under the same terms as Vim itself. See :help license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].