From e0dfc1e2d14c152ca5d67c2e1b0cfae41bc3c4a3 Mon Sep 17 00:00:00 2001 From: Prunebutt Date: Fri, 21 Nov 2025 22:08:37 +0100 Subject: [PATCH] configure astrocore more --- config/core.nix | 16 +++++++++++++++- flake.nix | 17 +++++++++++++---- plugins/astrocore.nix | 42 +++++++++++++++++++++++++++++++++++++---- plugins/astroui.nix | 7 +++++++ plugins/default.nix | 15 +++++++++++---- plugins/lsp/default.nix | 28 +++++++++++++++++++++++++++ 6 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 plugins/astroui.nix create mode 100644 plugins/lsp/default.nix diff --git a/config/core.nix b/config/core.nix index fbd058b..40016bd 100644 --- a/config/core.nix +++ b/config/core.nix @@ -1,3 +1,17 @@ -{ +{pkgs,...}@args: { enablePrintInit = true; + + # extraPackages = with pkgs; [ + # ]; + opts = { + relativenumber = true; + number = true; + spell = false; + signcolumn = "yes"; + wrap = false; + }; + + withNodeJs = args.withNojeJs or true; + + # TODO: autocmnds necessary? } diff --git a/flake.nix b/flake.nix index 4a93a5c..f57aa99 100644 --- a/flake.nix +++ b/flake.nix @@ -7,9 +7,7 @@ }; outputs = { self, nixpkgs, nixvim, flake-utils, ... }@inputs: - let - config = import ./config; # import the module directly - in flake-utils.lib.eachDefaultSystem (system: + flake-utils.lib.eachDefaultSystem (system: let nixvimLib = nixvim.lib.${system}; pkgs = import nixpkgs { inherit system; }; @@ -18,6 +16,16 @@ inherit pkgs; module = ./.; }; + mkNixvim = specialArgs: + nixvim.legacyPackages.${system}.makeNixvimWithModule { + inherit pkgs; + + module = ./.; + + extraSpecialArgs = specialArgs // { + inherit pkgs; + }; + }; in { formatter = nixpkgs.legacyPackages.${system}.alejandra; @@ -30,7 +38,8 @@ packages = { # Lets you run `nix run .` to start nixvim - default = nvim; + default = mkNixvim { }; + lite = mkNixvim { withNodeJs = false; }; }; devShells.default = import ./shell.nix { inherit pkgs; }; diff --git a/plugins/astrocore.nix b/plugins/astrocore.nix index 6411b99..99b708c 100644 --- a/plugins/astrocore.nix +++ b/plugins/astrocore.nix @@ -1,12 +1,12 @@ {pkgs, lib,...}: let - inherit lib.nixvim.lua.toLuaObject; + inherit (lib.nixvim.lua) toLuaObject; options = { features = { - large_buf = { size = 1024 * 256; lines = 10000 }; # set global limits for large files for disabling features like treesitter + large_buf = { size = 1024 * 256; lines = 10000; }; # set global limits for large files for disabling features like treesitter autopairs = true; # enable autopairs at start cmp = true; # enable completion at start - diagnostics = { virtual_text = true; virtual_lines = false }; # diagnostic settings on startup + diagnostics = { virtual_text = true; virtual_lines = false; }; # diagnostic settings on startup highlighturl = true; # highlight URLs at start notifications = true; # enable notifications at start }; @@ -28,11 +28,45 @@ # [".*/etc/foo/.*"] = "fooscript"; # }; # }; + rooter = { + # list of detectors in order of prevalence, elements can be: + # "lsp" : lsp detection + # string[] : a list of directory patterns to look for + # fun(bufnr: integer): string|string[] : a function that takes a buffer number and outputs detected roots + detector = [ + "lsp" # highest priority is getting workspace from running language servers + [ ".git" "_darcs" ".hg" ".bzr" ".svn" ] # next check for a version controlled parent directory + [ "lua" "MakeFile" "package.json" ] # lastly check for known project root files + ]; + # ignore things from root detection + ignore = { + servers = []; # list of language server names to ignore (Ex. { "efm" }) + dirs = []; # list of directory patterns (Ex. { "~/.cargo/*" }) + }; + # automatically update working directory (update manually with `:AstroRoot`) + autochdir = false; + # scope of working directory to change ("global"|"tab"|"win") + scope = "global"; + # show notification on every working directory change + notify = true; + }; + sessions = { + autosave = { + last = true; # autosave last session + cwd = true; # auosave session for each working dir + }; + # Patterns to ignore when saving sessions + ignore = { + dirs = []; # working directories to ignore sessions in + filetypes = [ "gitcommit" "gitrebase" ]; # filetypes to ignore sessions + buftypes = []; # buffer types to ignore sessions + }; + }; }; in { extraPlugins = [pkgs.vimPlugins.astrocore]; extraConfigLua = /*lua*/ '' require('astrocore').setup(${toLuaObject options}) - '' + ''; } diff --git a/plugins/astroui.nix b/plugins/astroui.nix new file mode 100644 index 0000000..1dc2258 --- /dev/null +++ b/plugins/astroui.nix @@ -0,0 +1,7 @@ +{pkgs, lib, ...}:{ + extraPlugins = [pkgs.vimPlugins.astroui]; + + extraConfigLua = /*lua*/ '' + require('astroui').setup({}); + ''; +} diff --git a/plugins/default.nix b/plugins/default.nix index 8cfbb04..b99a78f 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -1,5 +1,12 @@ -{ - imports = [ - ./treesitter.nix - ]; +{lib, ...}: let + definitions = lib.attrNames ( + lib.filterAttrs + (filename: kind: + filename != "default.nix" + && (kind == "regular" || kind == "directory") + ) + (builtins.readDir ./.) + ); +in { + imports = map (file: import ./${file}) definitions; } diff --git a/plugins/lsp/default.nix b/plugins/lsp/default.nix new file mode 100644 index 0000000..4f513e0 --- /dev/null +++ b/plugins/lsp/default.nix @@ -0,0 +1,28 @@ +{pkgs, ...}@args:{ + plugins.lsp = { + enable = true; + + servers = { + bashls.enable = true; + cssls.enable = true; + docker_compose_language_service.enable = true; + dockerls.enable = true; + helm_ls.enable = true; + html.enable = true; + jsonls.enable = true; + lua_ls.enable = true; + nginx_language_server.enable = true; + nixd.enable = true; + pyright.enable = true; + yamlls.enable = true; + clangd.enable = true; + marksman.enable = true; + texlab.enable = true; + lemminx.enable = true; # XML + + java_language_server.enable = false; + zls.enable = false; + rust_analyzer.enable = false; + }; + }; +}