From 1ab08427800b9a2da826a16b585529d056cbea3e Mon Sep 17 00:00:00 2001 From: lazaralex98 Date: Fri, 19 Jul 2024 19:22:55 +0300 Subject: [PATCH] document how to use stdin in nvim --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f40c3eb..57332a5 100644 --- a/README.md +++ b/README.md @@ -143,8 +143,21 @@ vim.api.nvim_exec([[ ]], false) ``` -You should also be able to configure it with input from stdin and output to stdout using the `--stdin` flag, -but I'm too much of a nvim noob to figure out how to configure it. +### Nvim with --stdin + +You can also use stdin/stdout mode for nvim. This is an example of `init.lua`. + +```lua +-- Create an augroup for tcsort +local tcsort_group = vim.api.nvim_create_augroup("tcsort", { clear = true }) + +-- Create an autocmd for BufWritePre event +vim.api.nvim_create_autocmd("BufWritePre", { + group = tcsort_group, + pattern = "*.templ", + command = "silent! %!tcsort --stdin", +}) +``` ## Contributing