61 lines
2 KiB
Lua
61 lines
2 KiB
Lua
-- Highlight whatever is being yanked
|
|
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
|
|
command = 'silent! lua require"vim.hl".on_yank{timeout=500}',
|
|
desc = "Highlight yanked text whenevery yanking something",
|
|
group = vim.api.nvim_create_augroup("highlightyanks", { clear = true }),
|
|
})
|
|
|
|
local private_mode = function()
|
|
vim.o.shada = ""
|
|
vim.o.swapfile = false
|
|
vim.o.undofile = false
|
|
vim.o.backup = false
|
|
vim.o.writebackup = false
|
|
vim.o.shelltemp = false
|
|
vim.o.history = 0
|
|
vim.o.modeline = false
|
|
vim.o.secure = true
|
|
end
|
|
-- Special setting for editing gopass files - make sure nothing leaks outside the directories it
|
|
-- is supposed to
|
|
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
|
|
group = vim.api.nvim_create_augroup("passnoleak", { clear = true }),
|
|
pattern = {
|
|
"/dev/shm/gopass.*",
|
|
"/dev/shm/pass.?*/?*.txt",
|
|
"$TMPDIR/pass.?*/?*.txt",
|
|
"/tmp/pass.?*/?*.txt",
|
|
},
|
|
desc = "Don't leak any information when editing potential password files",
|
|
callback = private_mode,
|
|
})
|
|
vim.api.nvim_create_autocmd({ "BufNewFile", "BufReadPre" }, {
|
|
group = vim.api.nvim_create_augroup("PrivateJrnl", {}),
|
|
pattern = "*.jrnl",
|
|
desc = "Don't leak information when editing jrnl files",
|
|
callback = private_mode,
|
|
})
|
|
|
|
-- remove line numbers from terminal buffers
|
|
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
|
desc = "Hide buffer numbers for terminals",
|
|
pattern = "*",
|
|
command = "setlocal nonumber norelativenumber",
|
|
})
|
|
|
|
-- Custom spell enable which fires an event that other things can
|
|
-- hook into.
|
|
-- Toggles off and on by default, only turns on if called with bang.
|
|
vim.api.nvim_create_user_command("SpellToggle", function(opt)
|
|
vim.opt.spell = opt.bang or not vim.opt.spell:get()
|
|
if vim.opt.spell:get() then
|
|
if next(opt.fargs) ~= nil then
|
|
vim.opt.spelllang = opt.fargs
|
|
end
|
|
vim.api.nvim_exec_autocmds("User", { pattern = "SpellEnable" })
|
|
vim.notify("Spellcheck enabled")
|
|
else
|
|
vim.api.nvim_exec_autocmds("User", { pattern = "SpellDisable" })
|
|
vim.notify("Spellcheck disabled")
|
|
end
|
|
end, { nargs = "*", bang = true })
|