Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fix file uri #235

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions lua/codeium/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ local function buf_to_codeium(bufnr)
language = language,
text = text,
line_ending = line_ending,
absolute_uri = 'file://' .. vim.api.nvim_buf_get_name(bufnr),
absolute_uri = util.get_uri(vim.api.nvim_buf_get_name(bufnr)),
}
end

Expand Down Expand Up @@ -186,8 +186,8 @@ function Source:complete(params, callback)
editor_language = filetype,
language = language,
cursor_position = { row = cursor.row - 1, col = cursor.col - 1 },
absolute_uri = 'file://' .. vim.api.nvim_buf_get_name(bufnr),
workspace_uri = 'file://' .. util.get_relative_path(bufnr),
absolute_uri = util.get_uri(vim.api.nvim_buf_get_name(bufnr)),
workspace_uri = util.get_uri(util.get_relative_path(bufnr)),
line_ending = line_ending,
cursor_offset = cursor_offset,
},
Expand Down
9 changes: 9 additions & 0 deletions lua/codeium/util.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local enums = require("codeium.enums")
local io = require("codeium.io")
local M = {}

function M.fallback_call(calls, with_filter, fallback_value)
Expand Down Expand Up @@ -38,4 +39,12 @@ function M.get_relative_path(bufnr)
return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":")
end

function M.get_uri(path)
local info = io.get_system_info()
if info.is_windows then
path = path:gsub("\\", "/")
end
return "file://" .. path
end

return M
Loading