mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-08 09:09:49 +01:00
Compare commits
18 commits
01744b650f
...
bcf23686d0
Author | SHA1 | Date | |
---|---|---|---|
|
bcf23686d0 | ||
|
eb132eec36 | ||
|
6dc07ba5c1 | ||
46aa168b2d | |||
|
9aad80d5e6 | ||
ac905b8aed | |||
|
90a5a42742 | ||
8bab0497fb | |||
f26744c6ce | |||
62d296a2dc | |||
8c66f10550 | |||
ea3d488cf4 | |||
|
0946d43921 | ||
|
7eb8d07bcf | ||
52042f624c | |||
af31021ce4 | |||
|
ed69816f68 | ||
4f61628399 |
14 changed files with 128 additions and 103 deletions
|
@ -13,4 +13,8 @@
|
||||||
|
|
||||||
[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`.
|
||||||
|
|
|
@ -1729,11 +1729,11 @@
|
||||||
"plugin-run-nvim": {
|
"plugin-run-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1732918526,
|
"lastModified": 1734816675,
|
||||||
"narHash": "sha256-kiszNmZZDXG8tAPMQKuGJDCkqCMzsWT7BkCvkVsH2lA=",
|
"narHash": "sha256-Wuk5HG+vHXAbifzp5YB5V/FxBhBRNWLeypkRczpXbvQ=",
|
||||||
"owner": "diniamo",
|
"owner": "diniamo",
|
||||||
"repo": "run.nvim",
|
"repo": "run.nvim",
|
||||||
"rev": "d867466e01b8fa4e54a589b9ef446cf43fb966de",
|
"rev": "6cd971afdce6443d7a070dcc23af51da1cc932f9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModules = {
|
nixosModules = {
|
||||||
nvf = import ./flake/modules/nixos.nix self.packages lib;
|
nvf = import ./flake/modules/nixos.nix self.packages lib inputs;
|
||||||
default = self.nixosModules.nvf;
|
default = self.nixosModules.nvf;
|
||||||
neovim-flake =
|
neovim-flake =
|
||||||
lib.warn ''
|
lib.warn ''
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# NixOS module
|
# NixOS module
|
||||||
packages: lib: {
|
packages: lib: inputs: {
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
|
@ -8,15 +8,19 @@ packages: lib: {
|
||||||
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
|
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) attrsOf anything bool;
|
inherit (lib.types) anything bool submoduleWith;
|
||||||
inherit (lib.nvim) neovimConfiguration;
|
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
|
||||||
|
|
||||||
cfg = config.programs.nvf;
|
cfg = config.programs.nvf;
|
||||||
|
|
||||||
neovimConfigured = neovimConfiguration {
|
nvfModule = submoduleWith {
|
||||||
inherit pkgs;
|
description = "Nvf module";
|
||||||
modules = [cfg.settings];
|
class = "nvf";
|
||||||
|
specialArgs = {
|
||||||
|
inherit pkgs lib inputs;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
{imports = import ../../modules/modules.nix {inherit pkgs lib;};}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -55,7 +59,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = attrsOf anythingConcatLists;
|
type = nvfModule;
|
||||||
default = {};
|
default = {};
|
||||||
description = "Attribute set of nvf preferences.";
|
description = "Attribute set of nvf preferences.";
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
|
@ -78,7 +82,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.nvf.finalPackage = neovimConfigured.neovim;
|
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");
|
||||||
|
|
|
@ -1,57 +1,9 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption;
|
inherit (lib.options) mergeEqualOption;
|
||||||
inherit (lib.strings) isString isStringLike;
|
inherit (lib.strings) isString;
|
||||||
inherit (lib.types) anything attrsOf listOf mkOptionType;
|
inherit (lib.types) listOf mkOptionType;
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
inherit (builtins) stringLength match;
|
||||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
|
|
||||||
in {
|
in {
|
||||||
# HACK: Does this break anything in our case?
|
|
||||||
# A modified version of the nixpkgs anything type that concatenates lists
|
|
||||||
# This isn't the default because the order in which the lists are concatenated depends on the order in which the modules are imported,
|
|
||||||
# which makes it non-deterministic
|
|
||||||
anythingConcatLists =
|
|
||||||
anything
|
|
||||||
// {
|
|
||||||
merge = loc: defs: let
|
|
||||||
getType = value:
|
|
||||||
if isAttrs value && isStringLike value
|
|
||||||
then "stringCoercibleSet"
|
|
||||||
else typeOf value;
|
|
||||||
|
|
||||||
# Throw an error if not all defs have the same type
|
|
||||||
checkType = getType (head defs).value;
|
|
||||||
commonType =
|
|
||||||
if any (def: getType def.value != checkType) defs
|
|
||||||
then throw "The option `${showOption loc}' has conflicting option types in ${showFiles (getFiles defs)}"
|
|
||||||
else checkType;
|
|
||||||
|
|
||||||
mergeFunctions = {
|
|
||||||
# Recursively merge attribute sets
|
|
||||||
set = (attrsOf anythingConcatLists).merge;
|
|
||||||
|
|
||||||
# Overridden behavior for lists, that concatenates lists
|
|
||||||
list = _: defs: concatLists (map (e: e.value) defs);
|
|
||||||
|
|
||||||
# This means it's a package, only accept a single definition
|
|
||||||
stringCoercibleSet = mergeOneOption;
|
|
||||||
|
|
||||||
# This works by passing the argument to the functions,
|
|
||||||
# and merging their returns values instead
|
|
||||||
lambda = loc: defs: arg:
|
|
||||||
anythingConcatLists.merge
|
|
||||||
(loc ++ ["<function body>"])
|
|
||||||
(map (def: {
|
|
||||||
inherit (def) file;
|
|
||||||
value = def.value arg;
|
|
||||||
})
|
|
||||||
defs);
|
|
||||||
};
|
|
||||||
in
|
|
||||||
# Merge the defs with the correct function from above, if available
|
|
||||||
# otherwise only allow equal values
|
|
||||||
(mergeFunctions.${commonType} or mergeEqualOption) loc defs;
|
|
||||||
};
|
|
||||||
|
|
||||||
mergelessListOf = elemType: let
|
mergelessListOf = elemType: let
|
||||||
super = listOf elemType;
|
super = listOf elemType;
|
||||||
in
|
in
|
||||||
|
|
|
@ -11,5 +11,5 @@ in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (customTypes) anythingConcatLists char hexColor mergelessListOf;
|
inherit (customTypes) char hexColor mergelessListOf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ in {
|
||||||
./csharp.nix
|
./csharp.nix
|
||||||
./julia.nix
|
./julia.nix
|
||||||
./nu.nix
|
./nu.nix
|
||||||
|
./odin.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages = {
|
options.vim.languages = {
|
||||||
|
|
|
@ -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"}''
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
|
|
71
modules/plugins/languages/odin.nix
Normal file
71
modules/plugins/languages/odin.nix
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
|
@ -57,6 +57,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
|
|
|
@ -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 = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)];
|
mkdp_filetypes = 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;
|
||||||
|
|
|
@ -4,51 +4,33 @@
|
||||||
...
|
...
|
||||||
}: 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 key mode;
|
inherit mode key;
|
||||||
};
|
};
|
||||||
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)
|
(mkLznKey "i" cfg.setupOpts.keymaps.insert_line)
|
||||||
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line)
|
(mkLznKey "x" cfg.setupOpts.keymaps.visual)
|
||||||
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual)
|
(mkLznKey "x" cfg.setupOpts.keymaps.visual_line)
|
||||||
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line)
|
(mkLznKey "n" cfg.setupOpts.keymaps.normal)
|
||||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal)
|
(mkLznKey "n" cfg.setupOpts.keymaps.normal_cur)
|
||||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur)
|
(mkLznKey "n" cfg.setupOpts.keymaps.normal_line)
|
||||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line)
|
(mkLznKey "n" cfg.setupOpts.keymaps.normal_cur_line)
|
||||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line)
|
(mkLznKey "n" cfg.setupOpts.keymaps.delete)
|
||||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.delete)
|
(mkLznKey "n" cfg.setupOpts.keymaps.change)
|
||||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.change)
|
(mkLznKey "n" cfg.setupOpts.keymaps.change_line)
|
||||||
(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)"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
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})"
|
||||||
|
|
|
@ -74,6 +74,15 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
Loading…
Reference in a new issue