2022-05-03 17:24:11 +01:00
|
|
|
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,
|
|
|
|
-- })
|
2021-08-22 08:49:15 +01:00
|
|
|
|
|
|
|
-- Use relative & absolute line numbers in 'n' & 'i' modes respectively
|
2022-05-03 17:24:11 +01:00
|
|
|
-- autocmd("InsertEnter", {
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.opt.relativenumber = false
|
|
|
|
-- end,
|
|
|
|
-- })
|
|
|
|
-- autocmd("InsertLeave", {
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.opt.relativenumber = true
|
|
|
|
-- end,
|
|
|
|
-- })
|
2021-08-22 08:49:15 +01:00
|
|
|
|
|
|
|
-- Open a file from its last left off position
|
2022-05-03 17:24:11 +01: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 08:49:15 +01:00
|
|
|
-- File extension specific tabbing
|
2022-05-03 17:24:11 +01: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 06:25:04 +01: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,
|
|
|
|
-- })
|