not quite sure what I've done here

This commit is contained in:
Squibid 2025-11-22 17:22:23 -05:00
parent b22873f45f
commit 83aaa5aef3
Signed by: squibid
GPG key ID: BECE5684D3C4005D
18 changed files with 392 additions and 392 deletions

View file

@ -13,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 = {
"/usr/lib/jvm/openjdk21/bin/java", -- 💀 "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

@ -14,7 +14,7 @@ return {
checkThirdParty = "ApplyInMemory", checkThirdParty = "ApplyInMemory",
library = { library = {
vim.env.VIMRUNTIME, vim.env.VIMRUNTIME,
"${3rd}/luv/library" "${3rd}/luv/library"
} }
} }
} }

View file

@ -31,10 +31,10 @@ auto("BufWritePre", {
}) })
auto({ "BufEnter", "CursorMoved", "CursorMovedI" }, { auto({ "BufEnter", "CursorMoved", "CursorMovedI" }, {
group = bufcheck, group = bufcheck,
callback = function() callback = function()
core.todo.todo_comments() core.todo.todo_comments()
end end
}) })
core.color.setup_termbg_sync() core.color.setup_termbg_sync()

View file

@ -3,9 +3,9 @@ local map, lz = core.misc.map, core.misc.lz
--- feed keys as userinput --- feed keys as userinput
---@param keys string keys ---@param keys string keys
local function feedkeys(keys) local function feedkeys(keys)
vim.api.nvim_feedkeys( vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes(keys, true, false, true), vim.api.nvim_replace_termcodes(keys, true, false, true),
"n", true) "n", true)
end end
-- vim binds -- vim binds
@ -27,27 +27,27 @@ map("n", "<C-i>", lz "<C-i>zz")
-- trigger completion menu -- trigger completion menu
-- (stolen from https://gist.github.com/MariaSolOs/2e44a86f569323c478e5a078d0cf98cc) -- (stolen from https://gist.github.com/MariaSolOs/2e44a86f569323c478e5a078d0cf98cc)
map("i", "<C-n>", function() map("i", "<C-n>", function()
-- if the completion menu is already visible just go to the next item -- if the completion menu is already visible just go to the next item
if vim.fn.pumvisible() ~= 0 then if vim.fn.pumvisible() ~= 0 then
feedkeys("<C-n>") feedkeys("<C-n>")
else else
if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then
vim.lsp.completion.get() vim.lsp.completion.get()
else else
if vim.bo.omnifunc == "" then if vim.bo.omnifunc == "" then
feedkeys("<C-x><C-n>") feedkeys("<C-x><C-n>")
else else
feedkeys("<C-x><C-o>") feedkeys("<C-x><C-o>")
end end
end end
end end
end, { desc = "Trigger/select next completion" }) end, { desc = "Trigger/select next completion" })
map("i", "<CR>", function() map("i", "<CR>", function()
if vim.fn.pumvisible() ~= 0 then if vim.fn.pumvisible() ~= 0 then
feedkeys("<C-e><CR>") feedkeys("<C-e><CR>")
else else
feedkeys("<CR>") feedkeys("<CR>")
end end
end, { desc = "prevent omnifunc from completing on <CR>" }) end, { desc = "prevent omnifunc from completing on <CR>" })
map("i", "<C-s>", "<C-x><C-s>", { desc = "Trigger spell completion" }) 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" })
@ -57,9 +57,9 @@ map("n", "<M-j>", lz "<cmd>cnext<CR>zz", { desc = "qf next" })
map("n", "<M-k>", lz "<cmd>cprev<CR>zz", { 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>", lz(function() map("n", "<M-x>", lz(function()
local win = vim.api.nvim_get_current_win() local win = vim.api.nvim_get_current_win()
vim.cmd.cope() vim.cmd.cope()
vim.api.nvim_set_current_win(win) vim.api.nvim_set_current_win(win)
end), { desc = "qf open" }) end), { desc = "qf open" })
-- man pages -- man pages

View file

@ -24,7 +24,7 @@ return {
load = function() load = function()
require("mason").setup { require("mason").setup {
ui = { ui = {
-- not sure why these are nerdfont icons by default -- not sure why these are nerdfont icons by default
icons = { icons = {
package_installed = "+", package_installed = "+",
package_pending = "?", package_pending = "?",

View file

@ -1,49 +1,49 @@
local map = core.misc.map local map = core.misc.map
return { "L3MON4D3/LuaSnip", return { "L3MON4D3/LuaSnip",
branch = "v2.*", branch = "v2.*",
config = function() config = function()
vim.cmd("make install_jsregexp") vim.cmd("make install_jsregexp")
end, end,
lazy = function(load) lazy = function(load)
load:keymap({"i", "s"}, "<c-a>") load:keymap({"i", "s"}, "<c-a>")
load:keymap({"i", "s"}, "<c-e>") load:keymap({"i", "s"}, "<c-e>")
load:keymap({"i", "s"}, "<c-j>") load:keymap({"i", "s"}, "<c-j>")
load:keymap({"i", "s"}, "<c-k>") load:keymap({"i", "s"}, "<c-k>")
load:auto("InsertEnter") load:auto("InsertEnter")
end, end,
load = function() load = function()
local ls = require("luasnip") local ls = require("luasnip")
-- replace the builtin snippet handler with luasnip so I get all my fancy -- replace the builtin snippet handler with luasnip so I get all my fancy
-- stuff -- stuff
vim.snippet.expand = ls.lsp_expand vim.snippet.expand = ls.lsp_expand
ls.config.setup { ls.config.setup {
keep_roots = true, keep_roots = true,
link_roots = true, link_roots = true,
link_children = true, link_children = true,
exit_roots = not true exit_roots = not true
} }
map({"i", "s"}, "<C-e>", ls.expand) map({"i", "s"}, "<C-e>", ls.expand)
map({"i", "s"}, "<C-j>", function() ls.jump(1) end) map({"i", "s"}, "<C-j>", function() ls.jump(1) end)
map({"i", "s"}, "<C-k>", function() ls.jump(-1) end) map({"i", "s"}, "<C-k>", function() ls.jump(-1) end)
map({"i", "s"}, "<C-a>", function() map({"i", "s"}, "<C-a>", function()
if ls.choice_active() then if ls.choice_active() then
ls.change_choice(1) ls.change_choice(1)
end end
end) end)
-- collect all snippets and add them -- collect all snippets and add them
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua",
true)) do true)) do
local fn = file:gsub("^.*/", ""):gsub("%.lua$", "") local fn = file:gsub("^.*/", ""):gsub("%.lua$", "")
local ret = require("snippets."..fn) local ret = require("snippets."..fn)
if type(ret) ~= "boolean" then if type(ret) ~= "boolean" then
ls.add_snippets(fn, ret, { key = fn }) ls.add_snippets(fn, ret, { key = fn })
end end
end end
end end
} }

View file

@ -20,14 +20,14 @@ return { "mellow-theme/mellow.nvim",
["NormalFloat"] = { fg = c.fg, bg = "#111111" }, ["NormalFloat"] = { fg = c.fg, bg = "#111111" },
["FloatBorder"] = { bg = "#111111" }, ["FloatBorder"] = { bg = "#111111" },
-- Make pmenu look good -- Make pmenu look good
["Pmenu"] = { link = "NormalFloat" }, ["Pmenu"] = { link = "NormalFloat" },
["PmenuSel"] = { link = "Normal" }, ["PmenuSel"] = { link = "Normal" },
["PmenuKind"] = { link = "@constant" }, ["PmenuKind"] = { link = "@constant" },
["PmenuKindSel"] = { ["PmenuKindSel"] = {
fg = core.color.copyhl("Comment").fg, fg = core.color.copyhl("Comment").fg,
bold = true bold = true
}, },
-- make diagnostics have an undercurl -- make diagnostics have an undercurl
["DiagnosticUnderlineError"] = { fg = c.red, undercurl = true }, ["DiagnosticUnderlineError"] = { fg = c.red, undercurl = true },
@ -43,19 +43,19 @@ return { "mellow-theme/mellow.nvim",
["TelescopePreviewNormal"] = { link = "NormalFloat" }, ["TelescopePreviewNormal"] = { link = "NormalFloat" },
["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" }, ["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" },
-- add highlight groups for my todo highlighting -- add highlight groups for my todo highlighting
["TodoTODO"] = { link = "DiagnosticHint" }, ["TodoTODO"] = { link = "DiagnosticHint" },
["TodoTODOBG"] = { fg = c.bg, bg = c.cyan, bold = true }, ["TodoTODOBG"] = { fg = c.bg, bg = c.cyan, bold = true },
["TodoTODOSIGN"] = { fg = c.cyan, bg = c.cyan, bold = true }, ["TodoTODOSIGN"] = { fg = c.cyan, bg = c.cyan, bold = true },
["TodoBUG"] = { link = "DiagnosticError" }, ["TodoBUG"] = { link = "DiagnosticError" },
["TodoBUGBG"] = { fg = c.bg, bg = c.red, bold = true }, ["TodoBUGBG"] = { fg = c.bg, bg = c.red, bold = true },
["TodoBUGSIGN"] = { fg = c.red, bg = c.red, bold = true }, ["TodoBUGSIGN"] = { fg = c.red, bg = c.red, bold = true },
["TodoTEST"] = { link = "DiagnosticInfo" }, ["TodoTEST"] = { link = "DiagnosticInfo" },
["TodoTESTBG"] = { fg = c.bg, bg = c.blue, bold = true }, ["TodoTESTBG"] = { fg = c.bg, bg = c.blue, bold = true },
["TodoTESTSIGN"] = { fg = c.blue, bg = c.blue, bold = true }, ["TodoTESTSIGN"] = { fg = c.blue, bg = c.blue, bold = true },
["TodoWARN"] = { link = "DiagnosticWarn" }, ["TodoWARN"] = { link = "DiagnosticWarn" },
["TodoWARNBG"] = { fg = c.bg, bg = c.yellow, bold = true }, ["TodoWARNBG"] = { fg = c.bg, bg = c.yellow, bold = true },
["TodoWARNSIGN"] = { fg = c.yellow, bg = c.yellow, bold = true }, ["TodoWARNSIGN"] = { fg = c.yellow, bg = c.yellow, bold = true },
} }
end end
end end

View file

@ -14,11 +14,11 @@ return { "stevearc/oil.nvim",
for i = 1, #permission_str do for i = 1, #permission_str do
local char = permission_str:sub(i, i) local char = permission_str:sub(i, i)
table.insert(hls, { ({ table.insert(hls, { ({
["-"] = "NonText", ["-"] = "NonText",
["r"] = "DiagnosticSignWarn", ["r"] = "DiagnosticSignWarn",
["w"] = "DiagnosticSignHint", ["w"] = "DiagnosticSignHint",
["x"] = "DiagnosticSignOk" ["x"] = "DiagnosticSignOk"
})[char], i - 1, i }) })[char], i - 1, i })
end end
return hls return hls
end, end,
@ -26,12 +26,12 @@ return { "stevearc/oil.nvim",
{ "size", highlight = "@number" } { "size", highlight = "@number" }
}, },
-- fix the damn border -- fix the damn border
confirmation = { winborder = vim.o.winborder }, confirmation = { winborder = vim.o.winborder },
progress = { winborder = vim.o.winborder }, progress = { winborder = vim.o.winborder },
ssh = { winborder = vim.o.winborder }, ssh = { winborder = vim.o.winborder },
keymaps_help = { winborder = vim.o.winborder } keymaps_help = { winborder = vim.o.winborder }
} }
map("n", "-", "<cmd>Oil<CR>") map("n", "-", "<cmd>Oil<CR>")
end end

View file

@ -1,10 +1,10 @@
return { "NickvanDyke/opencode.nvim", return { "NickvanDyke/opencode.nvim",
load = function() load = function()
core.misc.map("n", "<leader>oa", function() core.misc.map("n", "<leader>oa", function()
require("opencode").ask() require("opencode").ask()
end, { desc = "Ask opencode" }) end, { desc = "Ask opencode" })
core.misc.map("v", "<leader>oa", function() core.misc.map("v", "<leader>oa", function()
require("opencode").ask("@selection: ") require("opencode").ask("@selection: ")
end, { desc = "Ask opencode about selection" }) end, { desc = "Ask opencode about selection" })
end end
} }

View file

@ -44,72 +44,72 @@ return { "nvim-telescope/telescope.nvim",
load = function() load = function()
local telescope = require("telescope") local telescope = require("telescope")
local actions = require("telescope.actions") local actions = require("telescope.actions")
local action_state = require("telescope.actions.state") local action_state = require("telescope.actions.state")
local function send_limited_to_qflist_and_open(prompt_bufnr) local function send_limited_to_qflist_and_open(prompt_bufnr)
local picker = action_state.get_current_picker(prompt_bufnr) local picker = action_state.get_current_picker(prompt_bufnr)
local entries = {} local entries = {}
local max_items = 100 local max_items = 100
local count = 0 local count = 0
for entry in picker.manager:iter() do for entry in picker.manager:iter() do
if count >= max_items then if count >= max_items then
break break
end end
local filename = entry.path or entry.filename or entry.value local filename = entry.path or entry.filename or entry.value
local text = entry.text or entry.value local text = entry.text or entry.value
if not text then if not text then
if type(entry.value) == "table" then if type(entry.value) == "table" then
text = entry.value.text text = entry.value.text
else else
text = entry.value text = entry.value
end end
end end
local pattern local pattern
if not entry.lnum then if not entry.lnum then
if type(entry.display) == "string" then if type(entry.display) == "string" then
pattern = entry.display pattern = entry.display
elseif type(entry.ordinal) == "string" then elseif type(entry.ordinal) == "string" then
pattern = entry.ordinal pattern = entry.ordinal
elseif type(text) == "string" then elseif type(text) == "string" then
pattern = text pattern = text
else else
entry.lnum = 1 entry.lnum = 1
end end
end end
if filename then if filename then
table.insert(entries, { table.insert(entries, {
filename = filename, filename = filename,
text = text, text = text,
lnum = entry.lnum, lnum = entry.lnum,
col = entry.col, col = entry.col,
-- we try and put a pattern in based on the info we receive from -- we try and put a pattern in based on the info we receive from
-- telescope so that the qf list takes us to the correct place -- telescope so that the qf list takes us to the correct place
pattern = pattern pattern = pattern
}) })
count = count + 1 count = count + 1
end end
end end
if #entries > 0 then if #entries > 0 then
-- make sure errors get suppressed. I don't care -- make sure errors get suppressed. I don't care
pcall(vim.fn.setqflist, {}, " ", { pcall(vim.fn.setqflist, {}, " ", {
title = "Telescope Limited Results", title = "Telescope Limited Results",
items = entries items = entries
}) })
end end
actions.select_default(prompt_bufnr) actions.select_default(prompt_bufnr)
end end
telescope.setup { telescope.setup {
defaults = { defaults = {
layout_strategy = "bottom_pane", layout_strategy = "bottom_pane",
borderchars = { " ", " ", " ", " ", " ", " ", " ", " " }, borderchars = { " ", " ", " ", " ", " ", " ", " ", " " },
mappings = { mappings = {
i = { i = {
["<esc>"] = actions.close, ["<esc>"] = actions.close,
@ -119,11 +119,11 @@ return { "nvim-telescope/telescope.nvim",
} }
} }
}, },
pickers = { pickers = {
colorscheme = { colorscheme = {
enable_preview = true enable_preview = true
} }
}, },
extensions = { extensions = {
fzf = {} fzf = {}
} }
@ -154,6 +154,6 @@ return { "nvim-telescope/telescope.nvim",
} }
end, { desc = "find files in plugin directory" }) end, { desc = "find files in plugin directory" })
map("n", "<leader>tt", "<cmd>Telescope<CR>") map("n", "<leader>tt", "<cmd>Telescope<CR>")
end end
} }

View file

@ -49,11 +49,11 @@ return {
} }
} }
core.misc.map("n", "<leader><leader>t", function() core.misc.map("n", "<leader><leader>t", function()
pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", { pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", {
buf = vim.api.nvim_get_current_buf() buf = vim.api.nvim_get_current_buf()
})) }))
end) end)
end end
}, },
@ -77,7 +77,7 @@ return {
{ "windwp/nvim-ts-autotag", { "windwp/nvim-ts-autotag",
reqs = "nvim-treesitter/nvim-treesitter", reqs = "nvim-treesitter/nvim-treesitter",
disable = true, disable = true,
-- lazy = dep_short.auto({ "BufReadPre", "BufNewFile" }), -- lazy = dep_short.auto({ "BufReadPre", "BufNewFile" }),
load = function() load = function()
require("nvim-ts-autotag").setup {} require("nvim-ts-autotag").setup {}

View file

@ -7,10 +7,10 @@ local M = {}
function M.copyhl(hlgroup, namespace) function M.copyhl(hlgroup, namespace)
namespace = namespace or 0 namespace = namespace or 0
local res = { local res = {
["foreground"] = "#ff0000", ["foreground"] = "#ff0000",
["background"] = "#ff0000", ["background"] = "#ff0000",
["special"] = "#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,

View file

@ -8,8 +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? -- 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
@ -37,32 +37,32 @@ end
local group = misc.augroup("lsp.bind") local group = misc.augroup("lsp.bind")
auto("LspAttach", { auto("LspAttach", {
group = group, group = group,
callback = function(ctx) callback = function(ctx)
local list_opts = { on_list = on_list } local list_opts = { on_list = on_list }
local opts = { buffer = ctx.buf, nowait = true } local opts = { buffer = ctx.buf, nowait = true }
-- LSP actions -- LSP actions
map("n", "K", vim.lsp.buf.hover, opts) map("n", "K", vim.lsp.buf.hover, opts)
map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts) map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts)
map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts) map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts)
map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts) map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts)
map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts) map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts)
map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts) map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
map("n", "<S-Tab>", vim.lsp.buf.signature_help, opts) map("n", "<S-Tab>", vim.lsp.buf.signature_help, opts)
map("n", "<leader>r", vim.lsp.buf.rename, opts) map("n", "<leader>r", vim.lsp.buf.rename, opts)
map("n", "gA", vim.lsp.buf.code_action, opts) map("n", "gA", vim.lsp.buf.code_action, opts)
-- Diagnostics -- Diagnostics
map("n", "[d", function() map("n", "[d", function()
vim.diagnostic.jump({ count = -1 }) vim.diagnostic.jump({ count = -1 })
end, opts) end, opts)
map("n", "]d", function() map("n", "]d", function()
vim.diagnostic.jump({ count = 1 }) vim.diagnostic.jump({ count = 1 })
end, opts) end, opts)
map("n", "gb", vim.diagnostic.setqflist, opts) map("n", "gb", vim.diagnostic.setqflist, opts)
-- formatting -- formatting
map("n", "<leader>c", vim.lsp.buf.format) map("n", "<leader>c", vim.lsp.buf.format)
end end
}) })

View file

@ -9,16 +9,16 @@
---@param list table list of chars ---@param list table list of chars
---@param char number|string char to add ---@param char number|string char to add
local function add_to_client(list, char) local function add_to_client(list, char)
local c local c
if type(char) == "string" then if type(char) == "string" then
c = char c = char
elseif type(char) == "number" then elseif type(char) == "number" then
c = string.char(char) c = string.char(char)
end end
if not table.contains(list, c) then if not table.contains(list, c) then
table.insert(list, c) table.insert(list, c)
end end
end end
-- make sure we can add autos -- make sure we can add autos
@ -29,49 +29,49 @@ local completion_group = misc.augroup("lsp.completion")
-- Configure the lsp completion menu. In addition to setting up lsp completion -- Configure the lsp completion menu. In addition to setting up lsp completion
-- this also styles it to look nice. -- this also styles it to look nice.
auto("LspAttach", { auto("LspAttach", {
group = completion_group, group = completion_group,
callback = function(ctx) callback = function(ctx)
local client = vim.lsp.get_client_by_id(ctx.data.client_id) local client = vim.lsp.get_client_by_id(ctx.data.client_id)
if not client or not client:supports_method("textDocument/completion") then if not client or not client:supports_method("textDocument/completion") then
return return
end end
-- Make completion menu appear whenever you type something. -- Make completion menu appear whenever you type something.
local c = client.server_capabilities.completionProvider.triggerCharacters local c = client.server_capabilities.completionProvider.triggerCharacters
if c then if c then
for i = 32, 126 do for i = 32, 126 do
add_to_client(c, string.char(i)) add_to_client(c, string.char(i))
end end
end end
vim.lsp.completion.enable(true, client.id, ctx.buf, { vim.lsp.completion.enable(true, client.id, ctx.buf, {
autotrigger = true, autotrigger = true,
convert = function(item) convert = function(item)
local kind = vim.lsp.protocol.CompletionItemKind[item.kind] or 'u' local kind = vim.lsp.protocol.CompletionItemKind[item.kind] or 'u'
return { return {
-- in the future if we ever get the ability to highlight specific -- in the future if we ever get the ability to highlight specific
-- entries in the pummenu I'd like to add treesitter highlighting to -- entries in the pummenu I'd like to add treesitter highlighting to
-- the entries -- the entries
abbr = item.label:gsub('%b()', ''), abbr = item.label:gsub('%b()', ''),
kind = kind:sub(1, 1):lower(), kind = kind:sub(1, 1):lower(),
menu = '' menu = ''
} }
end end
}) })
end end
}) })
-- attempt to style the completion documentation popup -- attempt to style the completion documentation popup
auto("CompleteChanged", { auto("CompleteChanged", {
group = completion_group, group = completion_group,
callback = function() callback = function()
local info = vim.fn.complete_info({ "selected" }) local info = vim.fn.complete_info({ "selected" })
if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then
vim.bo[info.preview_bufnr].filetype = "markdown" vim.bo[info.preview_bufnr].filetype = "markdown"
vim.wo[info.preview_winid].conceallevel = 2 vim.wo[info.preview_winid].conceallevel = 2
vim.wo[info.preview_winid].concealcursor = "niv" vim.wo[info.preview_winid].concealcursor = "niv"
end end
end end
}) })
-- Add snippet support to lsp clients who don't do it for us. Currently this -- Add snippet support to lsp clients who don't do it for us. Currently this
@ -81,121 +81,121 @@ auto("CompleteChanged", {
-- not follow the c-style function call style. I've only gotten this working in -- not follow the c-style function call style. I've only gotten this working in
-- lua thus far. -- lua thus far.
auto("CompleteDonePre", { auto("CompleteDonePre", {
group = completion_group, group = completion_group,
callback = function() callback = function()
local item = vim.tbl_get( local item = vim.tbl_get(
vim.v.completed_item, vim.v.completed_item,
"user_data", "user_data",
"nvim", "nvim",
"lsp", "lsp",
"completion_item" "completion_item"
) )
if not item then if not item then
return return
end end
-- TODO: we need to truncate the item.label to ensure that we don't -- TODO: we need to truncate the item.label to ensure that we don't
-- duplicate any text below is my attempt to start work on it: -- duplicate any text below is my attempt to start work on it:
-- --
-- local cursor = vim.api.nvim_win_get_cursor(0) -- local cursor = vim.api.nvim_win_get_cursor(0)
-- local line = vim.api.nvim_buf_get_lines( -- local line = vim.api.nvim_buf_get_lines(
-- vim.api.nvim_win_get_buf(0), -- vim.api.nvim_win_get_buf(0),
-- cursor[1] - 1, -- cursor[1] - 1,
-- cursor[1], -- cursor[1],
-- false -- false
-- )[1] -- )[1]
-- item.label = string.gsub(item.label, string.sub(line, cursor[2] + 1), "") -- item.label = string.gsub(item.label, string.sub(line, cursor[2] + 1), "")
-- item.insertText = item.label -- item.insertText = item.label
-- if the item isn't a snippet then we might want to create a snippet -- if the item isn't a snippet then we might want to create a snippet
if item.label and item.kind and item.insertTextFormat then if item.label and item.kind and item.insertTextFormat then
if item.insertTextFormat ~= 2 and item.kind == 3 then if item.insertTextFormat ~= 2 and item.kind == 3 then
local n_complete_item = vim.v.completed_item local n_complete_item = vim.v.completed_item
-- attempt to modify the function args to create a snippet -- attempt to modify the function args to create a snippet
local paren1 = string.find(item.label, "%(") local paren1 = string.find(item.label, "%(")
if not paren1 then if not paren1 then
return return
end end
-- try and create a snippet from a function call -- try and create a snippet from a function call
local i = 1 local i = 1
local text = "" local text = ""
local l_paren = paren1 local l_paren = paren1
local next, is_paren local next, is_paren
while not is_paren do while not is_paren do
-- find the next token -- find the next token
next = string.find(item.label, "%,", l_paren + 1) next = string.find(item.label, "%,", l_paren + 1)
if not next then if not next then
next = string.find(item.label, "%)", l_paren + 1) next = string.find(item.label, "%)", l_paren + 1)
if not next then if not next then
return return
end end
is_paren = true is_paren = true
end end
-- concat text -- concat text
if text == "" then if text == "" then
-- start the snippet -- start the snippet
text = string.sub(item.label, 0, l_paren).."${"..i..":" text = string.sub(item.label, 0, l_paren).."${"..i..":"
else else
-- continue the snippet -- continue the snippet
text = text.."}, ".."${"..i..":" text = text.."}, ".."${"..i..":"
end end
do -- add the content of the argument to the snippet do -- add the content of the argument to the snippet
-- we need to account for cases in which the developer uses spaces -- we need to account for cases in which the developer uses spaces
-- between their commas and code -- between their commas and code
local is_space = string.sub(item.label, l_paren + 1, l_paren + 1) local is_space = string.sub(item.label, l_paren + 1, l_paren + 1)
local plus = is_space == " " and 2 or 1 local plus = is_space == " " and 2 or 1
text = text..string.sub(item.label, l_paren + plus, next - 1) text = text..string.sub(item.label, l_paren + plus, next - 1)
end end
-- increment -- increment
l_paren = next l_paren = next
i = i + 1 i = i + 1
end end
-- end the snippet -- end the snippet
text = text.."})" text = text.."})"
n_complete_item.user_data.nvim.lsp.completion_item.insertText = text n_complete_item.user_data.nvim.lsp.completion_item.insertText = text
n_complete_item.user_data.nvim.lsp.completion_item.insertTextFormat = 2 n_complete_item.user_data.nvim.lsp.completion_item.insertTextFormat = 2
n_complete_item.user_data.nvim.lsp.completion_item.kind = 3 n_complete_item.user_data.nvim.lsp.completion_item.kind = 3
vim.v.completed_item = n_complete_item vim.v.completed_item = n_complete_item
end end
end end
end end
}) })
-- show the signature help when inside a function call -- show the signature help when inside a function call
auto("CompleteDone", { auto("CompleteDone", {
group = completion_group, group = completion_group,
callback = function(ctx) callback = function(ctx)
-- make sure there's an lsp client, and make sure the lsp client supports -- make sure there's an lsp client, and make sure the lsp client supports
-- textDocument/signatureHelp -- textDocument/signatureHelp
local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1] local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1]
if not client or not client:supports_method("textDocument/signatureHelp") then if not client or not client:supports_method("textDocument/signatureHelp") then
return return
end end
-- show the signature help -- show the signature help
local item = vim.tbl_get( local item = vim.tbl_get(
vim.v.completed_item, vim.v.completed_item,
"user_data", "user_data",
"nvim", "nvim",
"lsp", "lsp",
"completion_item" "completion_item"
) )
if not item then if not item then
return return
end end
-- show signature help when the completion is a function -- show signature help when the completion is a function
if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then
-- for some reason calling vim.schedule didn't work for me -- for some reason calling vim.schedule didn't work for me
vim.defer_fn(vim.lsp.buf.signature_help, 100) vim.defer_fn(vim.lsp.buf.signature_help, 100)
end end
end, end,
desc = "Auto show signature help when completion is done" desc = "Auto show signature help when completion is done"
}) })

View file

@ -23,9 +23,9 @@ function M.setup()
capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.lsp.protocol.make_client_capabilities()
} }
require("core.lsp.binds") require("core.lsp.binds")
require("core.lsp.completion") require("core.lsp.completion")
require("core.lsp.wtf") require("core.lsp.wtf")
end end
return M return M

View file

@ -9,29 +9,29 @@ auto('LspAttach', {
group = wtf_group, group = wtf_group,
callback = function(ctx) callback = function(ctx)
local client = vim.lsp.get_client_by_id(ctx.data.client_id) local client = vim.lsp.get_client_by_id(ctx.data.client_id)
if not client then if not client then
return return
end end
-- 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
pcall(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
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
-- disabled for now cause I don't like it -- disabled for now cause I don't like it
-- -- enable type formatting which allows lsps to modify text while you're -- -- enable type formatting which allows lsps to modify text while you're
-- -- typing for example if you insert {} in a string in python basedpyright -- -- typing for example if you insert {} in a string in python basedpyright
-- -- will change the string to a format string -- -- will change the string to a format string
-- if client:supports_method('textDocument/onTypeFormatting') then -- if client:supports_method('textDocument/onTypeFormatting') then
-- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id }) -- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id })
-- end -- end
end end
}) })

View file

@ -24,7 +24,7 @@ function M.map(mode, bind, cmd, opts)
end end
end end
vim.keymap.set(mode, bind, cmd, opts) vim.keymap.set(mode, bind, cmd, opts)
end end
--- a small map wrapper to easily create local buffer mappings --- a small map wrapper to easily create local buffer mappings
@ -56,18 +56,18 @@ end
---@return string|function lazified ---@return string|function lazified
---@nodiscard ---@nodiscard
function M.lz(txt) function M.lz(txt)
if type(txt) == "string" then if type(txt) == "string" then
return "<cmd>se lz<CR>"..txt.."<cmd>se lz!<CR>" return "<cmd>se lz<CR>"..txt.."<cmd>se lz!<CR>"
elseif type(txt) == "function" then elseif type(txt) == "function" then
return function() return function()
vim.cmd.se("lz") vim.cmd.se("lz")
-- gotta make sure we can always unset lz -- gotta make sure we can always unset lz
pcall(txt) pcall(txt)
vim.cmd.se("lz!") vim.cmd.se("lz!")
end end
else else
return txt return txt
end end
end end
return M return M

View file

@ -3,17 +3,17 @@ dofile(core.snippets)
return { return {
-- print inspect text -- print inspect text
s("inspect", { s("inspect", {
t("print(vim.inspect("), t("print(vim.inspect("),
i(0), i(0),
t("))") t("))")
}), }),
-- print inspect text -- print inspect text
s("M", { s("M", {
i(1, "M"); i(1, "M");
t({ " = {}", "" }), t({ " = {}", "" }),
i(0), i(0),
t({ "", "return " }), t({ "", "return " }),
r(1) r(1)
}) })
} }