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

View file

@ -68,6 +68,23 @@
"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": {
"flake": false,
"locked": {
@ -203,6 +220,23 @@
"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": {
"flake": false,
"locked": {
@ -254,6 +288,22 @@
"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": {
"flake": false,
"locked": {
@ -276,6 +326,7 @@
"cmp-nvim-lsp": "cmp-nvim-lsp",
"editorconfig-nvim": "editorconfig-nvim",
"gitsigns-nvim": "gitsigns-nvim",
"hop-nvim": "hop-nvim",
"lspsaga-nvim": "lspsaga-nvim",
"lualine-lsp-progress": "lualine-lsp-progress",
"lualine-nvim": "lualine-nvim",
@ -284,9 +335,11 @@
"nixpkgs": "nixpkgs",
"nvim-cmp": "nvim-cmp",
"nvim-lspconfig": "nvim-lspconfig",
"nvim-orgmode": "nvim-orgmode",
"nvim-tree-lua": "nvim-tree-lua",
"nvim-treesitter": "nvim-treesitter",
"nvim-web-devicons": "nvim-web-devicons",
"org-bullets-nvim": "org-bullets-nvim",
"plenary-nvim": "plenary-nvim",
"tabby-nvim": "tabby-nvim",
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",

View file

@ -130,6 +130,26 @@
url = "github:catppuccin/nvim?rev=9ac18414f0446478024b19018d73b7ea14f6fc96";
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, ... }:
@ -161,6 +181,10 @@
"lualine-lsp-progress"
"nvim-web-devicons"
"theme"
# ux
"hop-nvim"
"nvim-orgmode"
"org-bullets-nvim"
];
mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }:
@ -182,7 +206,7 @@
{
overlays = {
default = final: prev: {
myneovim = prev.callPackage ./. (mkNvimPlugins prev);
myneovim = prev.callPackage self (mkNvimPlugins prev);
};
};
} //
@ -190,23 +214,30 @@
let
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
{
apps.default = {
type = "app";
program = "${neovim}/bin/nvim";
};
apps.test = {
type = "app";
program = "${testNeovim}/bin/nvim";
};
packages.default = neovim;
packages.test = testNeovim;
devShells.default = pkgs.mkShell {
packages = [
(neovim.override {
enableDevIcons = true;
enableTabby = true;
grammarFileTypes = [ "nix" "lua" ];
})
pkgs.stylua # lua formatter
];
};

View file

@ -1,3 +1,5 @@
{ lib, ... }:
let
inherit (builtins) length elemAt isList isString hasAttr getAttr;
@ -49,6 +51,7 @@ let
in
{
inherit (lib) importJSON;
inherit foldr concatMap;
inherit optional getAttrOpt;
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)
+ (builtins.readFile ./telescope-nvim.lua);
luaConfig = (readFile ./nvim-tree.lua)
+ (readFile ./telescope-nvim.lua);
plugins = [ nvim-tree-lua ]
++ [ telescope-nvim telescope-live-grep-args-nvim ];

View file

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

View file

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

View file

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

View file

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

View file

@ -1,22 +1,34 @@
{ tree-sitter, grammarFileTypes, ... }:
{ nvim-treesitter, ... }:
{ lib
, nvim-treesitter
, tree-sitter
, grammarFileTypes
, ...
}:
let
treesitterGrammars = tree-sitter.withPlugins
(grammars: map (ft: grammars."tree-sitter-${ft}") grammarFileTypes);
inherit (builtins) readFile;
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: {
postPatch = ''
rm -r parser
ln -s ${treesitterGrammars} parser
ln -s ${treeSitterGrammars} parser
'';
});
in
{
luaConfig = builtins.readFile ./treesitter.lua;
luaConfig = readFile ./treesitter.lua;
plugins = [
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
, theme
, lualine-nvim
, lualine-lsp-progress
, nvim-web-devicons
, tabby-nvim
, enableDevIcons ? false
, enableTabby ? false
, themeCfg ? { }
, ...
}:
let
inherit (builtins) readFile isString;
inherit (builtins) readFile;
themeFlavour = if isString (lib.getAttrOpt "flavour" theme) then theme.flavour else "frappe";
themeConfig = if isString (lib.getAttrOpt "config" theme) then theme.config else ''
themeFlavour = if themeCfg ? flavour then theme.flavour else "frappe";
themeConfig = if themeCfg ? config then theme.config else ''
vim.g.catppuccin_flavour = "${themeFlavour}"
require("catppuccin").setup()
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()