summaryrefslogtreecommitdiff
path: root/pkgs/custom-neovim/config
diff options
context:
space:
mode:
authortriethyl <triethylammonium@pm.me>2025-07-31 17:44:05 -0400
committertriethyl <triethylammonium@pm.me>2025-07-31 17:44:05 -0400
commiteb02235412221124db07918dbbaf23c7b1d8580f (patch)
tree350de102f79f944f36463939e61ef18890957e1e /pkgs/custom-neovim/config
parent168864226d2629279efed9630d0af8cae4c914b2 (diff)
neovim: renamed ui to statusline
Diffstat (limited to 'pkgs/custom-neovim/config')
-rw-r--r--pkgs/custom-neovim/config/init.lua2
-rw-r--r--pkgs/custom-neovim/config/lua/statusline.lua (renamed from pkgs/custom-neovim/config/lua/ui.lua)114
2 files changed, 71 insertions, 45 deletions
diff --git a/pkgs/custom-neovim/config/init.lua b/pkgs/custom-neovim/config/init.lua
index d817bb6..4a42bfc 100644
--- a/pkgs/custom-neovim/config/init.lua
+++ b/pkgs/custom-neovim/config/init.lua
@@ -8,7 +8,7 @@ require("autocommands")
require("colorschemes")
require("neovide")
require("mappings")
-require("ui")
+require("statusline")
-- Require plugin configs.
-- UI Plugins:
diff --git a/pkgs/custom-neovim/config/lua/ui.lua b/pkgs/custom-neovim/config/lua/statusline.lua
index 62127f1..9ee89c2 100644
--- a/pkgs/custom-neovim/config/lua/ui.lua
+++ b/pkgs/custom-neovim/config/lua/statusline.lua
@@ -1,5 +1,3 @@
--- UI customizations without plugins.
-
-- Statusline
-- TODO: Components to add
@@ -18,6 +16,46 @@
-- Highlight pattern
local hi_pattern = '%%#%s#%s%%*'
+-- Convert mode to string
+local mode_to_str = {
+ ['n'] = 'NORMAL',
+ ['no'] = 'OP-PENDING',
+ ['nov'] = 'OP-PENDING',
+ ['noV'] = 'OP-PENDING',
+ ['no\22'] = 'OP-PENDING',
+ ['niI'] = 'NORMAL',
+ ['niR'] = 'NORMAL',
+ ['niV'] = 'NORMAL',
+ ['nt'] = 'NORMAL',
+ ['ntT'] = 'NORMAL',
+ ['v'] = 'VISUAL',
+ ['vs'] = 'VISUAL',
+ ['V'] = 'VISUAL',
+ ['Vs'] = 'VISUAL',
+ ['\22'] = 'VISUAL',
+ ['\22s'] = 'VISUAL',
+ ['s'] = 'SELECT',
+ ['S'] = 'SELECT',
+ ['\19'] = 'SELECT',
+ ['i'] = 'INSERT',
+ ['ic'] = 'INSERT',
+ ['ix'] = 'INSERT',
+ ['R'] = 'REPLACE',
+ ['Rc'] = 'REPLACE',
+ ['Rx'] = 'REPLACE',
+ ['Rv'] = 'VIRT REPLACE',
+ ['Rvc'] = 'VIRT REPLACE',
+ ['Rvx'] = 'VIRT REPLACE',
+ ['c'] = 'COMMAND',
+ ['cv'] = 'VIM EX',
+ ['ce'] = 'EX',
+ ['r'] = 'PROMPT',
+ ['rm'] = 'MORE',
+ ['r?'] = 'CONFIRM',
+ ['!'] = 'SHELL',
+ ['t'] = 'TERMINAL',
+}
+
local statusline_components = {
micro_spacer = function()
@@ -61,46 +99,6 @@ local statusline_components = {
end,
mode = function()
- -- Note that: \19 = ^S and \22 = ^V.
- local mode_to_str = {
- ['n'] = 'NORMAL',
- ['no'] = 'OP-PENDING',
- ['nov'] = 'OP-PENDING',
- ['noV'] = 'OP-PENDING',
- ['no\22'] = 'OP-PENDING',
- ['niI'] = 'NORMAL',
- ['niR'] = 'NORMAL',
- ['niV'] = 'NORMAL',
- ['nt'] = 'NORMAL',
- ['ntT'] = 'NORMAL',
- ['v'] = 'VISUAL',
- ['vs'] = 'VISUAL',
- ['V'] = 'VISUAL',
- ['Vs'] = 'VISUAL',
- ['\22'] = 'VISUAL',
- ['\22s'] = 'VISUAL',
- ['s'] = 'SELECT',
- ['S'] = 'SELECT',
- ['\19'] = 'SELECT',
- ['i'] = 'INSERT',
- ['ic'] = 'INSERT',
- ['ix'] = 'INSERT',
- ['R'] = 'REPLACE',
- ['Rc'] = 'REPLACE',
- ['Rx'] = 'REPLACE',
- ['Rv'] = 'VIRT REPLACE',
- ['Rvc'] = 'VIRT REPLACE',
- ['Rvx'] = 'VIRT REPLACE',
- ['c'] = 'COMMAND',
- ['cv'] = 'VIM EX',
- ['ce'] = 'EX',
- ['r'] = 'PROMPT',
- ['rm'] = 'MORE',
- ['r?'] = 'CONFIRM',
- ['!'] = 'SHELL',
- ['t'] = 'TERMINAL',
- }
-
-- Get the respective string to display.
local mode = mode_to_str[vim.api.nvim_get_mode().mode] or 'UNKNOWN'
@@ -124,6 +122,30 @@ local statusline_components = {
return hi_pattern:format(hl, string.format(' %s ', mode))
end,
+ position = function()
+ -- Get the respective string to display.
+ local mode = mode_to_str[vim.api.nvim_get_mode().mode] or 'UNKNOWN'
+
+ -- Set the highlight group.
+ local hl = 'MiniStatuslineModeOther'
+ if mode:find 'NORMAL' then
+ hl = 'MiniStatuslineModeNormal'
+ elseif mode:find 'PENDING' then
+ hl = 'MiniStatuslineModeNormal'
+ elseif mode:find 'VISUAL' then
+ hl = 'MiniStatuslineModeVisual'
+ elseif mode:find 'REPLACE' then
+ hl = 'MiniStatuslineModeReplace'
+ elseif mode:find 'INSERT' or mode:find 'SELECT' then
+ hl = 'MiniStatuslineModeInsert'
+ elseif mode:find 'COMMAND' or mode:find 'TERMINAL' or mode:find 'EX' then
+ hl = 'MiniStatuslineModeCommand'
+ end
+
+ -- Construct the component.
+ return hi_pattern:format(hl, ' %2l:%-2c ')
+ end,
+
git_branch = function()
if vim.b.minigit_summary and vim.b.minigit_summary.head_name then
return string.format('  %s ', vim.b.minigit_summary.head_name)
@@ -144,13 +166,17 @@ end
local statusline = {
get_component("micro_spacer"),
+
get_component("mode"),
get_component("diagnostic_status"),
get_component("git_branch"),
+
get_component("spacer"), -- spacer
+
'%{&filetype}', -- filetype
- ' %2p%%', -- progress %
- ' %3l:%-2c ' -- position
+ ' %2p%% ', -- progress %
+ get_component("position"),
+
}
vim.o.statusline = table.concat(statusline, '')