Skip to content

Improved Text Retrieval & Split-Screen Window#8

Closed
sudhanshu19102003 wants to merge 3 commits intoCopilotC-Nvim:mainfrom
sudhanshu19102003:main
Closed

Improved Text Retrieval & Split-Screen Window#8
sudhanshu19102003 wants to merge 3 commits intoCopilotC-Nvim:mainfrom
sudhanshu19102003:main

Conversation

@sudhanshu19102003
Copy link
Copy Markdown

Changes Made

  • Modified the window opening behavior to split-screen.
  • Replaced nvim.current.eval("getreg('"')") with nvim.current.buffer[:] for retrieving the code.

Tip

nvim.current.eval("getreg('"')") :
It only contains the text from the most recent yank, delete, change, or put operation, if there were no changes it didn't give any output
Before
Screenshot 2024-01-02 151549
After
Screenshot 2024-01-02 151714

it only contains the text from the most recent yank, delete, change, or put operation, if there were no changes it didn't gave any output

so i changed it to
nvim.current.buffer[:]
@sudhanshu19102003 sudhanshu19102003 changed the title minor Improved Text Retrieval & Split-Screen Window Jan 2, 2024
@jellydn
Copy link
Copy Markdown
Contributor

jellydn commented Jan 3, 2024

I've implemented a similar approach on my fork jellydn@97fcd70

I think the view mode/option should be configured.

return {
  -- Import the copilot plugin
  { import = "lazyvim.plugins.extras.coding.copilot" },
  {
    "jellydn/CopilotChat.nvim",
    branch = "canary",
    opts = {
       mode = "split"
    },
    build = function()
      vim.defer_fn(function()
        vim.cmd("UpdateRemotePlugins")
        vim.notify("CopilotChat - Updated remote plugins. Please restart Neovim.")
      end, 3000)
    end,
    event = "VeryLazy",
    keys = {
      { "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
      { "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
    },
  },
}

@sudhanshu19102003
Copy link
Copy Markdown
Author

Ya that's great but we still have to change the
nvim.current.eval("getreg('"')") : to nvim.current.buffer[:]

@jellydn
Copy link
Copy Markdown
Contributor

jellydn commented Jan 4, 2024

Ya that's great but we still have to change the nvim.current.eval("getreg('"')") : to nvim.current.buffer[:]

I am not sure about it. Let's see @gptlang view on your PR.

@gptlang
Copy link
Copy Markdown
Contributor

gptlang commented Jan 13, 2024

I completely missed this PR. Lost access to my email and didn't get notifications. Just fixed it recently. Sorry abut that (which is why i got notification of closing)

@gptlang
Copy link
Copy Markdown
Contributor

gptlang commented Jan 13, 2024

After looking at it a bit more, I agree with @jellydn's approach of being able to configure it (even though I do split pretty much 99% of the time)


# Get code from the unnamed register
code = self.nvim.eval("getreg('\"')")
code = self.nvim.current.buffer[:]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this pass the whole file in the buffer in or just the visible part?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole file which is opened currently

@gptlang gptlang closed this Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants