refactor: rewrite auto-commands in lua

This commit is contained in:
Arman.H 2022-05-03 20:54:11 +04:30 committed by siduck
parent 854534f54c
commit 5ed71fe682

View File

@ -1,11 +1,43 @@
-- uncomment this if you want to open nvim with a dir
-- vim.cmd [[ autocmd BufEnter * if &buftype != "terminal" | lcd %:p:h | endif ]]
local autocmd = vim.api.nvim_create_autocmd
-- Uncomment this if you want to open nvim with a dir
-- autocmd("BufEnter", {
-- callback = function()
-- if vim.api.nvim_buf_get_option(0, "buftype") ~= "terminal" then
-- vim.cmd "lcd %:p:h"
-- end
-- end,
-- })
-- Use relative & absolute line numbers in 'n' & 'i' modes respectively
-- vim.cmd[[ au InsertEnter * set norelativenumber ]]
-- vim.cmd[[ au InsertLeave * set relativenumber ]]
-- autocmd("InsertEnter", {
-- callback = function()
-- vim.opt.relativenumber = false
-- end,
-- })
-- autocmd("InsertLeave", {
-- callback = function()
-- vim.opt.relativenumber = true
-- end,
-- })
-- Open a file from its last left off position
-- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]]
-- autocmd("BufReadPost", {
-- callback = function()
-- if not vim.fn.expand("%:p"):match ".git" and vim.fn.line "'\"" > 1 and vim.fn.line "'\"" <= vim.fn.line "$" then
-- vim.cmd "normal! g'\""
-- vim.cmd "normal zz"
-- end
-- end,
-- })
-- File extension specific tabbing
-- vim.cmd [[ autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 ]]
-- autocmd("Filetype", {
-- pattern = "python",
-- callback = function()
-- vim.opt_local.expandtab = true
-- vim.opt_local.tabstop = 4
-- vim.opt_local.shiftwidth = 4
-- vim.opt_local.softtabstop = 4
-- end,
-- })