mirror of
https://github.com/harivansh-afk/nvim.git
synced 2026-04-15 07:04:47 +00:00
net config
This commit is contained in:
parent
93b7b93d64
commit
dd59a54b92
36 changed files with 960 additions and 631 deletions
36
plugin/autocmds.lua
Normal file
36
plugin/autocmds.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
-- Autocommands
|
||||
local api = vim.api
|
||||
local augroup = api.nvim_create_augroup("UserAutocmds", { clear = true })
|
||||
|
||||
-- Highlight on yank
|
||||
api.nvim_create_autocmd("TextYankPost", {
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
|
||||
end,
|
||||
desc = "Highlight text on yank",
|
||||
})
|
||||
|
||||
-- Restore cursor position on file open
|
||||
api.nvim_create_autocmd("BufReadPost", {
|
||||
group = augroup,
|
||||
callback = function()
|
||||
local mark = api.nvim_buf_get_mark(0, '"')
|
||||
local line_count = api.nvim_buf_line_count(0)
|
||||
if mark[1] > 0 and mark[1] <= line_count then
|
||||
pcall(api.nvim_win_set_cursor, 0, mark)
|
||||
end
|
||||
end,
|
||||
desc = "Restore cursor position",
|
||||
})
|
||||
|
||||
-- Auto-resize splits on VimResized
|
||||
api.nvim_create_autocmd("VimResized", {
|
||||
group = augroup,
|
||||
callback = function()
|
||||
local current_tab = vim.fn.tabpagenr()
|
||||
vim.cmd("tabdo wincmd =")
|
||||
vim.cmd("tabnext " .. current_tab)
|
||||
end,
|
||||
desc = "Auto-resize splits",
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue