Skip to content

Commit d4dad5f

Browse files
author
Ali Shahid
committed
[refactor] remove autocmd.lua and use configs.lua instead
1 parent dc21b7c commit d4dad5f

File tree

3 files changed

+62
-63
lines changed

3 files changed

+62
-63
lines changed

init.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ vim.g.maplocalleader = '|'
3232
require('plugins/impatient_nvim') -- impatient needs to be setup before any other lua plugin is loaded so it is recommended you add the following near the start of your
3333
require('plugins/filetype_nvim') -- Easily speed up your neovim startup time!
3434
require('configs') -- plugin independent configs
35-
require('autocmd') -- automatic commands
3635
require('mappings') -- plugin independent mappings
3736
require('customs/override_defalut') -- always put this config(override_defalut) at last because it's use to overide the any already defined config
3837

39-
4038
-- load/source PLUGINS CONFIGS
4139
-- loading plugins and its configs are managed in seperate config file, ~/.config/nvim/lua/plugins/packer_nvim.lua
4240
-- NOTE: laways load plugins at last

lua/autocmd.lua

Lines changed: 0 additions & 60 deletions
This file was deleted.

lua/configs.lua

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,68 @@ end
103103
-- vim.opt.cmdheight = 0 -- command height
104104
-- end
105105

106+
107+
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
108+
-- ━━━━━━━━━━━━━━━━━━━❰ Automate ❱━━━━━━━━━━━━━━━━━━━━ --
109+
110+
local group = vim.api.nvim_create_augroup("AbstractAutoGroup", {clear=true})
111+
112+
vim.api.nvim_create_autocmd(
113+
"TextYankPost",
114+
{
115+
desc = "highlight text on yank",
116+
pattern = "*",
117+
group = group,
118+
callback = function()
119+
vim.highlight.on_yank {
120+
higroup="Search", timeout=400, on_visual=true
121+
}
122+
end,
123+
}
124+
)
125+
126+
-- jump to the last position when reopening a file
127+
vim.cmd([[
128+
if has("autocmd")
129+
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
130+
endif
131+
]])
132+
133+
vim.api.nvim_create_autocmd(
134+
"BufWritePre",
135+
{
136+
desc = "remove whitespaces on save",
137+
pattern = "*",
138+
group = group,
139+
command = "%s/\\s\\+$//e",
140+
}
141+
)
142+
143+
vim.api.nvim_create_autocmd(
144+
"BufEnter",
145+
{
146+
desc = "don't auto comment new line",
147+
pattern = "*",
148+
group = group,
149+
command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
150+
}
151+
)
152+
153+
vim.api.nvim_create_autocmd(
154+
"VimResized",
155+
{
156+
desc = "auto resize splited windows",
157+
pattern = "*",
158+
group = group,
159+
command = "tabdo wincmd =",
160+
}
161+
)
162+
163+
-- ━━━━━━━━━━━━━━━━❰ end of Automate ❱━━━━━━━━━━━━━━━━ --
164+
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
165+
166+
106167
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
107-
-- ━━━━━━━━━━━━━━━❰ end of Plugin Configs ❱━━━━━━━━━━━━━━━━ --
168+
-- ━━━━━━━━━❰ end of Plugin-Independent Configs ❱━━━━━━━━━━ --
108169
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
109170

0 commit comments

Comments
 (0)