-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
109 lines (95 loc) · 3.54 KB
/
Copy pathflake.nix
File metadata and controls
109 lines (95 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{
description = "codestats.nvim development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
# Create a custom neovim wrapper with development tools
dev-environment = pkgs.symlinkJoin {
name = "codestats-dev-environment";
paths = with pkgs; [
stylua
lua-language-server
(writeScriptBin "nvim-dev" ''
#!${pkgs.bash}/bin/bash
NVIM_DATA_DIR=$(mktemp -d)
PLUGIN_DIR="$PWD" # Use current working directory
export NVIM_DATA_DIR PLUGIN_DIR
echo "Loading plugin from: $PLUGIN_DIR" # Debug print
${pkgs.neovim}/bin/nvim \
-u ${pkgs.writeText "init.lua" ''
-- Add plenary to runtime path
vim.opt.rtp:prepend("${pkgs.vimPlugins.plenary-nvim}")
vim.opt.rtp:prepend("${pkgs.vimPlugins.nui-nvim}")
-- Plugin configuration
local config = {
api_key = 'your token',
excluded_filetypes = { 'help', 'text', 'txt', 'log' },
pulse_interval = 5000,
username = 'skinnyvans',
debug = false
}
-- Function to setup/reload the plugin
local function setup_plugin()
-- Clear module cache
for name, _ in pairs(package.loaded) do
if name:match('^codestats') then
package.loaded[name] = nil
end
end
-- Add plugin to runtime path
if vim.env.PLUGIN_DIR then
print("Loading plugin from: " .. vim.env.PLUGIN_DIR)
vim.opt.rtp:prepend(vim.env.PLUGIN_DIR)
else
print("Warning: PLUGIN_DIR environment variable not set")
return false
end
-- Load plugin
local ok, codestats = pcall(require, 'codestats')
if ok then
codestats.setup(config)
return true
else
print("Warning: Could not load codestats plugin")
return false
end
end
-- Initial plugin setup
setup_plugin()
-- Reload function
function reload_codestats()
local success = setup_plugin()
if success then
vim.notify("codestats.nvim reloaded!", vim.log.levels.INFO)
else
vim.notify("Failed to reload codestats.nvim!", vim.log.levels.ERROR)
end
end
-- Map the reload function
vim.keymap.set('n', '<leader>cr', reload_codestats, { noremap = true, silent = true, desc = "Reload codestats.nvim" })
''} "$@"
'')
];
};
in
{
packages = {
default = dev-environment;
};
devShells.default = pkgs.mkShell {
buildInputs = [ dev-environment ];
};
}
);
}