Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 4a89600

Browse files
committed
cleanup a bit
Signed-off-by: Tomas Slusny <[email protected]>
1 parent b2968f6 commit 4a89600

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lua/autocomplete/buffer.lua

+2-8
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,14 @@ local function complete_treesitter(bufnr, prefix, cmp_start)
3737
local defs = locals.get_definitions_lookup_table(bufnr)
3838
local ft = vim.bo[bufnr].filetype
3939
local items = {}
40+
local kind_map = vim.tbl_map(string.lower, vim.tbl_keys(vim.lsp.protocol.CompletionItemKind))
4041

4142
for id, entry in pairs(defs) do
42-
-- FIXME: This is not pretty, the format of the ID is not documented and might change, but its fastest way
4343
local name = id:match('k_(.+)_%d+_%d+_%d+_%d+$')
4444
local node = entry.node
4545
local kind = entry.kind
4646
if node and kind then
47-
for _, k in ipairs(vim.lsp.protocol.CompletionItemKind) do
48-
if string.find(k:lower(), kind:lower()) then
49-
kind = k
50-
break
51-
end
52-
end
53-
47+
kind = kind_map[kind:lower()] or kind
5448
local start_line_node, _, _ = node:start()
5549
local end_line_node, _, _ = node:end_()
5650

lua/autocomplete/cmd.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ function M.setup()
1717
callback = function()
1818
local cmdline = vim.fn.getcmdline()
1919
local curpos = vim.fn.getcmdpos()
20-
local last_char = cmdline:sub(-1)
20+
local last_char = cmdline:sub(curpos - 1, curpos - 1)
2121

2222
if
2323
curpos == #cmdline + 1
2424
and vim.fn.pumvisible() == 0
25-
and last_char:match('[%w%/%: ]')
25+
and last_char:match('[%w%/%:- ]')
2626
and not cmdline:match('^%d+$')
2727
then
2828
vim.api.nvim_feedkeys(term, 'ti', false)

0 commit comments

Comments
 (0)