Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions lua/cmp_dap/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ function source:complete(_, callback)
local line = api.nvim_get_current_line()

local offset = vim.startswith(line, "dap> ") and 5 or 0
local typed = line:sub(offset + 1, col)
-- local typed = line:sub(offset + 1, col)
local components = vim.split(line, "[ \t]")
local typed = components[#components]

local completions = {}
if vim.startswith(typed, ".") then
Expand All @@ -94,7 +96,7 @@ function source:complete(_, callback)
session:request("completions", {
frameId = (session.current_frame or {}).id,
text = typed,
column = col + 1 - offset,
column = #typed + 1,
}, function(err, response)
if err then
return
Expand All @@ -121,18 +123,18 @@ end
---Get trigger characters. (Optional)
---@return string[]
function source:get_trigger_characters()
local session = require('dap').session()
local trigger_characters = session.capabilities.completionTriggerCharacters or {}
local contains_dot = false
for _, trigger_character in ipairs(trigger_characters) do
if trigger_character == '.' then
contains_dot = true
end
end
if not contains_dot then
table.insert(trigger_characters, '.') -- always add '.' as nvim-dap adds custom commands starting with .
end
return trigger_characters
-- local session = require('dap').session()
-- local trigger_characters = session.capabilities.completionTriggerCharacters or {}
-- local contains_dot = false
-- for _, trigger_character in ipairs(trigger_characters) do
-- if trigger_character == '.' then
-- contains_dot = true
-- end
-- end
-- if not contains_dot then
-- table.insert(trigger_characters, '.')
-- end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the logic here. Why did you comment this out?

return {"."}
end

---Execute command after item was accepted.
Expand Down