Compare commits

...

5 Commits

Author SHA1 Message Date
9e341ec60b
feat(nvim): add another keybind to open buffer list in telescope
All checks were successful
Check Formatting of Files / Check-Formatting (push) Successful in 1m8s
2024-09-02 07:08:47 -05:00
237ac15a93
refactor(nvim): remove bufferline from statusline 2024-09-02 07:08:35 -05:00
d8f46bf4e3
feat(nvim): add orgmode clocked task to statusline 2024-09-02 07:08:23 -05:00
4c2d469454
feat(nvim): add words to spellfile 2024-09-02 07:07:50 -05:00
2b2f0c413c
feat(nvim): synchronize orgmode files between nvim instances 2024-09-02 07:07:27 -05:00
5 changed files with 148 additions and 168 deletions

View File

@ -262,8 +262,7 @@ return {
end,
}, {
provider = seps.full.right .. " ",
hl = function(self)
local bg = self.bg_color_right
hl = function()
if conditions.is_active() then
return { fg = colors.sumiInk4, bg = colors.carpYellow }
else
@ -292,147 +291,6 @@ return {
end,
})
local buffer_hl = {
active = {
fg = colors.fujiWhite,
bg = colors.sumiInk4,
},
inactive = {
fg = colors.fujiGray,
bg = colors.sumiInk3,
},
}
local StatusLineBufnr = {
provider = function(self)
return tostring(self.bufnr) .. ". "
end,
hl = "Comment",
}
-- we redefine the filename component, as we probably only want the tail and not the relative path
local StatusLineFileName = {
init = function(self)
if self.filename:match("^term://.*") then
self.lfilename = self.filename:gsub(".*:", "")
else
self.lfilename = vim.fn.fnamemodify(self.filename, ":~:.")
end
if self.lfilename == "" then
self.lfilename = "[No Name]"
end
end,
flexible = 2,
{
provider = function(self)
return self.lfilename
end,
},
{
provider = function(self)
return vim.fn.pathshorten(self.lfilename)
end,
},
hl = function(self)
local fg
if self.is_active then
fg = buffer_hl.active.fg
else
fg = buffer_hl.inactive.fg
end
return { bold = self.is_active or self.is_visible, italic = true, fg = fg }
end,
}
-- this looks exactly like the FileFlags component that we saw in
-- #crash-course-part-ii-filename-and-friends, but we are indexing the bufnr explicitly
-- also, we are adding a nice icon for terminal buffers.
local StatusLineFileFlags = {
{
condition = function(self)
return vim.bo[self.bufnr].modified
end,
provider = "",
hl = { fg = colors.springGreen },
},
{
condition = function(self)
return not vim.bo[self.bufnr].modifiable or vim.bo[self.bufnr].readonly
end,
provider = "",
hl = { fg = colors.roninYellow },
},
}
-- Here the filename block finally comes together
local StatusLineFileNameBlock = {
init = function(self)
self.filename = vim.api.nvim_buf_get_name(self.bufnr)
end,
hl = function(self)
if self.is_active then
return buffer_hl.active
else
return buffer_hl.inactive
end
end,
on_click = {
callback = function(_, minwid, _, button)
if button == "m" then -- close on mouse middle click
vim.schedule(function()
vim.api.nvim_buf_delete(minwid, { force = false })
end)
else
vim.api.nvim_win_set_buf(0, minwid)
end
end,
minwid = function(self)
return self.bufnr
end,
name = "heirline_tabline_buffer_callback",
},
StatusLineBufnr,
FileIcon, -- turns out the version defined in #crash-course-part-ii-filename-and-friends can be reutilized as is here!
StatusLineFileName,
StatusLineFileFlags,
}
-- The final touch!
local StatusLineBufferBlock = {
{
provider = seps.full.left,
hl = function(self)
local fg
if self.is_active then
fg = buffer_hl.active.bg
else
fg = buffer_hl.inactive.bg
end
return { fg = fg, bg = utils.get_highlight("StatusLine").bg }
end,
},
StatusLineFileNameBlock,
{
provider = seps.full.right,
hl = function(self)
local fg
if self.is_active then
fg = buffer_hl.active.bg
else
fg = buffer_hl.inactive.bg
end
return { fg = fg, bg = utils.get_highlight("StatusLine").bg }
end,
},
}
-- and here we go
local BufferLine = utils.make_buflist(
StatusLineBufferBlock,
-- left truncation, optional (defaults to "<")
{ provider = "", hl = { fg = colors.katanaGray, bg = utils.get_highlight("StatusLine").bg } },
{ provider = "", hl = { fg = colors.katanaGray, bg = utils.get_highlight("StatusLine").bg } }
)
local Tabpage = {
static = {
num_mappings = {},
@ -693,6 +551,7 @@ return {
},
{
provider = function()
---@diagnostic disable-next-line: undefined-field
return (vim.b.ufo_foldlevel or vim.opt_local.foldlevel:get()) .. " "
end,
hl = {
@ -760,6 +619,80 @@ return {
vim.opt.showcmdloc = "statusline"
local org = require("orgmode")
local Orgmode = {
condition = function()
return org.initialized and org.clock.clocked_headline and org.clock.clocked_headline:is_clocked_in()
end,
update = function(self)
local time = os.time()
self.last_updated = self.last_updated or time
if time - self.last_updated >= 1 then
self.last_updated = time
return true
end
end,
margin(1),
{
provider = seps.full.left,
hl = {
fg = colors.sakuraPink,
bg = utils.get_highlight("StatusLine").bg,
},
},
{
provider = "",
hl = {
fg = colors.sumiInk0,
bg = colors.sakuraPink,
},
},
{
provider = seps.full.right .. " ",
hl = {
fg = colors.sakuraPink,
bg = colors.sumiInk4,
},
},
{
hl = {
fg = colors.sakuraPink,
bg = colors.sumiInk4,
},
provider = function()
local headline = org.clock.clocked_headline
if not headline then
return
end
local clocked_time = headline:get_logbook():get_total_with_active():to_string()
local effort = headline:get_property("effort")
local time_elapsed = ""
if effort then
time_elapsed = ("[%s/%s]"):format(clocked_time, effort)
else
time_elapsed = ("[%s]"):format(clocked_time)
end
-- Get the title and remove some org syntax from it
local title = headline:get_title():gsub("[~/*_=+]", "")
local message = ("%s %s"):format(time_elapsed, title)
if #message > 60 then
message = message:sub(1, 65) .. ""
end
return message
end,
},
{
provider = seps.full.right .. " ",
hl = {
fg = colors.sumiInk4,
bg = utils.get_highlight("StatusLine").bg,
},
},
}
return {
statusline = {
{
@ -937,7 +870,6 @@ return {
},
},
},
margin(1),
{
condition = conditions.is_git_repo,
@ -947,7 +879,7 @@ return {
or self.status_dict.removed ~= 0
or self.status_dict.changed ~= 0
end,
margin(1),
{
provider = seps.full.left,
hl = {
@ -1026,23 +958,11 @@ return {
},
},
},
Orgmode,
-- Align Right
{
provider = "%=",
},
BufferLine,
{
provider = seps.full.left,
hl = { fg = colors.roninYellow, bg = utils.get_highlight("StatusLine").bg },
},
{
provider = " 󱧶 ",
hl = { fg = colors.sumiInk0, bg = colors.roninYellow },
},
{
provider = seps.full.right,
hl = { fg = colors.roninYellow, bg = utils.get_highlight("StatusLine").bg },
},
TabPages,
},
winbar = {

View File

@ -7,21 +7,24 @@ return {
{ "<leader>o", desc = "> Org" },
},
config = function()
-- Setup orgmode
require("orgmode").setup({
local org = require("orgmode")
local agenda_globs = {
"~/Git/College/*",
"~/Git/College/*/*",
"~/Git/Projects/Blog/*",
"~/Git/Projects/Blog/docs/**/*",
"~/Notes/**/*",
"~/.config/home-manager/*",
"~/.config/home-manager/docs/**/*",
vim.fn.stdpath("config") .. "/**/*",
}
org.setup({
mappings = {
agenda = {
org_agenda_filter = "F",
},
},
org_agenda_files = {
"~/Git/College/**/*",
"~/Git/Projects/**/*",
"~/Notes/**/*",
"~/.config/home-manager/*",
"~/.config/home-manager/docs/**/*",
vim.fn.stdpath("config") .. "/**/*",
},
org_agenda_files = agenda_globs,
notifications = {
enabled = true,
cron_enabled = true,
@ -94,6 +97,61 @@ return {
vim.api.nvim_set_hl(0, "org_bold_delimiter", { link = "@punctuation.delimiter" })
vim.api.nvim_set_hl(0, "org_underline_delimiter", { link = "@punctuation.delimiter" })
vim.api.nvim_set_hl(0, "org_strikethrough_delimiter", { link = "@punctuation.delimiter" })
-- NOTE: Everything below is an attempt to get orgmode to sync between different Neovim
-- instaces. Ideally Orgmode would write to a central state file using Mutexes, but it
-- doesn't. Thus my shitty code below.
local watched_dirs = {}
local function watch_dir(dir)
local fs_watch = vim.uv.new_fs_event()
if not fs_watch then
error("Failed to create a fs watch for dir: " .. dir)
end
dir = vim.fn.fnamemodify(dir, ":p")
if dir:sub(-1) == "/" then
dir = dir:sub(1, -2)
end
if vim.tbl_contains(watched_dirs, dir) then
return
end
table.insert(watched_dirs, dir)
fs_watch:start(
dir,
{},
vim.schedule_wrap(function(_, fpath, _)
fpath = dir .. "/" .. fpath
if vim.fn.isdirectory(fpath) == 1 and not vim.tbl_contains(watched_dirs, fpath) then
watch_dir(fpath)
return
end
if vim.fn.fnamemodify(fpath, ":e") == "org" then
org.files:load(true)
org.clock:init()
end
end)
)
end
vim.defer_fn(function()
vim.wait(1000, function()
return org.initialized
end)
vim.iter(agenda_globs)
:map(function(glob)
glob = vim.fn.fnamemodify(glob, ":p")
local globs = vim.fn.glob(vim.fn.fnamemodify(glob, ":p"), false, true)
local base_glob_dir = glob:gsub("*/", ""):gsub("*", "")
table.insert(globs, base_glob_dir)
return globs
end)
:flatten()
:filter(function(f)
return vim.fn.isdirectory(f) == 1
end)
:map(watch_dir)
end, 1000)
end,
},
{

View File

@ -36,6 +36,7 @@ return {
{ "<leader>tgc", ":Telescope git_commits<CR>", desc = "Telescope: Git Commits", silent = true },
{ "<leader>tgb", ":Telescope git_branches<CR>", desc = "Telescope: Git Branches", silent = true },
{ "<leader>tf", ":Telescope find_files<CR>", desc = "Telescope: Find Files", silent = true },
{ "<leader>j", ":Telescope buffers<CR>", desc = "Telescope: Buffers", silent = true },
{ "<leader>tb", ":Telescope buffers<CR>", desc = "Telescope: Buffers", silent = true },
{ "<leader>th", ":Telescope help_tags<CR>", desc = "Telescope: Help Tags", silent = true },
{ "<leader>to", ":Telescope oldfiles<CR>", desc = "Telescope: Recent Files", silent = true },

View File

@ -332,3 +332,4 @@ Postgresql
Stylix
stylix
logrotate
cortisol