dense-analysis / neural

AI Vim/Neovim code generation plugin (OpenAI, ChatGPT, and more)
MIT License
455 stars 19 forks source link

Changing autocomplete keybind does not appear to work #2

Closed z4rathustr4 closed 1 year ago

z4rathustr4 commented 1 year ago

Hi, today I tested this awesome plugin (great job btw) with my personal configuration which is customized NvChad settings. I created a separated Lua file for this plugin with the example configuration and tried to change because it's my keybind for NvimTree, and it does not seem to work. neural.lua file:

local neural = {
    mappings = {
        swift = '<C-m>', -- Context completion
        prompt = '<C-space>', -- Open prompt
    },
    -- OpenAI settings
    open_ai = {
        temperature = 0.1,
        presence_penalty = 0.5,
        frequency_penalty = 0.5,
        max_tokens = 2048,
        context_lines = 16, -- Surrounding lines for swift completion
        api_key = 'some_api_key_i_wont_plaintext'
    },
    -- Visual settings
    ui = {
        use_prompt = true, -- Use visual floating Input
        use_animated_sign = true, -- Use animated sign mark
        show_hl = true,
        show_icon = true,
        icon = '🗲', -- Prompt/Static sign icon
        icon_color = '#ffe030', -- Sign icon color
        hl_color = '#4D4839', -- Line highlighting on output
        prompt_border_color = '#E5C07B',
    },
}

And my init.lua file in custom/plugins folder:

return {
  ["neovim/nvim-lspconfig"] = {
    config = function()
      require "plugins.configs.lspconfig"
      require "custom.plugins.lspconfig"
    end,
    },
  ["simrat39/rust-tools.nvim"] = {
    after = "nvim-lspconfig",
    config = function()
        require('rust-tools').setup({})
    end,
    },

    ["dense-analysis/neural"] = {
    config = function()
            require "custom.plugins.neural"
    end,
    requires = {
        "MunifTanjim/nui.nvim",
        }
    }

}

I hope someone can help and if it's my fault I'll figure it somehow in the next 3 hours 😆

Angelchev commented 1 year ago

Hey @z4rathustr4 thanks for taking a look. Have you tried passing the configuration table inside of the setup function when requiring neural?

Try this amended configuration and let me know if that works:

return {
  ["neovim/nvim-lspconfig"] = {
    config = function()
      require "plugins.configs.lspconfig"
      require "custom.plugins.lspconfig"
    end,
    },
  ["simrat39/rust-tools.nvim"] = {
    after = "nvim-lspconfig",
    config = function()
        require('rust-tools').setup({})
    end,
    },

    ["dense-analysis/neural"] = {
        config = function()
        require('custom.plugins.neural').setup{
            mappings = {
                swift = '<C-m>', -- Context completion
                prompt = '<C-space>', -- Open prompt
            },
            -- OpenAI settings
            open_ai = {
                temperature = 0.1,
                presence_penalty = 0.5,
                frequency_penalty = 0.5,
                max_tokens = 2048,
                context_lines = 16, -- Surrounding lines for swift completion
                api_key = 'some_api_key_i_wont_plaintext'
            },
            -- Visual settings
            ui = {
                use_prompt = true, -- Use visual floating Input
                use_animated_sign = true, -- Use animated sign mark
                show_hl = true,
                show_icon = true,
                icon = '🗲', -- Prompt/Static sign icon
                icon_color = '#ffe030', -- Sign icon color
                hl_color = '#4D4839', -- Line highlighting on output
                prompt_border_color = '#E5C07B',
            },
        }
    end,
    requires = {
        "MunifTanjim/nui.nvim",
        }
    }

}

I don't use any plugin managers myself so its possible I am missing something some kind of magic I don't understand.

z4rathustr4 commented 1 year ago

Somehow, it seems to work but now works with C-n and C-m at the same time. I'll temporary change my NvimTree keybind for now, but it seems like is hardcoded into the plugin's Lua. Thank you anyway! 😄

Angelchev commented 1 year ago

This is fixed thanks to @LoneExile at https://github.com/dense-analysis/neural/pull/6