From fa965c979733dbdb964df3d4deff3b11c8604cbc Mon Sep 17 00:00:00 2001 From: Galen Rowell Date: Wed, 18 Aug 2021 22:13:56 +1000 Subject: [PATCH] added relativenumber option & statusline option (#279) --- lua/chadrc.lua | 3 +++ lua/default_config.lua | 3 ++- lua/options.lua | 13 ++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 1f8d7d0b..ed859b5b 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -13,6 +13,7 @@ M.ui = { hidden_statusline = { -- these are filetypes, not pattern matched "NvimTree", + -- "terminal", }, } @@ -27,6 +28,8 @@ M.options = { timeoutlen = 400, clipboard = "unnamedplus", number = true, + -- relative numbers in normal mode tool at the bottom of options.lua + relativenumber = false, numberwidth = 2, expandtab = true, shiftwidth = 2, diff --git a/lua/default_config.lua b/lua/default_config.lua index 71f1dc91..459b05f3 100644 --- a/lua/default_config.lua +++ b/lua/default_config.lua @@ -13,7 +13,7 @@ M.ui = { hidden_statusline = { -- these are filetypes, not pattern matched "NvimTree", - "toggleterm", + -- "terminal", }, } @@ -28,6 +28,7 @@ M.options = { timeoutlen = 400, clipboard = "unnamedplus", number = true, + relativenumber = false, numberwidth = 2, expandtab = true, shiftwidth = 2, diff --git a/lua/options.lua b/lua/options.lua index 96016ec2..225bf585 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -27,7 +27,7 @@ opt.fillchars = { eob = " " } -- Numbers opt.number = options.number opt.numberwidth = options.numberwidth --- opt.relativenumber = true +opt.relativenumber = options.relativenumber -- Indenline opt.expandtab = options.expandtab @@ -67,9 +67,16 @@ for _, plugin in pairs(disabled_built_ins) do g["loaded_" .. plugin] = 1 end --- Don't show status line on certain windows +-- Use relative & absolute line numbers in 'n' & 'i' modes respectively +-- vim.cmd[[ au InsertEnter * set norelativenumber ]] +-- vim.cmd[[ au InsertLeave * set relativenumber ]] + +-- Don't show any numbers inside terminals vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber ]] -vim.cmd [[let hidden_statusline = luaeval('require("chadrc").ui.hidden_statusline') | autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter,TermEnter * nested if index(hidden_statusline, &ft) >= 0 | set laststatus=0 | else | set laststatus=2 | endif]] + +-- Don't show status line on certain windows +vim.cmd [[ au TermOpen term://* setfiletype terminal ]] +vim.cmd [[ let hidden_statusline = luaeval('require("chadrc").ui.hidden_statusline') | autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter,TermEnter * nested if index(hidden_statusline, &ft) >= 0 | set laststatus=0 | else | set laststatus=2 | endif ]] -- Open a file from its last left off position -- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]]