Merge remote-tracking branch 'refs/remotes/origin/nixos' into nixos

This commit is contained in:
Moritz Böhme 2024-02-13 09:40:24 +01:00
commit 5559e9291e
28 changed files with 749 additions and 552 deletions

View file

@ -0,0 +1,19 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.my.programs.exercism;
in
{
options.my.programs.exercism.enable = mkEnableOption "Exercism";
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ exercism ];
age.secrets.exercism = {
path = "/home/moritz/.config/exercism/user.json";
file = ../../secrets/exercism.age;
owner = "1000";
mode = "500";
};
};
}

View file

@ -29,19 +29,36 @@ in
);
};
};
setSearchEngines = mkEnableOption "firefox search engines";
package = mkOption {
type = types.package;
default = pkgs.firefox;
example = pkgs.firefox-esr;
};
};
config = mkIf cfg.enable {
home-manager.users.moritz.programs.firefox = {
enable = true;
policies = mkIf cfg.setSearchEngines {
SearchEngines = {
Default = "Kagi";
Remove = [ "Google" "Amazon.de" "Bing" ];
policies =
let
removeExtensions = [ "Google" "Amazon.de" "Bing" "Amazon" "Wikipedia (en)" "Wikipedia (de)" ];
convertName = name:
let
lower = toLower name;
escaped = replaceStrings [ "." ] [ "dot" ] lower;
sanitized = head (splitString " " escaped);
in
"${sanitized}@search.mozilla.org";
in
{
SearchEngines = mkIf (hasInfix "esr" cfg.package) {
Default = "Kagi";
Remove = removeExtensions;
};
ExtensionSettings = genAttrs
(map convertName removeExtensions)
(_: { installation_mode = "blocked"; });
};
};
package = if cfg.setSearchEngines then pkgs.firefox-esr else pkgs.firefox;
profiles."default" = {
extraConfig = mkIf cfg.arkenfox.enable ''
// Arkenfox user.js

View file

@ -114,6 +114,7 @@ in
'';
};
};
starship.enableTransience = true;
};
};
};

View file

@ -43,6 +43,9 @@ in
config = mkIf cfg.enable {
my = {
nixpkgs.overlays = [
inputs.hypr-contrib.overlays.default
];
programs = {
wallpaper.enable = true;
kitty.enable = true;
@ -62,6 +65,7 @@ in
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages.${pkgs.system}.default;
portalPackage = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
};
home-manager.users.moritz = {

View file

@ -10,14 +10,31 @@ in
options.my.programs.nvim.enable = mkEnableOption "nvim";
config = mkIf cfg.enable {
my.nixpkgs.overlays = [
(
_: prev:
with lib.my;
{
vimPlugins = prev.vimPlugins // {
nvim-treesitter = prev.vimPlugins.nvim-treesitter.overrideAttrs (_: {
version = mkVersionInput inputs.nvim-treesitter;
src = inputs.nvim-treesitter;
});
# HACK: to fix error in nixpkgs version of nvim-lspconfig
nvim-lspconfig = prev.vimPlugins.nvim-lspconfig.overrideAttrs (_: {
version = mkVersionInput inputs.nvim-lspconfig;
src = inputs.nvim-lspconfig;
});
};
}
)
];
home-manager.users.moritz = {
home.packages = with pkgs; [
(
if config.my.programs.hyprland.enable
then neovide-hyprland
else neovide
)
];
xdg.configFile."nvim/snippets" = {
recursive = true;
source = ./plugins/snippets;
};
programs.neovim = {
enable = true;
@ -44,7 +61,7 @@ in
shfmt
statix
taplo
yamlfix
stable.yamlfix
yamllint
];
extraLuaConfig = readFile ./options.lua;

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, inputs, ... }:
with builtins;
{
@ -83,26 +83,14 @@ with builtins;
{ plugin = cmp-cmdline; }
{ plugin = cmp-nvim-lsp; }
{ plugin = cmp_luasnip; }
{
plugin = copilot-cmp;
opts = { };
dependencies = [
{
plugin = copilot-lua;
opts = {
suggestion = { enabled = false; };
panel = { enabled = false; };
};
conf = /* lua */ ''
require("copilot").setup(opts)
vim.cmd("Copilot disable")
'';
}
];
}
{ plugin = cmp-spell; }
{ plugin = cmp-nvim-lsp-signature-help; }
{ plugin = friendly-snippets; }
{ plugin = lspkind-nvim; }
{ plugin = luasnip; }
{
plugin = luasnip;
conf = readFile ./lua/luasnip.lua;
}
];
}
{
@ -115,7 +103,10 @@ with builtins;
conf = readFile ./lua/nvim-lspconfig.lua;
dependencies = [
{
plugin = null-ls-nvim;
plugin = pkgs.vimPlugins.null-ls-nvim.overrideAttrs (_: {
version = lib.my.mkVersionInput inputs.none-ls-nvim;
src = inputs.none-ls-nvim;
});
conf = readFile ./lua/null-ls-nvim.lua;
dependencies = [
{ plugin = which-key-nvim; }
@ -144,7 +135,13 @@ with builtins;
{ plugin = dressing-nvim; }
];
}
{ plugin = actions-preview-nvim; }
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "actions-preview-nvim";
version = lib.my.mkVersionInput inputs.actions-preview-nvim;
src = inputs.actions-preview-nvim;
};
}
];
}
{
@ -231,22 +228,6 @@ with builtins;
event = [ "BufReadPost" "BufNewFile" ];
opts = { };
}
{
plugin = telekasten-nvim;
dependencies = [
{ plugin = telescope-nvim; }
{ plugin = which-key-nvim; }
{
plugin = markdown-preview-nvim;
ft = [ "md" ];
}
];
cmd = [ "Telekasten" ];
keys = [
{ key = "<leader>fz"; cmd = "<cmd>Telekasten<cr>"; desc = "Zettelkasten"; }
];
conf = builtins.readFile ./lua/zettelkasten-nvim.lua;
}
{
plugin = nvim-surround;
event = [ "BufReadPost" "BufNewFile" ];
@ -286,62 +267,13 @@ with builtins;
];
}
{
plugin = refactoring-nvim;
keys = [
{
key = "<leader>cR";
cmd = "<cmd>lua require('telescope').extensions.refactoring.refactors()<cr>";
desc = "Refactor";
mode = [ "x" "n" ];
}
];
dependencies = [
{ plugin = which-key-nvim; }
{ plugin = plenary-nvim; }
{ plugin = nvim-lspconfig; }
];
opts = { };
}
{
plugin = harpoon;
keys = [
{ key = "<leader>ha"; cmd = "<cmd>lua require('harpoon.mark').add_file()<cr>"; desc = "Add file"; }
{ key = "<leader>hh"; cmd = "<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>"; desc = "Harpoon"; }
{ key = "<leader>1"; cmd = "<cmd>lua require('harpoon.ui').nav_file(1)<cr>"; desc = "Harpoon file 1"; }
{ key = "<leader>2"; cmd = "<cmd>lua require('harpoon.ui').nav_file(2)<cr>"; desc = "Harpoon file 2"; }
{ key = "<leader>3"; cmd = "<cmd>lua require('harpoon.ui').nav_file(3)<cr>"; desc = "Harpoon file 3"; }
{ key = "<leader>4"; cmd = "<cmd>lua require('harpoon.ui').nav_file(4)<cr>"; desc = "Harpoon file 4"; }
];
opts = { };
init = /* lua */ ''
require("which-key").register({
["<leader>h"] = {
name = "harpoon",
},
})
'';
dependencies = [
{ plugin = which-key-nvim; }
];
}
{
plugin = nvim-puppeteer;
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "nvim-puppeteer";
version = lib.my.mkVersionInput inputs.nvim-puppeteer;
src = inputs.nvim-puppeteer;
};
lazy = false; # NOTE: plugin lazy-loads itself.
}
{
plugin = neotest;
keys = [
{ key = "<leader>ct"; cmd = "<cmd>lua require('neotest').summary.toggle()<cr>"; desc = "Test"; }
];
dependencies = [
{ plugin = plenary-nvim; }
{ plugin = FixCursorHold-nvim; }
# adapters
{ plugin = neotest-python; }
];
conf = readFile ./lua/neotest.lua;
}
{
plugin = conform-nvim;
keys = [
@ -350,41 +282,5 @@ with builtins;
cmd = [ "ConformInfo" "Format" ];
conf = readFile ./lua/conform.lua;
}
{
plugin = neogen;
keys = [
{ key = "<leader>cg"; cmd = "<cmd>Neogen<cr>"; desc = "Test"; }
];
opts = {
languages = {
python = {
template = {
annotation_convention = "reST";
};
};
};
};
cmd = [ "Neogen" ];
}
{
plugin = gen-nvim;
init = /* lua */ ''
require("gen").setup({
model = "zephyr:7b-beta", -- The default model to use.
display_mode = "float", -- The display mode. Can be "float" or "split".
show_prompt = false, -- Shows the Prompt submitted to Ollama.
show_model = false, -- Displays which model you are using at the beginning of your chat session.
no_auto_close = false, -- Never closes the window automatically.
init = function(options) end,
-- Function to initialize Ollama
command = "${lib.getExe pkgs.curl} --silent --no-buffer -X POST http://localhost:11434/api/generate -d $body",
-- The command for the Ollama service. You can use placeholders $prompt, $model and $body (shellescaped).
-- This can also be a lua function returning a command string, with options as the input parameter.
-- The executed command must return a JSON object with { response, context }
-- (context property is optional).
debug = false -- Prints errors and the command which is run.
})
'';
}
];
}

View file

@ -0,0 +1,24 @@
local ls = require("luasnip")
local types = require("luasnip.util.types")
-- Every unspecified option will be set to the default.
ls.setup({
history = true,
-- Update more often, :h events for more info.
update_events = "TextChanged,TextChangedI",
-- Snippets aren't automatically removed if their text is deleted.
-- `delete_check_events` determines on which events (:h events) a check for
-- deleted snippets is performed.
-- This can be especially useful when `history` is enabled.
delete_check_events = "TextChanged",
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = { { "<--", "Error" } },
},
},
},
})
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })

View file

@ -2,25 +2,17 @@ local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
end
cmp.setup({
formatting = {
format = require("lspkind").cmp_format({
mode = "symbol", -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
symbol_map = {
Copilot = "",
},
}),
},
enabled = function()
return not luasnip.jumpable(1)
end,
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
@ -31,34 +23,51 @@ cmp.setup({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<S-CR>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() and has_words_before() then
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<C-n>"] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(1)
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = {
sources = cmp.config.sources({
{ name = "async_path", priority = 1 },
{ name = "buffer", priority = 1 },
{ name = "luasnip", priority = 2 },
{ name = "copilot", priority = 3 },
{ name = "nvim_lsp", priority = 3 },
},
{ name = "nvim_lsp", priority = 2 },
{ name = "nvim_lsp_signature_help", priority = 3 },
{ name = "luasnip", priority = 4 },
}, {
{ name = "async_path" },
{ name = "buffer" },
{ name = "spell" },
}),
})
-- Set configuration for specific filetype.

View file

@ -126,6 +126,7 @@ end
local servers = {
"bashls",
"gleam",
"gopls",
"nil_ls",
"nixd",

View file

@ -0,0 +1,242 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local arg_template = [[
{arg}: {type}
]]
local function pyarg()
return sn(
nil,
fmt(arg_template, {
arg = i(1, "arg"),
type = i(2, "Any"),
})
)
end
local function pyargs(_, _, _, user_args)
local choices = {
sn(nil, i(1)),
sn(nil, {
not user_args and t(", ") or t(""),
d(1, pyarg),
d(2, pyargs, { user_args = { false } }),
}),
}
-- switch order for first call
if user_args then
local fst, snd = unpack(choices)
choices = { snd, fst }
end
return sn(nil, c(1, choices))
end
local def_template = [[
def {fname}({args}) -> {rtype}:
"""
{docs}
"""
{final}
]]
local def = s(
"def",
fmt(def_template, {
fname = i(1, "fname"),
args = d(2, pyargs, nil, { user_args = { true } }),
rtype = i(3, "None"),
docs = i(4, "Documentation"),
final = i(5, "pass"),
}, { priority = 1001 })
)
local defs_template = [[
def {mname}(self, {args}) -> {rtype}:
"""
{docs}
"""
{final}
]]
local defs = s(
"defs",
fmt(defs_template, {
mname = i(1, "mname"),
args = d(2, pyargs, nil, { user_args = { true } }),
rtype = i(3, "None"),
docs = i(4, "Documentation"),
final = i(5, "pass"),
}, { priority = 1001 })
)
local enum_template = [[
for {i}, {value} in enumerate({iter}):
{final}
]]
local dot_enum = postfix(".enum", {
d(1, function(_, parent)
return sn(
1,
fmt(enum_template, {
i = i(1, "i"),
value = i(2, "value"),
iter = t(parent.env.POSTFIX_MATCH),
final = i(3, "pass"),
})
)
end),
})
local enum = s(
"enum",
fmt(enum_template, {
i = i(1, "i"),
value = i(2, "value"),
iter = i(3, "iter"),
final = i(4, "pass"),
})
)
local for_template = [[
for {item} in {iter}:
{final}
]]
local dot_for = postfix(".for", {
d(1, function(_, parent)
return sn(
1,
fmt(for_template, {
item = i(1, "item"),
iter = t(parent.env.POSTFIX_MATCH),
final = i(2, "pass"),
})
)
end),
})
local items_template = [[
for {key}, {value} in {iter}:
{final}
]]
local dot_items = postfix(".items", {
d(1, function(_, parent)
return sn(
1,
fmt(items_template, {
key = i(1, "key"),
value = i(2, "value"),
iter = t(parent.env.POSTFIX_MATCH),
final = i(3, "pass"),
})
)
end),
})
local try_template = [[
try:
{raises}
except {exception} as {ename}:
{final}
]]
local dot_try = postfix(".try", {
d(1, function(_, parent)
return sn(
1,
fmt(try_template, {
raises = t(parent.env.POSTFIX_MATCH),
exception = i(1, "Exception"),
ename = i(2, "e"),
final = i(3, "pass"),
})
)
end),
})
local parr = s(
"parr",
fmt(
[[
:param {name}: {description}
:type {name}: {type}
]],
{
name = i(1, "name"),
description = i(2, "description"),
type = i(3, "type"),
},
{
repeat_duplicates = true,
}
)
)
local retr = s(
"retr",
fmt(
[[
:return: {description}
:rtype: {rtype}
]],
{
description = i(1, "description"),
rtype = i(2, "rtype"),
}
)
)
local raisr = s(
"raisr",
fmt(
[[
:raises {exception}: {description}
]],
{
exception = i(1, "Exception"),
description = i(2, "description"),
}
)
)
return {
def,
defs,
dot_enum,
dot_for,
dot_items,
dot_try,
enum,
parr,
retr,
raisr,
}

View file

@ -1,4 +1,4 @@
{ pkgs, config, ... }:
{ pkgs, ... }:
with builtins;
{

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, lib, inputs, ... }:
with builtins;
{
@ -21,12 +21,19 @@ with builtins;
opts = { };
}
{
plugin = statuscol-nvim;
plugin = pkgs.vimPlugins.statuscol-nvim.overrideAttrs (_: {
version = lib.my.mkVersionInput inputs.statuscol-nvim;
src = inputs.statuscol-nvim;
});
event = [ "VeryLazy" ];
conf = readFile ./lua/statuscol-nvim.lua;
}
{
plugin = smartcolumn-nvim;
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "smartcolumn-nvim";
version = lib.my.mkVersionInput inputs.smartcolumn-nvim;
src = inputs.smartcolumn-nvim;
};
event = [ "BufReadPost" "BufNewFile" ];
opts = {
colorcolumn = "120";
@ -43,5 +50,18 @@ with builtins;
conf = readFile ./lua/gitsigns-nvim.lua;
dependencies = [{ plugin = which-key-nvim; }];
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "hawtkeys-nvim";
version = lib.my.mkVersionInput inputs.hawtkeys-nvim;
src = inputs.hawtkeys-nvim;
};
cmd = [ "Hawtkeys" "HawtkeysAll" "HawtkeysDupes" ];
opts = { };
dependencies = [
{ plugin = plenary-nvim; }
{ plugin = nvim-treesitter; }
];
}
];
}