From a37ff7e71ffbc830d8e9924bd4a9ad99cb281ae1 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 18 Aug 2022 16:12:15 +0200 Subject: [PATCH] feat: show relativenumbers only in editable buffers --- init.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 1b699cc..9ab3420 100644 --- a/init.lua +++ b/init.lua @@ -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)