Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/notomo/cmdbuf.nvim
Alternative command-line window plugin for neovim
https://github.com/notomo/cmdbuf.nvim
neovim neovim-plugin
Last synced: 14 days ago
JSON representation
Alternative command-line window plugin for neovim
- Host: GitHub
- URL: https://github.com/notomo/cmdbuf.nvim
- Owner: notomo
- License: mit
- Created: 2021-01-30T10:31:08.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T23:34:50.000Z (18 days ago)
- Last Synced: 2024-10-22T20:35:26.064Z (17 days ago)
- Topics: neovim, neovim-plugin
- Language: Lua
- Homepage:
- Size: 144 KB
- Stars: 115
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - notomo/cmdbuf.nvim - Alternative command-line-window plugin. (Command Line / Indent)
README
# cmdbuf.nvim
[![ci](https://github.com/notomo/cmdbuf.nvim/workflows/ci/badge.svg?branch=main)](https://github.com/notomo/cmdbuf.nvim/actions?query=workflow%3Aci+branch%3Amain)
The builtin command-line window is a special window.
For example, you cannot leave it by `wincmd`.
This plugin provides command-line window functions by normal buffer and window.## Example
```lua
vim.keymap.set("n", "q:", function()
require("cmdbuf").split_open(vim.o.cmdwinheight)
end)
vim.keymap.set("c", "", function()
require("cmdbuf").split_open(vim.o.cmdwinheight, { line = vim.fn.getcmdline(), column = vim.fn.getcmdpos() })
vim.api.nvim_feedkeys(vim.keycode(""), "n", true)
end)-- Custom buffer mappings
vim.api.nvim_create_autocmd({ "User" }, {
group = vim.api.nvim_create_augroup("cmdbuf_setting", {}),
pattern = { "CmdbufNew" },
callback = function(args)
vim.bo.bufhidden = "wipe" -- if you don't need previous opened buffer state
vim.keymap.set("n", "q", [[quit]], { nowait = true, buffer = true })
vim.keymap.set("n", "dd", [[lua require('cmdbuf').delete()]], { buffer = true })
vim.keymap.set({ "n", "i" }, "", function()
return require("cmdbuf").cmdline_expr()
end, { buffer = true, expr = true })local typ = require("cmdbuf").get_context().type
if typ == "vim/cmd" then
-- you can filter buffer lines
local lines = vim
.iter(vim.api.nvim_buf_get_lines(args.buf, 0, -1, false))
:filter(function(line)
return line ~= "q"
end)
:totable()
vim.api.nvim_buf_set_lines(args.buf, 0, -1, false, lines)
end
end,
})-- open lua command-line window
vim.keymap.set("n", "ql", function()
require("cmdbuf").split_open(vim.o.cmdwinheight, { type = "lua/cmd" })
end)-- q/, q? alternative
vim.keymap.set("n", "q/", function()
require("cmdbuf").split_open(vim.o.cmdwinheight, { type = "vim/search/forward" })
end)
vim.keymap.set("n", "q?", function()
require("cmdbuf").split_open(vim.o.cmdwinheight, { type = "vim/search/backward" })
end)
```