development settings, and renaming neovim to nixvim

This commit is contained in:
cnst
2024-08-21 21:21:40 +02:00
parent dd8959e1b4
commit f06c33e482
37 changed files with 349 additions and 267 deletions

View File

@@ -0,0 +1,58 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.ai;
in {
options = {
modules.devtools.nixvim.plugins.ai.enable = mkEnableOption "Enables AI tools for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins = {
chatgpt = {
enable = true;
settings = {
api_key_cmd = "cat ${config.sops.secrets.openai_api_key.path}";
};
};
copilot-chat.enable = true;
copilot-lua = {
enable = true;
suggestion = {
enabled = true;
autoTrigger = true;
keymap.accept = "<C-CR>";
};
panel.enabled = false;
};
};
keymaps = [
{
action = "<cmd>CopilotChatToggle<CR>";
key = "<leader>ac";
options = {
desc = "Toggle Coilot chat";
};
mode = [
"n"
];
}
{
action = "<cmd>ChatGPT<CR>";
key = "<leader>ag";
options = {
desc = "Toggle ChatGPT";
};
mode = [
"n"
];
}
];
};
};
}

View File

@@ -0,0 +1,23 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.barbar;
in {
options = {
modules.devtools.nixvim.plugins.barbar.enable = mkEnableOption "Enables Barbar plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.barbar = {
enable = true;
keymaps = {
next.key = "<TAB>";
previous.key = "<S-TAB>";
close.key = "<C-w>";
};
};
};
}

View File

@@ -0,0 +1,23 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.comment;
in {
options = {
modules.devtools.nixvim.plugins.comment.enable = mkEnableOption "Enables Comment plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.comment = {
enable = true;
settings = {
opleader.line = "<C-b>";
toggler.line = "<C-b>";
};
};
};
}

View File

@@ -0,0 +1,37 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.conform-nvim;
in {
options = {
modules.devtools.nixvim.plugins.conform-nvim.enable = mkEnableOption "Enables Conform plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.conform-nvim = {
enable = true;
formatOnSave = {
lspFallback = true;
timeoutMs = 500;
};
notifyOnError = true;
formattersByFt = {
liquidsoap = ["liquidsoap-prettier"];
html = [["prettierd" "prettier"]];
css = [["prettierd" "prettier"]];
javascript = [["prettierd" "prettier"]];
javascriptreact = [["prettierd" "prettier"]];
typescript = [["prettierd" "prettier"]];
typescriptreact = [["prettierd" "prettier"]];
python = ["black"];
lua = ["stylua"];
nix = ["alejandra"];
markdown = [["prettierd" "prettier"]];
yaml = ["yamllint" "yamlfmt"];
};
};
};
}

View File

@@ -0,0 +1,23 @@
{userModules, ...}: {
imports = [
"${userModules}/devtools/nixvim/plugins/ai.nix"
"${userModules}/devtools/nixvim/plugins/barbar.nix"
"${userModules}/devtools/nixvim/plugins/comment.nix"
"${userModules}/devtools/nixvim/plugins/conform.nix"
"${userModules}/devtools/nixvim/plugins/efm.nix"
"${userModules}/devtools/nixvim/plugins/floaterm.nix"
"${userModules}/devtools/nixvim/plugins/harpoon.nix"
"${userModules}/devtools/nixvim/plugins/lsp.nix"
"${userModules}/devtools/nixvim/plugins/lualine.nix"
"${userModules}/devtools/nixvim/plugins/markdown-preview.nix"
"${userModules}/devtools/nixvim/plugins/neo-tree.nix"
"${userModules}/devtools/nixvim/plugins/nonels.nix"
"${userModules}/devtools/nixvim/plugins/startify.nix"
"${userModules}/devtools/nixvim/plugins/tagbar.nix"
"${userModules}/devtools/nixvim/plugins/telescope.nix"
"${userModules}/devtools/nixvim/plugins/treesitter.nix"
"${userModules}/devtools/nixvim/plugins/vimtex.nix"
"${userModules}/devtools/nixvim/plugins/yanky.nix"
"${userModules}/devtools/nixvim/plugins/rustaceanvim.nix"
];
}

View File

@@ -0,0 +1,35 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.efm;
in {
options = {
modules.devtools.nixvim.plugins.efm.enable = mkEnableOption "Enables EFM LSP support for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins = {
lsp.servers.efm = {
enable = true;
extraOptions.init_options = {
documentFormatting = true;
documentRangeFormatting = true;
hover = true;
documentSymbol = true;
codeAction = true;
completion = true;
};
};
lsp-format = {
enable = true;
lspServersToEnable = ["efm"];
};
efmls-configs.enable = true;
};
};
}

View File

@@ -0,0 +1,23 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.floaterm;
in {
options = {
modules.devtools.nixvim.plugins.floaterm.enable = mkEnableOption "Enables Floaterm plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.floaterm = {
enable = true;
width = 0.8;
height = 0.8;
title = "";
keymaps.toggle = "<leader>,";
};
};
}

View File

@@ -0,0 +1,31 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.harpoon;
in {
options = {
modules.devtools.nixvim.plugins.harpoon.enable = mkEnableOption "Enables Harpoon plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.harpoon = {
enable = true;
keymapsSilent = true;
keymaps = {
addFile = "<leader>a";
toggleQuickMenu = "<C-e>";
navFile = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-m>";
};
};
};
};
}

View File

@@ -0,0 +1,88 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.lsp;
in {
options = {
modules.devtools.nixvim.plugins.lsp = {
enable = mkEnableOption "Enables LSP support for nixvim";
servers = {
cssls.enable = mkEnableOption "Enable CSS LSP";
tailwindcss.enable = mkEnableOption "Enable TailwindCSS LSP";
html.enable = mkEnableOption "Enable HTML LSP";
astro.enable = mkEnableOption "Enable AstroJS LSP";
phpactor.enable = mkEnableOption "Enable PHP LSP";
svelte.enable = mkEnableOption "Enable Svelte LSP";
vuels.enable = mkEnableOption "Enable Vue LSP";
pyright.enable = mkEnableOption "Enable Python LSP";
marksman.enable = mkEnableOption "Enable Markdown LSP";
nixd.enable = mkEnableOption "Enable Nix LSP";
dockerls.enable = mkEnableOption "Enable Docker LSP";
bashls.enable = mkEnableOption "Enable Bash LSP";
clangd.enable = mkEnableOption "Enable C/C++ LSP";
csharp-ls.enable = mkEnableOption "Enable C# LSP";
yamlls.enable = mkEnableOption "Enable YAML LSP";
lua-ls.enable = mkEnableOption "Enable Lua LSP";
tsserver.enable = mkEnableOption "Enable TypeScript/JavaScript LSP";
rust-analyzer.enable = mkEnableOption "Enable Rust LSP";
};
};
};
config = mkIf cfg.enable {
programs.nixvim.plugins.lsp = {
enable = true;
keymaps = {
silent = true;
diagnostic = {
"<leader>k" = "goto_prev";
"<leader>j" = "goto_next";
};
lspBuf = {
gd = "definition";
gD = "references";
gt = "type_definition";
gi = "implementation";
K = "hover";
"<F2>" = "rename";
};
};
servers = {
cssls = mkIf cfg.servers.cssls.enable {};
tailwindcss = mkIf cfg.servers.tailwindcss.enable {};
html = mkIf cfg.servers.html.enable {};
astro = mkIf cfg.servers.astro.enable {};
phpactor = mkIf cfg.servers.phpactor.enable {};
svelte = mkIf cfg.servers.svelte.enable {};
vuels = mkIf cfg.servers.vuels.enable {};
pyright = mkIf cfg.servers.pyright.enable {};
marksman = mkIf cfg.servers.marksman.enable {};
nixd = mkIf cfg.servers.nixd.enable {};
dockerls = mkIf cfg.servers.dockerls.enable {};
bashls = mkIf cfg.servers.bashls.enable {};
clangd = mkIf cfg.servers.clangd.enable {};
csharp-ls = mkIf cfg.servers.csharp-ls.enable {};
yamlls = mkIf cfg.servers.yamlls.enable {};
lua-ls = mkIf cfg.servers.lua-ls.enable {
settings.telemetry.enable = false;
settings.diagnostics.globals = ["vim"];
};
tsserver = mkIf cfg.servers.tsserver.enable {};
rust-analyzer = mkIf cfg.servers.rust-analyzer.enable {
installRustc = true;
installCargo = true;
settings = {
checkOnSave = true;
check.command = "clippy";
};
};
};
};
};
}

View File

@@ -0,0 +1,56 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.lualine;
in {
options = {
modules.devtools.nixvim.plugins.lualine.enable = mkEnableOption "Enables Lualine plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.lualine = {
enable = true;
theme = "gruvbox-material";
globalstatus = true;
sections = {
lualine_a = ["mode"];
lualine_b = ["branch"];
lualine_c = ["filename" "diff"];
lualine_x = [
"diagnostics"
# Show active language server
{
name.__raw = ''
function()
local msg = ""
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end
'';
icon = "";
color.fg = "#ffffff";
}
"encoding"
"fileformat"
"filetype"
];
};
};
};
}

View File

@@ -0,0 +1,33 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.markdown-preview;
in {
options = {
modules.devtools.nixvim.plugins.markdown-preview.enable = mkEnableOption "Enables Markdown Preview plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins.markdown-preview = {
enable = true;
settings = {
auto_close = false;
theme = "dark";
};
};
files."after/ftplugin/markdown.lua".keymaps = [
{
mode = "n";
key = "<leader>m";
action = ":MarkdownPreview<cr>";
}
];
};
};
}

View File

@@ -0,0 +1,35 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.neo-tree;
in {
options = {
modules.devtools.nixvim.plugins.neo-tree.enable = mkEnableOption "Enables nix-tree plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins.neo-tree = {
enable = true;
closeIfLastWindow = true;
window = {
width = 30;
autoExpandWidth = true;
};
};
keymaps = [
{
mode = "n";
key = "<leader>n";
action = ":nixtree action=focus reveal toggle<CR>";
options.silent = true;
}
];
};
};
}

View File

@@ -0,0 +1,57 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.none-ls;
in {
options = {
modules.devtools.nixvim.plugins.none-ls.enable = mkEnableOption "Enables None-LS plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.none-ls = {
enable = true;
settings = {
cmd = ["bash -c nvim"];
debug = true;
};
sources = {
code_actions = {
statix.enable = true;
gitsigns.enable = true;
};
diagnostics = {
statix.enable = true;
deadnix.enable = true;
pylint.enable = true;
checkstyle.enable = true;
};
formatting = {
alejandra.enable = true;
stylua.enable = true;
shfmt.enable = true;
nixpkgs_fmt.enable = true;
google_java_format.enable = false;
prettier = {
enable = true;
disableTsServerFormatter = true;
};
black = {
enable = true;
settings = ''
{
extra_args = { "--fast" };
}
'';
};
};
completion = {
luasnip.enable = true;
spell.enable = true;
};
};
};
};
}

View File

@@ -0,0 +1,21 @@
{
lib,
pkgs,
config,
...
}:
with lib; let
cfg = config.modules.devtools.nixvim.plugins.rustaceanvim;
in {
options.modules.devtools.nixvim.plugins.rustaceanvim = {
enable = mkEnableOption "Whether to enable rustaceanvim.";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins = {
rustaceanvim.enable = true;
};
};
};
}

View File

@@ -0,0 +1,36 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.startify;
in {
options = {
modules.devtools.nixvim.plugins.startify.enable = mkEnableOption "Enables Startify plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.startify = {
enable = true;
settings = {
custom_header = [
""
" "
" "
" "
" "
" "
" "
];
change_to_dir = false;
use_unicode = true;
lists = [{type = "dir";}];
files_number = 30;
skiplist = ["flake.lock"];
};
};
};
}

View File

@@ -0,0 +1,30 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.tagbar;
in {
options = {
modules.devtools.nixvim.plugins.tagbar.enable = mkEnableOption "Enables Tagbar plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins.tagbar = {
enable = true;
settings.width = 50;
};
keymaps = [
{
mode = "n";
key = "<C-g>";
action = ":TagbarToggle<cr>";
options.silent = true;
}
];
};
};
}

View File

@@ -0,0 +1,42 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.telescope;
in {
options = {
modules.devtools.nixvim.plugins.telescope.enable = mkEnableOption "Enables Telescope plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.telescope = {
enable = true;
keymaps = {
"<leader>ff" = "find_files";
"<leader>fg" = "live_grep";
"<leader>b" = "buffers";
"<leader>fh" = "help_tags";
"<leader>fd" = "diagnostics";
"<C-p>" = "git_files";
"<leader>p" = "oldfiles";
"<C-f>" = "live_grep";
};
settings.defaults = {
file_ignore_patterns = [
"^.git/"
"^.mypy_cache/"
"^__pycache__/"
"^output/"
"^data/"
"%.ipynb"
];
set_env.COLORTERM = "truecolor";
};
};
};
}

View File

@@ -0,0 +1,40 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.treesitter;
in {
options = {
modules.devtools.nixvim.plugins = {
treesitter.enable = mkEnableOption "Enables Treesitter plugin for nixvim";
};
};
config = mkIf cfg.enable {
programs.nixvim.plugins = {
treesitter = {
enable = true;
nixvimInjections = true;
settings = {
highlight.enable = true;
indent.enable = true;
};
folding = true;
};
treesitter-refactor = mkIf cfg.enable {
enable = true;
highlightDefinitions = {
enable = true;
clearOnCursorMove = false;
};
};
hmts = mkIf cfg.enable {
enable = true;
};
};
};
}

View File

@@ -0,0 +1,78 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.vimtex;
in {
options = {
modules.devtools.nixvim.plugins.vimtex.enable = mkEnableOption "Enables VimTeX plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins.vimtex = {
enable = true;
settings = {
view_method = "zathura";
quickfix_enabled = true;
quickfix_open_on_warning = false;
quickfix_ignore_filters = [
"Underfull"
"Overfull"
"specifier changed to"
"Token not allowed in a PDF string"
];
toc_config = {
name = "TOC";
layers = ["content" "todo"];
resize = true;
split_width = 50;
todo_sorted = false;
show_help = true;
show_numbers = true;
mode = 2;
};
};
};
files."after/ftplugin/tex.lua".keymaps = [
{
mode = "n";
key = "m";
action = ":VimtexView<cr>";
}
];
autoCmd = [
{
event = ["BufEnter" "BufWinEnter"];
pattern = "*.tex";
command = "set filetype=tex \"| VimtexTocOpen";
}
{
event = "FileType";
pattern = ["tex" "latex"];
callback = ''
function ()
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'vimtex#fold#level(v:lnum)'
vim.o.foldtext = 'vimtex#fold#text()'
end
'';
}
{
event = "User";
pattern = "VimtexEventInitPost";
callback = "vimtex#compiler#compile";
}
{
event = "User";
pattern = "VimtexEventQuit";
command = "call vimtex#compiler#clean(0)";
}
];
};
};
}

View File

@@ -0,0 +1,18 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.yanky;
in {
options = {
modules.devtools.nixvim.plugins.yanky.enable = mkEnableOption "Enables Yanky plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.yanky = {
enable = true;
};
};
}