add tabbyml

This commit is contained in:
Dmitriy Pleshevskiy 2023-06-09 14:37:25 +03:00
parent 45117804e7
commit 91b9f31c3f
Signed by: pleshevskiy
GPG Key ID: 79C4487B44403985
8 changed files with 71 additions and 16 deletions

View File

@ -32,6 +32,22 @@
"type": "github"
}
},
"cmp-tabby": {
"flake": false,
"locked": {
"lastModified": 1681450408,
"narHash": "sha256-0swK9LV91SeZO0SQl8zVs7GmQNMYwQm7XyQE0iPbc/w=",
"owner": "nzlov",
"repo": "cmp-tabby",
"rev": "c0cb81024ee1500a722b3c35f64dd282c11bc7ba",
"type": "github"
},
"original": {
"owner": "nzlov",
"repo": "cmp-tabby",
"type": "github"
}
},
"editorconfig-nvim": {
"flake": false,
"locked": {
@ -359,6 +375,7 @@
"inputs": {
"cmp-luasnip": "cmp-luasnip",
"cmp-nvim-lsp": "cmp-nvim-lsp",
"cmp-tabby": "cmp-tabby",
"editorconfig-nvim": "editorconfig-nvim",
"flake-utils": "flake-utils",
"gitsigns-nvim": "gitsigns-nvim",

View File

@ -156,6 +156,12 @@
url = "github:norcalli/nvim-colorizer.lua";
flake = false;
};
# https://github.com/nzlov/cmp-tabby
cmp-tabby = {
url = "github:nzlov/cmp-tabby";
flake = false;
};
};
outputs = inputs @ { self, nixpkgs, flake-utils, nix2lua, ... }:
@ -191,6 +197,7 @@
"nvim-orgmode"
"org-bullets-nvim"
"nvim-colorizer"
"cmp-tabby"
];
mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }:
@ -238,7 +245,7 @@
recommendedNeovim = (minimalNeovim.override {
enableDevIcons = true;
enableTabby = true;
enableTabby = false;
plugins = with minimalNeovim.nix2lua; {
nvimTree.settings = {
@ -293,6 +300,7 @@
};
};
};
tabbyml.enable = true;
});
};

View File

@ -1,4 +1,4 @@
{ lib, ... }:
{ lib, substituteAll, ... }:
let
inherit (builtins) length elemAt isList isString hasAttr getAttr;
@ -49,10 +49,17 @@ let
mkLuaRc = contents: concatMap mkLuaHeredoc contents;
############################################################################
# Configs
readSubFile = src: params: builtins.readFile
(substituteAll (params // { inherit src; }));
in
{
inherit (lib) importJSON attrByPath;
inherit foldr concatMap;
inherit optional getAttrOpt;
inherit mkLuaHeredoc mkLuaRc;
inherit readSubFile substituteAll;
}

View File

@ -22,8 +22,7 @@
let
inherit (builtins) catAttrs readFile;
myLib = import ./lib.nix { inherit lib; } // {
inherit substituteAll;
myLib = import ./lib.nix { inherit lib substituteAll; } // {
inherit (nix2lua.lib) toLua mkLuaNil;
};
@ -54,13 +53,18 @@ let
basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = catAttrs "luaConfig" pluginsSettings;
allConfigs = basicConfigs ++ pluginConfigs ++ [ extraLuaConfig ];
# TODO: DRY
tabbymlEnable = lib.attrByPath [ "tabbyml" "enable" ] false plugins;
nodeJsEnable = tabbymlEnable;
in
(wrapNeovim neovim-unwrapped {
inherit viAlias;
inherit vimAlias;
withPython3 = false;
withNodeJs = false;
withNodeJs = nodeJsEnable;
withRuby = false;
configure = {

View File

@ -0,0 +1,3 @@
local tabby = require('cmp_tabby.config')
tabby:setup(@tabbymlSettings@)

View File

@ -7,25 +7,42 @@
, nvim-cmp
, cmp-nvim-lsp
, cmp-luasnip
, cmp-tabby
, ...
}:
let
inherit (builtins) readFile;
tabbymlEnable = lib.attrByPath [ "tabbyml" "enable" ] false plugins;
tabbymlDefaultSettings = {
host = "http://127.0.0.1:8080";
};
tabbymlSettings = lib.toLua (lib.attrByPath [ "tabbyml" "settings" ] tabbymlDefaultSettings plugins);
tabbymlLuaConfig = lib.optional tabbymlEnable
(lib.readSubFile ./cmp-tabby.lua { inherit tabbymlSettings; });
cmpSources = lib.toLua ([
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{ name = "orgmode"; }
] ++ lib.optional tabbymlEnable [{ name = "cmp-tabby"; }]);
cmpLuaConfig = lib.readSubFile ./nvim-cmp.lua { inherit cmpSources; };
lspconfigLuaConfig = lib.readSubFile ./lspconfig.lua
{ inherit lspConfigServers lspSagaSettings; };
lsp = [ nvim-lspconfig nlsp-settings-nvim lspsaga-nvim ];
snippets = [ luasnip ];
completions = [
nvim-cmp # Autocompletion
cmp-nvim-lsp # LSP source for nvim-cmp
cmp-luasnip # Snippets source for nvim-cmp
];
] ++ lib.optional tabbymlEnable [ cmp-tabby ];
lspConfigServers = lib.toLua (lib.attrByPath [ "lspConfig" "servers" ] [ ] plugins);
lspSagaSettings = lib.toLua (lib.attrByPath [ "lspSaga" "settings" ] { } plugins);
in
{
luaConfig = (readFile (lib.substituteAll { src = ./lspconfig.lua; inherit lspConfigServers lspSagaSettings; }))
+ (readFile ./nvim-cmp.lua);
luaConfig = lspconfigLuaConfig + tabbymlLuaConfig + cmpLuaConfig;
plugins = lsp
++ snippets

View File

@ -36,9 +36,5 @@ cmp.setup({
end
end, { "i", "s" }),
}),
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "orgmode" },
},
sources = @cmpSources@,
})

View File

@ -15,11 +15,14 @@ let
orgmodeEnable = lib.attrByPath [ "orgmode" "enable" ] enableOrgMode plugins;
orgmodeSettings = lib.toLua (lib.attrByPath [ "orgmode" "settings" ] { } plugins);
orgmodeLuaConfig = lib.optional orgmodeEnable (readFile (lib.substituteAll { src = ./nvim-orgmode.lua; inherit orgmodeSettings; }));
orgmodeLuaConfig = lib.optional orgmodeEnable
(lib.readSubFile ./nvim-orgmode.lua { inherit orgmodeSettings; });
colorizerFiletypes = lib.toLua (lib.attrByPath [ "colorizer" "filetypes" ] lib.mkLuaNil plugins);
colorizerSettings = lib.toLua (lib.attrByPath [ "colorizer" "settings" ] lib.mkLuaNil plugins);
colorizerLuaConfig = readFile (lib.substituteAll { src = ./nvim-colorizer.lua; inherit colorizerFiletypes colorizerSettings; });
colorizerLuaConfig = lib.readSubFile ./nvim-colorizer.lua
{ inherit colorizerFiletypes colorizerSettings; };
in
{
luaConfig = hopLuaConfig + orgmodeLuaConfig + colorizerLuaConfig;