more stuff

This commit is contained in:
2025-09-16 00:34:25 -04:00
parent 9c7c46855c
commit 72d99537bf
9 changed files with 195 additions and 26 deletions

View File

@@ -12,7 +12,7 @@ local java_dap_install = core.mason.get_pkg_path("java-debug-adapter")
-- make sure to check if things with 💀 need updating -- make sure to check if things with 💀 need updating
local config = { local config = {
cmd = { cmd = {
"java", -- 💀 "/usr/lib/jvm/openjdk21/bin/java", -- 💀
"-jar", "-jar",
vim.fn.glob(vim.fs.joinpath(jdtls_install, "plugins/org.eclipse.equinox.launcher_*.jar")), vim.fn.glob(vim.fs.joinpath(jdtls_install, "plugins/org.eclipse.equinox.launcher_*.jar")),
"-configuration", jdtls_install.."config_linux", "-configuration", jdtls_install.."config_linux",

View File

@@ -30,4 +30,12 @@ auto("BufWritePre", {
end end
}) })
-- FIXME: disable for now until I can do more work and make it work better
-- auto({ "BufEnter", "CursorMoved", "CursorMovedI" }, {
-- group = bufcheck,
-- callback = function()
-- core.color.todo_comments()
-- end
-- })
core.color.setup_termbg_sync() core.color.setup_termbg_sync()

View File

@@ -53,10 +53,14 @@ map("i", "<C-s>", "<C-x><C-s>", { desc = "Trigger spell completion" })
map("n", "<C-s>", lz "<cmd>se spell<CR>ea<C-x><C-s><cmd>se nospell<CR>", { desc = "Trigger spell completion" }) map("n", "<C-s>", lz "<cmd>se spell<CR>ea<C-x><C-s><cmd>se nospell<CR>", { desc = "Trigger spell completion" })
-- quickfix -- quickfix
map("n", "<M-j>", "<cmd>cnext<CR>", { desc = "qf next" }) map("n", "<M-j>", lz "<cmd>cnext<CR>zz", { desc = "qf next" })
map("n", "<M-k>", "<cmd>cprev<CR>", { desc = "qf prev" }) map("n", "<M-k>", lz "<cmd>cprev<CR>zz", { desc = "qf prev" })
map("n", "<M-c>", "<cmd>cclose<CR>", { desc = "qf close" }) map("n", "<M-c>", "<cmd>cclose<CR>", { desc = "qf close" })
map("n", "<M-x>", "<cmd>cope<CR>", { desc = "qf open" }) map("n", "<M-x>", lz(function()
local win = vim.api.nvim_get_current_win()
vim.cmd.cope()
vim.api.nvim_set_current_win(win)
end), { desc = "qf open" })
-- man pages -- man pages
map("n", "<C-k>", "<cmd>Man<CR>") map("n", "<C-k>", "<cmd>Man<CR>")

View File

@@ -35,9 +35,11 @@ vim.o.winborder = "solid"
-- wild menus -- wild menus
vim.o.ph = 20 vim.o.ph = 20
vim.o.wic = true vim.o.wic = true
vim.o.wop = "fuzzy,pum,tagfile" vim.o.wop = "fuzzy,pum"
vim.o.wim = "noselect:lastused,full"
-- completion -- completion
vim.o.cpt = ".,w,b,u,d,i"
vim.o.cot = "menu,menuone,noinsert,fuzzy,popup" vim.o.cot = "menu,menuone,noinsert,fuzzy,popup"
vim.o.cia = "kind,abbr,menu" vim.o.cia = "kind,abbr,menu"
-- waiting for https://github.com/neovim/neovim/pull/25541 to land -- waiting for https://github.com/neovim/neovim/pull/25541 to land

View File

@@ -39,12 +39,23 @@ return { "mellow-theme/mellow.nvim",
-- telescope styling so I can see when coding outside (real) -- telescope styling so I can see when coding outside (real)
["TelescopeResultsNormal"] = { bg = c.bg_dark }, ["TelescopeResultsNormal"] = { bg = c.bg_dark },
["TelescopeResultsBorder"] = { link = "TelescopeResultsNormal" }, ["TelescopeResultsBorder"] = { link = "TelescopeResultsNormal" },
["TelescopeResultsTitle"] = { ["TelescopeResultsTitle"] = { bg = c.bg, fg = c.bg },
bg = core.color.copyhl("TelescopeResultsNormal").background,
fg = core.color.copyhl("TelescopeResultsNormal").background
},
["TelescopePreviewNormal"] = { link = "NormalFloat" }, ["TelescopePreviewNormal"] = { link = "NormalFloat" },
["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" } ["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" },
-- add highlight groups for my todo highlighting
["TodoTODO"] = { link = "DiagnosticHint" },
["TodoTODOBG"] = { fg = c.bg, bg = c.cyan, bold = true },
["TodoTODOSIGN"] = { fg = c.cyan, bg = c.cyan, bold = true },
["TodoBUG"] = { link = "DiagnosticError" },
["TodoBUGBG"] = { fg = c.bg, bg = c.red, bold = true },
["TodoBUGSIGN"] = { fg = c.red, bg = c.red, bold = true },
["TodoTEST"] = { link = "DiagnosticInfo" },
["TodoTESTBG"] = { fg = c.bg, bg = c.blue, bold = true },
["TodoTESTSIGN"] = { fg = c.blue, bg = c.blue, bold = true },
["TodoWARN"] = { link = "DiagnosticWarn" },
["TodoWARNBG"] = { fg = c.bg, bg = c.yellow, bold = true },
["TodoWARNSIGN"] = { fg = c.yellow, bg = c.yellow, bold = true },
} }
end end
end end

View File

@@ -6,19 +6,19 @@ local M = {}
---@return table ---@return table
function M.copyhl(hlgroup, namespace) function M.copyhl(hlgroup, namespace)
namespace = namespace or 0 namespace = namespace or 0
local res = {} local res = {
["foreground"] = "#ff0000",
["background"] = "#ff0000",
["special"] = "#ff0000"
}
local ok, hl = pcall(vim.api.nvim_get_hl, namespace, { local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
name = hlgroup, name = hlgroup,
create = false create = false
}) })
if not ok then if not ok then
-- return default -- return error colors
return { return res
["foreground"] = "#000000",
["background"] = "#000000",
["special"] = "#000000"
}
end end
for _, key in pairs({ "foreground", "background", "special" }) do for _, key in pairs({ "foreground", "background", "special" }) do
@@ -29,6 +29,136 @@ function M.copyhl(hlgroup, namespace)
return res return res
end end
local todo_comments_conf = {
TODO = {
-- TODO:
-- NOTE:
-- INFO:
"TODO", "NOTE", "INFO",
hlgroup = "TodoTODO"
},
BUG = {
-- BUG:
-- FIXME:
"BUG", "FIXME",
hlgroup = "TodoBUG"
},
TEST = {
-- TEST:
-- PERF:
"TEST", "PERF",
hlgroup = "TodoTEST"
},
WARN = {
-- WARN:
-- HACK:
"WARN", "HACK",
hlgroup = "TodoWARN"
}
}
local todo_hl_ns = vim.api.nvim_create_namespace("todo_highlights")
--- highlight todo comments in the current buffer.
--- No I won't use folke's super bloated plugin.
---
--- TODO: make this work with coniguious comment blocks like this one.
--- currently this line won't be highlighted, but I'd like it to be
---
--- TEST: We could make this a plugin called ts-todo-hl or smthn like that, but
--- I'd be willing to bet no one would use it cause everyone loves folke too
--- much
function M.todo_comments()
local bufnr = vim.api.nvim_win_get_buf(0)
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
if not ok or not parser then
return
end
-- Construct the query for comments.
-- We're using treesitter so that I don't have to use external tooling.
local ok, comment_query = pcall(vim.treesitter.query.parse,
parser:lang(),
"(comment) @comment"
)
if not ok then
return
end
parser:parse(false, function(err, trees)
if err then
return
end
local root = trees[1]:root()
for _, match in comment_query:iter_matches(root, bufnr, 0, -1) do
for _, nodes in pairs(match) do
for _, node in ipairs(nodes) do
if not node or node:type() ~= "comment" then
goto continue
end
local text = vim.treesitter.get_node_text(node, bufnr)
-- TODO: instead of doing everything relative to the node we at this
-- point should obtain the node start and use a for loop to iterate
-- over the lines until we're no longer in a comment. This should
-- make dealing with comment blocks easier, and working with these
-- multiline comments easier.
for _, type in pairs(todo_comments_conf) do
for _, v in ipairs(type) do
local s, e = string.find(text, v..":")
if not s or not e then
s, e = string.find(text, v.."%b():")
end
if s and e then
local s_row, s_col = node:start()
local e_row, e_col = node:end_()
-- ensure that our string indicies are relative to the line
s = s + s_col
e = e + s_col
ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, todo_hl_ns, s_row, e, {
hl_mode = "replace",
hl_group = type.hlgroup,
end_col = e_col,
end_row = e_row
})
if not ok then
print("fg", s_row, e, e_col, e_row)
print("fg", err)
end
ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, todo_hl_ns, s_row, s - 2, {
hl_mode = "replace",
hl_group = type.hlgroup.."BG",
end_col = e - 1,
end_row = s_row
})
if not ok then
print("bg", s_row, s - 2, e - 1, s_row)
print("bg", err)
end
ok, err = pcall(vim.api.nvim_buf_set_extmark, bufnr, todo_hl_ns, s_row, e - 1, {
hl_mode = "replace",
hl_group = type.hlgroup.."SIGN",
end_col = e,
end_row = s_row
})
if not ok then
print("sn", s_row, e - 1, e, s_row)
print("sn", err)
end
end
end
end
::continue::
end
end
end
end)
end
-- Source: 'runtime/lua/vim/_defaults.lua' in Neovim source -- Source: 'runtime/lua/vim/_defaults.lua' in Neovim source
local function parse_osc11(x) local function parse_osc11(x)
local r, g, b = x:match('^\027%]11;rgb:(%x+)/(%x+)/(%x+)$') local r, g, b = x:match('^\027%]11;rgb:(%x+)/(%x+)/(%x+)$')

View File

@@ -8,6 +8,8 @@ local function on_list(opts)
-- get to the closest reference to the cursor (likely the one gr or gd was -- get to the closest reference to the cursor (likely the one gr or gd was
-- called on) -- called on)
--
-- TODO: switch this to use opts.idx?
local closest, distance = 1, false local closest, distance = 1, false
for i, item in ipairs(opts.items) do for i, item in ipairs(opts.items) do
if item.filename and vim.fn.expand("%:p") == item.filename then if item.filename and vim.fn.expand("%:p") == item.filename then

View File

@@ -26,11 +26,12 @@ auto('LspAttach', {
pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id }) pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id })
end end
-- enable type formatting which allows lsps to modify text while you're -- disabled for now cause I don't like it
-- typing for example if you insert {} in a string in python basedpyright -- -- enable type formatting which allows lsps to modify text while you're
-- will change the string to a format string -- -- typing for example if you insert {} in a string in python basedpyright
if client:supports_method('textDocument/onTypeFormatting') then -- -- will change the string to a format string
pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id }) -- if client:supports_method('textDocument/onTypeFormatting') then
end -- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id })
-- end
end end
}) })

View File

@@ -52,11 +52,22 @@ end
--- Make an action lazy. This is mostly useful for keybinds which do a lot and --- Make an action lazy. This is mostly useful for keybinds which do a lot and
--- you want to make sure the screen doesn't flash --- you want to make sure the screen doesn't flash
---@param txt string the action ---@param txt string|function the action
---@return string lazified ---@return string|function lazified
---@nodiscard ---@nodiscard
function M.lz(txt) function M.lz(txt)
return "<cmd>se lz<CR>"..txt.."<cmd>se lz!<CR>" if type(txt) == "string" then
return "<cmd>se lz<CR>"..txt.."<cmd>se lz!<CR>"
elseif type(txt) == "function" then
return function()
vim.cmd.se("lz")
-- gotta make sure we can always unset lz
pcall(txt)
vim.cmd.se("lz!")
end
else
return txt
end
end end
return M return M