Migrate configuration to nixvim

This commit is contained in:
♥ Minnie ♥ 2024-08-04 21:19:37 +08:00
parent be9fe07ba1
commit 8772a4ca32
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
18 changed files with 759 additions and 0 deletions

View file

@ -0,0 +1,38 @@
{ ... }:
{
# Autocompletion plugin
plugins.cmp = {
enable = true;
# Options provided to the require('cmp').setup function.
settings = {
# The sources to use
sources = [
{ name = "nvim_lsp"; } # LSP source for cmp
{ name = "luasnip"; } # Snippets source for cmp
];
# The snippet expansion function.
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
# cmp mappings declaration
mapping = {
# Select next/previous item.
"<C-e>" = "cmp.mapping.select_next_item()";
"<C-o>" = "cmp.mapping.select_prev_item()";
# Scroll through documentation.
"<C-s>" = "cmp.mapping.scroll_docs(-4)";
"<C-t>" = "cmp.mapping.scroll_docs(4)";
# Confirm selection.
"<C-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
# Exit completion.
"<C-Esc>" = "cmp.mapping.abort()";
};
};
# Scans the sources array and enable the corresponding plugins if they are known to nixvim.
autoEnableSources = true;
};
}

View file

@ -0,0 +1,23 @@
{ ... }:
{
plugins.bufdelete = {
enable = true;
};
keymaps = [
{
mode = "n";
key = "<leader>bd";
action = "<cmd>Bdelete<cr>";
options.desc = "Buffer Delete";
}
{
mode = "n";
key = "<leader>bw";
action = "<cmd>Bwipeout<cr>";
options.desc = "Buffer Wipeout";
}
];
}

View file

@ -0,0 +1,8 @@
{ ... }:
{
plugins.comment = {
enable = true;
};
}

View file

@ -0,0 +1,17 @@
{ ... }:
{
plugins.neo-tree = {
enable = true;
};
keymaps = [
{
mode = "n";
key = "\\";
action = "<cmd>Neotree toggle<cr>";
options.desc = "Toggle Neotree";
}
];
}

View file

@ -0,0 +1,24 @@
{ pkgs, ... }:
{
# Tree-sitter is a parser generator tool and an incremental parsing library.
plugins.treesitter = {
enable = true;
# Options provided to the require('nvim-treesitter.configs').setup function.
settings = {
highlight = {
enable = true; # Enable syntax highlighing.
};
indent = {
enable = true; # Enable auto indentation.
};
};
# Highlight `extraConfigLua` as lua.
nixvimInjections = true;
# Install all grammar packages.
grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars;
};
}

View file

@ -0,0 +1,8 @@
{ ... }:
{
plugins.gitsigns = {
enable = true;
};
}

View file

@ -0,0 +1,17 @@
{ ... }:
{
plugins.lazygit = {
enable = true;
};
keymaps = [
{
mode = "n";
key = "<leader>lg";
action = "<cmd>LazyGit<cr>";
options.desc = "LazyGit";
}
];
}

View file

@ -0,0 +1,57 @@
{ ... }:
{
plugins.lsp = {
enable = true; # Enable neovim's built-in LSP.
# Configure our language servers
servers = {
# C/C++
clangd = {
enable = true;
};
# Clojure
clojure-lsp = {
enable = true;
};
# Haskell
hls = {
enable = true;
};
# Lua
lua-ls = {
enable = true;
};
# Nix
nil-ls = {
enable = true;
};
# YAML
yamlls = {
enable = true;
};
};
keymaps = {
# nvim-lsp keymaps should be silent
silent = true;
# Configure keymaps for our diagnostics.
diagnostic = {
"<leader>n" = "open_float"; # Show diagnostics in floating window.
"<leader>o" = "goto_prev"; # Jump to previous diagnostic.
"<leader>e" = "goto_next"; # Jump to next diagnostic.
};
# Configure keymaps for our lspbuf.
lspBuf = {
K = "hover"; # Displays hover information¹
gr = "references"; # Lists all the references¹
gd = "definition"; # Jumps to the definition¹
gD = "declaration"; # Jumps to the declaration¹
gi = "implementation"; # Lists all the implementations¹
gt = "type_definition"; # Jumps to the definition of the type¹
# ¹ for the symbol under the cursor
};
};
};
}

View file

@ -0,0 +1,12 @@
{ ... }:
{
plugins.luasnip = {
enable = true;
extraConfig = {
enable_autosnippets = true;
store_selection_keys = "<Tab>";
};
};
}

View file

@ -0,0 +1,15 @@
{ pkgs, ... }:
{
extraPlugins = with pkgs.vimPlugins; [
gruvbox-material
];
extraConfigLua = ''
vim.o.termguicolors = true
vim.g.gruvbox_material_background = 'hard'
vim.g.gruvbox_material_enable_italic = 1
vim.cmd.colorscheme('gruvbox-material')
'';
}

View file

@ -0,0 +1,75 @@
{ ... }:
{
plugins.lualine = {
enable = true;
globalstatus = true;
theme = "gruvbox-material";
# Load our extensions
extensions = [
"nvim-tree"
];
# Icons for our separators
componentSeparators = { left = ""; right = ""; };
sectionSeparators = { left = ""; right = ""; };
# Display components in tabline
tabline.lualine_a = [ { name = "buffers"; } ];
# Lualine has sections as shown below
# +-------------------------------------------------+
# | A | B | C X | Y | Z |
# +-------------------------------------------------+
sections = {
# Section A
lualine_a = [ { name = "mode"; icon = ""; } ];
# Section B
lualine_b = [
# Git branch
{ name = "branch"; icon = ""; }
# Git diff status
{ name = "diff";
extraConfig.symbols = {
added = " ";
modified = " ";
removed = " ";
};
}
# Diagnostic count from nvim_lsp
{ name = "diagnostics";
extraConfig = {
sources = [ "nvim_lsp" ];
symbols = {
error = " ";
warn = " ";
info = " ";
hint = "󰝶 ";
};
};
}
];
# Section C
lualine_c = [ { name = "filename"; extraConfig = { path = 1; }; } ];
# Section X
lualine_x = [
{ name = "encoding"; }
{ name = "fileformat"; }
{ name = "filetype"; }
];
# Section Y
lualine_y = [ { name = "progress"; } ];
# Section Z
lualine_z = [ { name = "location"; } ];
};
};
}

View file

@ -0,0 +1,19 @@
{ ... }:
{
plugins.telescope = {
enable = true;
keymaps = {
"<leader>ff" = {
action = "find_files";
options.desc = "Find Files";
};
"<leader>fb" = {
action = "buffers";
options.desc = "Buffers";
};
};
};
}

View file

@ -0,0 +1,8 @@
{ ... }:
{
plugins.which-key = {
enable = true;
};
}