Exafunction / codeium.nvim

A native neovim extension for Codeium
MIT License
647 stars 50 forks source link

completion requests not formatted correctly for some file types #68

Closed WillEhrendreich closed 9 months ago

WillEhrendreich commented 1 year ago

I have been digging like mad on this.

ok, so when you get a full print out of the exact args that are being sent to a curl when a job is started, it isn't consistent for all filetypes. i think this is what is messing up plaintext and fsharp, and possibly others..

example of how lua (which works and doesn't throw any errors) looks args = { "-sSL", "-D", "C:\Users\Will.ehrendreich\AppData\Local\Temp\plenary_curl_6c4b488e.headers", "-X", "POST", "-H", "Content-Type: application/json", "--data-raw",
'{ "editor_options": {"insert_spaces": true, "tab_size": 2}, "metadata": {"extension_name": "vim", "ide_name": "neovim", "request_id": 14, "api_key": "[redacted]", "extension_version": "1.2.36", "ide_version": "0.10.0-"}, "document": {"editor_language": "lua", "language": 23, "line_ending": "\r\n", "cursor_offset": 90, "text": "-- bootstrap lazy.nvim, LazyVim and your plugins\r\nlocal vim = vim\r\nrequire(\"config.lazy\")l\r\n"}}', "http://localhost:30383/exa.language_server_pb.LanguageServerService/GetCompletions" },

ok, so this is a screwed up one from fsharp

args = { "-sSL", "-D", "C:\Users\Will.ehrendreich\AppData\Local\Temp\plenary_curl_b55f4f56.headers", "-X", "POST", "-H", "Content-Type: application/json", "--data-raw", "{\"editor_options\": {\"insert_spaces\": true, \"tab_size\": 2}, \"metadata\": {\"extension_name\": \"vim\", \"ide_name\": \"neovim\", \"request_id\": 42, \"api_key\": \"[redacted]\", \"extension_version\": \"1.2.36\", \"ide_version\": \"0.10.0-\"}, \"document\": {\"editor_language\": \"fsharp\", \"language\": 59, \"line_ending\": \"\r\n\", \"cursor_offset\": 10574, \"text\": \"[redacted]" }\r\n\r\n\"}}", "http://localhost:30383/exa.language_server_pb.LanguageServerService/GetCompletions" },

now, how is it that running the same function util.get_editor_options(bufnr) gives the 2 different results? why is the fsharp and plain text one with escaped \" chars everywhere? How do we normalize that so it doesn't happen?

WillEhrendreich commented 1 year ago

ack.. it screwed up the screw up.. lol.. markdown i tell ya.

  args = {
    "-sSL",
    "-D",
    "C:\\Users\\Will.ehrendreich\\AppData\\Local\\Temp\\plenary_curl_d37b476e.headers",
    "-X",
    "POST",
    "-H",
    "Content-Type: application/json",
    "--data-raw", 
  "{\"editor_options\": {\"insert_spaces\": true, \"tab_size\": 2}, \"metadata\": {\"extension_name\": \"vim\", \"ide_name\": \"neovim\", \"request_id\": 5, 
   \"api_key\": \"[REDACTED]\", 
   \"extension_version\": \"1.2.36\", \"ide_version\": \"0.10.0-\"}, \"document\": {\"editor_language\": \"fsharp\", \"language\": 59, 
  \"line_ending\": \"\\r\\n\", \"cursor_offset\": 10569, 
   \"text\": \"[REDACTED]\",
    "http://localhost:30383/exa.language_server_pb.LanguageServerService/GetCompletions"
  },

but here's where things get even more strange, it doesn't throw an error for all of my fsharp files.

it formats the job arguments correctly for some files and not others. when it gets sent to plenary, it fails to spawn the process on my "types.fs" but not my "sheetFormatting.fs" file.

the next part that's super strange is that as far as i can tell it's sent over TO

WillEhrendreich commented 1 year ago

I was not finished writing that.. i must have hit close by mistake..

anyway, if i print out the info that's sent to the first argument of self.server.request_completion in source.lua, i get a perfectly reasonable output, there doesn't seem to be any formatting change until after that point.

here's what i was doing to check how that looks:


local firstArgToRequest = 
{
    editor_language = filetype,
    language = language,
    cursor_offset = cursor_offset,
    text = text,
    line_ending = line_ending,
}
  if language == enums.languages.fsharp then
    print("first argument to request: " ..vim.inspect(firstArgToRequest) )
    print("editor_options: " .. vim.inspect(editor_options) )

  end
    cancel = self.server.request_completion(
        firstArgToRequest,
        editor_options,
        function(success, json)
            remove_event()

            if not success then
                callback(nil)
            end

            if json and json.state and json.state.state == "CODEIUM_STATE_SUCCESS" and json.completionItems then
                handle_completions(json.completionItems)
            else
                callback(nil)
            end
        end
    )
end
WillEhrendreich commented 9 months ago

Closing this as I'm not sure it's an issue anymore..