supermaven-inc / supermaven-nvim

The official Neovim plugin for Supermaven
https://supermaven.com/
MIT License
619 stars 30 forks source link

Cursor doesn't move when I accept multi-line suggestions #2

Closed amirhhashemi closed 4 months ago

amirhhashemi commented 4 months ago

I have the following code:

export function useCreateClient() {
    const queryClient = useQueryClient();

    return useMutation({>|<
>>      mutationFn: async (data) => {
}

>|< represents the cursor and the lines started with >> represent the Supermaven suggestion. When I accept the suggestion with Tab, the suggested code inserts but the cursor stays where it was:

export function useCreateClient() {
    const queryClient = useQueryClient();

    return useMutation({>|<
>>      mutationFn: async (data) => {
        mutationFn: async (data) => {
}

As the result, I get the same suggestion again. No matter how many time I accept the suggestion, it gives me the same suggestion over and over again:

export function useCreateClient() {
    const queryClient = useQueryClient();

    return useMutation({>|<
>>      mutationFn: async (data) => {
        mutationFn: async (data) => {
        mutationFn: async (data) => {
        mutationFn: async (data) => {
        mutationFn: async (data) => {
}

This does not happen when the suggestion is on the same line as the cursor.

I'm using the latest nightly release of neovim:

NVIM v0.10.0-dev-3103+gca735c755

And I'm using the Pro version.

super-jacob commented 4 months ago

We're having trouble reproducing this. Could you provide some more information about your setup? Do you have any other plugins installed or any custom keybindings that could affect this?

amirhhashemi commented 4 months ago

I don't think any of my plugins or keybindings could affect this, but I can investigate it. https://github.com/supermaven-inc/supermaven-nvim/pull/5 fixed the issue though.

amirhhashemi commented 4 months ago

I was able to reproduce it in a clean install with this config:

-- init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
      "supermaven-inc/supermaven-nvim",
      config = function()
        require("supermaven-nvim").setup({})
      end,
    },
}, {})
Hashiraee commented 4 months ago

With:

NVIM v0.10.0-dev-3117+g4e5c633ed
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068

And:

-- init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
      dir="~/Dev/nvim/plugin/supermaven-nvim", -- This includes PR #7 
      config = function()
        require("supermaven-nvim").setup({})
      end,
    },
}, {})

Using PR #7 i get the correct behaviour and this does not occur anymore.