Compare commits

..

10 commits

Author SHA1 Message Date
Ching Pei Yang
3c3b08ff77
nixos: use attrset for long function args 2024-12-29 19:08:31 +01:00
Ching Pei Yang
dd567ccb7e
home-manager: use attr for long function args 2024-12-29 19:08:31 +01:00
Ching Pei Yang
8280ac0feb
nixos: remove redundant import module 2024-12-29 19:08:31 +01:00
Ching Pei Yang
1e94b7920d
home-manager: remove redundant import module 2024-12-29 19:08:31 +01:00
Ching Pei Yang
d0f942d12c
lib: remove anythingConcatLists 2024-12-29 19:08:30 +01:00
Ching Pei Yang
498d3d9370
nixos: use proper submodule type for settings 2024-12-29 19:08:30 +01:00
Ching Pei Yang
4078288bf8
module: remove redundant code
the bulk of the build step is moved to modules/wrapper/build
2024-12-29 19:08:30 +01:00
Ching Pei Yang
0bf8b4fce5
home-manager: use proper submodule type for settings 2024-12-29 19:08:30 +01:00
Ching Pei Yang
9f93f9f487
wrapper: add built package as option 2024-12-29 19:08:30 +01:00
Ching Pei Yang
e11c8aa7a0
wrapper: rename build dir to environemnt 2024-12-22 21:46:17 +01:00
17 changed files with 77 additions and 150 deletions

View file

@ -13,11 +13,4 @@
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim
- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim]. - Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim]
[diniamo](https://github.com/diniamo):
- Add Odin support under `vim.languages.odin`.
- Disable the built-in format-on-save feature of zls. Use `vim.lsp.formatOnSave`
instead.

View file

@ -38,11 +38,11 @@
}, },
"mnw": { "mnw": {
"locked": { "locked": {
"lastModified": 1735150973, "lastModified": 1731821965,
"narHash": "sha256-OJhcCAoaMMXeD6o4qI/hxBCNELJp4dN8D5LJZc8w8XA=", "narHash": "sha256-QiGi/HBQRnIRGY4gQPuH7T3hr7NznOpEO7qNpF5ldmE=",
"owner": "Gerg-L", "owner": "Gerg-L",
"repo": "mnw", "repo": "mnw",
"rev": "40cd0b006cc48dffd0f8698ad7f54cf1d56779a6", "rev": "5fe5c41975ed0af55f55dc37cd28ba906a5d015e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1729,11 +1729,11 @@
"plugin-run-nvim": { "plugin-run-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1735501787, "lastModified": 1732918526,
"narHash": "sha256-CFOyOARCLQiMOhFPeqz8n2ULyaaRxRZrOk0FCibjuIM=", "narHash": "sha256-kiszNmZZDXG8tAPMQKuGJDCkqCMzsWT7BkCvkVsH2lA=",
"owner": "diniamo", "owner": "diniamo",
"repo": "run.nvim", "repo": "run.nvim",
"rev": "9015c9cece816ccf10a185b420f6e345fd990802", "rev": "d867466e01b8fa4e54a589b9ef446cf43fb966de",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -31,7 +31,10 @@
}; };
homeManagerModules = { homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix {inherit lib self;}; nvf = import ./flake/modules/home-manager.nix {
inherit lib inputs;
inherit (self) packages;
};
default = self.homeManagerModules.nvf; default = self.homeManagerModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
@ -42,7 +45,10 @@
}; };
nixosModules = { nixosModules = {
nvf = import ./flake/modules/nixos.nix {inherit lib self;}; nvf = import ./flake/modules/nixos.nix {
inherit lib inputs;
inherit (self) packages;
};
default = self.nixosModules.nvf; default = self.nixosModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''

View file

@ -1,13 +1,13 @@
# Home Manager module # Home Manager module
{ {
self, packages,
lib, lib,
inputs,
}: { }: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (self) packages inputs;
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf mkAliasOptionModule; inherit (lib.modules) mkIf mkAliasOptionModule;
inherit (lib.lists) optional; inherit (lib.lists) optional;
@ -84,7 +84,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nvf.finalPackage = cfg.settings.vim.build.finalPackage; programs.nvf.finalPackage = config.programs.nvf.settings.vim.build.finalPackage;
home = { home = {
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";}; sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};

View file

@ -1,13 +1,13 @@
# NixOS module # NixOS module
{ {
self, packages,
lib, lib,
inputs,
}: { }: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (self) inputs packages;
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule; inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
inherit (lib.lists) optional; inherit (lib.lists) optional;
@ -84,7 +84,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nvf.finalPackage = cfg.settings.vim.build.finalPackage; programs.nvf.finalPackage = config.programs.nvf.settings.vim.build.finalPackage;
environment = { environment = {
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");

View file

@ -1,7 +1,8 @@
{lib}: let {lib}: let
inherit (lib.options) mergeEqualOption; inherit (lib.options) mergeEqualOption;
inherit (lib.strings) isString stringLength match; inherit (lib.strings) isString;
inherit (lib.types) listOf mkOptionType; inherit (lib.types) listOf mkOptionType;
inherit (builtins) stringLength match;
in { in {
mergelessListOf = elemType: let mergelessListOf = elemType: let
super = listOf elemType; super = listOf elemType;

View file

@ -77,9 +77,6 @@ in {
-- buffer is a real file on the disk -- buffer is a real file on the disk
local real_file = vim.fn.filereadable(data.file) == 1 local real_file = vim.fn.filereadable(data.file) == 1
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
-- buffer is a [No Name] -- buffer is a [No Name]
local no_name = data.file == "" and vim.bo[data.buf].buftype == "" local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
@ -87,7 +84,7 @@ in {
local filetype = vim.bo[data.buf].ft local filetype = vim.bo[data.buf].ft
-- only files please -- only files please
if not real_file and not directory and not no_name then if not real_file and not no_name then
return return
end end
@ -96,10 +93,6 @@ in {
return return
end end
-- cd if buffer is a directory
if directory then
vim.cmd.cd(data.file)
end
-- open the tree but don't focus it -- open the tree but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false }) require("nvim-tree.api").tree.toggle({ focus = false })
end end

View file

@ -37,7 +37,6 @@ in {
./csharp.nix ./csharp.nix
./julia.nix ./julia.nix
./nu.nix ./nu.nix
./odin.nix
]; ];
options.vim.languages = { options.vim.languages = {

View file

@ -92,7 +92,7 @@ in {
cmd = ${ cmd = ${
if isList cfg.dap.package if isList cfg.dap.package
then expToLua cfg.dap.package then expToLua cfg.dap.package
else ''{"${cfg.dap.package}/bin/haskell-debug-adapter"}'' else ''${cfg.dap.package}/bin/haskell-debug-adapter''
}, },
}, },
''} ''}

View file

@ -1,71 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
defaultServer = "ols";
servers = {
ols = {
package = pkgs.ols;
lspConfig = ''
lspconfig.ols.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/ols'}"
}
}
'';
};
};
cfg = config.vim.languages.odin;
in {
options.vim.languages.odin = {
enable = mkEnableOption "Odin language support";
treesitter = {
enable = mkEnableOption "Odin treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "odin";
};
lsp = {
enable = mkEnableOption "Odin LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "Odin LSP server to use";
};
package = mkOption {
description = "Ols package, or the command to run as a list of strings";
type = either package (listOf str);
default = pkgs.ols;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.odin-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -6,7 +6,7 @@
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge mkDefault; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) either listOf package str enum; inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
@ -57,25 +57,15 @@ in {
}; };
}; };
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {
vim.treesitter = { vim.treesitter.enable = true;
enable = true; vim.treesitter.grammars = [cfg.treesitter.package];
grammars = [cfg.treesitter.package];
};
}) })
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
vim = { vim.lsp.lspconfig.enable = true;
lsp.lspconfig = { vim.lsp.lspconfig.sources.zig-lsp = servers.${cfg.lsp.server}.lspConfig;
enable = true;
sources.zig-lsp = servers.${cfg.lsp.server}.lspConfig;
};
# nvf handles autosaving already
globals.zig_fmt_autosave = mkDefault 0;
};
}) })
]); ]);
} }

View file

@ -20,9 +20,17 @@ in {
cmd = "Run"; cmd = "Run";
keys = [ keys = [
(mkKeymap "n" cfg.mappings.run "<cmd>Run<cr>" {desc = mappings.run.description;}) (mkKeymap "n" cfg.mappings.run "<cmd>Run<CR>" {desc = mappings.run.description;})
(mkKeymap "n" cfg.mappings.runOverride "<cmd>Run!<cr>" {desc = mappings.runOverride.description;}) (mkKeymap "n" cfg.mappings.runOverride "<cmd>Run!<CR>" {desc = mappings.runOverride.description;})
(mkKeymap "n" cfg.mappings.runCommand "<cmd>RunPrompt<cr>" {desc = mappings.run.description;}) (mkKeymap "n" cfg.mappings.runCommand ''
function()
local input = vim.fn.input("Run command: ")
if input ~= "" then require("run").run(input, false) end
end
'' {
desc = mappings.run.description;
lua = true;
})
]; ];
}; };

View file

@ -16,7 +16,7 @@ in {
pluginRC.nvim-notify = entryAnywhere '' pluginRC.nvim-notify = entryAnywhere ''
local notify = require("notify") local notify = require("notify")
notify.setup(${toLuaObject cfg.setupOpts}) notify.setup(${toLuaObject cfg.setupOpts})
vim.notify = notify.notify vim.notify = notify
''; '';
}; };
}; };

View file

@ -4,8 +4,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib.strings) concatMapStringsSep;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
cfg = config.vim.utility.preview.markdownPreview; cfg = config.vim.utility.preview.markdownPreview;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -15,7 +15,7 @@ in {
mkdp_auto_start = cfg.autoStart; mkdp_auto_start = cfg.autoStart;
mkdp_auto_close = cfg.autoClose; mkdp_auto_close = cfg.autoClose;
mkdp_refresh_slow = cfg.lazyRefresh; mkdp_refresh_slow = cfg.lazyRefresh;
mkdp_filetypes = cfg.filetypes; mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)];
mkdp_command_for_global = cfg.alwaysAllowPreview; mkdp_command_for_global = cfg.alwaysAllowPreview;
mkdp_open_to_the_world = cfg.broadcastServer; mkdp_open_to_the_world = cfg.broadcastServer;
mkdp_open_ip = cfg.customIP; mkdp_open_ip = cfg.customIP;

View file

@ -4,33 +4,51 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.utility.surround; cfg = config.vim.utility.surround;
mkLznKey = mode: key: { mkLznKey = mode: key: {
inherit mode key; inherit key mode;
}; };
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["nvim-surround"];
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
lazy.plugins.nvim-surround = { lazy.plugins.nvim-surround = {
package = "nvim-surround"; package = "nvim-surround";
setupModule = "nvim-surround"; setupModule = "nvim-surround";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
keys = [ keys =
(mkLznKey "i" cfg.setupOpts.keymaps.insert) [
(mkLznKey "i" cfg.setupOpts.keymaps.insert_line) (mkLznKey ["i"] cfg.setupOpts.keymaps.insert)
(mkLznKey "x" cfg.setupOpts.keymaps.visual) (mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line)
(mkLznKey "x" cfg.setupOpts.keymaps.visual_line) (mkLznKey ["x"] cfg.setupOpts.keymaps.visual)
(mkLznKey "n" cfg.setupOpts.keymaps.normal) (mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line)
(mkLznKey "n" cfg.setupOpts.keymaps.normal_cur) (mkLznKey ["n"] cfg.setupOpts.keymaps.normal)
(mkLznKey "n" cfg.setupOpts.keymaps.normal_line) (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur)
(mkLznKey "n" cfg.setupOpts.keymaps.normal_cur_line) (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line)
(mkLznKey "n" cfg.setupOpts.keymaps.delete) (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line)
(mkLznKey "n" cfg.setupOpts.keymaps.change) (mkLznKey ["n"] cfg.setupOpts.keymaps.delete)
(mkLznKey "n" cfg.setupOpts.keymaps.change_line) (mkLznKey ["n"] cfg.setupOpts.keymaps.change)
]; (mkLznKey ["n"] cfg.setupOpts.keymaps.change_line)
]
++ map (mkLznKey ["n" "i" "v"]) [
"<Plug>(nvim-surround-insert)"
"<Plug>(nvim-surround-insert-line)"
"<Plug>(nvim-surround-normal)"
"<Plug>(nvim-surround-normal-cur)"
"<Plug>(nvim-surround-normal-line)"
"<Plug>(nvim-surround-normal-cur-line)"
"<Plug>(nvim-surround-visual)"
"<Plug>(nvim-surround-visual-line)"
"<Plug>(nvim-surround-delete)"
"<Plug>(nvim-surround-change)"
"<Plug>(nvim-surround-change-line)"
];
}; };
}; };
}; };

View file

@ -76,7 +76,6 @@
else else
mkLuaInline '' mkLuaInline ''
function() function()
${optionalString (spec.beforeSetup != null) spec.beforeSetup}
${ ${
optionalString (spec.setupModule != null) optionalString (spec.setupModule != null)
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"

View file

@ -74,15 +74,6 @@
''; '';
}; };
beforeSetup = mkOption {
type = nullOr lines;
default = null;
description = ''
Lua code to run after the plugin is loaded, but before the setup
function is called.
'';
};
setupModule = mkOption { setupModule = mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;