Refactore nvim config

This commit is contained in:
Martin Pander
2026-02-10 22:00:42 +01:00
parent eb1c83806d
commit 65cc61773f
7 changed files with 100 additions and 87 deletions

View File

@@ -22,4 +22,5 @@
}; };
dot.tmux.workMode = true; dot.tmux.workMode = true;
dot.nvim.workMode = true;
} }

View File

@@ -1,6 +1,14 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let
cfg = config.dot.nvim;
in
{ {
options.dot.nvim = {
workMode = lib.mkEnableOption "work-specific neovim configuration";
};
config = {
programs.neovim = { programs.neovim = {
enable = true; enable = true;
@@ -71,17 +79,18 @@
(nvim-treesitter.withPlugins (p: [ p.awk p.bash p.c p.c_sharp p.cpp p.css p.diff p.dockerfile p.doxygen p.git_config p.gitcommit p.go p.gomod p.gosum p.gotmpl p.helm p.haskell p.html p.http p.java p.javascript p.json p.latex p.lua p.markdown p.markdown_inline p.matlab p.nix p.printf p.python p.regex p.rust p.sql p.strace p.supercollider p.svelte p.swift p.terraform p.tmux p.toml p.typescript p.vim p.xml p.yaml p.zig ])) (nvim-treesitter.withPlugins (p: [ p.awk p.bash p.c p.c_sharp p.cpp p.css p.diff p.dockerfile p.doxygen p.git_config p.gitcommit p.go p.gomod p.gosum p.gotmpl p.helm p.haskell p.html p.http p.java p.javascript p.json p.latex p.lua p.markdown p.markdown_inline p.matlab p.nix p.printf p.python p.regex p.rust p.sql p.strace p.supercollider p.svelte p.swift p.terraform p.tmux p.toml p.typescript p.vim p.xml p.yaml p.zig ]))
]; ];
# Use extraLuaConfig for home-manager 25.11 compatibility extraLuaConfig = ''
# (initLua was renamed from extraLuaConfig in later versions) _G.is_work = ${if cfg.workMode then "true" else "false"}
extraLuaConfig = builtins.concatStringsSep "\n" [ _G.is_mac = ${if pkgs.stdenv.isDarwin then "true" else "false"}
(lib.strings.fileContents ../../../nvim/base.lua) '';
(lib.strings.fileContents ../../../nvim/keymaps.lua)
(lib.strings.fileContents ../../../nvim/plugins.lua)
(lib.strings.fileContents ../../../nvim/filetype.lua)
];
}; };
# Symlink the nvim directory to ~/.config/nvim
# This allows for editing the config without a nix rebuild
xdg.configFile."nvim".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dev/dot/nvim";
home.packages = with pkgs; [ home.packages = with pkgs; [
nodejs-slim nodejs-slim
]; ];
};
} }

7
nvim/init.lua Normal file
View File

@@ -0,0 +1,7 @@
-- init.lua
-- This file is managed by Nix, but requires standard Lua modules from the lua/ directory
require('base')
require('keymaps')
require('plugins')
require('filetype')

View File

@@ -10,10 +10,6 @@ require('mini.move').setup()
require('flash').setup() require('flash').setup()
require('ts-comments').setup() require('ts-comments').setup()
local function is_wsl_env()
return os.getenv("WSL_DISTRO_NAME") ~= nil or os.getenv("WSL_INTEROP") ~= nil
end
vim.g.tagbar_left=1 vim.g.tagbar_left=1
vim.g.tagbar_autoclose=1 vim.g.tagbar_autoclose=1
vim.g.tagbar_autofocus=1 vim.g.tagbar_autofocus=1
@@ -381,7 +377,7 @@ dap.configurations.zig = {
}, },
} }
if vim.fn.has("mac") then if _G.is_mac then
workspaces = { workspaces = {
{ {
name = "privat", name = "privat",
@@ -400,7 +396,7 @@ if vim.fn.has("mac") then
} }
end end
if is_wsl_env() then if _G.is_work then
workspaces = { workspaces = {
{ {
name = "work", name = "work",