Refactor configuration.

This commit is contained in:
Saeed Afzal
2025-11-11 21:21:15 +00:00
parent 871d8ebc66
commit a3c43dc5ea
4 changed files with 64 additions and 78 deletions

25
lua/core/autocmds.lua Normal file
View File

@@ -0,0 +1,25 @@
vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
callback = function()
vim.cmd [[
hi Normal guibg=none ctermbg=none
hi NonText guibg=none ctermbg=none
hi NormalFloat guibg=none ctermbg=none
]]
end
})
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.ts", "*.tsx" },
command = "compiler tsc"
})
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = "*.go",
command = "Tabs 4"
})
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = "*.rs",
command = "compiler cargo"
})

26
lua/core/commands.lua Normal file
View File

@@ -0,0 +1,26 @@
local function indent(n, expand)
local size = 4
if n ~= "" then size = n end
local num = tonumber(size)
if num then
size = num
end
vim.o.expandtab = expand
vim.o.shiftwidth = size
vim.o.tabstop = size
end
vim.api.nvim_create_user_command("Tabs", function(v)
indent(v.args, false)
end, { nargs = "?" })
vim.api.nvim_create_user_command("Spaces", function(v)
indent(v.args, true)
end, { nargs = "?" })
vim.api.nvim_create_user_command("TE", function(v)
vim.cmd("split")
vim.cmd("term " .. v.args)
end, { nargs = "*", force = true })