Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Myzel394/easytables.nvim
Easily insert and edit markdown tables using Neovim with a live preview and useful helpers
https://github.com/Myzel394/easytables.nvim
markdown neovim neovim-plugin neovim-plugins nvim nvim-plugin
Last synced: 7 days ago
JSON representation
Easily insert and edit markdown tables using Neovim with a live preview and useful helpers
- Host: GitHub
- URL: https://github.com/Myzel394/easytables.nvim
- Owner: Myzel394
- Created: 2023-10-04T19:40:30.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-07-25T20:30:30.000Z (4 months ago)
- Last Synced: 2024-08-02T06:19:21.271Z (3 months ago)
- Topics: markdown, neovim, neovim-plugin, neovim-plugins, nvim, nvim-plugin
- Language: Lua
- Homepage:
- Size: 413 KB
- Stars: 89
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-neovim - Myzel394/easytables.nvim - Easily insert and edit markdown tables with a live preview and useful helpers. (Programming Languages Support / Markdown and LaTeX)
README
# Easytables
##### Make Markdown tables great again!
[Preview of usage of easytables](https://github.com/Myzel394/easytables.nvim/assets/50424412/d8bcb0c2-9b8b-468a-b1a8-f0032543f1e9)
**Please note that this is a work in progress.**
## Features
- Preview tables in real time
- Add and remove rows and columns
- Move rows and columns
- Move cells## Usage
### Installation
Using [packer](https://github.com/wbthomason/packer.nvim):
```lua
use "Myzel394/easytables.nvim"
```### Tutorial
#### Inserting a new table
Go to the place where you want to insert your table and either call:
* `:EasyTablesCreateNew x` - Creates a new table with `` columns and `` rows
* `:EasyTablesCreateNew ` - Creates a square table with the size of `` (eg. `:EasyTablesCreateNew 5` -> Creates a `5x5` table)
* `:EasyTablesCreateNew x` - Creates a table with `` columns and **one** row
* `:EasyTablesCreateNew x` - Creates a table with **one** column and `` rows#### Editing an existing table
Go to your table (doesn't matter where, can be at a border or inside a cell) and type:
`:EasyTablesImportThisTable`
### Custom Setup
**Make sure to call the `setup` function!**
`after/plugin/easytables.lua`
```lua
require("easytables").setup {
-- Your configuration comes here
}
```#### Default configuration
By default, easytables configures default characters for the table and registers the following keymaps:
- ``: Move cell left (in normal mode, applies to all other directions)
- ``: Swaps cell with cell to the left (in normal mode, applies to all other directions)
- ``: Swaps column with column to the left (in normal mode, applies to all other directions)
- `: Move cell to the next cell (in normal mode, either to the right or to the beginning of the next line)
- ``: Move cell to the previous cell (in normal mode, either to the left or to the end of the previous line)This is the default configuration:
```lua
{
table = {
-- Whether to enable the header by default
header_enabled_by_default = true,
window = {
preview_title = "Table Preview",
prompt_title = "Cell content",
-- Either "auto" to automatically size the window, or a string
-- in the format of "x" (e.g. "20x10")
size = "auto"
},
cell = {
-- Min width of a cell (excluding padding)
min_width = 3,
-- Filler character for empty cells
filler = " ",
align = "left",
},
-- Characters used to draw the table
-- Do not worry about multibyte characters, they are handled correctly
border = {
top_left = "┌",
top_right = "┐",
bottom_left = "└",
bottom_right = "┘",
horizontal = "─",
vertical = "│",
left_t = "├",
right_t = "┤",
top_t = "┬",
bottom_t = "┴",
cross = "┼",
header_left_t = "╞",
header_right_t = "╡",
header_bottom_t = "╧",
header_cross = "╪",
header_horizontal = "═",
}
},
export = {
markdown = {
-- Padding around the cell content, applied BOTH left AND right
-- E.g: padding = 1, content = "foo" -> " foo "
padding = 1,
-- What markdown characters are used for the export, you probably
-- don't want to change these
characters = {
horizontal = "-",
vertical = "|",
-- Filler for padding
filler = " "
}
}
},
set_mappings = function(buf)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":JumpLeft",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithLeftCell",
{}
)vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":JumpRight",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithRightCell",
{}
)vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":JumpUp",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithUpperCell",
{}
)vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":JumpDown",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithLowerCell",
{}
)vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":JumpToNextCell",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":JumpToPreviousCell",
{}
)vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithLeftColumn",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithRightColumn",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithUpperRow",
{}
)
vim.api.nvim_buf_set_keymap(
buf,
"n",
"",
":SwapWithLowerRow",
{}
)
end}
```## Limitations
* This plugin currently does not work well with big tables
## This project is stupid, the code is awful, go away
I know that the code is probably not the best, it's my first ever written neovim plugin.
You are more than welcome to contribute to this project, I will gladly accept any help.## Donate
It might sound crazy, but if you would just donate 1$, it would totally mean to world to me, since
it's a really small amount and if everyone did that, I can totally focus on easytables and my other open
source projects. :)You can donate via:
- [GitHub Sponsors](https://github.com/sponsors/Myzel394)
- Bitcoin: `bc1qw054829yj8e2u8glxnfcg3w22dkek577mjt5x6`
- Monero: `83dm5wyuckG4aPbuMREHCEgLNwVn5i7963SKBhECaA7Ueb7DKBTy639R3QfMtb3DsFHMp8u6WGiCFgbdRDBBcz5sLduUtm8`