summaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/custom-neovim/config/init.lua7
-rw-r--r--pkgs/custom-neovim/config/lua/ui.lua157
-rw-r--r--pkgs/custom-neovim/config/lua/utilities.lua17
-rw-r--r--pkgs/custom-neovim/design.md5
4 files changed, 175 insertions, 11 deletions
diff --git a/pkgs/custom-neovim/config/init.lua b/pkgs/custom-neovim/config/init.lua
index 1c1f70f..d817bb6 100644
--- a/pkgs/custom-neovim/config/init.lua
+++ b/pkgs/custom-neovim/config/init.lua
@@ -5,13 +5,13 @@ require("art")
-- Require config parts.
require("options")
require("autocommands")
-require("colorscheme")
+require("colorschemes")
require("neovide")
require("mappings")
+require("ui")
-- Require plugin configs.
-- UI Plugins:
-require("plugins.lualine")
require("plugins.tabby")
require("plugins.mini.clue")
require("plugins.mini.indentscope")
@@ -24,6 +24,9 @@ require("plugins.mini.files")
require("plugins.lspconfig")
require("plugins.actions-preview")
+-- Utility Plugins:
+require("plugins.mini.git")
+
-- Misc Plugins:
require("plugins.presence")
require("plugins.snacks")
diff --git a/pkgs/custom-neovim/config/lua/ui.lua b/pkgs/custom-neovim/config/lua/ui.lua
index 1127fb3..62127f1 100644
--- a/pkgs/custom-neovim/config/lua/ui.lua
+++ b/pkgs/custom-neovim/config/lua/ui.lua
@@ -1,13 +1,156 @@
-- UI customizations without plugins.
+-- Statusline
+
+-- TODO: Components to add
+--
+-- mode
+-- git diff
+-- git branch
+--
+-- cwd
+--
+-- lsp diagnostics
+-- lsp status
+-- position %
+-- location ##:##
+
+-- Highlight pattern
+local hi_pattern = '%%#%s#%s%%*'
+
+local statusline_components = {
+
+ micro_spacer = function()
+ return " "
+ end,
+
+ spacer = function()
+ return '%='
+ end,
+
+ old_diagnostic_status = function()
+ local ok = ' λ '
+
+ local ignore = {
+ ['c'] = true, -- command mode
+ ['t'] = true -- terminal mode
+ }
+
+ local mode = vim.api.nvim_get_mode().mode
+
+ if ignore[mode] then
+ return ok
+ end
+
+ local levels = vim.diagnostic.severity
+ local errors = #vim.diagnostic.get(0, {severity = levels.ERROR})
+ if errors > 0 then
+ return ' ✘ '
+ end
+
+ local warnings = #vim.diagnostic.get(0, {severity = levels.WARN})
+ if warnings > 0 then
+ return ' ▲ '
+ end
+
+ return ok
+ end,
+
+ diagnostic_status = function()
+ return ""
+ 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'
+
+ -- 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, string.format(' %s ', mode))
+ 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)
+ else
+ return '' -- Return an empty string or some default value if the branch name is not available
+ end
+ end
+
+}
+
+Statusline_component = function(name)
+ return statusline_components[name]()
+end
+
+local get_component = function(name)
+ return string.format('%%{%%v:lua.Statusline_component("%s")%%} ', name)
+end
+
local statusline = {
- ' %t',
- '%r',
- '%m',
- '%=',
- '%{&filetype}',
- ' %2p%%',
- ' %3l:%-2c '
+ 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
}
vim.o.statusline = table.concat(statusline, '')
diff --git a/pkgs/custom-neovim/config/lua/utilities.lua b/pkgs/custom-neovim/config/lua/utilities.lua
index 77645ca..d2a26b6 100644
--- a/pkgs/custom-neovim/config/lua/utilities.lua
+++ b/pkgs/custom-neovim/config/lua/utilities.lua
@@ -32,3 +32,20 @@ Utils.generate_theme_from_highlight_groups = function()
background = get_highlight_colors("Normal").bg,
}
end
+
+Utils.link_highlight = function(first_highlight, second_highlight)
+ vim.cmd.highlight {bang = true, "link", first_highlight, second_highlight}
+end
+
+Utils.replaceInTable = function(t, str1, str2)
+ for key, value in pairs(t) do
+ if type(value) == "string" then
+ -- Replace <C-w> with <leader>w in the string
+ t[key] = value:gsub(str1, str2)
+ elseif type(value) == "table" then
+ -- Recursively process nested tables
+ Utils.replaceInTable(value, str1, str2)
+ end
+ end
+ return t
+end
diff --git a/pkgs/custom-neovim/design.md b/pkgs/custom-neovim/design.md
index d9d667e..d634834 100644
--- a/pkgs/custom-neovim/design.md
+++ b/pkgs/custom-neovim/design.md
@@ -11,8 +11,9 @@
## Todo
- Figure out good session management
-- install oil.nvim to replace default dir manager
-- Configure snacks terminal manager
+- Configure terminal management
- add quick window switcher plugin
- make vertical dividers the same color as text
+- add automatic parentheses
+- add smart indentation