From 9ad2a8e0486e6f8b522d303c54a0fb8294b79cd0 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 23 Jun 2026 13:57:40 +0300 Subject: Sort jdtls code actions and completions based on packages I prefer, and add static import to certain Kapi procs --- .config/nvim/lua/plugins/blink-cmp.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to '.config/nvim/lua/plugins/blink-cmp.lua') diff --git a/.config/nvim/lua/plugins/blink-cmp.lua b/.config/nvim/lua/plugins/blink-cmp.lua index fdf6d87..0c3f6d5 100644 --- a/.config/nvim/lua/plugins/blink-cmp.lua +++ b/.config/nvim/lua/plugins/blink-cmp.lua @@ -108,6 +108,32 @@ return { end, items) end, }, + + lsp = { + name = 'lsp', + module = 'blink.cmp.sources.lsp', + transform_items = function(ctx, items) + if vim.bo[ctx.bufnr].filetype == 'java' then + local java_package_weights = require('plugins.nvim-jdtls').java_package_weights + + for _, item in ipairs(items) do + -- jdtls puts the fully qualified package path inside 'detail' + local detail = item.detail or '' + if detail ~= '' then + for pattern, weight in pairs(java_package_weights) do + pattern = '^' .. pattern + if detail:match(pattern) then + item.score_offset = weight + break -- Match found, move to the next item + end + end + end + end + end + + return items + end, + }, }, }, -- cgit v1.3.1