configuration.nix/nvim/dev-plugins.nix
Jalil David Salamé Messina 26a77f6b6b
All checks were successful
/ check (push) Successful in 47s
/ build (audiomenu) (push) Successful in 2s
/ build (docs) (push) Successful in 2s
/ build (jpassmenu) (push) Successful in 2s
/ build (nixosConfigurations.vm.config.system.build.toplevel) (push) Successful in 1s
/ build (nvim) (push) Successful in 1s
[chore] flake.lock: update inputs
Flake lock file updates:

• Updated input 'home-manager':
    'github:nix-community/home-manager/c7ffc9727d115e433fd884a62dc164b587ff651d' (2024-12-07)
  → 'github:nix-community/home-manager/1318c3f3b068cdcea922fa7c1a0a1f0c96c22f5f' (2024-12-11)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/4dc2fc4e62dbf62b84132fe526356fbac7b03541' (2024-12-05)
  → 'github:NixOS/nixpkgs/a0f3e10d94359665dba45b71b4227b0aeb851f8e' (2024-12-10)
• Updated input 'nixvim':
    'github:nix-community/nixvim/4b5364a66bffd22536e358214b37068b34287a7a' (2024-12-08)
  → 'github:nix-community/nixvim/c181014422fa9261db06fc9b5ecbf67f42c30ec3' (2024-12-13)
• Updated input 'stylix':
    'github:danth/stylix/d13ffb381c83b6139b9d67feff7addf18f8408fe' (2024-11-30)
  → 'github:danth/stylix/9015d5d0d5d100f849129c43d257b827d300b089' (2024-12-13)
• Updated input 'stylix/gnome-shell':
    'github:GNOME/gnome-shell/0d0aadf013f78a7f7f1dc984d0d812971864b934' (2024-04-21)
  → 'github:GNOME/gnome-shell/dadd58f630eeea41d645ee225a63f719390829dc' (2024-11-23)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/357cda84af1d74626afb7fb3bc12d6957167cda9' (2024-12-08)
  → 'github:numtide/treefmt-nix/0ce9d149d99bc383d1f2d85f31f6ebd146e46085' (2024-12-09)
• Updated input 'unstable':
    'github:NixOS/nixpkgs/22c3f2cf41a0e70184334a958e6b124fb0ce3e01' (2024-12-07)
  → 'github:NixOS/nixpkgs/5d67ea6b4b63378b9c13be21e2ec9d1afc921713' (2024-12-11)
2024-12-14 12:11:26 +01:00

188 lines
4.7 KiB
Nix

{
lib,
pkgs,
config,
helpers,
...
}:
let
inherit (helpers) enableExceptInTests;
cfg = config.jhome.nvim;
enabledLSPs = [
"basedpyright"
"bashls"
"clangd"
# "html" # Not writing html
"jsonls"
"marksman"
"nixd"
"ruff"
"taplo"
# "texlab" # Not using it
"typos_lsp"
# "typst_lsp" # Not using it
"zls"
];
in
{
config = lib.mkIf cfg.dev.enable (
lib.mkMerge [
# Enable LSPs
{
plugins.lsp.servers = lib.genAttrs enabledLSPs (_: {
enable = true;
});
}
# Remove bundled LSPs
(lib.mkIf (!cfg.dev.bundleLSPs) {
plugins.lsp.servers = lib.genAttrs enabledLSPs (_: {
package = null;
});
})
# Configure LSPs
{
plugins = {
lsp = {
enable = true;
servers = {
# Pyright needs to have the project root set?
basedpyright.rootDir = # lua
''
function()
return vim.fs.root(0, {'flake.nix', '.git', '.jj', 'pyproject.toml', 'setup.py'})
end
'';
bashls.package = lib.mkDefault pkgs.bash-language-server;
# Adds ~2 GiB, install in a devShell instead
clangd.package = lib.mkDefault null;
# zls & other zig tools are big, install in a devShell instead
zls.package = lib.mkDefault null;
};
};
lspkind = {
enable = true;
mode = "symbol";
extraOptions.maxwidth = 50;
};
lsp-lines.enable = true;
};
}
# Configure Treesitter
{
plugins.treesitter = {
enable = true;
settings = {
highlight.enable = true;
indent.enable = true;
incremental_election.enable = true;
};
};
}
# Do not bundle treesitter grammars
(lib.mkIf (!cfg.dev.bundleGrammars) { plugins.treesitter.grammarPackages = [ ]; })
# Remove tools for building gramars when bundling them
(lib.mkIf cfg.dev.bundleGrammars {
plugins.treesitter = {
gccPackage = null;
nodejsPackage = null;
treesitterPackage = null;
};
})
# Configure Formatters
{
extraPackages = [
pkgs.luajitPackages.jsregexp
pkgs.shfmt
pkgs.stylua
pkgs.taplo
pkgs.yamlfmt
];
plugins.conform-nvim = {
enable = true;
settings = {
formatters.nixfmt.command = "${lib.getExe pkgs.nixfmt-rfc-style}";
formatters_by_ft = {
"_" = [ "trim_whitespace" ];
c = [ "clang_format" ];
cpp = [ "clang_format" ];
lua = [ "stylua" ];
nix = [ "nixfmt" ];
rust = [ "rustfmt" ];
sh = [ "shfmt" ];
toml = [ "taplo" ];
yaml = [ "yamlfmt" ];
zig = [ "zigfmt" ];
};
};
};
}
# Configure Linters
{
extraPackages = [
pkgs.dash
pkgs.statix
];
plugins.lint = {
enable = true;
lintersByFt = {
# latex = [ "chktex" ]; # Not in use
nix = [ "statix" ];
sh = [ "dash" ];
zsh = [ "zsh" ];
};
};
}
# Jupyter notebooks
{
extraPackages = [ (pkgs.python3.withPackages (p: [ p.jupytext ])) ];
plugins = {
image.enable = enableExceptInTests;
jupytext = {
enable = true;
settings.custom_language_formatting.python = {
extension = "md";
style = "markdown";
force_ft = "markdown";
};
};
molten = {
enable = true;
settings = {
image_provider = "image.nvim";
virt_text_output = true;
molten_auto_open_output = false;
molten_virt_lines_off_by_1 = true;
};
};
};
}
# Rust plugins
{
plugins = {
bacon = {
enable = true;
settings.quickfix.enabled = true;
};
rustaceanvim = {
enable = true;
# Install through rustup
rustAnalyzerPackage = null;
};
};
}
# Other plugins
{
plugins = {
colorizer = {
enable = true;
settings.user_default_options = {
names = false; # disable named colors (i.e. red)
mode = "virtualtext";
};
};
otter.enable = true;
};
}
]
);
}