transition to lazy loading and lua colorscheme in progress
This commit is contained in:
parent
853ade4fba
commit
f546b387e4
199
lua/plugins/colorscheme.lua
Normal file
199
lua/plugins/colorscheme.lua
Normal file
@ -0,0 +1,199 @@
|
||||
-- [[
|
||||
-- This file is largely based on work done by Andrew Wong (w0ng)
|
||||
-- Find the original file and additional credits at: https://github.com/w0ng/vim-hybrid
|
||||
--
|
||||
-- ]]
|
||||
|
||||
return {
|
||||
|
||||
{
|
||||
"custom/hybrid",
|
||||
name = "hybrid-colorscheme",
|
||||
lazy = "false",
|
||||
priority = 1000,
|
||||
config = function()
|
||||
-- Clear existing highlights
|
||||
vim.cmd("highlight clear")
|
||||
|
||||
-- Reset syntax if it exists
|
||||
if vim.fn.exists("syntax_on") then
|
||||
vim.cmd("syntax reset")
|
||||
end
|
||||
|
||||
vim.g.colors_name = "hybrid"
|
||||
vim.o.background = "dark"
|
||||
vim.o.termguicolors = true
|
||||
|
||||
local colors = {
|
||||
-- Core colors with both GUI and cterm values
|
||||
background = { gui = "#1d1f21", cterm = 234 },
|
||||
foreground = { gui = "#c5c8c6", cterm = 250 },
|
||||
selection = { gui = "#373b41", cterm = 237 },
|
||||
line = { gui = "#282a2e", cterm = 235 },
|
||||
comment = { gui = "#707880", cterm = 243 },
|
||||
|
||||
-- Syntax colors
|
||||
red = { gui = "#cc6666", cterm = 167 },
|
||||
orange = { gui = "#de935f", cterm = 173 },
|
||||
yellow = { gui = "#f0c674", cterm = 221 },
|
||||
green = { gui = "#b5bd68", cterm = 143 },
|
||||
aqua = { gui = "#8abeb7", cterm = 109 },
|
||||
blue = { gui = "#81a2be", cterm = 110 },
|
||||
purple = { gui = "#b294bb", cterm = 139 },
|
||||
|
||||
-- UI colors
|
||||
window = { gui = "#303030", cterm = 236 },
|
||||
darkcolumn = { gui = "#1c1c1c", cterm = 234 },
|
||||
|
||||
-- Git/diff colors
|
||||
add_bg = { gui = "#5F875F", cterm = 65 },
|
||||
add_fg = { gui = "#d7ffaf", cterm = 193 },
|
||||
change_bg = { gui = "#5F5F87", cterm = 60 },
|
||||
change_fg = { gui = "#d7d7ff", cterm = 189 },
|
||||
del_bg = { gui = "#cc6666", cterm = 167 },
|
||||
|
||||
-- Dark variants
|
||||
dark_red = { gui = "#5f0000", cterm = 52 },
|
||||
dark_blue = { gui = "#00005f", cterm = 17 },
|
||||
dark_cyan = { gui = "#005f5f", cterm = 24 },
|
||||
dark_purple = { gui = "#5f005f", cterm = 53 },
|
||||
}
|
||||
|
||||
-- helper function to set highlights
|
||||
local function hi(group, opts)
|
||||
vim.api.nvim_set_hl(0, group, opts)
|
||||
end
|
||||
|
||||
-- Editor UI
|
||||
hi("Normal", { fg = colors.foreground.gui, bg = colors.background.gui, ctermfg = colors.foreground.cterm, ctermbg = colors.background.cterm })
|
||||
hi("ColorColumn", { bg = colors.line.gui, ctermbg = colors.line.cterm })
|
||||
hi("CursorColumn", { bg = colors.line.gui, ctermbg = colors.line.cterm })
|
||||
hi("CursorLine", {})
|
||||
hi("CursorLineNr", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
hi("Directory", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("LineNr", { fg = colors.comment.gui, ctermfg = colors.comment.cterm })
|
||||
hi("VertSplit", { fg = colors.window.gui, ctermfg = colors.window.cterm })
|
||||
hi("Folded", { fg = colors.comment.gui, bg = colors.darkcolumn.gui, ctermfg = colors.comment.cterm, ctermbg = colors.darkcolumn.cterm })
|
||||
hi("FoldColumn", { bg = colors.darkcolumn.gui, ctermbg = colors.darkcolumn.cterm })
|
||||
hi("SignColumn", { bg = colors.darkcolumn.gui, ctermbg = colors.darkcolumn.cterm })
|
||||
hi("MatchParen", { fg = colors.background.gui, bg = colors.change_bg.gui, ctermfg = colors.background.cterm, ctermbg = colors.change_bg.cterm })
|
||||
hi("NonText", { fg = colors.selection.gui, ctermfg = colors.selection.cterm })
|
||||
hi("SpecialKey", { fg = colors.selection.gui, ctermfg = colors.selection.cterm })
|
||||
hi("Visual", { bg = colors.selection.gui, ctermbg = colors.selection.cterm })
|
||||
hi("Search", { fg = colors.background.gui, bg = colors.yellow.gui, ctermfg = colors.background.cterm, ctermbg = colors.yellow.cterm })
|
||||
hi("Title", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
|
||||
-- Messages
|
||||
hi("ModeMsg", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
hi("MoreMsg", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
hi("ErrorMsg", { fg = colors.background.gui, bg = colors.red.gui, ctermfg = colors.background.cterm, ctermbg = colors.red.cterm, standout = true })
|
||||
hi("WarningMsg", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("Question", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
|
||||
-- Popup menu
|
||||
hi("Pmenu", { fg = colors.foreground.gui, bg = colors.selection.gui, ctermfg = colors.foreground.cterm, ctermbg = colors.selection.cterm })
|
||||
hi("PmenuSel", { fg = colors.foreground.gui, bg = colors.selection.gui, ctermfg = colors.foreground.cterm, ctermbg = colors.selection.cterm, reverse = true })
|
||||
|
||||
-- Status line
|
||||
hi("StatusLine", { fg = colors.comment.gui, bg = colors.background.gui, ctermfg = colors.comment.cterm, ctermbg = colors.background.cterm, reverse = true })
|
||||
hi("StatusLineNC", { fg = colors.window.gui, bg = colors.comment.gui, ctermfg = colors.window.cterm, ctermbg = colors.comment.cterm, reverse = true })
|
||||
hi("TabLine", { fg = colors.foreground.gui, bg = colors.darkcolumn.gui, ctermfg = colors.foreground.cterm, ctermbg = colors.darkcolumn.cterm, reverse = true })
|
||||
|
||||
-- Diffs
|
||||
hi("DiffAdd", { fg = colors.add_fg.gui, bg = colors.add_bg.gui, ctermfg = colors.add_fg.cterm, ctermbg = colors.add_bg.cterm })
|
||||
hi("DiffChange", { fg = colors.change_fg.gui, bg = colors.change_bg.gui, ctermfg = colors.change_fg.cterm, ctermbg = colors.change_bg.cterm })
|
||||
hi("DiffDelete", { fg = colors.background.gui, bg = colors.del_bg.gui, ctermfg = colors.background.cterm, ctermbg = colors.del_bg.cterm })
|
||||
hi("DiffText", { fg = colors.background.gui, bg = colors.blue.gui, ctermfg = colors.background.cterm, ctermbg = colors.blue.cterm })
|
||||
|
||||
-- Spelling
|
||||
hi("SpellCap", { sp = colors.blue.gui, ctermfg = colors.blue.cterm, undercurl = true })
|
||||
hi("SpellLocal", { sp = colors.aqua.gui, ctermfg = colors.aqua.cterm, undercurl = true })
|
||||
hi("SpellBad", { sp = colors.red.gui, ctermfg = colors.red.cterm, undercurl = true })
|
||||
hi("SpellRare", { fg = colors.purple.gui, bg = colors.dark_purple.gui, ctermfg = colors.purple.cterm, ctermbg = colors.dark_purple.cterm, underline = true })
|
||||
|
||||
-- Syntax highlighting
|
||||
hi("Comment", { fg = colors.comment.gui, ctermfg = colors.comment.cterm })
|
||||
|
||||
hi("Constant", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("String", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
|
||||
hi("Identifier", { fg = colors.purple.gui, ctermfg = colors.purple.cterm })
|
||||
hi("Function", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
|
||||
hi("Statement", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("Operator", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("PreProc", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("Type", { fg = colors.orange.gui, ctermfg = colors.orange.cterm })
|
||||
hi("Structure", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("Special", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
hi("Underlined", { fg = colors.blue.gui, ctermfg = colors.blue.cterm, underline = true })
|
||||
|
||||
hi("Error", { fg = colors.red.gui, bg = colors.dark_red.gui, ctermfg = colors.red.cterm, ctermbg = colors.dark_red.cterm, underline = true })
|
||||
hi("Todo", { fg = colors.add_fg.gui, ctermfg = colors.add_fg.cterm })
|
||||
|
||||
-- Quickfix
|
||||
hi("qfLineNr", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
|
||||
-- Tree-sitter highlight groups
|
||||
hi("@variable", { fg = colors.foreground.gui, ctermfg = colors.foreground.cterm })
|
||||
hi("@variable.builtin", { fg = colors.purple.gui, ctermfg = colors.purple.cterm })
|
||||
hi("@variable.parameter", { fg = colors.orange.gui, ctermfg = colors.orange.cterm })
|
||||
-- hi("@variable.member", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
|
||||
hi("@constant", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("@constant.builtin", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("@constant.macro", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("@string", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
hi("@string.escape", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
hi("@string.regexp", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("@character", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
hi("@number", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("@boolean", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("@float", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
|
||||
hi("@function", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
hi("@function.builtin", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
hi("@function.call", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
hi("@function.macro", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
hi("@function.method", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
|
||||
hi("@constructor", { fg = colors.orange.gui, ctermfg = colors.orange.cterm })
|
||||
hi("@operator", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("@keyword", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@keyword.function", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@keyword.operator", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@keyword.return", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@keyword.conditional", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@keyword.repeat", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@keyword.import", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("@type", { fg = colors.orange.gui, ctermfg = colors.orange.cterm })
|
||||
hi("@type.builtin", { fg = colors.orange.gui, ctermfg = colors.orange.cterm })
|
||||
hi("@type.qualifier", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
|
||||
hi("@property", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
hi("@field", { fg = colors.red.gui, ctermfg = colors.red.cterm })
|
||||
|
||||
hi("@punctuation.delimiter", { fg = colors.foreground.gui, ctermfg = colors.foreground.cterm })
|
||||
hi("@punctuation.bracket", { fg = colors.foreground.gui, ctermfg = colors.foreground.cterm })
|
||||
hi("@punctuation.special", { fg = colors.aqua.gui, ctermfg = colors.aqua.cterm })
|
||||
|
||||
hi("@comment", { fg = colors.comment.gui, ctermfg = colors.comment.cterm })
|
||||
hi("@comment.documentation", { fg = colors.comment.gui, ctermfg = colors.comment.cterm })
|
||||
|
||||
hi("@tag", { fg = colors.blue.gui, ctermfg = colors.blue.cterm })
|
||||
hi("@tag.attribute", { fg = colors.orange.gui, ctermfg = colors.orange.cterm })
|
||||
hi("@tag.delimiter", { fg = colors.foreground.gui, ctermfg = colors.foreground.cterm })
|
||||
-- Set up highlight links separately
|
||||
vim.api.nvim_set_hl(0, "diffRemoved", { link = "Constant" })
|
||||
vim.api.nvim_set_hl(0, "diffAdded", { link = "Special" })
|
||||
end,
|
||||
}
|
||||
|
||||
}
|
325
lua/plugins/due_nvim.lua
Normal file
325
lua/plugins/due_nvim.lua
Normal file
@ -0,0 +1,325 @@
|
||||
local M = {}
|
||||
_VT_NS = vim.api.nvim_create_namespace("lsp_signature")
|
||||
|
||||
local prescript
|
||||
local prescript_hi
|
||||
local due_hi
|
||||
local ft
|
||||
local today
|
||||
local today_hi
|
||||
local overdue
|
||||
local overdue_hi
|
||||
local date_hi
|
||||
local pattern_start
|
||||
local pattern_end
|
||||
|
||||
local use_clock_time
|
||||
local use_clock_today
|
||||
local use_seconds
|
||||
local default_due_time
|
||||
|
||||
local user_hour
|
||||
local user_min
|
||||
local user_sec
|
||||
|
||||
local date_pattern
|
||||
local datetime_pattern
|
||||
local datetime12_pattern
|
||||
local fulldate_pattern
|
||||
local fulldatetime_pattern
|
||||
local fulldatetime12_pattern
|
||||
|
||||
local regex_hi
|
||||
|
||||
local update_rate
|
||||
|
||||
local function patternify(str)
|
||||
return str:gsub("[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%1")
|
||||
end
|
||||
|
||||
local function regexify(str) return str:gsub("\\%^%$%.%*~%[%]&", "\\%1") end
|
||||
|
||||
local function make_pattern(pattern)
|
||||
return patternify(pattern_start) .. pattern:gsub('%(', ''):gsub('%)', '') ..
|
||||
patternify(pattern_end)
|
||||
end
|
||||
|
||||
local function make_pattern_match(pattern)
|
||||
return patternify(pattern_start) .. pattern .. patternify(pattern_end)
|
||||
end
|
||||
|
||||
local function parseDue(due)
|
||||
local year = 31556926
|
||||
local month = 2629743
|
||||
local week = 604800
|
||||
local day = 86400
|
||||
local hour = 3600
|
||||
local minute = 60
|
||||
local res = ''
|
||||
local is_today = due < day
|
||||
|
||||
if due >= year then
|
||||
res = res .. math.floor(due / year) .. 'y '
|
||||
due = due % year
|
||||
end
|
||||
|
||||
if due >= month then
|
||||
res = res .. math.floor(due / month) .. 'm '
|
||||
due = due % month
|
||||
end
|
||||
|
||||
if due >= week then
|
||||
res = res .. math.floor(due / week) .. 'w '
|
||||
due = due % week
|
||||
end
|
||||
|
||||
if use_clock_time or (is_today and use_clock_today) then
|
||||
if due >= day then
|
||||
res = res .. math.floor(due / day) .. 'd '
|
||||
due = due % day
|
||||
end
|
||||
|
||||
if due >= hour then
|
||||
res = res .. math.floor(due / hour) .. 'h '
|
||||
due = due % hour
|
||||
end
|
||||
|
||||
if due >= minute then
|
||||
res = res .. math.floor(due / minute) .. 'min '
|
||||
due = due % minute
|
||||
end
|
||||
|
||||
if use_seconds then res = res .. math.floor(due / 1) + 1 .. 's ' end
|
||||
|
||||
else
|
||||
res = res .. math.floor(due / day) + 1 .. 'd '
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
function M.setup(c)
|
||||
c = c or {}
|
||||
use_clock_time = c.use_clock_time or false
|
||||
use_clock_today = c.use_clock_time or false
|
||||
if type(c.use_seconds) == 'boolean' then
|
||||
use_seconds = c.use_seconds
|
||||
else
|
||||
use_seconds = c.use_clock_time or false
|
||||
end
|
||||
update_rate = c.update_rate or
|
||||
(use_clock_time and (use_seconds and 1000 or 60000) or 0)
|
||||
default_due_time = c.default_due_time or 'midnight'
|
||||
prescript = c.prescript or 'due: '
|
||||
prescript_hi = c.prescript_hi or 'Comment'
|
||||
due_hi = c.due_hi or 'String'
|
||||
ft = c.ft or '*.md'
|
||||
today = c.today or 'TODAY'
|
||||
today_hi = c.today_hi or 'Character'
|
||||
overdue = c.overdue or 'OVERDUE'
|
||||
overdue_hi = c.overdue_hi or 'Error'
|
||||
date_hi = c.date_hi or 'Conceal'
|
||||
week_hi = c.week_hi or 'Question'
|
||||
pattern_start = c.pattern_start or '<'
|
||||
pattern_end = c.pattern_end or '>'
|
||||
date_pattern = c.date_pattern or '(%d%d)%-(%d%d)'
|
||||
datetime_pattern = c.datetime_pattern or (date_pattern .. ' (%d+):(%d%d)')
|
||||
datetime12_pattern = c.datetime12_pattern or (datetime_pattern .. ' (%a%a)')
|
||||
fulldate_pattern = c.fulldate_pattern or ('(%d%d%d%d)%-' .. date_pattern)
|
||||
fulldatetime_pattern = c.fulldatetime_pattern or
|
||||
('(%d%d%d%d)%-' .. datetime_pattern)
|
||||
fulldatetime12_pattern = c.fulldatetime12_pattern or
|
||||
(fulldatetime_pattern .. ' (%a%a)')
|
||||
regex_hi = c.regex_hi or
|
||||
"\\d*-*\\d\\+-\\d\\+\\( \\d*:\\d*\\( \\a\\a\\)\\?\\)\\?"
|
||||
|
||||
if default_due_time == "midnight" then
|
||||
user_hour = 23
|
||||
user_min = 59
|
||||
user_sec = 59
|
||||
elseif default_due_time == "noon" then
|
||||
user_hour = 12
|
||||
user_min = 00
|
||||
user_sec = 00
|
||||
end
|
||||
|
||||
local regex_start = regexify(pattern_start)
|
||||
local regex_end = regexify(pattern_end)
|
||||
|
||||
local regex_hi_full = '/' .. regex_start .. regex_hi .. regex_end .. '/'
|
||||
|
||||
vim.api.nvim_exec(string.format(
|
||||
[[
|
||||
augroup Due
|
||||
autocmd!
|
||||
autocmd BufEnter %s lua require("due_nvim").draw(0)
|
||||
autocmd BufEnter %s lua require("due_nvim").async_update(0)
|
||||
autocmd InsertLeave %s lua require("due_nvim").redraw(0)
|
||||
autocmd TextChanged %s lua require("due_nvim").redraw(0)
|
||||
autocmd TextChangedI %s lua require("due_nvim").redraw(0)
|
||||
autocmd BufEnter %s syn match DueDate %s display containedin=mkdNonListItemBlock,mkdListItemLine,mkdBlockquote conceal
|
||||
autocmd BufEnter %s hi def link DueDate %s
|
||||
augroup END
|
||||
]] , ft, ft, ft, ft, ft, ft, regex_hi_full, ft, date_hi),
|
||||
false
|
||||
)
|
||||
-- old autcmd
|
||||
--autocmd BufEnter %s syn match DueDate %s display containedin=mkdNonListItemBlock,mkdListItemLine,mkdBlockquote contained conceal
|
||||
end
|
||||
|
||||
local function draw_due(due, buf, key)
|
||||
local parsed
|
||||
|
||||
if due > 0 then
|
||||
if not (use_clock_time or use_clock_today) and due < 86400 then
|
||||
parsed = { today, today_hi }
|
||||
elseif due < 86400 then
|
||||
parsed = { parseDue(due), today_hi }
|
||||
elseif due < 604800 then
|
||||
parsed = { parseDue(due), due_hi }
|
||||
else
|
||||
parsed = { parseDue(due), week_hi }
|
||||
end
|
||||
else
|
||||
parsed = { overdue, overdue_hi }
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_virtual_text(buf, _VT_NS, key - 1,
|
||||
{ { prescript, prescript_hi }, parsed }, {})
|
||||
end
|
||||
|
||||
function M.draw(buf)
|
||||
-- get current time
|
||||
local now = os.time(os.date('*t'))
|
||||
|
||||
-- find which date pattern is being passed in by user
|
||||
for key, value in pairs(vim.api.nvim_buf_get_lines(buf, 0, -1, {})) do
|
||||
local fulldatetime12 = value:match(make_pattern(fulldatetime12_pattern))
|
||||
if fulldatetime12 then
|
||||
local year, month, day, hour, min, period =
|
||||
fulldatetime12:match(make_pattern_match(fulldatetime12_pattern))
|
||||
hour = tonumber(hour)
|
||||
local is_pm = period:lower() == 'pm'
|
||||
if is_pm and hour < 12 or not is_pm and hour == 12 then
|
||||
hour = hour + 12
|
||||
if hour == 24 then
|
||||
hour = 0
|
||||
end
|
||||
end
|
||||
draw_due(os.time({
|
||||
year = year,
|
||||
month = month,
|
||||
day = day,
|
||||
hour = hour,
|
||||
min = min,
|
||||
sec = user_sec
|
||||
}) - now, buf, key)
|
||||
goto continue
|
||||
end
|
||||
|
||||
local fulldatetime = value:match(make_pattern(fulldatetime_pattern))
|
||||
if fulldatetime then
|
||||
local year, month, day, hour, min =
|
||||
fulldatetime:match(make_pattern_match(fulldatetime_pattern))
|
||||
draw_due(os.time({
|
||||
year = year,
|
||||
month = month,
|
||||
day = day,
|
||||
hour = hour,
|
||||
min = min,
|
||||
sec = user_sec
|
||||
}) - now, buf, key)
|
||||
goto continue
|
||||
end
|
||||
|
||||
local fulldate = value:match(make_pattern(fulldate_pattern))
|
||||
if fulldate then
|
||||
local year, month, day = fulldate:match(make_pattern_match(
|
||||
fulldate_pattern))
|
||||
draw_due(os.time({
|
||||
year = year,
|
||||
month = month,
|
||||
day = day,
|
||||
hour = user_hour,
|
||||
min = user_min,
|
||||
sec = user_sec
|
||||
}) - now, buf, key)
|
||||
goto continue
|
||||
end
|
||||
|
||||
local datetime12 = value:match(make_pattern(datetime12_pattern))
|
||||
if datetime12 then
|
||||
local month, day, hour, min, period =
|
||||
datetime12:match(make_pattern_match(datetime12_pattern))
|
||||
local year = os.date("%Y")
|
||||
hour = tonumber(hour)
|
||||
local is_pm = period:lower() == 'pm'
|
||||
if is_pm and hour < 12 or not is_pm and hour == 12 then
|
||||
hour = hour + 12
|
||||
if hour == 24 then
|
||||
hour = 0
|
||||
end
|
||||
end
|
||||
draw_due(os.time({
|
||||
year = year,
|
||||
month = month,
|
||||
day = day,
|
||||
hour = hour,
|
||||
min = min,
|
||||
sec = user_sec
|
||||
}) - now, buf, key)
|
||||
goto continue
|
||||
end
|
||||
|
||||
local datetime = value:match(make_pattern(datetime_pattern))
|
||||
if datetime then
|
||||
local month, day, hour, min = datetime:match(make_pattern_match(
|
||||
datetime_pattern))
|
||||
local year = os.date("%Y")
|
||||
draw_due(os.time({
|
||||
year = year,
|
||||
month = month,
|
||||
day = day,
|
||||
hour = hour,
|
||||
min = min,
|
||||
sec = user_sec
|
||||
}) - now, buf, key)
|
||||
goto continue
|
||||
end
|
||||
|
||||
local date = value:match(make_pattern(date_pattern))
|
||||
if date then
|
||||
local month, day = date:match(make_pattern_match(date_pattern))
|
||||
local year = os.date("%Y")
|
||||
|
||||
draw_due(os.time({
|
||||
year = year,
|
||||
month = month,
|
||||
day = day,
|
||||
hour = user_hour,
|
||||
min = user_min,
|
||||
sec = user_sec
|
||||
}) - now, buf, key)
|
||||
goto continue
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function M.clear(buf) vim.api.nvim_buf_clear_namespace(buf, _VT_NS, 0, -1) end
|
||||
|
||||
function M.redraw(buf)
|
||||
M.clear(buf)
|
||||
M.draw(buf)
|
||||
end
|
||||
|
||||
function M.async_update(buf)
|
||||
if update_rate <= 0 then return end
|
||||
local timer = vim.loop.new_timer()
|
||||
timer:start(update_rate, 0, vim.schedule_wrap(function()
|
||||
M.redraw(buf)
|
||||
M.async_update(buf)
|
||||
end))
|
||||
end
|
||||
|
||||
return M
|
33
lua/plugins/filetree.lua
Normal file
33
lua/plugins/filetree.lua
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
return {
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v3.x",
|
||||
depends = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"MunifTanjim/nui.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
opts = {
|
||||
|
||||
},
|
||||
lazy = false, -- neo-tree lazy loads itself
|
||||
}
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
event = "VimEnter",
|
||||
depends = { "nvim-lua/plenary.nvim"},
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_config = {
|
||||
horizontal = { width = 0.8 }
|
||||
},
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<leader>s", "<cmd>Telescope spell_suggest<cr>", desc = "Spelling suggestions" },
|
||||
},
|
||||
|
||||
}
|
99
lua/plugins/lsp.lua
Normal file
99
lua/plugins/lsp.lua
Normal file
@ -0,0 +1,99 @@
|
||||
-- language server setup
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
},
|
||||
config = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- Go
|
||||
lspconfig.gopls.setup{
|
||||
cmd = {"gopls", "serve"},
|
||||
filetypes = {"go", "gomod"},
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
-- C/C++
|
||||
lspconfig.clangd.setup{}
|
||||
|
||||
-- Arduino (C)
|
||||
lspconfig.arduino_language_server.setup{}
|
||||
|
||||
-- Lua
|
||||
lspconfig.lua_ls.setup{
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {globals = {'vim', 'opts'}},
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Rust
|
||||
lspconfig.rust_analyzer.setup{}
|
||||
|
||||
-- Python
|
||||
lspconfig.pylsp.setup{}
|
||||
|
||||
-- TypeScript
|
||||
lspconfig.tsserver.setup{}
|
||||
|
||||
-- Fix virtual text going off screen
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
severity_sort = false,
|
||||
})
|
||||
|
||||
-- creating key mappings
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(ev)
|
||||
-- custom colors
|
||||
vim.cmd('hi DiagnosticUnderlineError cterm=undercurl')
|
||||
vim.cmd('hi DiagnosticUnderlineWarn cterm=undercurl')
|
||||
vim.cmd('hi DiagnosticUnderlineInfo cterm=undercurl')
|
||||
vim.cmd('hi DiagnosticUnderlineHint cterm=undercurl')
|
||||
vim.cmd('hi DiagnosticUnderlineOk cterm=undercurl')
|
||||
-- key mappings
|
||||
local opts = { buffer = ev.buf,}
|
||||
-- error viewing
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
|
||||
-- def viewing/rename
|
||||
vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
|
||||
-- auto hover for error viewing
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
opts = {
|
||||
buffer = ev.buf,
|
||||
focusable = false,
|
||||
border = 'rounded',
|
||||
source = 'always',
|
||||
prefix = ' ',
|
||||
scope = 'cursor',
|
||||
close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user