ux: add orgmode plugin

This commit is contained in:
Dmitriy Pleshevskiy 2022-10-22 23:35:27 +03:00
parent 116764c3a0
commit b6f33bfb03
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
14 changed files with 194 additions and 47 deletions

View file

@ -1,6 +1,7 @@
{ enableDevIcons ? false { enableDevIcons ? false
, enableBarBar ? false , enableBarBar ? false
, enableTabby ? false , enableTabby ? false
, enableOrgMode ? false
, viAlias ? false , viAlias ? false
, vimAlias ? false , vimAlias ? false
, grammarFileTypes ? [ "nix" ] , grammarFileTypes ? [ "nix" ]
@ -9,39 +10,42 @@
, neovim-unwrapped , neovim-unwrapped
, tree-sitter , tree-sitter
, vimPlugins , vimPlugins
, lib
, ... , ...
}: }:
let let
lib = import ./lib.nix; inherit (builtins) catAttrs isFunction readFile;
myLib = import ./lib.nix { inherit lib; };
pluginParams = vimPlugins // { inherit lib; }; pluginParams = vimPlugins // {
inherit tree-sitter grammarFileTypes;
inherit enableDevIcons enableTabby enableOrgMode;
themeCfg = theme;
lib = myLib;
};
callPlugin = op: if builtins.isFunction op then op pluginParams else import op pluginParams; callPlugin = op:
callPlugins = list: builtins.map callPlugin list; if isFunction op then op pluginParams else import op pluginParams;
callPlugins = list: map callPlugin list;
plugins = callPlugins [ plugins = callPlugins [
./plugins/config ./plugins/config
(import ./plugins/syntax { ./plugins/syntax
inherit tree-sitter grammarFileTypes;
})
./plugins/git ./plugins/git
./plugins/explorer ./plugins/explorer
(import ./plugins/theme { ./plugins/theme
inherit enableDevIcons enableTabby;
inherit theme;
})
./plugins/lsp ./plugins/lsp
./plugins/formatter ./plugins/formatter
./plugins/ux ./plugins/ux
]; ];
basePlugins = [ vimPlugins.plenary-nvim ]; basePlugins = [ vimPlugins.plenary-nvim ];
customPlugins = builtins.catAttrs "plugins" plugins; customPlugins = catAttrs "plugins" plugins;
allPlugins = basePlugins ++ customPlugins; allPlugins = basePlugins ++ customPlugins;
basicConfigs = builtins.map builtins.readFile [ ./config/basic.lua ]; basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = builtins.catAttrs "luaConfig" plugins; pluginConfigs = catAttrs "luaConfig" plugins;
allConfigs = basicConfigs ++ pluginConfigs; allConfigs = basicConfigs ++ pluginConfigs;
in in
wrapNeovim neovim-unwrapped { wrapNeovim neovim-unwrapped {
@ -53,7 +57,7 @@ wrapNeovim neovim-unwrapped {
withRuby = false; withRuby = false;
configure = { configure = {
customRC = lib.mkLuaRc allConfigs; customRC = myLib.mkLuaRc allConfigs;
packages.myVimPackages = { start = allPlugins; }; packages.myVimPackages = { start = allPlugins; };
}; };

View file

@ -68,6 +68,23 @@
"type": "github" "type": "github"
} }
}, },
"hop-nvim": {
"flake": false,
"locked": {
"lastModified": 1665333065,
"narHash": "sha256-eBWzvdwbPlwArx7M8Q5mQtXVHASxo8CC/4ZIhBHd0vg=",
"owner": "phaazon",
"repo": "hop.nvim",
"rev": "6591b3656b75ff313cc38dc662a7ee8f75f1c165",
"type": "github"
},
"original": {
"owner": "phaazon",
"repo": "hop.nvim",
"rev": "6591b3656b75ff313cc38dc662a7ee8f75f1c165",
"type": "github"
}
},
"lspsaga-nvim": { "lspsaga-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -203,6 +220,23 @@
"type": "github" "type": "github"
} }
}, },
"nvim-orgmode": {
"flake": false,
"locked": {
"lastModified": 1666428597,
"narHash": "sha256-3/0hqJhZ7qBbZ79b5UwjcmQgwLu/J7YmD/8r8G0LB0A=",
"owner": "nvim-orgmode",
"repo": "orgmode",
"rev": "806b8b9b81eaaf9b236f0a20d8e0486da23f448c",
"type": "github"
},
"original": {
"owner": "nvim-orgmode",
"repo": "orgmode",
"rev": "806b8b9b81eaaf9b236f0a20d8e0486da23f448c",
"type": "github"
}
},
"nvim-tree-lua": { "nvim-tree-lua": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -254,6 +288,22 @@
"type": "github" "type": "github"
} }
}, },
"org-bullets-nvim": {
"flake": false,
"locked": {
"lastModified": 1660733415,
"narHash": "sha256-LUp57b7QFDpxWkByOYLdKUi7YrARgl0JL8WNgHfHwjE=",
"owner": "akinsho",
"repo": "org-bullets.nvim",
"rev": "345a351a387e957a5cb3b8072e96d748f4693540",
"type": "github"
},
"original": {
"owner": "akinsho",
"repo": "org-bullets.nvim",
"type": "github"
}
},
"plenary-nvim": { "plenary-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -276,6 +326,7 @@
"cmp-nvim-lsp": "cmp-nvim-lsp", "cmp-nvim-lsp": "cmp-nvim-lsp",
"editorconfig-nvim": "editorconfig-nvim", "editorconfig-nvim": "editorconfig-nvim",
"gitsigns-nvim": "gitsigns-nvim", "gitsigns-nvim": "gitsigns-nvim",
"hop-nvim": "hop-nvim",
"lspsaga-nvim": "lspsaga-nvim", "lspsaga-nvim": "lspsaga-nvim",
"lualine-lsp-progress": "lualine-lsp-progress", "lualine-lsp-progress": "lualine-lsp-progress",
"lualine-nvim": "lualine-nvim", "lualine-nvim": "lualine-nvim",
@ -284,9 +335,11 @@
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nvim-cmp": "nvim-cmp", "nvim-cmp": "nvim-cmp",
"nvim-lspconfig": "nvim-lspconfig", "nvim-lspconfig": "nvim-lspconfig",
"nvim-orgmode": "nvim-orgmode",
"nvim-tree-lua": "nvim-tree-lua", "nvim-tree-lua": "nvim-tree-lua",
"nvim-treesitter": "nvim-treesitter", "nvim-treesitter": "nvim-treesitter",
"nvim-web-devicons": "nvim-web-devicons", "nvim-web-devicons": "nvim-web-devicons",
"org-bullets-nvim": "org-bullets-nvim",
"plenary-nvim": "plenary-nvim", "plenary-nvim": "plenary-nvim",
"tabby-nvim": "tabby-nvim", "tabby-nvim": "tabby-nvim",
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim", "telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",

View file

@ -130,6 +130,26 @@
url = "github:catppuccin/nvim?rev=9ac18414f0446478024b19018d73b7ea14f6fc96"; url = "github:catppuccin/nvim?rev=9ac18414f0446478024b19018d73b7ea14f6fc96";
flake = false; flake = false;
}; };
# ux
# https://github.com/phaazon/hop.nvim
hop-nvim = {
url = "github:phaazon/hop.nvim?rev=6591b3656b75ff313cc38dc662a7ee8f75f1c165";
flake = false;
};
# https://github.com/nvim-orgmode/orgmode
nvim-orgmode = {
url = "github:nvim-orgmode/orgmode?rev=806b8b9b81eaaf9b236f0a20d8e0486da23f448c";
flake = false;
};
# https://github.com/akinsho/org-bullets.nvim
org-bullets-nvim = {
url = "github:akinsho/org-bullets.nvim";
flake = false;
};
}; };
outputs = inputs @ { self, nixpkgs, utils, ... }: outputs = inputs @ { self, nixpkgs, utils, ... }:
@ -161,6 +181,10 @@
"lualine-lsp-progress" "lualine-lsp-progress"
"nvim-web-devicons" "nvim-web-devicons"
"theme" "theme"
# ux
"hop-nvim"
"nvim-orgmode"
"org-bullets-nvim"
]; ];
mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }: mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }:
@ -182,7 +206,7 @@
{ {
overlays = { overlays = {
default = final: prev: { default = final: prev: {
myneovim = prev.callPackage ./. (mkNvimPlugins prev); myneovim = prev.callPackage self (mkNvimPlugins prev);
}; };
}; };
} // } //
@ -190,23 +214,30 @@
let let
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
neovim = pkgs.callPackage ./. (mkNvimPlugins pkgs); neovim = pkgs.callPackage self (mkNvimPlugins pkgs);
testNeovim = (neovim.override {
enableDevIcons = true;
enableTabby = true;
enableOrgMode = true;
grammarFileTypes = [ "nix" "lua" "org" ];
});
in in
{ {
apps.default = { apps.default = {
type = "app"; type = "app";
program = "${neovim}/bin/nvim"; program = "${neovim}/bin/nvim";
}; };
apps.test = {
type = "app";
program = "${testNeovim}/bin/nvim";
};
packages.default = neovim; packages.default = neovim;
packages.test = testNeovim;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = [ packages = [
(neovim.override {
enableDevIcons = true;
enableTabby = true;
grammarFileTypes = [ "nix" "lua" ];
})
pkgs.stylua # lua formatter pkgs.stylua # lua formatter
]; ];
}; };

View file

@ -1,3 +1,5 @@
{ lib, ... }:
let let
inherit (builtins) length elemAt isList isString hasAttr getAttr; inherit (builtins) length elemAt isList isString hasAttr getAttr;
@ -49,6 +51,7 @@ let
in in
{ {
inherit (lib) importJSON;
inherit foldr concatMap; inherit foldr concatMap;
inherit optional getAttrOpt; inherit optional getAttrOpt;
inherit mkLuaHeredoc mkLuaRc; inherit mkLuaHeredoc mkLuaRc;

View file

@ -1,8 +1,15 @@
{ nvim-tree-lua, telescope-nvim, telescope-live-grep-args-nvim, ... }: { nvim-tree-lua
, telescope-nvim
, telescope-live-grep-args-nvim
, ...
}:
let
inherit (builtins) readFile;
in
{ {
luaConfig = (builtins.readFile ./nvim-tree.lua) luaConfig = (readFile ./nvim-tree.lua)
+ (builtins.readFile ./telescope-nvim.lua); + (readFile ./telescope-nvim.lua);
plugins = [ nvim-tree-lua ] plugins = [ nvim-tree-lua ]
++ [ telescope-nvim telescope-live-grep-args-nvim ]; ++ [ telescope-nvim telescope-live-grep-args-nvim ];

View file

@ -1,7 +1,10 @@
{ neoformat, ... }: { neoformat, ... }:
let
inherit (builtins) readFile;
in
{ {
luaConfig = builtins.readFile ./neoformat.lua; luaConfig = readFile ./neoformat.lua;
plugins = [ neoformat ]; plugins = [ neoformat ];
} }

View file

@ -1,7 +1,10 @@
{ gitsigns-nvim, ... }: { gitsigns-nvim, ... }:
let
inherit (builtins) readFile;
in
{ {
luaConfig = builtins.readFile ./gitsigns-nvim.lua; luaConfig = readFile ./gitsigns-nvim.lua;
plugins = [ gitsigns-nvim ]; plugins = [ gitsigns-nvim ];
} }

View file

@ -8,6 +8,7 @@
}: }:
let let
inherit (builtins) readFile;
lsp = [ nvim-lspconfig lspsaga-nvim ]; lsp = [ nvim-lspconfig lspsaga-nvim ];
snippets = [ luasnip ]; snippets = [ luasnip ];
completions = [ completions = [
@ -17,8 +18,8 @@ let
]; ];
in in
{ {
luaConfig = (builtins.readFile ./lspconfig.lua) luaConfig = (readFile ./lspconfig.lua)
+ (builtins.readFile ./nvim-cmp.lua); + (readFile ./nvim-cmp.lua);
plugins = lsp plugins = lsp
++ snippets ++ snippets

View file

@ -39,5 +39,6 @@ cmp.setup({
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "orgmode" },
}, },
}) })

View file

@ -1,22 +1,34 @@
{ tree-sitter, grammarFileTypes, ... }: { lib
, nvim-treesitter
{ nvim-treesitter, ... }: , tree-sitter
, grammarFileTypes
, ...
}:
let let
treesitterGrammars = tree-sitter.withPlugins inherit (builtins) readFile;
(grammars: map (ft: grammars."tree-sitter-${ft}") grammarFileTypes);
extraGrammars = {
tree-sitter-org = lib.importJSON ./tree-sitter-org-nvim.json // { language = "org"; };
};
extended-treesitter = tree-sitter.override { inherit extraGrammars; };
treeSitterGrammars = extended-treesitter.withPlugins (
grammars: map (ft: grammars."tree-sitter-${ft}") grammarFileTypes
);
nvim-treesitter-with-grammars = nvim-treesitter.overrideAttrs (oldAttrs: { nvim-treesitter-with-grammars = nvim-treesitter.overrideAttrs (oldAttrs: {
postPatch = '' postPatch = ''
rm -r parser rm -r parser
ln -s ${treesitterGrammars} parser ln -s ${treeSitterGrammars} parser
''; '';
}); });
in in
{ {
luaConfig = builtins.readFile ./treesitter.lua; luaConfig = readFile ./treesitter.lua;
plugins = [ plugins = [
nvim-treesitter-with-grammars nvim-treesitter-with-grammars

View file

@ -0,0 +1,11 @@
{
"url": "https://github.com/milisims/tree-sitter-org",
"rev": "081179c52b3e8175af62b9b91dc099d010c38770",
"date": "2022-10-21T23:23:29-04:00",
"path": "/nix/store/7jy3jqyd02kryfgz16k3zxg2kmjz0wqf-tree-sitter-org",
"sha256": "0h9krbaq9j6ijf86sg0w221s0zbpbx5f7m1l0whzjahbrqpnqgxl",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}

View file

@ -1,22 +1,20 @@
{ enableDevIcons ? false
, enableTabby ? false
, theme ? { }
}:
{ lib { lib
, theme , theme
, lualine-nvim , lualine-nvim
, lualine-lsp-progress , lualine-lsp-progress
, nvim-web-devicons , nvim-web-devicons
, tabby-nvim , tabby-nvim
, enableDevIcons ? false
, enableTabby ? false
, themeCfg ? { }
, ... , ...
}: }:
let let
inherit (builtins) readFile isString; inherit (builtins) readFile;
themeFlavour = if isString (lib.getAttrOpt "flavour" theme) then theme.flavour else "frappe"; themeFlavour = if themeCfg ? flavour then theme.flavour else "frappe";
themeConfig = if isString (lib.getAttrOpt "config" theme) then theme.config else '' themeConfig = if themeCfg ? config then theme.config else ''
vim.g.catppuccin_flavour = "${themeFlavour}" vim.g.catppuccin_flavour = "${themeFlavour}"
require("catppuccin").setup() require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]]) vim.cmd([[colorscheme catppuccin]])

View file

@ -1,7 +1,18 @@
{ hop-nvim, ... }: { lib
, hop-nvim
, nvim-orgmode
, org-bullets-nvim
, enableOrgMode ? false
, ...
}:
let
inherit (builtins) readFile;
in
{ {
luaConfig = builtins.readFile ./hop-nvim.lua; luaConfig = readFile ./hop-nvim.lua
+ lib.optional enableOrgMode (readFile ./nvim-orgmode.lua);
plugins = [ hop-nvim ]; plugins = [ hop-nvim ]
++ lib.optional enableOrgMode [ nvim-orgmode org-bullets-nvim ];
} }

View file

@ -0,0 +1,9 @@
require("orgmode").setup_ts_grammar()
require("orgmode").setup({
org_agenda_files = { "~/orgs/**/*" },
org_default_notes_file = "~/orgs/refile.org",
win_split_mode = "tabnew",
org_hide_leading_stars = true,
})
require("org-bullets").setup()