From 7ae7e95ca8e0249582635c0efdae0d2d4a7585e0 Mon Sep 17 00:00:00 2001 From: Saransh Saini Date: Fri, 27 Sep 2024 19:38:48 -0700 Subject: [PATCH 1/2] file uri windows --- lua/codeium/source.lua | 6 +++--- lua/codeium/util.lua | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lua/codeium/source.lua b/lua/codeium/source.lua index 82fba43..c60b553 100644 --- a/lua/codeium/source.lua +++ b/lua/codeium/source.lua @@ -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 @@ -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, }, diff --git a/lua/codeium/util.lua b/lua/codeium/util.lua index 4a0206c..a125dfd 100644 --- a/lua/codeium/util.lua +++ b/lua/codeium/util.lua @@ -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) @@ -38,4 +39,14 @@ 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 = "file://" .. path:gsub("\\", "/") + return path + else + return 'file://' .. path + end +end + return M From 1a6c347447c91f4db029c36eed1a0f64f5f09eda Mon Sep 17 00:00:00 2001 From: Saransh Saini Date: Fri, 27 Sep 2024 19:41:49 -0700 Subject: [PATCH 2/2] clean --- lua/codeium/util.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/codeium/util.lua b/lua/codeium/util.lua index a125dfd..4ac91f1 100644 --- a/lua/codeium/util.lua +++ b/lua/codeium/util.lua @@ -42,11 +42,9 @@ end function M.get_uri(path) local info = io.get_system_info() if info.is_windows then - path = "file://" .. path:gsub("\\", "/") - return path - else - return 'file://' .. path + path = path:gsub("\\", "/") end + return "file://" .. path end return M