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" "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": { "editorconfig-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -359,6 +375,7 @@
"inputs": { "inputs": {
"cmp-luasnip": "cmp-luasnip", "cmp-luasnip": "cmp-luasnip",
"cmp-nvim-lsp": "cmp-nvim-lsp", "cmp-nvim-lsp": "cmp-nvim-lsp",
"cmp-tabby": "cmp-tabby",
"editorconfig-nvim": "editorconfig-nvim", "editorconfig-nvim": "editorconfig-nvim",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"gitsigns-nvim": "gitsigns-nvim", "gitsigns-nvim": "gitsigns-nvim",

View file

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

View file

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

View file

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

View file

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

View file

@ -7,25 +7,42 @@
, nvim-cmp , nvim-cmp
, cmp-nvim-lsp , cmp-nvim-lsp
, cmp-luasnip , cmp-luasnip
, cmp-tabby
, ... , ...
}: }:
let 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 ]; lsp = [ nvim-lspconfig nlsp-settings-nvim lspsaga-nvim ];
snippets = [ luasnip ]; snippets = [ luasnip ];
completions = [ completions = [
nvim-cmp # Autocompletion nvim-cmp # Autocompletion
cmp-nvim-lsp # LSP source for nvim-cmp cmp-nvim-lsp # LSP source for nvim-cmp
cmp-luasnip # Snippets source for nvim-cmp cmp-luasnip # Snippets source for nvim-cmp
]; ] ++ lib.optional tabbymlEnable [ cmp-tabby ];
lspConfigServers = lib.toLua (lib.attrByPath [ "lspConfig" "servers" ] [ ] plugins); lspConfigServers = lib.toLua (lib.attrByPath [ "lspConfig" "servers" ] [ ] plugins);
lspSagaSettings = lib.toLua (lib.attrByPath [ "lspSaga" "settings" ] { } plugins); lspSagaSettings = lib.toLua (lib.attrByPath [ "lspSaga" "settings" ] { } plugins);
in in
{ {
luaConfig = (readFile (lib.substituteAll { src = ./lspconfig.lua; inherit lspConfigServers lspSagaSettings; })) luaConfig = lspconfigLuaConfig + tabbymlLuaConfig + cmpLuaConfig;
+ (readFile ./nvim-cmp.lua);
plugins = lsp plugins = lsp
++ snippets ++ snippets

View file

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

View file

@ -15,11 +15,14 @@ let
orgmodeEnable = lib.attrByPath [ "orgmode" "enable" ] enableOrgMode plugins; orgmodeEnable = lib.attrByPath [ "orgmode" "enable" ] enableOrgMode plugins;
orgmodeSettings = lib.toLua (lib.attrByPath [ "orgmode" "settings" ] { } 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); colorizerFiletypes = lib.toLua (lib.attrByPath [ "colorizer" "filetypes" ] lib.mkLuaNil plugins);
colorizerSettings = lib.toLua (lib.attrByPath [ "colorizer" "settings" ] 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 in
{ {
luaConfig = hopLuaConfig + orgmodeLuaConfig + colorizerLuaConfig; luaConfig = hopLuaConfig + orgmodeLuaConfig + colorizerLuaConfig;