Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

languages/odin: init #505

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/release-notes/rl-0.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@

[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`.
1 change: 1 addition & 0 deletions modules/plugins/languages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ in {
./csharp.nix
./julia.nix
./nu.nix
./odin.nix
];

options.vim.languages = {
Expand Down
71 changes: 71 additions & 0 deletions modules/plugins/languages/odin.nix
Original file line number Diff line number Diff line change
@@ -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;
})
]);
}
1 change: 1 addition & 0 deletions modules/plugins/languages/zig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ in {
};
};
};

config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
Expand Down
Loading