From 51c37ffb2313822d7e58a3292fdeeaf280d7d6d2 Mon Sep 17 00:00:00 2001 From: Ellis Rahhal Date: Sun, 16 Feb 2025 23:22:51 -0800 Subject: [PATCH] added several plugins --- plugins/avante.nix | 64 ++++++++++++++++++++++++++++ plugins/bash.nix | 24 +++++++++++ plugins/cmp.nix | 1 + plugins/codecompanion.nix | 2 +- plugins/dap.nix | 87 +++++++++++++++++++++++++++++++++++++++ plugins/default.nix | 11 ++++- 6 files changed, 186 insertions(+), 3 deletions(-) create mode 100644 plugins/avante.nix create mode 100644 plugins/bash.nix create mode 100644 plugins/dap.nix diff --git a/plugins/avante.nix b/plugins/avante.nix new file mode 100644 index 0000000..96d504c --- /dev/null +++ b/plugins/avante.nix @@ -0,0 +1,64 @@ +{ ... }: +{ + programs.nixvim.plugins.avante = { + enable = true; + + settings = { + provider = "ollama"; + + claude = { + api_key_name = ""; + }; + openai = { + api_key_name = ""; + }; + + vendors = { + ollama = { + api_key_name = ""; + endpoint = "http://localhost:11434/v1"; + model = "hf.co/unsloth/DeepSeek-R1-Distill-Qwen-1.5B-GGUF"; + temperature = "0.6"; + parse_curl_args.__raw = '' + function(opts, code_opts) + return { + url = opts.endpoint .. "/chat/completions", + headers = { + ["Accept"] = "application/json", + ["Content-Type"] = "application/json", + ["x-api-key"] = "ollama", + }, + body = { + model = opts.model, + messages = require("avante.providers").copilot.parse_messages(code_opts), + max_tokens = opts.max_tokens, + stream = true, + }, + } + end''; + parse_response_data.__raw = '' + function(data_stream, event_state, opts) + require("avante.providers").openai.parse_response(data_stream, event_state, opts) + end''; + }; + }; + + mappings = { + ask = "ca"; + edit = "ce"; + refresh = "cr"; + focus = "cf"; + toggle = { + default = "ct"; + debug = "cd"; + hint = "ch"; + suggestion = "cs"; + repomap = "cR"; + }; + files = { + add_current = "cc"; + }; + }; + }; + }; +} diff --git a/plugins/bash.nix b/plugins/bash.nix new file mode 100644 index 0000000..f58d0f9 --- /dev/null +++ b/plugins/bash.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +{ + programs.nixvim.plugins = { + lsp.servers.bashls = { + enable = true; + + filetypes = ["sh" "zsh"]; + }; + + none-ls = { + sources = { + formatting.shfmt.enable = true; + formatting.shellharden.enable = true; + }; + }; + }; + + environment.systemPackages = with pkgs; [ + shellcheck + shellharden + shfmt + nodePackages.bash-language-server + ]; +} diff --git a/plugins/cmp.nix b/plugins/cmp.nix index ecfb677..83cd1ba 100644 --- a/plugins/cmp.nix +++ b/plugins/cmp.nix @@ -42,6 +42,7 @@ option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; keywordLength = 3; } + { name = "codecompanion"; } { name = "copilot"; } { name = "path"; # file system paths diff --git a/plugins/codecompanion.nix b/plugins/codecompanion.nix index 2a9178f..006a1ae 100644 --- a/plugins/codecompanion.nix +++ b/plugins/codecompanion.nix @@ -41,7 +41,7 @@ openai.__raw = '' function() - return require('codecompanion.adapters').extend('copilot', { + return require('codecompanion.adapters').extend('openai', { env = { api_key = "cmd:${pkgs.passage}/bin/passage /apis/ai/openai" } diff --git a/plugins/dap.nix b/plugins/dap.nix new file mode 100644 index 0000000..ded10b8 --- /dev/null +++ b/plugins/dap.nix @@ -0,0 +1,87 @@ +{ ... }: +{ + programs.nixvim = { + plugins = { + dap.enable = true; + dap-ui.enable = true; + dap-virtual-text.enable = true; + }; + + extraConfigLua = '' + vim.fn.sign_define("DapBreakpoint", { text = "● ", texthl = "DiagnosticSignError", linehl = "", numhl = "" }) + vim.fn.sign_define("DapBreakpointCondition", { text = "● ", texthl = "DiagnosticSignWarn", linehl = "", numhl = "" }) + vim.fn.sign_define("DapLogPoint", { text = "● ", texthl = "DiagnosticSignInfo", linehl = "", numhl = "" }) + vim.fn.sign_define("DapStopped", { text = "→ ", texthl = "DiagnosticSignWarn", linehl = "", numhl = "" }) + vim.fn.sign_define("DapBreakpointReject", { text = "●", texthl = "DiagnosticSignHint", linehl = "", numhl = "" }) + ''; + + keymaps = [ + { + mode = "n"; + key = "dB"; + action = "lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))"; + options.desc = "set breakpoint with condition"; + } + { + mode = "n"; + key = "db"; + action = "lua require('dap').toggle_breakpoint()"; + options.desc = "Toggle Breakpoint"; + } + { + mode = "n"; + key = "dc"; + action = "lua require('dapui').close()"; + options.desc = "Close"; + } + { + mode = "n"; + key = "ddr"; + action = "lua require('dap').repl.open()"; + options.desc = "Repl"; + } + { + mode = "n"; + key = "de"; + action = "lua require('dap').step_out()"; + options.desc = "Step Out"; + } + { + mode = "n"; + key = "dlp"; + action = "lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: '))"; + options.desc = "Log Point Message"; + } + { + mode = "n"; + key = "dn"; + action = "lua require('dap').step_over()"; + options.desc = "Step Over"; + } + { + mode = "n"; + key = "do"; + action = "lua require('dapui').open()"; + options.desc = "Open"; + } + { + mode = "n"; + key = "dr"; + action = "lua require('dap').continue()"; + options.desc = "Continue"; + } + { + mode = "n"; + key = "ds"; + action = "lua require('dap').step_into()"; + options.desc = "Step Into"; + } + { + mode = "n"; + key = "dt"; + action = "lua require('dapui').close()"; + options.desc = "Toggle"; + } + ]; + }; +} diff --git a/plugins/default.nix b/plugins/default.nix index b9f4526..af58c89 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -1,6 +1,8 @@ { config, ... }: { imports = [ + ./avante.nix + ./bash.nix # ./blink-cmp.nix # ./blink-cmp-copilot.nix # ./blink-cmp-dictionary.nix @@ -10,6 +12,7 @@ ./cmp.nix ./codecompanion.nix ./copilot.nix + ./dap.nix ./diffview.nix ./fzf-lua.nix ./indent-blankline.nix @@ -33,9 +36,12 @@ ## are part of the buffer rotation notify = { enable = false; - topDown = false; + settings = { + top_down = false; + }; }; nvim-autopairs.enable = true; + nvim-bqf.enable = true; nvim-lightbulb.enable = true; # config = '' # lua << EOF @@ -55,10 +61,11 @@ rainbow-delimiters.enable = true; sleuth.enable = true; startify.enable = config.nixvim-config.enable-startify; + tmux-navigator.enable = true; treesitter.enable = true; treesitter-context.enable = true; - tmux-navigator.enable = true; trouble.enable = true; + ts-autotag.enable = true; # ## Needed for telescope, nvim-tree, trouble, diffview, bufferline, and other plugins # ## Only on unstable at the moment web-devicons.enable = true;