Compare commits

10 Commits

Author SHA1 Message Date
597de90d41 add lsp document symbols telescope keybind 2025-10-16 21:38:01 -04:00
47b0e795cd fix highlighting 2025-10-16 21:37:04 -04:00
a96cb4bef7 ooh a fancy border that actually looks good 2025-10-16 21:36:41 -04:00
06a9c9e45d comment a problem for future me 2025-10-16 21:36:06 -04:00
55f11ab1ba add basedpyright lsp configuration 2025-10-16 21:34:49 -04:00
43b4369041 A while ago I decided to try out tabs instead of spaces. Bad idea...
It just doesn't make sense, why would you choose to use tabs when you
really get nothing out of them. I've heard arguments that everyone get's
what they want in terms of formatting, but that doesn't really feel
accurate because now I've got code looking messy depending on where it
is you're looking at it on which really sucks. I'm going back to two
space indentation and if a project really wants to use something else
they can setup a formatter and/or .editorconfig file. If you read this
rant, respectfully, what are you doing with your time.
2025-09-24 01:16:40 -04:00
baec11b559 remove formatting 2025-09-22 13:12:02 -04:00
72d99537bf more stuff 2025-09-16 00:34:25 -04:00
9c7c46855c protect calls to lsp/wtf funcs as most of them are only on dev builds atm 2025-09-02 21:58:57 -04:00
86d7f17341 not sure why I forgot to update this comment the colors were removed...
a while ago
2025-09-02 11:06:13 -04:00
13 changed files with 227 additions and 68 deletions

View File

@@ -1,3 +1,4 @@
-- TODO: find out why this doesn't work when java isn't the first filetype I open
local map, auto = core.misc.map, core.misc.auto local map, auto = core.misc.map, core.misc.auto
local ok, jdtls = pcall(require, "jdtls") local ok, jdtls = pcall(require, "jdtls")
@@ -12,7 +13,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

@@ -0,0 +1,17 @@
return {
settings = {
python = {
pythonPath = "python"
},
basedpyright = {
reportAny = false,
analysis = {
autoSearchPaths = true,
diagnosticMode = "workspace",
inlayHints = {
callArgumentNames = true
}
}
}
}
}

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

@@ -12,6 +12,7 @@ vim.o.cc = "80"
-- indents + tabs -- indents + tabs
local tabwidth = 2 local tabwidth = 2
vim.o.et = true
vim.o.ts = tabwidth vim.o.ts = tabwidth
vim.o.sw = tabwidth vim.o.sw = tabwidth
vim.o.sts = -1 vim.o.sts = -1
@@ -29,15 +30,18 @@ vim.o.udf = true
-- searching -- searching
vim.o.ic = true vim.o.ic = true
-- make windows look nice -- make windows look nice wrapped in pcall cause it's causing my setup to go
vim.o.winborder = "solid" -- bezerk inside of git commit buffers
pcall(function() vim.o.winborder = '▄,▄,▄,█,▀,▀,▀,█' end)
-- 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
@@ -77,7 +81,7 @@ do -- statusline
"%r", -- readonly flag "%r", -- readonly flag
"%=", -- seperate left and right side "%=", -- seperate left and right side
-- print out the number of lsp clients attached with nice colors :) -- print out the number of lsp clients attached
"λ"..#vim.lsp.get_clients({ bufnr = 0 }), " ", "λ"..#vim.lsp.get_clients({ bufnr = 0 }), " ",
"%<", -- we can start truncating here (I want to keep the file name) "%<", -- we can start truncating here (I want to keep the file name)

View File

@@ -1,5 +1,3 @@
local nonels_augroup = core.misc.augroup("nullls formatting")
return { return {
{ "neovim/nvim-lspconfig", { "neovim/nvim-lspconfig",
reqs = { reqs = {
@@ -16,7 +14,6 @@ return {
"jdtls", "jdtls",
"lua_ls", "lua_ls",
"basedpyright", "basedpyright",
"black",
"debugpy" "debugpy"
} }
} }
@@ -41,33 +38,4 @@ return {
{ "mfussenegger/nvim-jdtls", { "mfussenegger/nvim-jdtls",
reqs = "mfussenegger/nvim-dap" reqs = "mfussenegger/nvim-dap"
}, },
{ "nvimtools/none-ls.nvim",
lazy = dep_short.ft("python"),
load = function()
local null_ls = require("null-ls")
null_ls.setup {
sources = {
null_ls.builtins.formatting.black,
},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({
group = nonels_augroup,
buffer = bufnr
})
core.misc.auto("BufWritePre", {
group = nonels_augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end
})
end
end
}
end
}
} }

View File

@@ -18,7 +18,7 @@ return { "mellow-theme/mellow.nvim",
-- make floats darker -- make floats darker
["NormalFloat"] = { fg = c.fg, bg = "#111111" }, ["NormalFloat"] = { fg = c.fg, bg = "#111111" },
["FloatBorder"] = { link = "NormalFloat" }, ["FloatBorder"] = { fg = "#111111" },
-- Make pmenu look good -- Make pmenu look good
["Pmenu"] = { link = "NormalFloat" }, ["Pmenu"] = { link = "NormalFloat" },
@@ -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

@@ -27,10 +27,10 @@ return { "stevearc/oil.nvim",
}, },
-- fix the damn border -- fix the damn border
confirmation = { border = vim.o.winborder }, confirmation = { winborder = vim.o.winborder },
progress = { border = vim.o.winborder }, progress = { winborder = vim.o.winborder },
ssh = { border = vim.o.winborder }, ssh = { winborder = vim.o.winborder },
keymaps_help = { border = vim.o.winborder } keymaps_help = { winborder = vim.o.winborder }
} }
map("n", "-", "<cmd>Oil<CR>") map("n", "-", "<cmd>Oil<CR>")

View File

@@ -36,6 +36,7 @@ return { "nvim-telescope/telescope.nvim",
load:keymap("n", "<leader>f") load:keymap("n", "<leader>f")
load:keymap("n", "<leader>s") load:keymap("n", "<leader>s")
load:keymap("n", "<leader>i") load:keymap("n", "<leader>i")
load:keymap("n", "<leader>;")
load:keymap("n", "<leader>tc") load:keymap("n", "<leader>tc")
load:keymap("n", "<leader>tp") load:keymap("n", "<leader>tp")
end, end,
@@ -141,6 +142,7 @@ return { "nvim-telescope/telescope.nvim",
desc = "Find strings." desc = "Find strings."
}) })
map("n", "<leader>i", telebuilt.help_tags, { desc = "find help tags." }) map("n", "<leader>i", telebuilt.help_tags, { desc = "find help tags." })
map("n", "<leader>;", telebuilt.lsp_document_symbols, { desc = "find doc symbols." })
-- find over specific directories -- find over specific directories
map("n", "<leader>tc", function() map("n", "<leader>tc", function()

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

@@ -16,21 +16,22 @@ auto('LspAttach', {
-- highlight color codes via lsp (supported by cssls) -- highlight color codes via lsp (supported by cssls)
-- #ff0000 -- #ff0000
if client:supports_method('textDocument/documentColor') then if client:supports_method('textDocument/documentColor') then
vim.lsp.document_color.enable(true, ctx.buf) pcall(vim.lsp.document_color.enable, true, ctx.buf)
end end
-- enable linked editing this allows lsps to modify things like html tags -- enable linked editing this allows lsps to modify things like html tags
-- for example when you change <p> to <a> </p> will be changed by the lsp -- for example when you change <p> to <a> </p> will be changed by the lsp
-- to </a> -- to </a>
if client:supports_method('textDocument/linkedEditingRange') then if client:supports_method('textDocument/linkedEditingRange') then
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
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