huggingface / llm.nvim

LLM powered development for Neovim
Apache License 2.0
788 stars 50 forks source link

Allow environment variables to be passed #82

Closed blmarket closed 5 months ago

blmarket commented 7 months ago

In order to set environment variable only to the LSP server, this set cmd_env from config if available.

Reference: https://neovim.io/doc/user/lsp.html#vim.lsp.ClientConfig


Example usage: See below example lazy.vim plugin configuration. with cmd_env, I can set log_level at the plugin config, instead of global environment.

local M = {
  'blmarket/llm.nvim',
  opts = {
    model = "gemma-7b-it-q4f16_2-MLC",
    backend = "openai",
    url = "http://127.0.0.1:8000/v1/completions",
    lsp = {
      bin_path = vim.fn.expand("$HOME/proj/llm-ls/target/release/llm-ls"),
      cmd_env = {
        LLM_LOG_LEVEL = "DEBUG",
      },
      version = "0.5.2",
    },
    fim = {
      enabled = false,
    },
    context_window = 1024,
    enable_suggestions_on_startup = true,
  },
}

return M
blmarket commented 5 months ago

Thanks for letting me know, rebased!

McPatate commented 5 months ago

Ah actually, last detail, could you update the README's setup section to include the parameter + a little comment to explain what it does? No need to be exhaustive!