mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/sg: init
This commit is contained in:
parent
5f3785feb8
commit
8f4bf6d300
2 changed files with 135 additions and 0 deletions
86
plugins/by-name/sg/default.nix
Normal file
86
plugins/by-name/sg/default.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{ lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
inherit (lib.nixvim) defaultNullOpts literalLua;
|
||||
in
|
||||
lib.nixvim.plugins.mkNeovimPlugin {
|
||||
name = "sg";
|
||||
packPathName = "sg.nvim";
|
||||
package = "sg-nvim";
|
||||
|
||||
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||
|
||||
extraOptions = {
|
||||
nodePackage = lib.mkPackageOption pkgs "nodejs" {
|
||||
nullable = true;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
extraConfig = cfg: {
|
||||
plugins.sg.settings.node_executable = lib.mkIf (cfg.nodePackage != null) (
|
||||
lib.mkDefault (lib.getExe cfg.nodePackage)
|
||||
);
|
||||
};
|
||||
|
||||
settingsOptions = {
|
||||
enable_cody = defaultNullOpts.mkBool true ''
|
||||
Enable/disable cody integration.
|
||||
'';
|
||||
|
||||
accept_tos = defaultNullOpts.mkBool false ''
|
||||
Accept the TOS without being prompted.
|
||||
'';
|
||||
|
||||
chat = {
|
||||
default_model = defaultNullOpts.mkStr null ''
|
||||
The name of the default model to use for the chat.
|
||||
'';
|
||||
};
|
||||
|
||||
download_binaries = defaultNullOpts.mkBool true ''
|
||||
Whether to download latest release from Github.
|
||||
|
||||
WARNING: This should not be needed in Nixvim.
|
||||
'';
|
||||
|
||||
node_executable = defaultNullOpts.mkStr "node" ''
|
||||
Path to the node executable.
|
||||
|
||||
If you set `nodePackage` to a non-null package, this option will automatically default to its
|
||||
path.
|
||||
'';
|
||||
|
||||
skip_node_check = defaultNullOpts.mkBool false ''
|
||||
Whether to skip node checks.
|
||||
|
||||
Useful if using other js runtime.
|
||||
'';
|
||||
|
||||
cody_agent = defaultNullOpts.mkStr (literalLua "vim.api.nvim_get_runtime_file('dist/cody-agent.js', false)[1]") ''
|
||||
Path to the cody-agent js bundle.
|
||||
'';
|
||||
|
||||
on_attach =
|
||||
defaultNullOpts.mkRaw
|
||||
''
|
||||
function(_, bufnr)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = bufnr })
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, { buffer = bufnr })
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = bufnr })
|
||||
end
|
||||
''
|
||||
''
|
||||
Function to run when attaching to `sg://<file>` buffers.
|
||||
'';
|
||||
|
||||
src_headers = defaultNullOpts.mkAttrsOf types.str null ''
|
||||
Headers to be sent with each `sg` request.
|
||||
'';
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
enable_cody = true;
|
||||
accept_tos = true;
|
||||
skip_node_check = true;
|
||||
};
|
||||
}
|
49
tests/test-sources/plugins/by-name/sg/default.nix
Normal file
49
tests/test-sources/plugins/by-name/sg/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.sg = {
|
||||
enable = true;
|
||||
|
||||
# When cody is enabled, sg.nvim tries to access the home directory
|
||||
settings.enable_cody = false;
|
||||
};
|
||||
};
|
||||
|
||||
default = {
|
||||
plugins.sg = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
# When cody is enabled, sg.nvim tries to access the home directory
|
||||
enable_cody = false;
|
||||
accept_tos = false;
|
||||
chat = {
|
||||
default_model = null;
|
||||
};
|
||||
download_binaries = true;
|
||||
node_executable = "node";
|
||||
skip_node_check = false;
|
||||
cody_agent.__raw = "vim.api.nvim_get_runtime_file('dist/cody-agent.js', false)[1]";
|
||||
on_attach.__raw = ''
|
||||
function(_, bufnr)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = bufnr })
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, { buffer = bufnr })
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = bufnr })
|
||||
end
|
||||
'';
|
||||
src_headers = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.sg = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
enable_cody = false;
|
||||
accept_tos = true;
|
||||
skip_node_check = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue