initial commit for native-only neovim plugin configuration
This commit is contained in:
+17
-20
@@ -1,5 +1,6 @@
|
||||
--[[
|
||||
|
||||
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣷⣦⣄⡀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||||
@@ -25,26 +26,24 @@
|
||||
| _/ /_____\__ \ || (_| | (__| <
|
||||
|_|/___| |___/\__\__,_|\___|_|\_\
|
||||
|
||||
Neovim 0.12 configuration
|
||||
(c) Frank Zechert 2026
|
||||
Neovim v0.12 configuration
|
||||
(C) Frank Zechert 2026
|
||||
]]
|
||||
|
||||
local map = vim.keymap.set
|
||||
|
||||
-- Pressing ESC twices leaves terminal mode
|
||||
map("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "exit terminanl" })
|
||||
-- pressing ESC twices leaves terminal mode
|
||||
map("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit Terminal Mode" })
|
||||
|
||||
-- Pressing ESC removes search highlights
|
||||
map("n", "<Esc>", "<Cmd>nohlsearch<Cr>")
|
||||
-- pressing ESC removes search highlights
|
||||
map("n", "<Esc>", "<Cmd>nohlsearch<CR>", { desc = "Remove search result highlights" })
|
||||
|
||||
-- Smart buffer switch (to alternative, previous, or next) if possible
|
||||
-- Smart buffer switch
|
||||
-- switch to the alternative buffer ("#"), if not available, switch to the
|
||||
-- previous buffer, if not possible, switch to the next buffer
|
||||
local function smart_buffer_switch(current)
|
||||
local alternative = vim.fn.bufnr("#")
|
||||
|
||||
-- get all listed buffers
|
||||
local buffers = vim.fn.getbufinfo({ buflisted = 1 })
|
||||
|
||||
-- find index of the current buffer
|
||||
local current_index = nil
|
||||
for index, buffer in ipairs(buffers) do
|
||||
if buffer.bufnr == current then
|
||||
@@ -52,13 +51,12 @@ local function smart_buffer_switch(current)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- try to switch to alternate buffer
|
||||
if alternative > 0 and vim.fn.buflisted(alternative) == 1 and alternative ~= current then
|
||||
vim.api.nvim_set_current_buf(alternative)
|
||||
-- try to switch to previous buffer
|
||||
elseif current_index and current_index > 1 then
|
||||
vim.api.nvim_set_current_buf(buffers[current_index -1].bufnr)
|
||||
vim.api.nvim_set_current_buf(buffers[current_index - 1].bufnr)
|
||||
-- try to switch to next buffer
|
||||
elseif current_index and current_index < #buffers then
|
||||
vim.api.nvim_set_current_buf(buffers[current_index + 1].bufnr)
|
||||
@@ -68,35 +66,34 @@ end
|
||||
local function smart_buffer_delete()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
smart_buffer_switch(current)
|
||||
-- delete current buffer
|
||||
vim.cmd(":confirm bdelete " .. current)
|
||||
end
|
||||
map("n", "<leader>bd", smart_buffer_delete, { desc = "Close Current Buffer" })
|
||||
|
||||
local function smart_buffer_wipeout()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
smart_buffer_switch(current)
|
||||
-- delete current buffer
|
||||
vim.cmd(":confirm bwipeout " .. current)
|
||||
end
|
||||
map("n", "<leader>bw", smart_buffer_wipeout, { desc = "Wipeout Current Buffer" })
|
||||
|
||||
local function delete_other_buffers()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
for _, buffer in ipairs(vim.api.nvim_list_bufs()) do
|
||||
for _, buffer in ipairs(vim.api.nvim_list_buffers()) do
|
||||
if buffer ~= current and vim.bo[buffer].buflisted and not vim.bo[buffer].modified then
|
||||
vim.api.nvim_buf_delete(buffer, {})
|
||||
end
|
||||
end
|
||||
end
|
||||
map("n", "<leader>bD", delete_other_buffers, { desc = "Close All Other Buffers" })
|
||||
|
||||
local function wipeout_other_buffers()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
for _, buffer in ipairs(vim.api.nvim_list_bufs()) do
|
||||
for _, buffer in ipairs(vim.api.nvim_list_buffers()) do
|
||||
if buffer ~= current and vim.bo[buffer].buflisted and not vim.bo[buffer].modified then
|
||||
vim.cmd("bwipeout " .. buffer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
map("n", "<leader>bd", smart_buffer_delete, { desc = "Close Current Buffer" })
|
||||
map("n", "<leader>bw", smart_buffer_wipeout, { desc = "Wipeout Current Buffer" })
|
||||
map("n", "<leader>bD", delete_other_buffers, { desc = "Close All Other Buffers" })
|
||||
map("n", "<leader>bW", wipeout_other_buffers, { desc = "Wipeout All Other Buffers" })
|
||||
|
||||
Reference in New Issue
Block a user