Skip to content

Commit

Permalink
Windows fix file uri (#235)
Browse files Browse the repository at this point in the history
* file uri windows

---------

Co-authored-by: Saransh Saini <saransh.saini@codeium.com>
  • Loading branch information
saranshsaini and saranshsaini authored Sep 28, 2024
1 parent e638b93 commit 17bbeff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit 17bbeff

Please sign in to comment.