feat: show relativenumbers only in editable buffers

This commit is contained in:
əlemi 2022-08-18 16:12:15 +02:00
parent 1ad29defc6
commit a37ff7e71f
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -38,6 +38,7 @@ vim.opt.foldlevelstart = 50
vim.opt.termguicolors = true
-- vim.opt.signcolumn = "yes"
vim.opt.switchbuf = "usetab"
vim.g.mapleader = "\\"
vim.opt.list = true -- always show whitespace chars
vim.opt.listchars = "tab:│ ,space:·,trail:•,nbsp:▭,precedes:◀,extends:▶"
@ -78,11 +79,17 @@ vim.opt.relativenumber = true
local number_mode_group = vim.api.nvim_create_augroup("NumberModeGroup", {clear=true})
vim.api.nvim_create_autocmd(
{ "InsertLeave", "BufEnter", "FocusGained", "WinEnter" },
{ callback=function() vim.opt.relativenumber = true end, group=number_mode_group }
{
callback = function() if vim.wo.number then vim.wo.relativenumber = true end end,
group = number_mode_group
}
)
vim.api.nvim_create_autocmd(
{ "InsertEnter", "BufLeave", "FocusLost", "WinLeave" },
{ callback=function() vim.opt.relativenumber = false end, group=number_mode_group }
{
callback=function() if vim.wo.number then vim.opt.relativenumber = false end end,
group=number_mode_group
}
)
@ -126,6 +133,16 @@ PALETTE:set_colors()
--|| UTILITY
function P(something) print(vim.inspect(something)) end
function HL()
local id = vim.fn.synID(vim.fn.line('.'), vim.fn.col('.'), 1)
local id_trans = vim.fn.synIDtrans(id)
local name = vim.fn.synIDattr(id_trans, 'name')
print(id)
print(id_trans)
print(name)
P(name)
end
vim.api.nvim_create_user_command(
'UpdateConfig',
function(args)