nvim/lua/config/utils.lua

289 lines
4.9 KiB
Lua
Raw Normal View History

local M = {}
M.has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end
2023-12-04 09:24:43 +01:00
M.feline_theme_dark = {
2023-06-20 19:00:40 +02:00
fg = '#c9d1d9',
bg = '#101010',
green = '#66cc66',
yellow = '#ffdd11',
purple = '#c678dd',
orange = '#cc8c3c',
peanut = '#f6d5a4',
red = '#e06c75',
aqua = '#61afef',
bg2 = '#484848',
dark_red = '#f75f5f',
normal = '#A9A9A9'
}
2023-12-04 09:24:43 +01:00
M.feline_theme_light = {
bg = '#c9d1d9',
fg = '#101010',
green = '#66cc66',
yellow = '#cca300',
purple = '#c678dd',
orange = '#cc8c3c',
peanut = '#f6d5a4',
red = '#e06c75',
aqua = '#61afef',
bg2 = '#484848',
dark_red = '#f75f5f',
normal = '#A9A9A9'
}
2023-06-20 19:00:40 +02:00
M.feline_vi_mode_colors = {
NORMAL = 'normal',
OP = 'green',
INSERT = 'yellow',
VISUAL = 'orange',
LINES = 'orange',
BLOCK = 'dark_red',
REPLACE = 'red',
COMMAND = 'aqua',
}
local left_component_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
2023-12-04 09:24:43 +01:00
-- local right_component_separator = {
-- str = ' ',
-- hl = {
-- fg = '#4a4a4a',
-- },
-- }
-- local left_section_separator = {
-- str = '',
-- hl = {
-- fg = 'normal',
-- },
-- }
2023-06-20 19:00:40 +02:00
local right_section_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local function selectionCount()
local isVisualMode = vim.fn.mode():find("[Vv]")
if not isVisualMode then return "" end
local starts = vim.fn.line("v")
local ends = vim.fn.line(".")
local lines = starts <= ends and ends - starts + 1 or starts - ends + 1
return "" .. tostring(lines) .. "L " .. tostring(vim.fn.wordcount().visual_chars) .. "C"
end
2023-06-25 17:10:09 +02:00
local function startupTime()
2023-12-04 09:24:43 +01:00
return tostring(require 'lazy'.stats().startuptime)
2023-06-25 17:10:09 +02:00
end
2023-06-20 19:00:40 +02:00
M.feline_c = {
right_separator = {
provider = '',
left_sep = ' ',
hl = {
fg = '#484848'
}
},
left_separator = {
provider = '',
left_sep = ' ',
hl = {
fg = '#484848'
}
},
vim_mode = {
provider = {
name = 'vi_mode',
opts = {
show_mode_name = true,
-- padding = "center", -- Uncomment for extra padding.
},
},
hl = function()
return {
2023-12-04 09:24:43 +01:00
fg = require('feline.providers.vi_mode').get_mode_color(),
-- fg = 'bg',
2023-06-20 19:00:40 +02:00
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = 'block',
right_sep = {
2023-12-04 09:24:43 +01:00
str = 'slant_right',
2023-06-20 19:00:40 +02:00
},
},
diagnostic_errors = {
provider = 'diagnostic_errors',
hl = {
fg = 'red',
},
},
diagnostic_warnings = {
provider = 'diagnostic_warnings',
hl = {
fg = 'yellow',
},
},
diagnostic_hints = {
provider = 'diagnostic_hints',
hl = {
fg = 'aqua',
},
},
diagnostic_info = {
provider = 'diagnostic_info',
},
file_info = {
provider = {
name = 'file_info',
opts = {
colored_icon = true,
type = 'relative-short',
},
},
hl = {
fg = 'bg2',
},
left_sep = ' ',
},
lsp_client_names = {
provider = 'lsp_client_names',
hl = {
fg = 'bg2',
},
left_sep = 'right',
},
file_type = {
provider = {
name = 'file_type',
opts = {
filetype_icon = false,
colored_icon = false,
case = 'lowercase',
},
},
hl = {
fg = 'bg2',
},
left_sep = left_component_separator,
right_sep = ' ',
},
file_encoding = {
provider = 'file_encoding',
hl = {
fg = 'bg2',
},
left_sep = left_component_separator,
right_sep = ' ',
},
position = {
provider = 'position',
hl = function()
return {
2023-12-04 09:24:43 +01:00
fg = require('feline.providers.vi_mode').get_mode_color(),
-- fg = 'bg',
2023-06-20 19:00:40 +02:00
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
right_sep = 'block',
left_sep = {
2023-12-04 09:24:43 +01:00
str = 'slant_left',
2023-06-20 19:00:40 +02:00
},
},
2023-06-25 17:10:09 +02:00
startup = {
provider = startupTime,
left_sep = ' ',
right_sep = ' ',
},
2023-06-20 19:00:40 +02:00
select_count = {
provider = selectionCount,
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = ' ',
right_sep = ' ',
},
line_percentage = {
provider = 'line_percentage',
hl = {
fg = 'normal',
},
left_sep = ' ',
right_sep = ' ',
},
scroll_bar = {
provider = 'scroll_bar',
hl = {
fg = 'yellow',
style = 'bold',
},
},
search_count = {
provider = 'search_count',
left_sep = left_component_separator,
right_sep = ' ',
},
macro = {
provider = 'macro',
hl = {
style = 'bold',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitBranch = {
provider = 'git_branch',
hl = {
fg = 'peanut',
bg = 'bg2',
style = 'bold',
},
left_sep = ' ',
right_sep = right_section_separator,
},
gitDiffAdded = {
provider = 'git_diff_added',
hl = {
fg = 'green',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffRemoved = {
provider = 'git_diff_removed',
hl = {
fg = 'red',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffChanged = {
provider = 'git_diff_changed',
hl = {
fg = 'fg',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'right_filled',
},
}
return M