2022-05-10 14:11:26 +02:00
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
|
|
|
|
-- Disable statusline in dashboard
|
|
|
|
autocmd("FileType", {
|
|
|
|
pattern = "alpha",
|
|
|
|
callback = function()
|
|
|
|
vim.opt.laststatus = 0
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
autocmd("BufUnload", {
|
|
|
|
buffer = 0,
|
|
|
|
callback = function()
|
|
|
|
vim.opt.laststatus = 3
|
|
|
|
end,
|
|
|
|
})
|
2022-05-03 18:24:11 +02:00
|
|
|
|
|
|
|
-- 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,
|
|
|
|
-- })
|
2021-08-22 09:49:15 +02:00
|
|
|
|
|
|
|
-- Use relative & absolute line numbers in 'n' & 'i' modes respectively
|
2022-05-03 18:24:11 +02:00
|
|
|
-- autocmd("InsertEnter", {
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.opt.relativenumber = false
|
|
|
|
-- end,
|
|
|
|
-- })
|
|
|
|
-- autocmd("InsertLeave", {
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.opt.relativenumber = true
|
|
|
|
-- end,
|
|
|
|
-- })
|
2021-08-22 09:49:15 +02:00
|
|
|
|
|
|
|
-- Open a file from its last left off position
|
2022-05-03 18:24:11 +02:00
|
|
|
-- 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,
|
|
|
|
-- })
|
|
|
|
|
2021-08-22 09:49:15 +02:00
|
|
|
-- File extension specific tabbing
|
2022-05-03 18:24:11 +02:00
|
|
|
-- 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,
|
|
|
|
-- })
|
2022-05-04 07:25:04 +02:00
|
|
|
|
|
|
|
-- Highlight yanked text
|
|
|
|
-- autocmd("TextYankPost", {
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.highlight.on_yank { higroup = "Visual", timeout = 200 }
|
|
|
|
-- end,
|
|
|
|
-- })
|
|
|
|
|
|
|
|
-- Enable spellchecking in markdown, text and gitcommit files
|
|
|
|
-- autocmd("FileType", {
|
|
|
|
-- pattern = { "gitcommit", "markdown", "text" },
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.opt_local.spell = true
|
|
|
|
-- end,
|
|
|
|
-- })
|