I'm not gonna bother

This commit is contained in:
2025-08-10 13:10:05 -04:00
parent 7c96b43098
commit d320577772
18 changed files with 182 additions and 192 deletions

View File

@ -1,4 +1,9 @@
-- stolen from https://github.com/glepnir/nvim with some modifications by me
-- My neovim autocomplete setup.
-- partially stolen from https://github.com/glepnir/nvim
--
-- To make this work nicely you're gonna want a solid snippet setup, for me this
-- is luasnip. If you too would like to use luasnip just set vim.snippet.expand
-- to luasnip.lsp_expand
--- add char to list of triggerable chars
---@param list table list of chars
@ -16,14 +21,15 @@ local function add_to_client(list, char)
end
end
-- make sure we can add autos
local misc = require("core.misc")
local auto = misc.auto
local completion_group = misc.augroup("lsp.completion")
local competion_group = misc.augroup("lsp.completion")
-- configure the lsp completion menu
-- Configure the lsp completion menu. In addition to setting up lsp completion
-- this also styles it to look nice.
auto("LspAttach", {
group = competion_group,
group = completion_group,
callback = function(ctx)
local client = vim.lsp.get_client_by_id(ctx.data.client_id)
if not client or not client:supports_method("textDocument/completion") then
@ -43,6 +49,9 @@ auto("LspAttach", {
convert = function(item)
local kind = vim.lsp.protocol.CompletionItemKind[item.kind] or 'u'
return {
-- in the future if we ever get the ability to highlight specific
-- entries in the pummenu I'd like to add treesitter highlighting to
-- the entries
abbr = item.label:gsub('%b()', ''),
kind = kind:sub(1, 1):lower(),
menu = ''
@ -54,7 +63,7 @@ auto("LspAttach", {
-- attempt to style the completion documentation popup
auto("CompleteChanged", {
group = competion_group,
group = completion_group,
callback = function()
local info = vim.fn.complete_info({ "selected" })
if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then
@ -69,9 +78,10 @@ auto("CompleteChanged", {
-- only supports function calls.
--
-- there's a very good chance this will give us problems for languages who do
-- not follow the c-style function call style
-- not follow the c-style function call style. I've only gotten this working in
-- lua thus far.
auto("CompleteDonePre", {
group = competion_group,
group = completion_group,
callback = function()
local item = vim.tbl_get(
vim.v.completed_item,
@ -138,6 +148,7 @@ auto("CompleteDonePre", {
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.kind = 3
vim.v.completed_item = n_complete_item
end
end
@ -146,12 +157,12 @@ auto("CompleteDonePre", {
-- show the signature help when inside a function call
auto("CompleteDone", {
group = competion_group,
group = completion_group,
callback = function(ctx)
-- make sure there's an lsp client, and make sure the lsp client supports
-- textDocument/signatureHelp
local client = vim.lsp.get_clients({ bufnr = ctx.buf })[0]
if not client or not client[0]:supports_method("textDocument/signatureHelp") then
local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1]
if not client or not client:supports_method("textDocument/signatureHelp") then
return
end
@ -169,9 +180,8 @@ auto("CompleteDone", {
-- show signature help when the completion is a function
if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then
vim.schedule(function()
vim.lsp.buf.signature_help()
end)
-- for some reason calling vim.schedule didn't work for me
vim.defer_fn(vim.lsp.buf.signature_help, 100)
end
end,
desc = "Auto show signature help when completion is done"