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
9 changes: 8 additions & 1 deletion lua/codeium/blink.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function M:get_completions(ctx, callback)
local offset = ctx.bounds.start_col
local cursor = ctx.cursor
local bufnr = ctx.bufnr
local buf_name = vim.api.nvim_buf_get_name(bufnr)
local filetype = vim.api.nvim_get_option_value("filetype", { buf = ctx.bufnr })
filetype = enums.filetype_aliases[filetype] or filetype or "text"
local language = enums.languages[filetype] or enums.languages.unspecified
Expand All @@ -113,6 +114,12 @@ function M:get_completions(ctx, callback)
local line_ending_len = utf8len(line_ending)
local editor_options = util.get_editor_options(bufnr)

-- Bail if we have no path
if buf_name == "" then
callback(nil)
return function() end
end

-- We need to calculate the number of bytes prior to the current character,
-- that starts with all the prior lines
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
Expand Down Expand Up @@ -157,7 +164,7 @@ function M:get_completions(ctx, callback)
editor_language = filetype,
language = language,
cursor_position = { row = cursor[1] - 1, col = cursor[2] },
absolute_uri = util.get_uri(vim.api.nvim_buf_get_name(bufnr)),
absolute_uri = util.get_uri(buf_name),
workspace_uri = util.get_uri(util.get_project_root()),
line_ending = line_ending,
cursor_offset = cursor_offset,
Expand Down