[go: up one dir, main page]

Skip to content

šŸ¤– Neovim code suggestion and completion (just like GitHub Copilot, but locally using Ollama)

License

Notifications You must be signed in to change notification settings

meeehdi-dev/bropilot.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 

Repository files navigation

Bropilot.nvim

Bropilot is a GitHub Copilot alternative that takes advantage of local LLMs through Ollama's API.

Current working models:

  • deepseek-coder-v2
  • starcoder2
  • codegemma (doesn't seem to work anymore... no idea why)
  • codellama

image

Setup

You need to have Ollama installed and running for bro to work. Official download link

For Linux:

curl -fsSL https://ollama.com/install.sh | sh
# And check that the service is running
systemctl status ollama

Configuration

Here is the default configuration.

  • auto_suggest is a boolean that enables automatic debounced suggestions
  • model is a string (e.g. "codellama:7b-code" or "codegemma:2b-code")
  • model_params is an optional table defining model params as per Ollama API params
  • prompt is a table defining the prefix, suffix and middle keywords for FIM
  • debounce is a number in milliseconds
  • keymap is a table to set the different keymap shortcuts
require('bropilot').setup({
  auto_suggest = false,
  model = "deepseek-coder-v2:16b-lite-base-q4_0",
  model_params = {
    num_ctx = 16384,
    num_predict = -2,
    temperature = 0.2,
    top_p = 0.95,
  },
  -- model_params = {
  --   mirostat = 0,
  --   mirostat_eta = 0.1,
  --   mirostat_tau = 5.0,
  --   num_ctx = 2048,
  --   repeat_last_n = 64,
  --   repeat_penalty = 1.1,
  --   temperature = 0.8,
  --   seed = 0,
  --   stop = {},
  --   tfs_z = 1,
  --   num_predict = 128,
  --   top_k = 40,
  --   top_p = 0.9,
  --   min_p = 0.0,
  -- },
  prompt = {
    prefix = "<ļ½œfimā–beginļ½œ>",
    suffix = "<ļ½œfimā–holeļ½œ>",
    middle = "<ļ½œfimā–endļ½œ>",
  },
  debounce = 100,
  keymap = {
    accept_word = "<C-Right>",
    accept_line = "<S-Right>",
    accept_block = "<Tab>",
    suggest = "<C-Down>",
  },
  ollama_url = "http://localhost:11434/api",
})

Usage

Install and configure using lazy.nvim

  {
    'meeehdi-dev/bropilot.nvim',
    event = "VeryLazy", -- preload model on start
    dependencies = {
      "nvim-lua/plenary.nvim",
      "j-hui/fidget.nvim",
    },
    config = true, -- setup with default options
  }
  -- or
  {
    'meeehdi-dev/bropilot.nvim',
    event = "VeryLazy", -- preload model on start
    dependencies = {
      "nvim-lua/plenary.nvim",
      "j-hui/fidget.nvim",
    },
    opts = {
      auto_suggest = true,
      model = "starcoder2:3b",
      prompt = { -- FIM prompt for starcoder2
        prefix = "<fim_prefix>",
        suffix = "<fim_suffix>",
        middle = "<fim_middle>",
      },
      debounce = 500,
      keymap = {
        accept_line = "<M-Right>",
      },
    },
    config = function (_, opts)
        require("bropilot").setup(opts)
    end,
  }

About

šŸ¤– Neovim code suggestion and completion (just like GitHub Copilot, but locally using Ollama)

Topics

Resources

License

Stars

Watchers

Forks

Languages