Compare commits

...

9 commits

Author SHA1 Message Date
diniamo
90a5a42742 languages/odin: init 2024-12-21 10:35:39 +01:00
raf
8bab0497fb
Merge pull request #500 from diniamo/lazy-before-setup
wrapper/lazy: add beforeSetup option
2024-12-21 08:17:41 +03:00
raf
f26744c6ce
Merge branch 'main' into lazy-before-setup 2024-12-21 08:15:08 +03:00
raf
62d296a2dc
Merge pull request #506 from amadaluzia/fix-haskell
languages/haskell: fix DAP command definition
2024-12-21 08:14:43 +03:00
raf
8c66f10550
Merge branch 'main' into fix-haskell 2024-12-21 08:14:31 +03:00
raf
ea3d488cf4
Merge pull request #504 from diniamo/surround-cleanup
surround: cleanup
2024-12-21 08:14:14 +03:00
Artur Manuel
0946d43921 languages/haskell: fix DAP command definition 2024-12-21 01:00:02 +00:00
diniamo
7eb8d07bcf surround: cleanup 2024-12-21 01:14:52 +01:00
diniamo
ed69816f68 wrapper/lazy: add beforeSetup option
Useful for avoiding a million require calls in setupOpts.
2024-12-20 10:43:36 +01:00
8 changed files with 104 additions and 35 deletions

View file

@ -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`.

View file

@ -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 = {

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

@ -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;
})
]);
}

View file

@ -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;

View file

@ -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)"
];
}; };
}; };
}; };

View file

@ -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})"

View file

@ -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;