refactor(nvim): add _file and config attrs to all submodules
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-21 23:34:10 -05:00
parent e1d77a4f3b
commit 0f627107ce
23 changed files with 243 additions and 209 deletions

View file

@ -87,7 +87,6 @@
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -84,7 +84,6 @@ in {
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -70,7 +70,6 @@
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -43,7 +43,6 @@
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -70,7 +70,6 @@
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -84,7 +84,6 @@
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -106,7 +106,6 @@
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};

View file

@ -4,7 +4,9 @@ self: {
pkgs,
...
}: let
inherit (lib) mkOption types;
inherit (lib) mkIf mkOption types;
cfg = config.programs.neovim;
in {
imports = [
./git
@ -17,94 +19,92 @@ in {
user = mkOption {
type = types.str;
};
enableIde = mkOption {
type = types.bool;
default = false;
};
};
config.programs.neovim = {
extraLuaConfig =
# lua
''
-- by default, the indent is 2 spaces.
vim.opt.smartindent = true;
vim.opt.expandtab = true;
vim.opt.shiftwidth = 2;
vim.opt.softtabstop = 2;
vim.opt.tabstop = 2;
config = mkIf cfg.enable {
programs.neovim = {
extraLuaConfig =
# lua
''
-- by default, the indent is 2 spaces.
vim.opt.smartindent = true;
vim.opt.expandtab = true;
vim.opt.shiftwidth = 2;
vim.opt.softtabstop = 2;
vim.opt.tabstop = 2;
vim.opt.number = true;
vim.opt.relativenumber = true;
vim.opt.number = true;
vim.opt.relativenumber = true;
vim.opt.undofile = true;
vim.opt.undodir = '${config.xdg.cacheHome}/nvim/';
vim.opt.undofile = true;
vim.opt.undodir = '${config.xdg.cacheHome}/nvim/';
-- Always show the signcolumn, otherwise it would shift
-- the text each time diagnostics appear/become resolved
vim.opt.signcolumn = 'yes';
-- Always show the signcolumn, otherwise it would shift
-- the text each time diagnostics appear/become resolved
vim.opt.signcolumn = 'yes';
-- remove highlight on words
vim.keymap.set('n', '<esc>', ':noh<cr><esc>', {
noremap = true,
silent = true,
});
-- remove highlight on words
vim.keymap.set('n', '<esc>', ':noh<cr><esc>', {
noremap = true,
silent = true,
});
-- https://github.com/seblj/roslyn.nvim/issues/121#issuecomment-2544076963
vim.opt.cmdheight = 2;
'';
-- https://github.com/seblj/roslyn.nvim/issues/121#issuecomment-2544076963
vim.opt.cmdheight = 2;
'';
plugins = [
pkgs.vimPlugins.fzfWrapper
pkgs.vimPlugins.fzf-vim
plugins = [
pkgs.vimPlugins.fzfWrapper
pkgs.vimPlugins.fzf-vim
{
plugin = pkgs.vimPlugins.todo-comments-nvim;
type = "lua";
config =
# lua
''
require('todo-comments').setup();
'';
}
{
plugin = pkgs.vimPlugins.mini-nvim;
type = "lua";
config =
# lua
''
-- TODO: see how this works
local ts_input = require('mini.surround').gen_spec.input.treesitter;
{
plugin = pkgs.vimPlugins.todo-comments-nvim;
type = "lua";
config =
# lua
''
require('todo-comments').setup();
'';
}
{
plugin = pkgs.vimPlugins.mini-nvim;
type = "lua";
config =
# lua
''
-- TODO: see how this works
local ts_input = require('mini.surround').gen_spec.input.treesitter;
require('mini.surround').setup({
custom_surroundings = {
-- Use tree-sitter to search for function call
f = {
input = ts_input({
outer = '@call.outer',
inner = '@call.inner',
});
},
},
});
'';
}
require('mini.surround').setup({
custom_surroundings = {
-- Use tree-sitter to search for function call
f = {
input = ts_input({
outer = '@call.outer',
inner = '@call.inner',
});
},
},
});
'';
}
{
plugin = pkgs.vimPlugins.nvim-config-local;
type = "lua";
config =
# lua
''
require('config-local').setup({
config_files = { '.nvim.lua', '.nvimrc', '.exrc' },
{
plugin = pkgs.vimPlugins.nvim-config-local;
type = "lua";
config =
# lua
''
require('config-local').setup({
config_files = { '.nvim.lua', '.nvimrc', '.exrc' },
-- Where the plugin keeps files data
hashfile = '${config.xdg.cacheHome}/nvim/config-local',
});
'';
}
];
-- Where the plugin keeps files data
hashfile = '${config.xdg.cacheHome}/nvim/config-local',
});
'';
}
];
};
};
# For accurate stack trace

View file

@ -8,51 +8,55 @@
cfg = config.programs.neovim;
in {
programs = mkIf cfg.enable {
# I love doing typos
bash.shellAliases = {
nivm = "nvim";
nivim = "nvim";
};
config = mkIf cfg.enable {
programs = {
# I love doing typos
bash.shellAliases = {
nivm = "nvim";
nivim = "nvim";
};
neovim = {
defaultEditor = true;
viAlias = true;
vimAlias = true;
neovim = {
defaultEditor = true;
viAlias = true;
vimAlias = true;
extraPackages = mkIf cfg.enableIde (attrValues {
inherit
(pkgs.nodePackages)
bash-language-server
;
extraPackages = attrValues {
inherit
(pkgs.nodePackages)
bash-language-server
;
inherit
(pkgs)
shellcheck
;
});
inherit
(pkgs)
shellcheck
;
};
extraLuaConfig =
mkIf cfg.enableIde
# lua
''
vim.api.nvim_create_autocmd('FileType', {
pattern = 'sh',
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
extraLuaConfig =
# lua
''
vim.api.nvim_create_autocmd('FileType', {
pattern = 'sh',
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
require('lspconfig').bashls.setup({
capabilities = default_capabilities,
require('lspconfig').bashls.setup({
capabilities = default_capabilities,
settings = {
bashIde = {
shellcheckPath = '${getExe pkgs.shellcheck}',
},
},
});
'';
settings = {
bashIde = {
shellcheckPath = '${getExe pkgs.shellcheck}',
},
},
});
'';
};
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -9,7 +9,7 @@
cfg = config.programs.neovim;
in {
config = mkIf cfg.enableIde {
config = mkIf cfg.enable {
xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" {
CompileFlags.Add = ["-D__cpp_concepts=202002L"];
};
@ -21,6 +21,7 @@ in {
''
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'cpp', 'c' },
-- FIXME: load direnv here https://github.com/actionshrimp/direnv.nvim?tab=readme-ov-file#using-nvim-lspconfig
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
'';
@ -57,4 +58,7 @@ in {
};
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -10,7 +10,7 @@ self: {
cfg = config.programs.neovim;
in {
config = mkIf cfg.enableIde {
config = mkIf cfg.enable {
programs = {
neovim = {
extraPackages = attrValues {
@ -73,5 +73,5 @@ in {
};
# For accurate stack trace
_file = ./csharp.nix;
_file = ./default.nix;
}

View file

@ -1,9 +1,12 @@
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) fileContents mkBefore;
inherit (lib) fileContents mkBefore mkIf;
cfg = config.programs.neovim;
in {
imports = [
./bash
@ -21,8 +24,8 @@ in {
(import ./web self)
];
config.programs = {
neovim = {
config = mkIf cfg.enable {
programs.neovim = {
extraLuaConfig =
mkBefore
# lua

View file

@ -6,8 +6,8 @@
inherit (lib) mkIf;
cfg = config.programs.neovim;
in
mkIf cfg.enableIde {
in {
config = mkIf cfg.enable {
programs = {
neovim = {
extraLuaConfig =
@ -24,4 +24,8 @@ in
'';
};
};
}
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -10,8 +10,8 @@
javaSdk = pkgs.temurin-bin-17;
javaPkgs = attrValues {inherit (pkgs) gradle maven;};
in
mkIf cfg.enableIde {
in {
config = mkIf cfg.enable {
home.packages = javaPkgs;
xdg.dataFile.".gradle/gradle.properties".text = ''
@ -81,4 +81,8 @@ in
];
};
};
}
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -7,8 +7,8 @@
inherit (lib) attrValues mkIf;
cfg = config.programs.neovim;
in
mkIf cfg.enableIde {
in {
config = mkIf cfg.enable {
programs = {
neovim = {
extraPackages = attrValues {
@ -26,6 +26,7 @@ in
pattern = 'yaml',
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
vim.api.nvim_create_autocmd('FileType', {
pattern = 'json',
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
@ -54,4 +55,8 @@ in
'';
};
};
}
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -9,8 +9,8 @@
cfg = config.programs.neovim;
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
in
mkIf cfg.enableIde {
in {
config = mkIf cfg.enable {
programs = {
neovim = {
extraPackages = attrValues {
@ -38,8 +38,8 @@ in
require("neodev").setup({
override = function(root_dir, library)
if root_dir:find('${flakeEnv}', 1, true) == 1 then
library.enabled = true
library.plugins = true
library.enabled = true;
library.plugins = true;
end
end,
});
@ -52,4 +52,8 @@ in
];
};
};
}
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -19,9 +19,7 @@ self: {
hash = "sha256-deQvQOOyK6iP7kjVrgEdFTyOP80RWXMrETs6gi7DTmo=";
};
in {
# live-server --quiet --browser=firefox --open=%outputfile% --watch=%outputfile% --wait=800
config = mkIf cfg.enableIde {
config = mkIf cfg.enable {
programs = {
neovim = {
extraPackages = attrValues {
@ -165,5 +163,5 @@ in {
};
# For accurate stack trace
_file = ./markdown.nix;
_file = ./default.nix;
}

View file

@ -18,13 +18,10 @@ self: {
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
flakeDir = "${removePrefix "/home/${cfg.user}/" flakeEnv}";
in {
config = mkIf cfg.enableIde {
config = mkIf cfg.enable {
assertions = [
{
assertion =
cfg.enableIde
&& hasPrefix "/home/${cfg.user}/" flakeEnv
|| !cfg.enableIde;
assertion = hasPrefix "/home/${cfg.user}/" flakeEnv;
message = ''
Your $FLAKE environment variable needs to point to a directory in
the main users' home to use the neovim module.
@ -79,5 +76,5 @@ in {
};
# For accurate stack trace
_file = ./nix.nix;
_file = ./default.nix;
}

View file

@ -7,23 +7,20 @@
inherit (lib) attrValues mkIf;
cfg = config.programs.neovim;
pythonPkgs = py:
(attrValues {
inherit (py) python-lsp-server;
})
++ py.python-lsp-server.optional-dependencies.all;
in {
config = mkIf cfg.enableIde {
config = mkIf cfg.enable {
programs = {
neovim = {
withPython3 = true;
extraPython3Packages = py:
(attrValues {
inherit (py) python-lsp-server;
})
++ py.python-lsp-server.optional-dependencies.all;
extraPackages =
(attrValues {
inherit (pkgs.python3Packages) python-lsp-server;
})
++ pkgs.python3Packages.python-lsp-server.optional-dependencies.all;
extraPython3Packages = pythonPkgs;
extraPackages = pythonPkgs pkgs.python3Packages;
extraLuaConfig =
# lua
@ -45,4 +42,7 @@ in {
};
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -7,8 +7,8 @@
inherit (lib) attrValues mkIf;
cfg = config.programs.neovim;
in
mkIf cfg.enableIde {
in {
config = mkIf cfg.enable {
programs = {
neovim = {
extraPackages = attrValues {
@ -35,4 +35,8 @@ in
'';
};
};
}
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -11,7 +11,7 @@ self: {
cfg = config.programs.neovim;
in {
config = mkIf cfg.enableIde {
config = mkIf cfg.enable {
programs = {
neovim = {
withNodeJs = true;
@ -200,5 +200,5 @@ in {
};
# For accurate stack trace
_file = ./web.nix;
_file = ./default.nix;
}

View file

@ -5,19 +5,19 @@ self: {
...
}: let
inherit (self.inputs) nvim-theme-src;
inherit (lib) attrValues fileContents optionals;
inherit (lib) attrValues fileContents mkIf;
cfg = config.programs.neovim;
in {
imports = [./treesitter.nix];
config.programs.neovim = {
extraPackages = attrValues {
inherit (pkgs) bat;
};
config = mkIf cfg.enable {
programs.neovim = {
extraPackages = attrValues {
inherit (pkgs) bat;
};
plugins =
[
plugins = [
{
plugin = pkgs.vimPlugins.dracula-nvim.overrideAttrs {
src = nvim-theme-src;
@ -100,8 +100,7 @@ in {
type = "lua";
config = fileContents ./config/heirline.lua;
}
]
++ optionals cfg.enableIde [
{
plugin = pkgs.vimPlugins.neo-tree-nvim;
type = "lua";
@ -176,8 +175,9 @@ in {
'';
}
];
};
};
# For accurate stack trace
_file = ./theme.nix;
_file = ./default.nix;
}

View file

@ -1,34 +1,48 @@
{pkgs, ...}: {
programs.neovim.plugins = [
{
plugin = pkgs.vimPlugins.nvim-treesitter-context;
type = "lua";
config =
# lua
''
require('treesitter-context').setup({
enable = true,
max_lines = 3,
min_window_height = 20,
});
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
vim.cmd.hi('TreesitterContextBottom', 'gui=underline guisp=Grey');
'';
}
cfg = config.programs.neovim;
in {
config = mkIf cfg.enable {
programs.neovim.plugins = [
{
plugin = pkgs.vimPlugins.nvim-treesitter-context;
type = "lua";
config =
# lua
''
require('treesitter-context').setup({
enable = true,
max_lines = 3,
min_window_height = 20,
});
pkgs.vimPlugins.nvim-treesitter-textobjects
vim.cmd.hi('TreesitterContextBottom', 'gui=underline guisp=Grey');
'';
}
{
plugin = pkgs.vimPlugins.nvim-treesitter.withAllGrammars;
type = "lua";
config =
# lua
''
require('nvim-treesitter.configs').setup({
highlight = { enable = true },
indent = { enable = true },
});
'';
}
];
pkgs.vimPlugins.nvim-treesitter-textobjects
{
plugin = pkgs.vimPlugins.nvim-treesitter.withAllGrammars;
type = "lua";
config =
# lua
''
require('nvim-treesitter.configs').setup({
highlight = { enable = true },
indent = { enable = true },
});
'';
}
];
};
# For accurate stack trace
_file = ./treesitter.nix;
}