feat: nixvim refactor

This commit is contained in:
2024-06-10 17:17:13 +02:00
parent 0603bb1123
commit 93e5f439f4
40 changed files with 7806 additions and 559 deletions

View File

@@ -0,0 +1,46 @@
{ lib, config, ... }:
let
cfg = config.presets.base.completion;
in
{
options.presets.base.completion = {
enable = lib.mkEnableOption "completion";
};
config = lib.mkIf cfg.enable {
plugins = {
luasnip.enable = true;
lspkind = {
enable = true;
mode = "symbol_text";
};
cmp = {
enable = true;
settings = {
mapping = {
"<C-n>" = "cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select})";
"<C-p>" = "cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select})";
"<C-Space>" = "cmp.mapping.confirm({select = true})";
"<C-Enter>" = "cmp.mapping.complete()";
};
sources = [
{ name = "path"; }
{ name = "luasnip"; }
{ name = "nvim_lsp"; }
{ name = "nvim_lsp_signature_help"; }
{ name = "nvim_lsp_document_symbol"; }
];
formatting.fields = [
"abbr"
"kind"
];
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
window = {
completion.border = "rounded";
documentation.border = "rounded";
};
};
};
};
};
}

View File

@@ -0,0 +1,99 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.base.diagnostics;
in
{
options.presets.base.diagnostics = {
enable = lib.mkEnableOption "diagnostics";
};
config = lib.mkIf cfg.enable {
extraConfigLua = ''
require("actions-preview").setup({})
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "󰌵" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
vim.diagnostic.config({
virtual_text = true,
signs = true,
underline = true,
update_in_insert = true,
severity_sort = false,
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
'';
keymaps = [
{
key = "<leader>sa";
mode = "n";
options.silent = true;
lua = true;
action = "require('actions-preview').code_actions";
}
{
key = "<leader>sx";
mode = "n";
options.silent = true;
lua = true;
action = "vim.lsp.buf.format";
}
{
key = "<leader>sR";
mode = "n";
options.silent = true;
action = "<cmd>:LspRestart<CR>";
}
{
key = "<leader>sn";
mode = "n";
options.silent = true;
action = "vim.lsp.buf.hover";
lua = true;
}
];
plugins = {
lsp.enable = true;
telescope = {
enable = true;
keymaps = {
"<leader>sr" = "lsp_references";
"<leader>sd" = "lsp_definitions";
"<leader>si" = "lsp_implementations";
"<leader>ss" = "lsp_document_symbols";
"<leader>sw" = "lsp_workspace_symbols";
"<leader>st" = "lsp_type_definitions";
"<leader>sh" = "diagnostics";
};
};
which-key.registrations."<leader>s" = {
name = "LSP";
n = "Hover";
r = "References";
R = "Restart LSP";
d = "Definitions";
i = "Implementations";
s = "Document Symbols";
w = "Workspace Symbols";
t = "Type Definitions";
h = "Diagnostics";
a = "Code Actions";
x = "LSP Format";
};
};
extraPlugins = [ pkgs.vimPlugins.actions-preview-nvim ];
};
}

View File

@@ -0,0 +1,30 @@
{ lib, config, ... }:
let
cfg = config.presets.base.find;
in
{
options.presets.base.find = {
enable = lib.mkEnableOption "file finding";
};
config = lib.mkIf cfg.enable {
plugins = {
telescope = {
enable = true;
keymaps = {
"<leader>ff" = "git_files";
"<leader>fa" = "find_files";
"<leader>fg" = "live_grep";
"<leader>fb" = "buffers";
};
};
which-key.registrations."<leader>f" = {
name = "Find";
f = "File";
a = "Untracked Files";
g = "Grep";
b = "Buffer";
};
};
};
}

View File

@@ -0,0 +1,35 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.base.formatting;
in
{
options.presets.base.formatting = {
enable = lib.mkEnableOption "formatting";
prettier = lib.mkEnableOption "prettier formatter";
};
config = lib.mkIf cfg.enable {
plugins.conform-nvim = {
enable = true;
formattersByFt = lib.mkIf cfg.prettier {
javascript = [ "prettierd" ];
markdown = [ "prettierd" ];
typescript = [ "prettierd" ];
json = [ "prettierd" ];
yaml = [ "prettierd" ];
html = [ "prettierd" ];
angular = [ "prettierd" ];
css = [ "prettierd" ];
scss = [ "prettierd" ];
less = [ "prettierd" ];
svelte = [ "prettierd" ];
};
};
extraPackages = lib.mkIf cfg.prettier [ pkgs.prettierd ];
};
}

View File

@@ -0,0 +1,19 @@
{ lib, config, ... }:
let
cfg = config.presets.base.minimap;
in
{
options.presets.base.minimap = {
enable = lib.mkEnableOption "minimap";
};
config = lib.mkIf cfg.enable {
globals = {
minimap_width = 10;
minimap_auto_start = 1;
minimap_auto_start_win_enter = 1;
minimap_close_buftypes = [ "nofile" ];
minimap_block_filetypes = [ "NvimTree" ];
};
};
}

View File

@@ -0,0 +1,52 @@
{ lib, config, ... }:
let
cfg = config.presets.base.status-line;
in
{
options.presets.base.status-line = {
enable = lib.mkEnableOption "status line";
};
config = lib.mkIf cfg.enable {
plugins = {
notify = {
enable = true;
backgroundColour = "#000000";
};
lualine = {
enable = true;
globalstatus = true;
sectionSeparators = {
left = "";
right = "";
};
componentSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = [
{
name = "mode";
separator = {
right = "";
left = "";
};
icon = "";
}
];
lualine_x = lib.mkAfter [ { name = "filetype"; } ];
lualine_z = [
{
name = "location";
separator = {
right = "";
left = "";
};
}
];
};
};
};
};
}

View File

@@ -0,0 +1,36 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.base.syntax;
in
{
options.presets.base.syntax = {
enable = lib.mkEnableOption "syntax highlighting";
};
config = lib.mkIf cfg.enable {
plugins = {
treesitter = {
enable = true;
indent = true;
grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars;
nixvimInjections = true;
};
indent-blankline = {
enable = lib.mkDefault true;
settings = {
indent.char = "";
scope.show_start = false;
};
};
illuminate.enable = lib.mkDefault true;
nvim-autopairs.enable = lib.mkDefault true;
nvim-colorizer.enable = lib.mkDefault true;
ts-autotag.enable = lib.mkDefault true;
};
};
}

View File

@@ -0,0 +1,32 @@
{ lib, config, ... }:
let
cfg = config.presets.base.tree;
in
{
options.presets.base.tree = {
enable = lib.mkEnableOption "file tree";
};
config = lib.mkIf cfg.enable {
keymaps = [
{
key = "<leader>ft";
action = "<cmd>:Neotree toggle<CR>";
}
];
plugins = {
neo-tree = {
enable = true;
filesystem.filteredItems.visible = true;
eventHandlers = {
file_opened = ''
function()
require('neo-tree').close_all()
end
'';
};
};
which-key.registrations."<leader>f".t = "Tree";
};
};
}