Switch to using nixvim and setup full config

This commit is contained in:
2024-10-26 13:44:29 +02:00
parent 63a548d6b9
commit 7718fb4118
3 changed files with 358 additions and 52 deletions

View File

@ -19,17 +19,17 @@
...
}:
with lib;
let
cfg = config.modules.neovim;
in
{
options.modules.neovim = {
enable = mkOption { default = false; };
enable = lib.mkOption { default = false; };
};
config = mkIf cfg.enable {
imports = [ inputs.nixvim.homeManagerModules.nixvim ];
config = lib.mkIf cfg.enable {
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
@ -41,56 +41,142 @@ in
gcc
ripgrep
fd
stylua
black
nixfmt-rfc-style # nixfmt
];
programs.neovim =
let
toLua = str: ''
lua << EOF
${str}
EOF
'';
in
{
# https://www.youtube.com/watch?v=YZAnJ0rwREA
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
colorschemes.catppuccin = {
enable = true;
viAlias = true;
vimAlias = true;
# vimdiffAlias = true;
# plugins = with pkgs.vimPlugins; [
# {
# plugin = dracula-nvim;
# config = "colorscheme dracula";
# }
# {
# plugin = comment-nvim;
# config = toLua ''require("Comment").setup()'';
# }
# # nix file support
# vim-nix
# # Syntax highlighting
# (nvim-treesitter.withPlugins (p: [
# p.tree-sitter-nix
# p.tree-sitter-vim
# p.tree-sitter-bash
# p.tree-sitter-lua
# p.tree-sitter-python
# p.tree-sitter-json
# p.tree-sitter-cpp
# p.tree-sitter-rust
# ]))
# ];
# extraConfig = ''
# set clipboard=unnamedplus
# '';
# extraLuaConfig = ''
# vim.o.termguicolors = true
# '';
settings.flavour = "mocha";
};
globals.mapleader = " ";
opts = {
number = false;
relativenumber = false;
};
clipboard.register = "unnamedplus"; # Use system clipboard
keymaps = [
{
action = "<cmd>Telescope live_grep<cr>";
key = "<leader>/";
}
{
action = "<cmd>Telescope find_files<cr>";
key = "<leader><space>";
}
{
action = "<cmd>Telescope file_browser<cr>";
key = "<leader>.";
}
{
action = "<cmd>Neogit<cr>";
key = "<leader>gg";
}
{
key = "<C-s>";
action = "<esc><cmd>lua require('conform').format()<cr><cmd>write<cr>";
mode = [
"i"
"x"
"n"
"s"
];
}
];
plugins = {
lualine.enable = true;
commentary.enable = true;
which-key.enable = true;
treesitter.enable = true; # enables all grammar packages
neogit.enable = true; # like magit
trouble.enable = true;
# Shows file trees
oil = {
enable = true;
settings = {
view_options.show_hidden = true;
};
};
# Code formatting
conform-nvim = {
enable = true;
formattersByFt = with pkgs; {
lua = [ "stylua" ];
python = [ "black" ];
nix = [ "nixfmt" ];
};
# extraOptions = {
# default_format_opts.lsp_format = "fallback";
# };
};
# autocomplete
cmp = {
enable = true;
autoEnableSources = true;
settings.sources = [
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "buffer"; }
];
settings.mapping = {
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()";
"<C-e>" = "cmp.mapping.abort()";
"<CR>" = "cmp.mapping.confirm({ select = true })";
};
};
# Fuzzy finder
telescope = {
enable = true;
defaults.mappings = {
i = {
"<C-j>".__raw = "require('telescope.actions').move_selection_next";
"<C-k>".__raw = "require('telescope.actions').move_selection_previous";
"<tab>".__raw = "require('telescope.actions').select_default";
};
};
extensions = {
fzf-native.enable = true;
file-browser = {
enable = true;
hidden = true; # show hidden files
};
};
# Small hack since these file-browser options are not implemented in nixvim jet
extraOptions = {
extensions.file_browser.follow_symlinks = true;
extensions.file_browser.no_ignore = true;
};
};
lsp = {
enable = true;
servers = {
rust-analyzer.enable = true;
nixd.enable = true;
pyright.enable = true;
dockerls.enable = true;
lua_ls.enable = true;
};
};
};
};
};
}