1 =================================================================================
2 nixCats.luaUtils
3 ---------------------------------------------------------------------------------
4 nixCats.luaUtils.intro
5 nixCats has good integration with pckr and other similar neovim package
6 managers.
7
8 Keep in mind they may not work so well on nixos,
9 so when you are on nixOS you should load neovim via nix
10 (not sure if that part needs stating)
11
12 to get your lua utils run
13
14 nix flake init -t github:BirdeeHub/nixCats-nvim#luaUtils
15
16 ALSO keep in mind, if you are not using nix, you will have to download
17 all your non-plugin, non-lsp dependencies manually, and this may suck.
18 Therefore, all this stuff about package managers may be of limited utility.
19
20 I have written some lua utilities to enable this.
21 There is a template for them, and you can use the flake init -t
22 variable to import the luaUtils template in the root directory of your config
23 to add it to your project in the correct place.
24
25 -------------------------------------------------------------------------------
26 nixCats.luaUtils.setup
27 They are located within the lua/nixCatsUtils directory of the
28 flake. The main init.lua in it contains a require("nixCatsUtils").setup
29 function, and a require("nixCatsUtils").isNixCats variable.
30
31 The require("nixCatsUtils").isNixCats variable is true if
32 you installed neovim via nix, and otherwise it is false.
33 This is used to enable package managers only when not loaded via nix.
34
35 You run the setup function in your init.lua file at the start, and tell it
36 what nixCats global command should default to if isNixCats is false.
37 The default is true.
38
39 IF YOU DO NOT DO THIS SETUP CALL:
40 the result will be that, when you load this folder without using nix,
41 the global nixCats function which you use everywhere
42 to check for categories will throw an error.
43 This setup function will give it a default value.
44 Of course, if you only ever download nvim with nix, this isnt needed.
45 But it cant hurt to include anyway.
46
47 vim.g.mapleader = ' '
48 vim.g.maplocalleader = ' '
49
50
51 require('nixCatsUtils').setup {
52 non_nix_value = true,
53 }
54
55 if require('nixCatsUtils').isNixCats then
56 print('using nixCats')
57 end
58
59 it also has a few other things that may prove handy
60
61
62
63 require('nixCatsUtils').lazyAdd(v, o)
64
65
66
67
68
69
70 require('nixCatsUtils').enableForCategory(v, default)
71
72
73
74
75
76
77
78
79
80
81
82 require('nixCatsUtils').getCatOrDefault(v, default)
83
84
85
86
87 require('nixCatsUtils').packageBinPath
88
89
90
91 ---------------------------------------------------------------------------------
92 nixCats.luaUtils.lazy
93 For instructions on using the lazy wrapper, check out this template example!
94 Disclaimer, it uses a new lazy option only
95 in pkgs.lazy-nvim from the unstable branch.
96 So if you are using nixpkgs stable for your neovim you will
97 need to download a newer version of lazy-nvim.
98
99 Use the following command in a new directory and check it out!
100
101 nix flake init -t github:BirdeeHub/nixCats-nvim#kickstart-nvim
102
103 In that template, all notes about the lazy wrapper are in comments that begin
104 with the string: NOTE: nixCats: so to find all of the info, search for that.
105
106 The 3 main utilities at require('nixCatsUtils.lazyCat')
107
108
109
110
111
112
113 require('nixCatsUtils.lazyCat').setup(pluginTable, nixLazyPath, lazySpecs, lazyCFG)
114
115
116
117
118 pluginTable should contain the plugin names, which lazy.nvim will match
119 against the repo names of the plugins.
120 You may get this by merging the tables of plugins provided by nix.
121
122 local plugins = require('nixCats').pawsible.allPlugins
123 local pluginTable = require('nixCatsUtils.lazyCat')
124 .mergePluginTables(plugins.start, plugins.opt)
125
126 NOTE: Keep in mind you may need to add a few items for plugins with different
127 repo names from their nix plugin names. When you do this, you should also
128 set the name field in that plugin's spec to the nix-provided value.
129
130
131
132 pluginTable[ [[Comment.nvim]] ] = ""
133 pluginTable[ [[LuaSnip]] ] = ""
134
135
136
137
138
139
140
141
142 You may view the list of plugin names provided by nix to make
143 this easier via :NixCats pawsible
144
145 If you do not have the correct name for the plugin in the pluginTable argument,
146 lazy.nvim will attempt to download the plugin normally. This will often work anyway.
147
148 nixLazyPath is the path to lazy.nvim downloaded via nix. You may get it
149 via the same table you got the other plugin names from.
150
151 lazy.nvim disables all normal plugin loading, so if you want to load a plugin
152 via nix, you must also fill out a spec for it.
153
154 If you plan on loading a plugin via nix, and it has a build step,
155 you may conditionally disable it via nixCatsUtils.lazyAdd function,
156 thus ensuring it does not run if nix downloads it,
157 but still runs if you did not load your config via nix.
158
159 The other 2 functions, which are useful for creating
160 the table of plugin names for the setup function above:
161
162
163 require('nixCatsUtils.lazyCat').mergePluginTables(table1, table2)
164
165 require('nixCatsUtils.lazyCat').getTableNamesOrListValues(pluginTable)
166
167 The tutorial:
168
169 kickstart-nvim = {
170 path = ./kickstart-nvim;
171 description = ''
172 The entirety of kickstart.nvim implemented as a nixCats flake.
173 With additional nix lsps for editing the nix part.
174 This is to serve as the tutorial for using the nixCats lazy wrapper.
175 '';
176 };
177
178 In that template, all notes about the lazy wrapper are in comments that begin
179 with the string: NOTE: nixCats: so to find all of the info, search for that.
180
181 ---------------------------------------------------------------------------------
182 nixCats.luaUtils.pckr
183 -- load the plugins via pckr
184 -- YOU are in charge of putting the plugin
185 -- urls and build steps in there,
186 -- and you should keep any setup functions and config
187 -- OUT of this table, as pckr is ONLY loaded when this
188 -- configuration is NOT loaded via nix.
189
190 -- TL;DR:
191 -- ### DONT USE CONFIG VARIABLE ###
192 -- unless you are ok with that instruction
193 -- not being ran when used via nix,
194 -- this file will not be ran when using nix
195
196 -- Do what you would have done via config variable,
197 -- somewhere else checked by category.
198
199 require('nixCatsUtils.catPacker').setup({
200
201 { 'joshdick/onedark.vim', },
202 { 'nvim-tree/nvim-web-devicons', },
203
204 { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate',
205 requires = {
206 'nvim-treesitter/nvim-treesitter-textobjects',
207 },
208 },
209 {'nvim-telescope/telescope.nvim',
210 requires = {
211 'nvim-lua/plenary.nvim',
212 { 'nvim-telescope/telescope-fzf-native.nvim', run = 'which make && make', }
213 },
214 },
215
216 { 'neovim/nvim-lspconfig',
217 requires = {
218 { 'williamboman/mason.nvim', },
219 { 'williamboman/mason-lspconfig.nvim', },
220 { 'j-hui/fidget.nvim', },
221 },
222 },
223
224
225
226 { 'folke/lazydev.nvim',
227 cond = function(_) end,
228 },
229 { 'hrsh7th/nvim-cmp',
230 requires = {
231 { 'onsails/lspkind.nvim', },
232 { 'L3MON4D3/LuaSnip', },
233 { 'saadparwaiz1/cmp_luasnip', },
234 { 'hrsh7th/cmp-nvim-lsp', },
235 { 'hrsh7th/cmp-nvim-lua', },
236 { 'hrsh7th/cmp-nvim-lsp-signature-help', },
237 { 'hrsh7th/cmp-path', },
238 { 'rafamadriz/friendly-snippets', },
239 { 'hrsh7th/cmp-buffer', },
240 { 'hrsh7th/cmp-cmdline', },
241 { 'dmitmel/cmp-cmdline-history', },
242 },
243 },
244
245 { 'mfussenegger/nvim-dap',
246 requires = {
247 { 'rcarriga/nvim-dap-ui', },
248 { 'theHamsta/nvim-dap-virtual-text', },
249 { 'jay-babu/mason-nvim-dap.nvim', },
250 },
251 },
252
253
254 { 'mbbill/undotree', },
255 { 'tpope/vim-fugitive', },
256 { 'tpope/vim-rhubarb', },
257 { 'tpope/vim-sleuth', },
258 { 'folke/which-key.nvim', },
259 { 'lewis6991/gitsigns.nvim', },
260 { 'nvim-lualine/lualine.nvim', },
261 { 'lukas-reineke/indent-blankline.nvim', },
262 { 'numToStr/Comment.nvim', },
263 { 'kylechui/nvim-surround',
264 requires = { 'tpope/vim-repeat', },
265 },
266
267 {
268 "iamcco/markdown-preview.nvim",
269 run = function() vim.fn["mkdp#util#install"]() end,
270 },
271 })
272
273 -- all the rest of the setup will be done using the normal setup functions later,
274 -- thus working regardless of what method loads the plugins.
275 -- only stuff pertaining to downloading should be added to pckr's table.
276
277 =================================================================================
278 vim:tw=78:ts=8:ft=help:norl: