diff --git a/flake.lock b/flake.lock index 3a24e6f..2e355bb 100644 --- a/flake.lock +++ b/flake.lock @@ -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", diff --git a/flake.nix b/flake.nix index 0155ad7..75a89dc 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }); }; diff --git a/lib.nix b/lib.nix index 6c7ecaf..fd5b3c1 100644 --- a/lib.nix +++ b/lib.nix @@ -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; } diff --git a/neovim.nix b/neovim.nix index b9705f5..a027cdb 100644 --- a/neovim.nix +++ b/neovim.nix @@ -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 = { diff --git a/plugins/lsp/cmp-tabby.lua b/plugins/lsp/cmp-tabby.lua new file mode 100644 index 0000000..9cf2158 --- /dev/null +++ b/plugins/lsp/cmp-tabby.lua @@ -0,0 +1,3 @@ +local tabby = require('cmp_tabby.config') + +tabby:setup(@tabbymlSettings@) diff --git a/plugins/lsp/default.nix b/plugins/lsp/default.nix index e174180..a774769 100644 --- a/plugins/lsp/default.nix +++ b/plugins/lsp/default.nix @@ -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 diff --git a/plugins/lsp/nvim-cmp.lua b/plugins/lsp/nvim-cmp.lua index 510e480..7b849ed 100644 --- a/plugins/lsp/nvim-cmp.lua +++ b/plugins/lsp/nvim-cmp.lua @@ -36,9 +36,5 @@ cmp.setup({ end end, { "i", "s" }), }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "orgmode" }, - }, + sources = @cmpSources@, }) diff --git a/plugins/ux/default.nix b/plugins/ux/default.nix index 38dea01..16629aa 100644 --- a/plugins/ux/default.nix +++ b/plugins/ux/default.nix @@ -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;