255 lines
6.8 KiB
Nix
255 lines
6.8 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
{
|
|
options.neovim = {
|
|
enable = lib.mkEnableOption "Enables neovim";
|
|
languages = {
|
|
c.enable = lib.mkEnableOption "Enables c support";
|
|
go.enable = lib.mkEnableOption "Enables go support";
|
|
nix.enable = lib.mkEnableOption "Enables nix support";
|
|
rust.enable = lib.mkEnableOption "Enables rust support";
|
|
typescript.enable = lib.mkEnableOption "Enables typescript support";
|
|
};
|
|
themes = {
|
|
catppuccin.enable = lib.mkEnableOption "Enables catppuccin theme";
|
|
};
|
|
plugins = {
|
|
comments.enable = lib.mkOption { default = true; };
|
|
fugitive.enable = lib.mkOption { default = true; };
|
|
lualine.enable = lib.mkOption { default = true; };
|
|
luasnip.enable = lib.mkOption { default = false; };
|
|
nvimcmp.enable = lib.mkOption { default = true; };
|
|
opencode.enable = lib.mkOption { default = true; };
|
|
telescope = {
|
|
enable = lib.mkOption { default = true; };
|
|
fzf.enable = lib.mkOption { default = true; };
|
|
};
|
|
treesitter.enable = lib.mkOption { default = true; };
|
|
wiki.enable = lib.mkOption { default = false; };
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.neovim.enable {
|
|
home.sessionVariables = {
|
|
EDITOR = "nvim";
|
|
VISUAL = "nvim";
|
|
};
|
|
|
|
programs.nixvim = {
|
|
enable = true;
|
|
viAlias = true;
|
|
vimAlias = true;
|
|
|
|
globals = {
|
|
mapleader = " ";
|
|
maplocalleader = " ";
|
|
rust_recommended_style = 0;
|
|
};
|
|
|
|
opts = {
|
|
list = true;
|
|
updatetime = 750;
|
|
|
|
tabstop = 2;
|
|
softtabstop = 0;
|
|
shiftwidth = 2;
|
|
smarttab = true;
|
|
expandtab = true;
|
|
|
|
colorcolumn = "81";
|
|
showmatch = true;
|
|
number = true;
|
|
relativenumber = true;
|
|
|
|
swapfile = false;
|
|
backup = false;
|
|
undofile = true;
|
|
undodir = "${config.xdg.configHome}/nvim/undodir";
|
|
|
|
smartcase = true;
|
|
};
|
|
|
|
keymaps = with config.lib.nixvim; [
|
|
{
|
|
key = "<leader>d";
|
|
mode = "n";
|
|
action = mkRaw "vim.diagnostic.open_float";
|
|
}
|
|
{
|
|
key = "<C-J>";
|
|
mode = "n";
|
|
action = "<C-W><C-J>";
|
|
}
|
|
{
|
|
key = "<C-K>";
|
|
mode = "n";
|
|
action = "<C-W><C-K>";
|
|
}
|
|
{
|
|
key = "<C-L>";
|
|
mode = "n";
|
|
action = "<C-W><C-L>";
|
|
}
|
|
{
|
|
key = "<C-H>";
|
|
mode = "n";
|
|
action = "<C-W><C-H>";
|
|
}
|
|
{
|
|
key = "<C-y>";
|
|
mode = "x";
|
|
action = "\"+y";
|
|
options.remap = true;
|
|
}
|
|
{
|
|
key = "<C-y>";
|
|
mode = "n";
|
|
action = "\"+yy";
|
|
options.remap = true;
|
|
}
|
|
{
|
|
key = "<C-p>";
|
|
mode = "n";
|
|
action = "\"+P";
|
|
options.remap = true;
|
|
}
|
|
] ++ lib.lists.optionals config.neovim.plugins.opencode.enable (let
|
|
ocFunc = cmd: let raw = "function() require('opencode').${cmd} end";
|
|
in (config.lib.nixvim.mkRaw raw);
|
|
in [
|
|
{
|
|
key = "<leader>ot";
|
|
action = ocFunc "toggle()";
|
|
mode = [ "n" "x" ];
|
|
options.desc = "Toggle opencode";
|
|
}
|
|
{
|
|
key = "<leader>oa";
|
|
action = ocFunc "ask('', { submit = true })";
|
|
mode = [ "n" "x" ];
|
|
options.desc = "Ask opencode...";
|
|
}
|
|
{
|
|
key = "<leader>or";
|
|
action = ocFunc "operator('@this ')";
|
|
mode = [ "n" "x" ];
|
|
options.desc = "Add range to opencode";
|
|
}
|
|
]);
|
|
};
|
|
|
|
programs.nixvim.colorschemes = with config.neovim.themes; {
|
|
catppuccin = lib.mkIf catppuccin.enable {
|
|
enable = true;
|
|
flavour = "mocha";
|
|
integrations.vimwiki = lib.mkIf wiki.enable true;
|
|
};
|
|
};
|
|
|
|
programs.nixvim.plugins = with config.neovim.plugins; {
|
|
comment.enable = comments.enable;
|
|
|
|
fugitive.enable = fugitive.enable;
|
|
|
|
lualine = lib.mkIf lualine.enable {
|
|
enable = true;
|
|
icons_enabled = true;
|
|
};
|
|
web-devicons.enable = lualine.enable;
|
|
|
|
luasnip.enable = luasnip.enable;
|
|
friendly-snippets.enable = luasnip.enable;
|
|
|
|
cmp = {
|
|
enable = nvimcmp.enable;
|
|
autoEnableSources = true;
|
|
settings = {
|
|
sources = [
|
|
{ name = "nvim_lsp"; }
|
|
{ name = "path"; }
|
|
{ name = "buffer"; }
|
|
] ++ lib.optional luasnip.enable { name = "cmp-luasnip"; };
|
|
mapping = with config.lib.nixvim; {
|
|
"<Tab>" = mkRaw
|
|
"cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
|
|
"<S-Tab>" = mkRaw
|
|
"cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
|
|
};
|
|
};
|
|
};
|
|
|
|
opencode = {
|
|
enable = opencode.enable;
|
|
settings = {
|
|
input.enabled = true;
|
|
lsp.enabled = true;
|
|
events.permissions.enabled = false;
|
|
};
|
|
};
|
|
snacks.enable = opencode.enable;
|
|
|
|
telescope = {
|
|
enable = telescope.enable;
|
|
keymaps = {
|
|
"<leader>ff" = "find_files";
|
|
"<leader>fg" = "git_files";
|
|
};
|
|
extensions = {
|
|
fzf = lib.mkIf telescope.fzf.enable {
|
|
enable = true;
|
|
fuzzy = true;
|
|
override_generic_sorter = true;
|
|
override_file_sorter = true;
|
|
case_mode = "smart_case";
|
|
};
|
|
};
|
|
};
|
|
|
|
treesitter = {
|
|
enable = treesitter.enable;
|
|
highlight.enable = true;
|
|
indent.enable = true;
|
|
folding.enable = false;
|
|
};
|
|
|
|
vimwiki = {
|
|
enable = wiki.enable;
|
|
list = [
|
|
{
|
|
path = "${config.xdg.userDirs.documents}/wiki";
|
|
links_space_char = "_";
|
|
ext = ".md";
|
|
syntax = "markdown";
|
|
}
|
|
];
|
|
};
|
|
|
|
nvim-lspconfig.enable = true;
|
|
nix.enable = config.neovim.languages.nix.enable;
|
|
rustaceanvim.enable = config.neovim.languages.rust.enable;
|
|
typsecript-tools.enable = config.neovim.languages.typescript.enable;
|
|
};
|
|
|
|
programs.nixvim.lsp = {
|
|
enable = true;
|
|
servers = with config.neovim.languages; {
|
|
clangd.enable = c.enable;
|
|
gopls.enable = go.enable;
|
|
nil_ls.enable = nix.enable;
|
|
rust_analyzer.enable = rust.enable;
|
|
tsserver.enable = typescript.enable;
|
|
};
|
|
keymaps = [
|
|
{ key = "gd"; lspBufAction = "definition"; }
|
|
{ key = "gD"; lspBufAction = "declaration"; }
|
|
{ key = "gi"; lspBufAction = "implementation"; }
|
|
{ key = "gt"; lspBufAction = "type_definition"; }
|
|
{ key = "K"; lspBufAction = "hover"; }
|
|
] ++ lib.optional config.neovim.plugins.telescope.enable {
|
|
key = "gr";
|
|
action = config.lib.nixvim.mkRaw
|
|
"require('telescope.builtin').lsp_references";
|
|
};
|
|
};
|
|
};
|
|
}
|