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

@@ -46,6 +46,7 @@
matugen = matugen.packages.${prev.system}.default; matugen = matugen.packages.${prev.system}.default;
gbmonctl = prev.callPackage ./overlays/gbmonctl { }; gbmonctl = prev.callPackage ./overlays/gbmonctl { };
lpc21isp = prev.callPackage ./overlays/lpc21isp { }; lpc21isp = prev.callPackage ./overlays/lpc21isp { };
rquickshare = prev.callPackage ./overlays/rquickshare { };
cura = prev.callPackage ./overlays/cura { }; cura = prev.callPackage ./overlays/cura { };
}) })
]; ];

View File

@@ -15,10 +15,6 @@
}; };
}; };
# I'm not happy about this but if I try to get ESP IDF working
# on nix for any longer I'm gonna lose my sanity
programs.nix-ld.enable = true;
# Bootloader. # Bootloader.
boot = { boot = {
quiet.enable = true; quiet.enable = true;
@@ -42,6 +38,7 @@
development = { development = {
enable = true; enable = true;
angular.enable = true; angular.enable = true;
android.enable = true;
svelte.enable = true; svelte.enable = true;
docker.enable = true; docker.enable = true;
}; };
@@ -103,8 +100,8 @@
"audio" "audio"
"video" "video"
"plugdev" "plugdev"
"adbusers"
"cdrom" "cdrom"
"kvm"
]; ];
}; };

View File

@@ -33,6 +33,10 @@
fileSystems."/boot" = { fileSystems."/boot" = {
device = "/dev/disk/by-uuid/6EC6-F0EF"; device = "/dev/disk/by-uuid/6EC6-F0EF";
fsType = "vfat"; fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
}; };
swapDevices = [ { device = "/dev/disk/by-uuid/b09fbba2-c97a-41bc-a3cd-8204e30204f8"; } ]; swapDevices = [ { device = "/dev/disk/by-uuid/b09fbba2-c97a-41bc-a3cd-8204e30204f8"; } ];

View File

@@ -1,4 +1,5 @@
{ ... }: { ... }:
{ {
theme.md3-evo.enable = true; theme.md3-evo.enable = true;
programs.zoxide.enable = true;
} }

View File

@@ -13,8 +13,8 @@
imports = [ imports = [
inputs.nixvim.homeManagerModules.nixvim inputs.nixvim.homeManagerModules.nixvim
inputs.anyrun.homeManagerModules.default inputs.anyrun.homeManagerModules.default
./programs/nixvim/presets
./programs/neovide.nix ./programs/neovide.nix
# ./default-apps.nix
./packages ./packages
./programs ./programs
./services ./services

View File

@@ -55,5 +55,6 @@
ranger ranger
neofetch neofetch
filezilla filezilla
# rquickshare
]; ];
} }

View File

@@ -21,4 +21,8 @@
]; ];
}; };
}; };
programs.nixvim = {
extraConfigLua = "if vim.g.neovide then vim.opt.linespace = -1 end";
globals.neovide_cursor_vfx_mode = "pixiedust";
};
} }

View File

@@ -15,11 +15,6 @@
smartindent = true; smartindent = true;
signcolumn = "yes"; signcolumn = "yes";
undodir = {
__raw = "os.getenv('HOME') .. '/.config/nvim/undodir'";
};
undofile = true;
scrolloff = 12; scrolloff = 12;
hlsearch = false; hlsearch = false;
@@ -29,398 +24,118 @@
fillchars.eob = " "; fillchars.eob = " ";
}; };
keymaps = import ./keymaps.nix;
globals = {
minimap_width = 10;
minimap_auto_start = 1;
minimap_auto_start_win_enter = 1;
minimap_close_buftypes = [ "nofile" ];
minimap_block_filetypes = [ "NvimTree" ];
mapleader = ";";
mergetool_layout = "mr";
mergetool_prefer_revision = "local";
neovide_cursor_vfx_mode = "pixiedust";
};
clipboard = { clipboard = {
register = "unnamedplus"; register = "unnamedplus";
providers.wl-copy.enable = true; providers.wl-copy.enable = true;
}; };
globals.mapleader = ";";
extraConfigLua = builtins.readFile ./extra-config.lua; presets = {
auto-save.enable = true;
auto-format.enable = true;
harpoon.enable = true;
lazygit.enable = true;
mergetool.enable = true;
trouble.enable = true;
base = {
completion.enable = true;
diagnostics.enable = true;
find.enable = true;
formatting = {
enable = true;
prettier = true;
};
status-line.enable = true;
syntax.enable = true;
tree.enable = true;
};
languages = {
angular.enable = true;
c.enable = true;
css = {
enable = true;
stylelint = true;
};
js = {
enable = true;
eslint = true;
npm = true;
};
lua.enable = true;
nix.enable = true;
python.enable = true;
rust.enable = true;
shell.enable = true;
};
};
keymaps = [
{
key = "<leader>u";
mode = "n";
action = "<cmd>:UndotreeToggle<CR>";
}
# Find/Navigate
{
key = "J";
mode = "v";
action = ":m '>+1<CR>gv=gv";
}
{
key = "K";
mode = "v";
action = ":m '<-2<CR>gv=gv";
}
{
key = "<C-d>";
mode = "n";
action = "<C-d>zz";
}
{
key = "<C-u>";
mode = "n";
action = "<C-u>zz";
}
{
key = "<leader>p";
mode = "x";
action = ''"_dP'';
}
{
key = "<leader>p";
mode = "n";
action = ''"_dP'';
}
{
key = "<leader>p";
mode = "v";
action = ''"_dP'';
}
];
plugins = { plugins = {
lualine = {
enable = true;
globalstatus = true;
sectionSeparators = {
left = "";
right = "";
};
componentSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = [
{
name = "mode";
separator = {
right = "";
left = "";
};
icon = "";
}
];
lualine_x = [
"(vim.g.disable_autoformat or vim.b.disable_autoformat) and '󱌓' or nil"
{ name = "filetype"; }
];
lualine_z = [
{
name = "location";
separator = {
right = "";
left = "";
};
}
];
};
};
auto-save = {
enable = true;
triggerEvents = [
"FocusLost"
"BufLeave"
];
};
indent-blankline = {
enable = true;
settings = {
indent.char = "";
scope.show_start = false;
};
};
illuminate.enable = true;
nvim-autopairs.enable = true;
nvim-colorizer.enable = true;
neo-tree = {
enable = true;
filesystem.filteredItems.visible = true;
eventHandlers = {
file_opened = ''
function()
require('neo-tree').close_all()
end
'';
};
};
undotree.enable = true;
notify = {
enable = true;
backgroundColour = "#000000";
};
toggleterm = {
enable = true;
settings = {
direction = "vertical";
size = 60;
};
};
luasnip.enable = true;
ts-autotag.enable = true;
leap.enable = true; leap.enable = true;
harpoon = {
enable = true; lsp.servers = {
enableTelescope = true; html.enable = true;
keymaps = { svelte.enable = true;
addFile = "hm";
navNext = "hn"; dockerls.enable = true;
navPrev = "hp";
}; yamlls.enable = true;
jsonls.enable = true;
taplo.enable = true;
}; };
telescope = {
enable = true;
keymaps = {
"<leader>ff" = "git_files";
"<leader>fa" = "find_files";
"<leader>fg" = "live_grep";
"<leader>fb" = "buffers";
"<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";
};
};
trouble = {
enable = true;
settings.use_diagnostic_signs = true;
};
treesitter = {
enable = true;
indent = true;
grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars;
nixvimInjections = true;
};
conform-nvim = {
enable = true;
formattersByFt = {
lua = [ "stylua" ];
javascript = [ "prettier" ];
markdown = [ "prettier" ];
typescript = [ "prettier" ];
json = [ "prettier" ];
yaml = [ "prettier" ];
html = [ "prettier" ];
angular = [ "prettier" ];
css = [ "prettier" ];
scss = [ "prettier" ];
less = [ "prettier" ];
svelte = [ "prettier" ];
rust = [ "rustfmt" ];
bash = [ "shfmt" ];
nix = [ "nixfmt" ];
};
formatOnSave = ''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_fallback = true };
end
'';
};
none-ls = {
enable = true;
sources = {
diagnostics.stylelint.enable = true;
formatting.stylelint.enable = true;
};
};
lsp = {
enable = true;
keymaps = {
diagnostic = { };
};
enabledServers = [
{
name = "angularls";
extraOptions = {
cmd = [
"ngserver"
"--stdio"
"--tsProbeLocations"
""
"--ngProbeLocations"
""
];
on_new_config = {
__raw = ''
function(new_config, new_root_dir)
new_config.cmd = {
new_root_dir .. "/node_modules/@angular/language-server/bin/ngserver",
"--stdio",
"--tsProbeLocations",
new_root_dir .. "/node_modules",
"--ngProbeLocations",
new_root_dir .. "/node_modules",
}
end
'';
};
filetypes = [
"typescript"
"html"
"typescriptreact"
"typescript.tsx"
"angular"
"html.angular"
];
on_attach = {
__raw = ''
function(client, bufnr)
if vim.bo[bufnr].filetype == "html" then
vim.bo[bufnr].filetype = "angular"
end
end
'';
};
};
}
];
servers = {
html.enable = true;
cssls.enable = true;
svelte.enable = true;
tsserver.enable = true;
eslint.enable = true;
dockerls.enable = true;
yamlls.enable = true;
jsonls.enable = true;
taplo.enable = true;
rust-analyzer = {
enable = true;
installCargo = false;
installRustc = false;
};
pylsp.enable = true;
clangd = {
enable = true;
cmd = [
"clangd"
"--offset-encoding=utf-16"
];
};
nil_ls.enable = true;
lua-ls.enable = true;
bashls.enable = true;
};
};
lspkind = {
enable = true;
mode = "symbol_text";
cmp = {
after = ''
function(entry, vim_item, kind)
if entry.source.name == "npm" then
kind.kind = ""
kind.kind_hl_group = "CmpItemKindNpm"
end
kind.kind = kind.kind .. " "
return kind
end
'';
};
symbolMap = {
Copilot = "";
};
};
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 = "npm";
keywordLength = 4;
priority = 10;
}
{ 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";
};
};
};
which-key = { which-key = {
enable = true; enable = true;
registrations = { registrations."<leader>p" = "Paste Keep Buffer";
"<leader>p" = "Paste Keep Buffer";
"<leader>n" = "Hover";
"<leader>g" = "Git";
"<leader>u" = "Undotree";
"<leader>s" = {
name = "LSP";
r = "References";
d = "Definitions";
i = "Implementations";
s = "Document Symbols";
w = "Workspace Symbols";
t = "Type Definitions";
h = "Diagnostics";
a = "Code Actions";
f = "Auto Formatting";
x = "LSP Format";
};
"<leader>x" = {
name = "Trouble";
x = "Toggle";
w = "Workspace Diagnostics";
d = "Document Diagnostics";
q = "Quickfix";
l = "Loclist";
};
"<leader>f" = {
name = "Find";
t = "Tree";
f = "File";
a = "Untracked Files";
g = "Grep";
b = "Buffer";
};
h = {
name = "Harpoon";
m = "Mark";
n = "Next";
p = "Prev";
};
};
}; };
copilot-lua = { copilot-lua = {
enable = true; enable = true;
suggestion.autoTrigger = true; suggestion.autoTrigger = true;
}; };
openscad = {
enable = true;
fuzzyFinder = "fzf";
};
nix.enable = true;
}; };
extraPackages = [
pkgs.nodePackages.typescript-language-server
pkgs.nodePackages.stylelint
pkgs.nodePackages.prettier
pkgs.jq
pkgs.html-tidy
pkgs.nixfmt-rfc-style
pkgs.stylua
pkgs.shfmt
pkgs.fzf
];
extraPlugins = with pkgs.vimPlugins; [
vim-mergetool
plenary-nvim
actions-preview-nvim
];
} }

View File

@@ -1,59 +0,0 @@
require("cmp-npm").setup({})
require("actions-preview").setup({})
if vim.g.neovide then
-- no idea why this is needed
vim.opt.linespace = -1
end
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" })
local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({
cmd = "lazygit",
dir = "git_dir",
direction = "float",
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
end,
on_close = function(term)
vim.cmd("startinsert!")
end,
})
function _lazygit_toggle()
lazygit:toggle()
end
vim.api.nvim_set_keymap("n", "<leader>g", "<cmd>lua _lazygit_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_create_user_command("ConformToggle", function(args)
if args.bang then
vim.b.disable_autoformat = not vim.b.disable_autoformat
else
vim.g.disable_autoformat = not vim.g.disable_autoformat
end
end, {
desc = "Disable autoformat-on-save",
bang = true,
})

View File

@@ -1,112 +0,0 @@
[
{
key = "<leader>u";
mode = "n";
action = "<cmd>:UndotreeToggle<CR>";
}
# Find/Navigate
{
key = "<leader>ft";
action = "<cmd>:Neotree toggle<CR>";
}
{
key = "J";
mode = "v";
action = ":m '>+1<CR>gv=gv";
}
{
key = "K";
mode = "v";
action = ":m '<-2<CR>gv=gv";
}
{
key = "<C-d>";
mode = "n";
action = "<C-d>zz";
}
{
key = "<C-u>";
mode = "n";
action = "<C-u>zz";
}
{
key = "<leader>p";
mode = "x";
action = ''"_dP'';
}
{
key = "<leader>p";
mode = "n";
action = ''"_dP'';
}
{
key = "<leader>p";
mode = "v";
action = ''"_dP'';
}
{
key = "<leader>n";
mode = "n";
options.silent = true;
action = "vim.lsp.buf.hover";
lua = true;
}
{
key = "hh";
mode = "n";
action = ":Telescope harpoon marks<CR>";
}
# LSP Actions
{
key = "<leader>sa";
mode = "n";
options.silent = true;
lua = true;
action = "require('actions-preview').code_actions";
}
{
key = "<leader>sf";
mode = "n";
options.silent = true;
action = "<cmd>:ConformToggle<CR>";
}
{
key = "<leader>sx";
mode = "n";
options.silent = true;
lua = true;
action = "vim.lsp.buf.format";
}
# Trouble
{
key = "<leader>xx";
mode = "n";
lua = true;
action = "require('trouble').toggle";
}
{
key = "<leader>xw";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('workspace_diagnostics') end";
}
{
key = "<leader>xd";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('document_diagnostics') end";
}
{
key = "<leader>xq";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('quickfix') end";
}
{
key = "<leader>xl";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('loclist') end";
}
]

View File

@@ -0,0 +1,71 @@
{ lib, config, ... }:
let
cfg = config.presets.auto-format;
in
{
options.presets.auto-format = {
enable = lib.mkEnableOption "auto-format";
varName = lib.mkOption {
type = lib.types.str;
default = "disable_autoformat";
};
commandName = lib.mkOption {
type = lib.types.str;
default = "AutoFormatToggle";
};
};
config = lib.mkIf cfg.enable {
userCommands.${cfg.commandName} = {
command = {
__raw = ''
function(args)
if args.bang then
vim.b.${cfg.varName} = not vim.b.${cfg.varName}
else
vim.g.${cfg.varName} = not vim.g.${cfg.varName}
end
end
'';
};
};
keymaps = [
{
key = "<leader>af";
mode = "n";
options.silent = true;
action = "<cmd>:${cfg.commandName}<CR>";
}
{
key = "<leader>aF";
mode = "n";
options.silent = true;
action = "<cmd>:${cfg.commandName}!<CR>";
}
];
plugins = {
which-key.registrations = {
"<leader>a" = {
name = "Auto Actions";
f = "Toggle auto-format";
F = "Toggle auto-format (buffer)";
};
};
conform-nvim.formatAfterSave = ''
function(bufnr)
if vim.g.${cfg.varName} or vim.b[bufnr].${cfg.varName} then
return
end
return { timeout_ms = 500, lsp_fallback = true };
end
'';
lualine.sections.lualine_x = lib.mkOrder 600 [
"(vim.g.${cfg.varName} or vim.b.${cfg.varName}) and '󱌓' or nil"
];
};
};
}

View File

@@ -0,0 +1,87 @@
{ lib, config, ... }:
let
cfg = config.presets.auto-save;
in
{
options.presets.auto-save = {
enable = lib.mkEnableOption "auto save";
varName = lib.mkOption {
type = lib.types.str;
default = "disable_autosave";
};
commandName = lib.mkOption {
type = lib.types.str;
default = "AutoSaveToggle";
};
event = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"BufHidden"
"FocusLost"
];
};
};
config = lib.mkIf cfg.enable {
autoCmd = [
{
event = cfg.event;
pattern = [ "*" ];
callback = {
__raw = ''
function()
if not vim.b.${cfg.varName} and not vim.g.${cfg.varName} then
vim.cmd('silent! w')
print("Auto save at " .. os.date("%H:%M:%S"))
end
end
'';
};
}
];
userCommands.${cfg.commandName} = {
bang = true;
command = {
__raw = ''
function(args)
if args.bang then
vim.b.${cfg.varName} = not vim.b.${cfg.varName}
else
vim.g.${cfg.varName} = not vim.g.${cfg.varName}
end
end
'';
};
};
keymaps = [
{
key = "<leader>as";
mode = "n";
options.silent = true;
action = "<cmd>:${cfg.commandName}<CR>";
}
{
key = "<leader>aS";
mode = "n";
options.silent = true;
action = "<cmd>:${cfg.commandName}!<CR>";
}
];
plugins = {
which-key.registrations = {
"<leader>a" = {
name = "Auto Actions";
s = "Toggle auto-save";
S = "Toggle auto-save (buffer)";
};
};
lualine.sections.lualine_x = lib.mkOrder 700 [
"(vim.g.${cfg.varName} or vim.b.${cfg.varName}) and '󱙃' or nil"
];
};
};
}

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";
};
};
}

View File

@@ -0,0 +1,37 @@
{ lib, ... }:
{
options.programs.nixvim = lib.mkOption {
type = lib.types.submodule (
{ config, ... }:
{
imports = [
./auto-save.nix
./auto-format.nix
./harpoon.nix
./mergetool.nix
./lazygit.nix
./trouble.nix
./undotree.nix
./base/completion.nix
./base/diagnostics.nix
./base/find.nix
./base/formatting.nix
./base/status-line.nix
./base/syntax.nix
./base/tree.nix
./languages/angular.nix
./languages/c.nix
./languages/css.nix
./languages/js.nix
./languages/lua.nix
./languages/nix.nix
./languages/python.nix
./languages/rust.nix
./languages/shell.nix
];
}
);
};
}

View File

@@ -0,0 +1,38 @@
{ lib, config, ... }:
let
cfg = config.presets.harpoon;
in
{
options.presets.harpoon = {
enable = lib.mkEnableOption "Harpoon";
};
config = lib.mkIf cfg.enable {
keymaps = [
{
key = "hh";
mode = "n";
action = ":Telescope harpoon marks<CR>";
}
];
plugins = {
telescope.enable = true;
harpoon = {
enable = true;
enableTelescope = true;
keymaps = {
addFile = "hm";
navNext = "hn";
navPrev = "hp";
};
};
which-key.registrations.h = {
name = "Harpoon";
h = "Marks";
m = "Mark";
n = "Next";
p = "Prev";
};
};
};
}

View File

@@ -0,0 +1,60 @@
{ lib, config, ... }:
let
cfg = config.presets.languages.angular;
in
{
options.presets.languages.angular = {
enable = lib.mkEnableOption "Angular";
};
config = lib.mkIf cfg.enable {
plugins = {
lsp.enabledServers = [
{
name = "angularls";
extraOptions = {
cmd = [
"ngserver"
"--stdio"
"--tsProbeLocations"
""
"--ngProbeLocations"
""
];
on_new_config = {
__raw = ''
function(new_config, new_root_dir)
new_config.cmd = {
new_root_dir .. "/node_modules/@angular/language-server/bin/ngserver",
"--stdio",
"--tsProbeLocations",
new_root_dir .. "/node_modules",
"--ngProbeLocations",
new_root_dir .. "/node_modules",
}
end
'';
};
filetypes = [
"typescript"
"html"
"typescriptreact"
"typescript.tsx"
"angular"
"html.angular"
];
on_attach = {
__raw = ''
function(client, bufnr)
if vim.bo[bufnr].filetype == "html" then
vim.bo[bufnr].filetype = "angular"
end
end
'';
};
};
}
];
};
};
}

View File

@@ -0,0 +1,25 @@
{ lib, config, ... }:
let
cfg = config.presets.languages.c;
in
{
options.presets.languages.c = {
enable = lib.mkEnableOption "C/C++";
};
config = lib.mkIf cfg.enable {
plugins = {
conform-nvim.formattersByFt = {
c = [ "clang-format" ];
cpp = [ "clang-format" ];
};
lsp.servers.clangd = {
enable = true;
cmd = [
"clangd"
"--offset-encoding=utf-16"
];
};
};
};
}

View File

@@ -0,0 +1,29 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.css;
in
{
options.presets.languages.css = {
enable = lib.mkEnableOption "CSS";
stylelint = lib.mkEnableOption "stylelint";
};
config = lib.mkIf cfg.enable {
plugins = {
none-ls = lib.mkIf cfg.stylelint {
enable = true;
sources = {
diagnostics.stylelint.enable = true;
formatting.stylelint.enable = true;
};
};
lsp.servers.cssls.enable = true;
};
extraPackages = lib.mkIf cfg.stylelint [ pkgs.nodePackages.stylelint ];
};
}

View File

@@ -0,0 +1,48 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.js;
in
{
options.presets.languages.js = {
enable = lib.mkEnableOption "JS";
eslint = lib.mkEnableOption "ESLint";
npm = lib.mkEnableOption "NPM package completion";
};
config = lib.mkIf cfg.enable {
extraConfigLua = lib.mkIf cfg.npm ''
require("cmp-npm").setup({})
'';
plugins = {
lspkind = lib.mkIf cfg.npm {
cmp.after = ''
function(entry, vim_item, kind)
if entry.source.name == "npm" then
kind.kind = ""
kind.kind_hl_group = "CmpItemKindNpm"
end
kind.kind = kind.kind .. " "
return kind
end
'';
};
cmp.settings.sources = lib.mkIf cfg.npm [
{
name = "npm";
keywordLength = 4;
priority = 10;
}
];
lsp.servers = {
tsserver.enable = true;
eslint.enable = lib.mkIf cfg.eslint true;
};
};
extraPackages = [ pkgs.nodePackages.typescript-language-server ];
};
}

View File

@@ -0,0 +1,22 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.lua;
in
{
options.presets.languages.lua = {
enable = lib.mkEnableOption "Lua";
};
config = lib.mkIf cfg.enable {
plugins = {
conform-nvim.formattersByFt.lua = [ "stylua" ];
lsp.servers.lua-ls.enable = true;
};
extraPackages = [ pkgs.stylua ];
};
}

View File

@@ -0,0 +1,23 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.nix;
in
{
options.presets.languages.nix = {
enable = lib.mkEnableOption "Nix";
};
config = lib.mkIf cfg.enable {
plugins = {
conform-nvim.formattersByFt.nix = [ "nixfmt" ];
lsp.servers.nil_ls.enable = true;
nix.enable = true;
};
extraPackages = [ pkgs.nixfmt-rfc-style ];
};
}

View File

@@ -0,0 +1,22 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.python;
in
{
options.presets.languages.python = {
enable = lib.mkEnableOption "Python";
};
config = lib.mkIf cfg.enable {
plugins = {
conform-nvim.formattersByFt.python = [ "black" ];
lsp.servers.pylsp.enable = true;
};
extraPackages = [ pkgs.black ];
};
}

View File

@@ -0,0 +1,20 @@
{ lib, config, ... }:
let
cfg = config.presets.languages.rust;
in
{
options.presets.languages.rust = {
enable = lib.mkEnableOption "Rust";
};
config = lib.mkIf cfg.enable {
plugins = {
conform-nvim.formattersByFt.rust = [ "rustfmt" ];
lsp.servers.rust-analyzer = {
enable = true;
installCargo = false;
installRustc = false;
};
};
};
}

View File

@@ -0,0 +1,22 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.shell;
in
{
options.presets.languages.shell = {
enable = lib.mkEnableOption "Shell/Bash";
};
config = lib.mkIf cfg.enable {
plugins = {
conform-nvim.formattersByFt.sh = [ "shfmt" ];
lsp.servers.bashls.enable = true;
};
extraPackages = [ pkgs.shfmt ];
};
}

View File

@@ -0,0 +1,75 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.lazygit;
in
{
options.presets.lazygit = {
enable = lib.mkEnableOption "LazyGit";
toggleBind = lib.mkOption {
type = lib.types.str;
default = "<leader>g";
};
commandName = lib.mkOption {
type = lib.types.str;
default = "ToggleLazyGit";
};
};
config = lib.mkIf cfg.enable {
extraConfigLua = ''
LazygitTerminal = require("toggleterm.terminal").Terminal:new({
cmd = "${lib.getExe pkgs.lazygit}",
dir = "git_dir",
direction = "float",
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
end,
on_close = function(_)
vim.cmd("startinsert!")
end,
})
function LazygitToggle()
lazygit:toggle()
end
'';
userCommands.${cfg.commandName} = {
command = {
__raw = ''
function()
LazygitTerminal:toggle()
end
'';
};
};
keymaps = [
{
key = cfg.toggleBind;
mode = "n";
options.silent = true;
action = "<cmd>:${cfg.commandName}<CR>";
}
];
plugins = {
toggleterm = {
enable = true;
settings = {
direction = lib.mkDefault "vertical";
size = lib.mkDefault 60;
};
};
which-key.registrations.${cfg.toggleBind} = "Git";
};
};
}

View File

@@ -0,0 +1,22 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.mergetool;
in
{
options.presets.mergetool = {
enable = lib.mkEnableOption "Mergetool";
};
config = lib.mkIf cfg.enable {
globals = {
mergetool_layout = "mr";
mergetool_prefer_revision = "local";
};
extraPlugins = [ pkgs.vimPlugins.vim-mergetool ];
};
}

View File

@@ -0,0 +1,58 @@
{ lib, config, ... }:
let
cfg = config.presets.trouble;
in
{
options.presets.trouble = {
enable = lib.mkEnableOption "trouble";
};
config = lib.mkIf cfg.enable {
keymaps = [
{
key = "<leader>xx";
mode = "n";
lua = true;
action = "require('trouble').toggle";
}
{
key = "<leader>xw";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('workspace_diagnostics') end";
}
{
key = "<leader>xd";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('document_diagnostics') end";
}
{
key = "<leader>xq";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('quickfix') end";
}
{
key = "<leader>xl";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('loclist') end";
}
];
plugins = {
trouble = {
enable = true;
settings.use_diagnostic_signs = true;
};
which-key.registrations."<leader>x" = {
name = "Trouble";
x = "Toggle";
w = "Workspace Diagnostics";
d = "Document Diagnostics";
q = "Quickfix";
l = "Loclist";
};
};
};
}

View File

@@ -0,0 +1,22 @@
{ lib, config, ... }:
let
cfg = config.presets.undotree;
in
{
options.presets.undotree = {
enable = lib.mkEnableOption "Undotree";
};
config = lib.mkIf cfg.enable {
opts = {
undodir = {
__raw = "os.getenv('HOME') .. '/.config/nvim/undodir'";
};
undofile = true;
};
plugins = {
undotree.enable = true;
which-key.registrations."<leader>u" = "Undotree";
};
};
}

View File

@@ -11,10 +11,11 @@ let
in in
{ {
options.hardware.audio.preset.pipewire = { options.hardware.audio.preset.pipewire = {
enable = mkEnableOption "Enable pipewire with sane defaults"; enable = mkEnableOption "pipewire with sane defaults";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ pavucontrol ];
hardware.pulseaudio.enable = false; hardware.pulseaudio.enable = false;
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {

View File

@@ -13,6 +13,7 @@ let
in in
{ {
imports = [ imports = [
./development/android.nix
./development/angular.nix ./development/angular.nix
./development/svelte.nix ./development/svelte.nix
./development/docker.nix ./development/docker.nix

View File

@@ -0,0 +1,23 @@
{
config,
username,
lib,
...
}:
with lib;
let
cfg = config.usecases.development.android;
in
{
options.usecases.development.android = {
enable = mkEnableOption "Android develompent";
};
config = mkIf cfg.enable {
programs.adb.enable = true;
users.users.${username}.extraGroups = [ "adbusers" ];
networking.firewall.allowedTCPPorts = [ 5037 ];
};
}

6499
overlays/rquickshare/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,141 @@
{
lib,
stdenv,
stdenvNoCC,
rustPlatform,
fetchFromGitHub,
buildGoModule,
wrapGAppsHook3,
cargo,
rustc,
esbuild,
cargo-tauri,
pkg-config,
nodePackages,
jq,
moreutils,
gtk3,
webkitgtk,
openssl,
cacert,
}:
stdenv.mkDerivation rec {
pname = "rquickshare";
version = "0.7.1";
src = fetchFromGitHub {
owner = "Martichou";
repo = "rquickshare";
rev = "v${version}";
hash = "sha256-T3J91WmXjeB+M11n6oAjyr1SL8/mtIeESNjPe0ZUVLo=";
};
sourceRoot = "${src.name}/frontend/src-tauri";
pnpm-deps = stdenvNoCC.mkDerivation {
pname = "${pname}-pnpm-deps";
inherit src version;
sourceRoot = "${src.name}/frontend";
nativeBuildInputs = [
jq
moreutils
nodePackages.pnpm
cacert
];
installPhase = ''
export HOME=$(mktemp -d)
pnpm config set store-dir $out
# use --ignore-script and --no-optional to avoid downloading binaries
# use --frozen-lockfile to avoid checking git deps
pnpm install --frozen-lockfile --no-optional --ignore-script
# Remove timestamp and sort the json files
rm -rf $out/v3/tmp
for f in $(find $out -name "*.json"); do
sed -i -E -e 's/"checkedAt":[0-9]+,//g' $f
jq --sort-keys . $f | sponge $f
done
'';
dontFixup = true;
outputHashMode = "recursive";
outputHash = "sha256-+uQLHy3A8HNMROy1k7L++T47+2a8wkFIFyqioBW/Dvk=";
};
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
outputHashes = {
"mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4=";
# All other crates in the same workspace reuse this hash.
"tauri-plugin-autostart-0.0.0" = "sha256-uOPFpWz715jT8zl9E6cF+tIsthqv4x9qx/z3dJKVtbw=";
};
};
nativeBuildInputs = [
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri
wrapGAppsHook3
nodePackages.pnpm
pkg-config
];
buildInputs = [
gtk3
openssl
webkitgtk
];
ESBUILD_BINARY_PATH = "${lib.getExe (
esbuild.override {
buildGoModule =
args:
buildGoModule (
args
// rec {
version = "0.19.8";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${version}";
hash = "sha256-f13YbgHFQk71g7twwQ2nSOGA0RG0YYM01opv6txRMuw=";
};
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
}
);
}
)}";
buildPhase = ''
runHook preBuild
export HOME=$(mktemp -d)
pnpm config set store-dir ${pnpm-deps}
chmod +w ..
pnpm install --offline --frozen-lockfile --no-optional --ignore-script
chmod -R +w ../node_modules
pnpm rebuild
pnpm tauri build -b deb
runHook postBuild
'';
installPhase = ''
runHook preInstall
mv target/release/bundle/deb/*/data/usr/ $out
runHook postInstall
'';
meta = {
description = "Rust implementation of NearbyShare/QuickShare from Android for Linux";
mainProgram = "r-quick-share";
homepage = "https://github.com/Martichou/rquickshare";
platforms = lib.platforms.linux;
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ theaninova ];
};
}