From 3694a8464622ae7729a4b573e4d4220db11fe389 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:05:43 +0300 Subject: [PATCH 01/29] feat: separate copilot module and configuration --- modules/assistant/copilot/config.nix | 24 ++++++++++++++++++++++++ modules/assistant/copilot/copilot.nix | 20 ++++++++++++++++++++ modules/assistant/copilot/default.nix | 6 ++++++ 3 files changed, 50 insertions(+) create mode 100644 modules/assistant/copilot/config.nix create mode 100644 modules/assistant/copilot/copilot.nix create mode 100644 modules/assistant/copilot/default.nix diff --git a/modules/assistant/copilot/config.nix b/modules/assistant/copilot/config.nix new file mode 100644 index 0000000..62d0251 --- /dev/null +++ b/modules/assistant/copilot/config.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.assistant.copilot; +in { + config = mkIf cfg.enable { + vim.startPlugins = [ + "copilot-lua" + pkgs.nodejs-slim-16_x + ]; + + vim.luaConfigRC.copilot = nvim.dag.entryAnywhere '' + require("copilot").setup({ + -- available options: https://github.com/zbirenbaum/copilot.lua + copilot_node_command = "${cfg.copilot_node_command}", + }) + ''; + }; +} diff --git a/modules/assistant/copilot/copilot.nix b/modules/assistant/copilot/copilot.nix new file mode 100644 index 0000000..5dc1245 --- /dev/null +++ b/modules/assistant/copilot/copilot.nix @@ -0,0 +1,20 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.assistant.copilot; +in { + options.vim.assistant.copilot = { + enable = mkEnableOption "Enable GitHub Copilot"; + + copilot_node_command = mkOption { + type = types.str; + default = "${lib.getExe pkgs.nodejs-slim-16_x}"; + description = "Path to nodejs"; + }; + }; +} diff --git a/modules/assistant/copilot/default.nix b/modules/assistant/copilot/default.nix new file mode 100644 index 0000000..fb291bd --- /dev/null +++ b/modules/assistant/copilot/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./copilot.nix + ./config.nix + ]; +} From a2e724a962f0f3cf92eba4b360b02c095602e0f4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:05:53 +0300 Subject: [PATCH 02/29] feat: separate tabnine module and configuration --- modules/assistant/tabnine/config.nix | 24 +++++++++++++++ modules/assistant/tabnine/default.nix | 6 ++++ modules/assistant/tabnine/tabnine.nix | 44 +++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 modules/assistant/tabnine/config.nix create mode 100644 modules/assistant/tabnine/default.nix create mode 100644 modules/assistant/tabnine/tabnine.nix diff --git a/modules/assistant/tabnine/config.nix b/modules/assistant/tabnine/config.nix new file mode 100644 index 0000000..8b10bcf --- /dev/null +++ b/modules/assistant/tabnine/config.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.assistant.tabnine; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["tabnine-nvim"]; + + vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere '' + require('tabnine').setup({ + disable_auto_comment = ${boolToString cfg.disable_auto_comment}, + accept_keymap = ${cfg.accept_keymap}, + dismiss_keymap = ${cfg.dismiss_keymap}, + debounce_ms = ${cfg.debounce_ms}, + execlude_filetypes = ${cfg.execlude_filetypes}, + }) + ''; + }; +} diff --git a/modules/assistant/tabnine/default.nix b/modules/assistant/tabnine/default.nix new file mode 100644 index 0000000..8e1722e --- /dev/null +++ b/modules/assistant/tabnine/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./tabnine.nix + ] +} \ No newline at end of file diff --git a/modules/assistant/tabnine/tabnine.nix b/modules/assistant/tabnine/tabnine.nix new file mode 100644 index 0000000..785e392 --- /dev/null +++ b/modules/assistant/tabnine/tabnine.nix @@ -0,0 +1,44 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.assistant.tabnine; +in { + options.vim.assistant.tabnine = { + enable = mkEnableOption "Enable TabNine assistant"; + + disable_auto_comment = mkOption { + type = types.bool; + default = true; + description = "Disable auto comment"; + }; + + accept_keymap = mkOption { + type = types.str; + default = ""; + description = "Accept keymap"; + }; + + dismiss_keymap = mkOption { + type = types.str; + default = ""; + description = "Dismiss keymap"; + }; + + debounce_ms = mkOption { + type = types.int; + default = 800; + description = "Debounce ms"; + }; + + execlude_filetypes = mkOption { + type = types.listOf types.str; + default = ["TelescopePrompt" "NvimTree" "alpha"]; + description = "Execlude filetypes"; + }; + }; +} From e265180cf176901ff2adfc7768c2625fa788ebe7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:06:04 +0300 Subject: [PATCH 03/29] dev: cleanup --- modules/assistant/copilot.nix | 28 ---------------------------- modules/assistant/default.nix | 2 +- modules/assistant/tabnine.nix | 28 ---------------------------- 3 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 modules/assistant/copilot.nix delete mode 100644 modules/assistant/tabnine.nix diff --git a/modules/assistant/copilot.nix b/modules/assistant/copilot.nix deleted file mode 100644 index b15d262..0000000 --- a/modules/assistant/copilot.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.assistant.copilot; -in { - options.vim.assistant.copilot = { - enable = mkEnableOption "Enable GitHub Copilot"; - }; - - config = mkIf cfg.enable { - vim.startPlugins = [ - "copilot-lua" - pkgs.nodejs-slim-16_x - ]; - - vim.luaConfigRC.copilot = nvim.dag.entryAnywhere '' - require("copilot").setup({ - -- available options: https://github.com/zbirenbaum/copilot.lua - copilot_node_command = "${lib.getExe pkgs.nodejs-slim-16_x}", - }) - ''; - }; -} diff --git a/modules/assistant/default.nix b/modules/assistant/default.nix index 68128af..a8096c8 100644 --- a/modules/assistant/default.nix +++ b/modules/assistant/default.nix @@ -1,6 +1,6 @@ _: { imports = [ - ./copilot.nix + ./copilot # ./tabnine.nix # removed until I find a way around the initialisation script the plugin requires ]; } diff --git a/modules/assistant/tabnine.nix b/modules/assistant/tabnine.nix deleted file mode 100644 index bb8cecc..0000000 --- a/modules/assistant/tabnine.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.assistant.tabnine; -in { - options.vim.assistant.tabnine = { - enable = mkEnableOption "Enable TabNine assistant"; - }; - - config = mkIf cfg.enable { - vim.startPlugins = ["tabnine-nvim"]; - - vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere '' - require('tabnine').setup({ - disable_auto_comment=true, - accept_keymap="", - dismiss_keymap = "", - debounce_ms = 800, - execlude_filetypes = {"TelescopePrompt", "NvimTree", "alpha"} - }) - ''; - }; -} From ec1eaeca0d210c736e957ef80565c36b6d720dc3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:51:32 +0300 Subject: [PATCH 04/29] feat: cleanup --- modules/assistant/tabnine/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/assistant/tabnine/default.nix b/modules/assistant/tabnine/default.nix index 8e1722e..84f3cf2 100644 --- a/modules/assistant/tabnine/default.nix +++ b/modules/assistant/tabnine/default.nix @@ -2,5 +2,5 @@ _: { imports = [ ./config.nix ./tabnine.nix - ] -} \ No newline at end of file + ]; +} From f9b44dd9cbce4987db4df07f47d77bd41f5d1190 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:52:18 +0300 Subject: [PATCH 05/29] feat: apply new module format to comment.nvim --- modules/comments/comment-nvim/comment-nvim.nix | 14 ++++++++++++++ .../{comment-nvim.nix => comment-nvim/config.nix} | 4 ---- modules/comments/comment-nvim/default.nix | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 modules/comments/comment-nvim/comment-nvim.nix rename modules/comments/{comment-nvim.nix => comment-nvim/config.nix} (77%) create mode 100644 modules/comments/comment-nvim/default.nix diff --git a/modules/comments/comment-nvim/comment-nvim.nix b/modules/comments/comment-nvim/comment-nvim.nix new file mode 100644 index 0000000..b445d91 --- /dev/null +++ b/modules/comments/comment-nvim/comment-nvim.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.comments.comment-nvim; +in { + options.vim.comments.comment-nvim = { + enable = mkEnableOption "comment-nvim"; + }; +} diff --git a/modules/comments/comment-nvim.nix b/modules/comments/comment-nvim/config.nix similarity index 77% rename from modules/comments/comment-nvim.nix rename to modules/comments/comment-nvim/config.nix index 1139b3c..8b0dbd0 100644 --- a/modules/comments/comment-nvim.nix +++ b/modules/comments/comment-nvim/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.comments.comment-nvim; in { - options.vim.comments.comment-nvim = { - enable = mkEnableOption "comment-nvim"; - }; - config = mkIf cfg.enable { vim.startPlugins = [ "comment-nvim" diff --git a/modules/comments/comment-nvim/default.nix b/modules/comments/comment-nvim/default.nix new file mode 100644 index 0000000..db4eb42 --- /dev/null +++ b/modules/comments/comment-nvim/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./comment-nvim.nix + ]; +} From 4436c2b2aaa23ded758f669ec80aaf2e8edc348d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:52:43 +0300 Subject: [PATCH 06/29] feat: apply new module format to nvim-cmp --- modules/completion/default.nix | 129 +---------------------- modules/completion/nvim-cmp/config.nix | 110 +++++++++++++++++++ modules/completion/nvim-cmp/default.nix | 6 ++ modules/completion/nvim-cmp/nvim-cmp.nix | 26 +++++ 4 files changed, 146 insertions(+), 125 deletions(-) create mode 100644 modules/completion/nvim-cmp/config.nix create mode 100644 modules/completion/nvim-cmp/default.nix create mode 100644 modules/completion/nvim-cmp/nvim-cmp.nix diff --git a/modules/completion/default.nix b/modules/completion/default.nix index bddc13b..77d51b4 100644 --- a/modules/completion/default.nix +++ b/modules/completion/default.nix @@ -1,126 +1,5 @@ -{ - pkgs, - lib, - config, - ... -}: -with lib; -with builtins; let - cfg = config.vim.autocomplete; -in { - options.vim = { - autocomplete = { - enable = mkOption { - type = types.bool; - default = false; - description = "enable autocomplete"; - }; - - type = mkOption { - type = types.enum ["nvim-cmp"]; - default = "nvim-cmp"; - description = "Set the autocomplete plugin. Options: [nvim-cmp]"; - }; - }; - }; - - config = mkIf cfg.enable { - vim.startPlugins = [ - "nvim-cmp" - "cmp-buffer" - "cmp-vsnip" - "cmp-path" - "cmp-treesitter" - ]; - - vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (nvim.dag.entryAnywhere '' - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) - end - - local cmp = require'cmp' - cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - sources = { - ${optionalString (config.vim.lsp.enable) "{ name = 'nvim_lsp' },"} - ${optionalString (config.vim.lsp.rust.enable) "{ name = 'crates' },"} - { name = 'vsnip' }, - { name = 'treesitter' }, - { name = 'path' }, - { name = 'buffer' }, - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c'}), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c'}), - [''] = cmp.config.disable, - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ - select = true, - }), - [''] = cmp.mapping(function (fallback) - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn['vsnip#available'](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function (fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn['vsnip#available'](-1) == 1 then - feedkeys("(vsnip-jump-prev)", "") - end - end, { 'i', 's' }) - }, - completion = { - completeopt = 'menu,menuone,noinsert', - }, - formatting = { - format = function(entry, vim_item) - -- type of kind - vim_item.kind = ${ - optionalString (config.vim.visuals.lspkind.enable) - "require('lspkind').presets.default[vim_item.kind] .. ' ' .." - } vim_item.kind - - -- name for each source - vim_item.menu = ({ - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - vsnip = "[VSnip]", - crates = "[Crates]", - path = "[Path]", - })[entry.source.name] - return vim_item - end, - } - }) - ${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") '' - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} })) - ''} - ''); - - vim.snippets.vsnip.enable = - if (cfg.type == "nvim-cmp") - then true - else config.vim.snippets.vsnip.enable; - }; +_: { + imports = [ + ./nvim-cmp + ]; } diff --git a/modules/completion/nvim-cmp/config.nix b/modules/completion/nvim-cmp/config.nix new file mode 100644 index 0000000..65675af --- /dev/null +++ b/modules/completion/nvim-cmp/config.nix @@ -0,0 +1,110 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim.autocomplete; +in { + config = mkIf cfg.enable { + vim.startPlugins = [ + "nvim-cmp" + "cmp-buffer" + "cmp-vsnip" + "cmp-path" + "cmp-treesitter" + ]; + + vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (nvim.dag.entryAnywhere '' + local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + local feedkey = function(key, mode) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) + end + + local cmp = require'cmp' + cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + sources = { + ${optionalString (config.vim.lsp.enable) "{ name = 'nvim_lsp' },"} + ${optionalString (config.vim.lsp.rust.enable) "{ name = 'crates' },"} + { name = 'vsnip' }, + { name = 'treesitter' }, + { name = 'path' }, + { name = 'buffer' }, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c'}), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c'}), + [''] = cmp.config.disable, + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ + select = true, + }), + [''] = cmp.mapping(function (fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn['vsnip#available'](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function (fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn['vsnip#available'](-1) == 1 then + feedkeys("(vsnip-jump-prev)", "") + end + end, { 'i', 's' }) + }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, + formatting = { + format = function(entry, vim_item) + -- type of kind + vim_item.kind = ${ + optionalString (config.vim.visuals.lspkind.enable) + "require('lspkind').presets.default[vim_item.kind] .. ' ' .." + } vim_item.kind + + -- name for each source + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + vsnip = "[VSnip]", + crates = "[Crates]", + path = "[Path]", + })[entry.source.name] + return vim_item + end, + } + }) + ${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") '' + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} })) + ''} + ''); + + vim.snippets.vsnip.enable = + if (cfg.type == "nvim-cmp") + then true + else config.vim.snippets.vsnip.enable; + }; +} diff --git a/modules/completion/nvim-cmp/default.nix b/modules/completion/nvim-cmp/default.nix new file mode 100644 index 0000000..603347f --- /dev/null +++ b/modules/completion/nvim-cmp/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./nvim-cmp.nix + ]; +} diff --git a/modules/completion/nvim-cmp/nvim-cmp.nix b/modules/completion/nvim-cmp/nvim-cmp.nix new file mode 100644 index 0000000..9986877 --- /dev/null +++ b/modules/completion/nvim-cmp/nvim-cmp.nix @@ -0,0 +1,26 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim.autocomplete; +in { + options.vim = { + autocomplete = { + enable = mkOption { + type = types.bool; + default = false; + description = "enable autocomplete"; + }; + + type = mkOption { + type = types.enum ["nvim-cmp"]; + default = "nvim-cmp"; + description = "Set the autocomplete plugin. Options: [nvim-cmp]"; + }; + }; + }; +} From f567b08e9238153ae011d172b503193370213725 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:53:09 +0300 Subject: [PATCH 07/29] feat: apply new module format to dashboard plugins [3/3] --- modules/dashboard/alpha/alpha.nix | 14 +++++ .../dashboard/{alpha.nix => alpha/config.nix} | 9 ++-- modules/dashboard/alpha/default.nix | 6 +++ .../config.nix} | 4 -- .../dashboard-nvim/dashboard-nvim.nix | 14 +++++ modules/dashboard/dashboard-nvim/default.nix | 6 +++ modules/dashboard/default.nix | 6 +-- modules/dashboard/startify/config.nix | 54 +++++++++++++++++++ modules/dashboard/startify/default.nix | 6 +++ modules/dashboard/{ => startify}/startify.nix | 39 -------------- 10 files changed, 106 insertions(+), 52 deletions(-) create mode 100644 modules/dashboard/alpha/alpha.nix rename modules/dashboard/{alpha.nix => alpha/config.nix} (97%) create mode 100644 modules/dashboard/alpha/default.nix rename modules/dashboard/{dashboard-nvim.nix => dashboard-nvim/config.nix} (77%) create mode 100644 modules/dashboard/dashboard-nvim/dashboard-nvim.nix create mode 100644 modules/dashboard/dashboard-nvim/default.nix create mode 100644 modules/dashboard/startify/config.nix create mode 100644 modules/dashboard/startify/default.nix rename modules/dashboard/{ => startify}/startify.nix (75%) diff --git a/modules/dashboard/alpha/alpha.nix b/modules/dashboard/alpha/alpha.nix new file mode 100644 index 0000000..c1101a7 --- /dev/null +++ b/modules/dashboard/alpha/alpha.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.dashboard.alpha; +in { + options.vim.dashboard.alpha = { + enable = mkEnableOption "alpha"; + }; +} diff --git a/modules/dashboard/alpha.nix b/modules/dashboard/alpha/config.nix similarity index 97% rename from modules/dashboard/alpha.nix rename to modules/dashboard/alpha/config.nix index 833ccdf..c5053ad 100644 --- a/modules/dashboard/alpha.nix +++ b/modules/dashboard/alpha/config.nix @@ -8,17 +8,14 @@ with lib; with builtins; let cfg = config.vim.dashboard.alpha; in { - options.vim.dashboard.alpha = { - enable = mkEnableOption "alpha"; - }; - config = mkIf cfg.enable { vim.startPlugins = [ "alpha-nvim" + "nvim-web-devicons" ]; - # the credit for this configuration goes to https://github.com/Rishabh672003 - # good work, honestly + # the entire credit for this dashboard configuration to https://github.com/Rishabh672003 + # honestly, excellent work vim.luaConfigRC.alpha = nvim.dag.entryAnywhere '' local alpha = require("alpha") local plenary_path = require("plenary.path") diff --git a/modules/dashboard/alpha/default.nix b/modules/dashboard/alpha/default.nix new file mode 100644 index 0000000..16496c6 --- /dev/null +++ b/modules/dashboard/alpha/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./alpha.nix + ./config.nix + ]; +} diff --git a/modules/dashboard/dashboard-nvim.nix b/modules/dashboard/dashboard-nvim/config.nix similarity index 77% rename from modules/dashboard/dashboard-nvim.nix rename to modules/dashboard/dashboard-nvim/config.nix index de7d2d6..e63399b 100644 --- a/modules/dashboard/dashboard-nvim.nix +++ b/modules/dashboard/dashboard-nvim/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.dashboard.dashboard-nvim; in { - options.vim.dashboard.dashboard-nvim = { - enable = mkEnableOption "dashboard-nvim"; - }; - config = mkIf cfg.enable { vim.startPlugins = [ "dashboard-nvim" diff --git a/modules/dashboard/dashboard-nvim/dashboard-nvim.nix b/modules/dashboard/dashboard-nvim/dashboard-nvim.nix new file mode 100644 index 0000000..b62667e --- /dev/null +++ b/modules/dashboard/dashboard-nvim/dashboard-nvim.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.dashboard.dashboard-nvim; +in { + options.vim.dashboard.dashboard-nvim = { + enable = mkEnableOption "dashboard-nvim"; + }; +} diff --git a/modules/dashboard/dashboard-nvim/default.nix b/modules/dashboard/dashboard-nvim/default.nix new file mode 100644 index 0000000..5bc4473 --- /dev/null +++ b/modules/dashboard/dashboard-nvim/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./dashboard-nvim.nix + ./config.nix + ]; +} diff --git a/modules/dashboard/default.nix b/modules/dashboard/default.nix index bdee0db..0056f89 100644 --- a/modules/dashboard/default.nix +++ b/modules/dashboard/default.nix @@ -5,8 +5,8 @@ ... }: { imports = [ - ./alpha.nix - ./dashboard-nvim.nix - ./startify.nix + ./alpha + ./dashboard-nvim + ./startify ]; } diff --git a/modules/dashboard/startify/config.nix b/modules/dashboard/startify/config.nix new file mode 100644 index 0000000..c69d774 --- /dev/null +++ b/modules/dashboard/startify/config.nix @@ -0,0 +1,54 @@ +{ + pkgs, + config, + lib, + ... +}: +with builtins; +with lib; let + cfg = config.vim.dashboard.startify; + + mkVimBool = val: + if val + then "1" + else "0"; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = with pkgs.neovimPlugins; [vim-startify]; + + vim.globals = { + "startify_custom_header" = + if cfg.customHeader == [] + then null + else cfg.customHeader; + "startify_custom_footer" = + if cfg.customFooter == [] + then null + else cfg.customFooter; + "startify_bookmarks" = cfg.bookmarks; + "startify_lists" = cfg.lists; + "startify_change_to_dir" = mkVimBool cfg.changeToDir; + "startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot; + "startify_change_cmd" = cfg.changeDirCmd; + "startify_skiplist" = cfg.skipList; + "startify_update_oldfiles" = mkVimBool cfg.updateOldFiles; + "startify_session_autoload" = mkVimBool cfg.sessionAutoload; + "startify_commands" = cfg.commands; + "startify_files_number" = cfg.filesNumber; + "startify_custom_indices" = cfg.customIndices; + "startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup; + "startify_enable_unsafe" = mkVimBool cfg.unsafe; + "startify_padding_left" = cfg.paddingLeft; + "startify_use_env" = mkVimBool cfg.useEnv; + "startify_session_before_save" = cfg.sessionBeforeSave; + "startify_session_persistence" = mkVimBool cfg.sessionPersistence; + "startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers; + "startify_session_dir" = cfg.sessionDir; + "startify_skiplist_server" = cfg.skipListServer; + "startify_session_remove_lines" = cfg.sessionRemoveLines; + "startify_session_savevars" = cfg.sessionSavevars; + "startify_session_savecmds" = cfg.sessionSavecmds; + "startify_session_sort" = mkVimBool cfg.sessionSort; + }; + }; +} diff --git a/modules/dashboard/startify/default.nix b/modules/dashboard/startify/default.nix new file mode 100644 index 0000000..12440c6 --- /dev/null +++ b/modules/dashboard/startify/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./startify.nix + ./config.nix + ]; +} diff --git a/modules/dashboard/startify.nix b/modules/dashboard/startify/startify.nix similarity index 75% rename from modules/dashboard/startify.nix rename to modules/dashboard/startify/startify.nix index a5fb405..bbf791e 100644 --- a/modules/dashboard/startify.nix +++ b/modules/dashboard/startify/startify.nix @@ -194,43 +194,4 @@ in { type = types.bool; }; }; - - config = mkIf (cfg.enable) { - vim.startPlugins = with pkgs.neovimPlugins; [vim-startify]; - - vim.globals = { - "startify_custom_header" = - if cfg.customHeader == [] - then null - else cfg.customHeader; - "startify_custom_footer" = - if cfg.customFooter == [] - then null - else cfg.customFooter; - "startify_bookmarks" = cfg.bookmarks; - "startify_lists" = cfg.lists; - "startify_change_to_dir" = mkVimBool cfg.changeToDir; - "startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot; - "startify_change_cmd" = cfg.changeDirCmd; - "startify_skiplist" = cfg.skipList; - "startify_update_oldfiles" = mkVimBool cfg.updateOldFiles; - "startify_session_autoload" = mkVimBool cfg.sessionAutoload; - "startify_commands" = cfg.commands; - "startify_files_number" = cfg.filesNumber; - "startify_custom_indices" = cfg.customIndices; - "startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup; - "startify_enable_unsafe" = mkVimBool cfg.unsafe; - "startify_padding_left" = cfg.paddingLeft; - "startify_use_env" = mkVimBool cfg.useEnv; - "startify_session_before_save" = cfg.sessionBeforeSave; - "startify_session_persistence" = mkVimBool cfg.sessionPersistence; - "startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers; - "startify_session_dir" = cfg.sessionDir; - "startify_skiplist_server" = cfg.skipListServer; - "startify_session_remove_lines" = cfg.sessionRemoveLines; - "startify_session_savevars" = cfg.sessionSavevars; - "startify_session_savecmds" = cfg.sessionSavecmds; - "startify_session_sort" = mkVimBool cfg.sessionSort; - }; - }; } From b917526be783962f9f0cdb93a79de34b7743f1f7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:53:34 +0300 Subject: [PATCH 08/29] modules/autopairs feat: apply new module format to nvim-autopairs --- modules/autopairs/default.nix | 46 +--- modules/autopairs/nvim-autopairs/config.nix | 27 +++ modules/autopairs/nvim-autopairs/default.nix | 6 + .../nvim-autopairs/nvim-autopairs.nix | 46 ++++ modules/basic/config.nix | 103 ++++++++ modules/basic/default.nix | 229 +----------------- modules/basic/module.nix | 132 ++++++++++ modules/comments/default.nix | 4 +- 8 files changed, 325 insertions(+), 268 deletions(-) create mode 100644 modules/autopairs/nvim-autopairs/config.nix create mode 100644 modules/autopairs/nvim-autopairs/default.nix create mode 100644 modules/autopairs/nvim-autopairs/nvim-autopairs.nix create mode 100644 modules/basic/config.nix create mode 100644 modules/basic/module.nix diff --git a/modules/autopairs/default.nix b/modules/autopairs/default.nix index 3e85003..742665c 100644 --- a/modules/autopairs/default.nix +++ b/modules/autopairs/default.nix @@ -1,43 +1,5 @@ -{ - pkgs, - lib, - config, - ... -}: -with lib; -with builtins; let - cfg = config.vim.autopairs; -in { - options.vim = { - autopairs = { - enable = mkOption { - type = types.bool; - default = false; - description = "enable autopairs"; - }; - - type = mkOption { - type = types.enum ["nvim-autopairs"]; - default = "nvim-autopairs"; - description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; - }; - }; - }; - - config = - mkIf cfg.enable - { - vim.startPlugins = ["nvim-autopairs"]; - - vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere '' - require("nvim-autopairs").setup{} - ${optionalString (config.vim.autocomplete.type == "nvim-compe") '' - require('nvim-autopairs.completion.compe').setup({ - map_cr = true, - map_complete = true, - auto_select = false, - }) - ''} - ''; - }; +_: { + imports = [ + ./nvim-autopairs + ]; } diff --git a/modules/autopairs/nvim-autopairs/config.nix b/modules/autopairs/nvim-autopairs/config.nix new file mode 100644 index 0000000..87903ef --- /dev/null +++ b/modules/autopairs/nvim-autopairs/config.nix @@ -0,0 +1,27 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim.autopairs; +in { + config = + mkIf (cfg.enable) + { + vim.startPlugins = ["nvim-autopairs"]; + + vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere '' + require("nvim-autopairs").setup{} + ${optionalString (config.vim.autocomplete.type == "nvim-compe") '' + require('nvim-autopairs.completion.compe').setup({ + map_cr = ${boolToString cfg.nvim-compe.map_cr}, + map_complete = ${boolToString cfg.nvim-compe.map_complete}, + auto_select = ${boolToString cfg.nvim-compe.auto_select}, + }) + ''} + ''; + }; +} diff --git a/modules/autopairs/nvim-autopairs/default.nix b/modules/autopairs/nvim-autopairs/default.nix new file mode 100644 index 0000000..f228331 --- /dev/null +++ b/modules/autopairs/nvim-autopairs/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./nvim-autopairs.nix + ]; +} diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix new file mode 100644 index 0000000..402561e --- /dev/null +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -0,0 +1,46 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim.autopairs; +in { + options.vim = { + autopairs = { + enable = mkOption { + type = types.bool; + default = false; + description = "enable autopairs"; + }; + + type = mkOption { + type = types.enum ["nvim-autopairs"]; + default = "nvim-autopairs"; + description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; + }; + + nvim-compe = { + map_cr = mkOption { + type = types.bool; + default = true; + description = "map on insert mode"; + }; + + map_complete = mkOption { + type = types.bool; + default = true; + description = "auto insert `(` after select function or method item"; + }; + + auto_select = mkOption { + type = types.bool; + default = false; + description = "auto select first item"; + }; + }; + }; + }; +} diff --git a/modules/basic/config.nix b/modules/basic/config.nix new file mode 100644 index 0000000..3c34cf2 --- /dev/null +++ b/modules/basic/config.nix @@ -0,0 +1,103 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim; +in { + config = { + vim.startPlugins = ["plenary-nvim"]; + + vim.nmap = mkIf cfg.disableArrows { + "" = ""; + "" = ""; + "" = ""; + "" = ""; + }; + + vim.imap = mkIf cfg.disableArrows { + "" = ""; + "" = ""; + "" = ""; + "" = ""; + }; + + vim.nnoremap = mkIf cfg.mapLeaderSpace {"" = "";}; + + vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] '' + " Settings that are set for everything + set encoding=utf-8 + set mouse=${cfg.mouseSupport} + set tabstop=${toString cfg.tabWidth} + set shiftwidth=${toString cfg.tabWidth} + set softtabstop=${toString cfg.tabWidth} + set expandtab + set cmdheight=${toString cfg.cmdHeight} + set updatetime=${toString cfg.updateTime} + set shortmess+=c + set tm=${toString cfg.mapTimeout} + set hidden + ${optionalString cfg.splitBelow '' + set splitbelow + ''} + ${optionalString cfg.splitRight '' + set splitright + ''} + ${optionalString cfg.showSignColumn '' + set signcolumn=yes + ''} + ${optionalString cfg.autoIndent '' + set autoindent + ''} + + ${optionalString cfg.preventJunkFiles '' + set noswapfile + set nobackup + set nowritebackup + ''} + ${optionalString (cfg.bell == "none") '' + set noerrorbells + set novisualbell + ''} + ${optionalString (cfg.bell == "on") '' + set novisualbell + ''} + ${optionalString (cfg.bell == "visual") '' + set noerrorbells + ''} + ${optionalString (cfg.lineNumberMode == "relative") '' + set relativenumber + ''} + ${optionalString (cfg.lineNumberMode == "number") '' + set number + ''} + ${optionalString (cfg.lineNumberMode == "relNumber") '' + set number relativenumber + ''} + ${optionalString cfg.useSystemClipboard '' + set clipboard+=unnamedplus + ''} + ${optionalString cfg.mapLeaderSpace '' + let mapleader=" " + let maplocalleader=" " + ''} + ${optionalString cfg.syntaxHighlighting '' + syntax on + ''} + ${optionalString (!cfg.wordWrap) '' + set nowrap + ''} + ${optionalString cfg.hideSearchHighlight '' + set nohlsearch + set incsearch + ''} + ${optionalString cfg.colourTerm '' + set termguicolors + set t_Co=256 + ''} + ''; + }; +} diff --git a/modules/basic/default.nix b/modules/basic/default.nix index f020608..a883939 100644 --- a/modules/basic/default.nix +++ b/modules/basic/default.nix @@ -1,225 +1,6 @@ -{ - pkgs, - lib, - config, - ... -}: -with lib; -with builtins; let - cfg = config.vim; -in { - options.vim = { - colourTerm = mkOption { - type = types.bool; - default = true; - description = "Set terminal up for 256 colours"; - }; - - disableArrows = mkOption { - type = types.bool; - default = false; - description = "Set to prevent arrow keys from moving cursor"; - }; - - hideSearchHighlight = mkOption { - type = types.bool; - default = false; - description = "Hide search highlight so it doesn't stay highlighted"; - }; - - scrollOffset = mkOption { - type = types.int; - default = 8; - description = "Start scrolling this number of lines from the top or bottom of the page."; - }; - - wordWrap = mkOption { - type = types.bool; - default = true; - description = "Enable word wrapping."; - }; - - syntaxHighlighting = mkOption { - type = types.bool; - default = true; - description = "Enable syntax highlighting"; - }; - - mapLeaderSpace = mkOption { - type = types.bool; - default = true; - description = "Map the space key to leader key"; - }; - - useSystemClipboard = mkOption { - type = types.bool; - default = true; - description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; - }; - - mouseSupport = mkOption { - type = with types; enum ["a" "n" "v" "i" "c"]; - default = "a"; - description = "Set modes for mouse support. a - all, n - normal, v - visual, i - insert, c - command"; - }; - - lineNumberMode = mkOption { - type = with types; enum ["relative" "number" "relNumber" "none"]; - default = "relNumber"; - description = "How line numbers are displayed. none, relative, number, relNumber"; - }; - - preventJunkFiles = mkOption { - type = types.bool; - default = false; - description = "Prevent swapfile, backupfile from being created"; - }; - - tabWidth = mkOption { - type = types.int; - default = 4; - description = "Set the width of tabs"; - }; - - autoIndent = mkOption { - type = types.bool; - default = true; - description = "Enable auto indent"; - }; - - cmdHeight = mkOption { - type = types.int; - default = 1; - description = "Height of the command pane"; - }; - - updateTime = mkOption { - type = types.int; - default = 300; - description = "The number of milliseconds till Cursor Hold event is fired"; - }; - - showSignColumn = mkOption { - type = types.bool; - default = true; - description = "Show the sign column"; - }; - - bell = mkOption { - type = types.enum ["none" "visual" "on"]; - default = "none"; - description = "Set how bells are handled. Options: on, visual or none"; - }; - - mapTimeout = mkOption { - type = types.int; - default = 500; - description = "Timeout in ms that neovim will wait for mapped action to complete"; - }; - - splitBelow = mkOption { - type = types.bool; - default = true; - description = "New splits will open below instead of on top"; - }; - - splitRight = mkOption { - type = types.bool; - default = true; - description = "New splits will open to the right"; - }; - }; - - config = { - vim.startPlugins = ["plenary-nvim"]; - - vim.nmap = mkIf cfg.disableArrows { - "" = ""; - "" = ""; - "" = ""; - "" = ""; - }; - - vim.imap = mkIf cfg.disableArrows { - "" = ""; - "" = ""; - "" = ""; - "" = ""; - }; - - vim.nnoremap = mkIf cfg.mapLeaderSpace {"" = "";}; - - vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] '' - " Settings that are set for everything - set encoding=utf-8 - set mouse=${cfg.mouseSupport} - set tabstop=${toString cfg.tabWidth} - set shiftwidth=${toString cfg.tabWidth} - set softtabstop=${toString cfg.tabWidth} - set expandtab - set cmdheight=${toString cfg.cmdHeight} - set updatetime=${toString cfg.updateTime} - set shortmess+=c - set tm=${toString cfg.mapTimeout} - set hidden - ${optionalString cfg.splitBelow '' - set splitbelow - ''} - ${optionalString cfg.splitRight '' - set splitright - ''} - ${optionalString cfg.showSignColumn '' - set signcolumn=yes - ''} - ${optionalString cfg.autoIndent '' - set autoindent - ''} - - ${optionalString cfg.preventJunkFiles '' - set noswapfile - set nobackup - set nowritebackup - ''} - ${optionalString (cfg.bell == "none") '' - set noerrorbells - set novisualbell - ''} - ${optionalString (cfg.bell == "on") '' - set novisualbell - ''} - ${optionalString (cfg.bell == "visual") '' - set noerrorbells - ''} - ${optionalString (cfg.lineNumberMode == "relative") '' - set relativenumber - ''} - ${optionalString (cfg.lineNumberMode == "number") '' - set number - ''} - ${optionalString (cfg.lineNumberMode == "relNumber") '' - set number relativenumber - ''} - ${optionalString cfg.useSystemClipboard '' - set clipboard+=unnamedplus - ''} - ${optionalString cfg.mapLeaderSpace '' - let mapleader=" " - let maplocalleader=" " - ''} - ${optionalString cfg.syntaxHighlighting '' - syntax on - ''} - ${optionalString (!cfg.wordWrap) '' - set nowrap - ''} - ${optionalString cfg.hideSearchHighlight '' - set nohlsearch - set incsearch - ''} - ${optionalString cfg.colourTerm '' - set termguicolors - set t_Co=256 - ''} - ''; - }; +_: { + imports = [ + ./config.nix + ./module.nix + ]; } diff --git a/modules/basic/module.nix b/modules/basic/module.nix new file mode 100644 index 0000000..e1f5dff --- /dev/null +++ b/modules/basic/module.nix @@ -0,0 +1,132 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +with builtins; let + cfg = config.vim; +in { + options.vim = { + colourTerm = mkOption { + type = types.bool; + default = true; + description = "Set terminal up for 256 colours"; + }; + + disableArrows = mkOption { + type = types.bool; + default = false; + description = "Set to prevent arrow keys from moving cursor"; + }; + + hideSearchHighlight = mkOption { + type = types.bool; + default = false; + description = "Hide search highlight so it doesn't stay highlighted"; + }; + + scrollOffset = mkOption { + type = types.int; + default = 8; + description = "Start scrolling this number of lines from the top or bottom of the page."; + }; + + wordWrap = mkOption { + type = types.bool; + default = true; + description = "Enable word wrapping."; + }; + + syntaxHighlighting = mkOption { + type = types.bool; + default = true; + description = "Enable syntax highlighting"; + }; + + mapLeaderSpace = mkOption { + type = types.bool; + default = true; + description = "Map the space key to leader key"; + }; + + useSystemClipboard = mkOption { + type = types.bool; + default = true; + description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; + }; + + mouseSupport = mkOption { + type = with types; enum ["a" "n" "v" "i" "c"]; + default = "a"; + description = "Set modes for mouse support. a - all, n - normal, v - visual, i - insert, c - command"; + }; + + lineNumberMode = mkOption { + type = with types; enum ["relative" "number" "relNumber" "none"]; + default = "relNumber"; + description = "How line numbers are displayed. none, relative, number, relNumber"; + }; + + preventJunkFiles = mkOption { + type = types.bool; + default = false; + description = "Prevent swapfile, backupfile from being created"; + }; + + tabWidth = mkOption { + type = types.int; + default = 4; + description = "Set the width of tabs"; + }; + + autoIndent = mkOption { + type = types.bool; + default = true; + description = "Enable auto indent"; + }; + + cmdHeight = mkOption { + type = types.int; + default = 1; + description = "Height of the command pane"; + }; + + updateTime = mkOption { + type = types.int; + default = 300; + description = "The number of milliseconds till Cursor Hold event is fired"; + }; + + showSignColumn = mkOption { + type = types.bool; + default = true; + description = "Show the sign column"; + }; + + bell = mkOption { + type = types.enum ["none" "visual" "on"]; + default = "none"; + description = "Set how bells are handled. Options: on, visual or none"; + }; + + mapTimeout = mkOption { + type = types.int; + default = 500; + description = "Timeout in ms that neovim will wait for mapped action to complete"; + }; + + splitBelow = mkOption { + type = types.bool; + default = true; + description = "New splits will open below instead of on top"; + }; + + splitRight = mkOption { + type = types.bool; + default = true; + description = "New splits will open to the right"; + }; + }; +} diff --git a/modules/comments/default.nix b/modules/comments/default.nix index 8efe564..138ad80 100644 --- a/modules/comments/default.nix +++ b/modules/comments/default.nix @@ -1,6 +1,6 @@ _: { imports = [ - ./comment-nvim.nix - ./kommentary.nix + ./comment-nvim + ./kommentary.nix # WARNING: WILL BE REMOVED IN THE NEXT MAJOR RELEASE ]; } From 5ace8e9ba2ef0f81e7c4cfc09c6c4f5f89e07b22 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:24:31 +0300 Subject: [PATCH 09/29] feat: feat: update flake inputs (27/02/2023) --- flake.lock | 161 +++++++++++++++++++++++++++++------------------------ 1 file changed, 89 insertions(+), 72 deletions(-) diff --git a/flake.lock b/flake.lock index 5b539ce..5736be9 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "alpha-nvim": { "flake": false, "locked": { - "lastModified": 1676565390, - "narHash": "sha256-p4yLMgLUA0yzOlABVatrcPKTrKoJBHxC9scXGWbUYxE=", + "lastModified": 1677109657, + "narHash": "sha256-DkUs2570WKxY1cG+spZWvCCNYhCTTp6uSCsj9i8yXxw=", "owner": "goolord", "repo": "alpha-nvim", - "rev": "b3eef69e95674905bf26c7740dd4bbb09b355494", + "rev": "b6c7b5d9d6d2633722255abf2be3ecb8733e8d2d", "type": "github" }, "original": { @@ -35,11 +35,11 @@ "catppuccin": { "flake": false, "locked": { - "lastModified": 1676603815, - "narHash": "sha256-50K4S8adyhD64jCGLFE/FCdo1SCeqZbkG2OrtgUp9UE=", + "lastModified": 1677516778, + "narHash": "sha256-3knbj1w+i9b3Pi0mBS3tgjj82C4JQp4ZfhFh4qPfG2Y=", "owner": "catppuccin", "repo": "nvim", - "rev": "60f8f40df0db92b5715642b3ea7074380c4b7995", + "rev": "7c392fb5f27daa6addee050f7b7522718e8d9357", "type": "github" }, "original": { @@ -195,11 +195,11 @@ "colorizer": { "flake": false, "locked": { - "lastModified": 1674354831, - "narHash": "sha256-JbAjfoPUfLQ7ijRh8kank4iSZLOcxPJKt/uOTJap8/A=", + "lastModified": 1677384277, + "narHash": "sha256-pvXbfvGRLqLVHCAXs3AAKLPb4xfeFcjy14kMFFHCObE=", "owner": "uga-rosa", "repo": "ccc.nvim", - "rev": "be0a8122fd77efb7b6a0d672bab10417e68fab8b", + "rev": "9738eb1d47bdb5d808f1c427e1c2db3dadae00b7", "type": "github" }, "original": { @@ -227,11 +227,11 @@ "copilot-lua": { "flake": false, "locked": { - "lastModified": 1676663591, - "narHash": "sha256-RO93/7L/vR1EHjeEv0o6mpnDD6aCsu5CX6CRYdDf9ok=", + "lastModified": 1677479736, + "narHash": "sha256-n/SCrzzzL5WUHJk0sCXbgGusk/dQuy8DI9Pqdh+lVeQ=", "owner": "zbirenbaum", "repo": "copilot.lua", - "rev": "5304ea7079f38df200f4357401f1510fd00560a8", + "rev": "b41d4c9c7d4f5e0272bcf94061b88e244904c56f", "type": "github" }, "original": { @@ -243,11 +243,11 @@ "crates-nvim": { "flake": false, "locked": { - "lastModified": 1676072696, - "narHash": "sha256-e30Ir+Kd0EuvGoqORLtIA3aloL9djuebZYkBssWA0L8=", + "lastModified": 1677075483, + "narHash": "sha256-xarbPUL3yFMOn5Bse+syw1vLxqA/krS3tbuu/baup/k=", "owner": "Saecki", "repo": "crates.nvim", - "rev": "3fc7ddac13ddf65914a733ef074317c4c72ef05b", + "rev": "c33aae75745877ee1ef16f5781478f4f2f120623", "type": "github" }, "original": { @@ -259,11 +259,11 @@ "dashboard-nvim": { "flake": false, "locked": { - "lastModified": 1676532963, - "narHash": "sha256-0nPYwQ+NVEWBqmSHdpjj4aaX+OZiAXBuzdZUNIRg4uk=", + "lastModified": 1677391173, + "narHash": "sha256-a9+XhUwN3yGwFX+kq22VJxrU06Emjen7Y7pQsF5K8tY=", "owner": "glepnir", "repo": "dashboard-nvim", - "rev": "2312a5024748e869a355d91170f2e8fbf2bd5a51", + "rev": "398ba8d9390c13c87a964cbca756319531fffdb7", "type": "github" }, "original": { @@ -292,11 +292,11 @@ "dressing-nvim": { "flake": false, "locked": { - "lastModified": 1675626245, - "narHash": "sha256-tBO21/0rpil2lItFl9UzALXNJbvmSfQuW+LOGet9YgI=", + "lastModified": 1677218794, + "narHash": "sha256-89HwP+zxMN5CPPN3dd3yMfCB07mtBhv6lcWuEWnedfw=", "owner": "stevearc", "repo": "dressing.nvim", - "rev": "db716a0f1279f79a886c0e0b6ab3c3d5ffdb42fe", + "rev": "5f44f829481640be0f96759c965ae22a3bcaf7ce", "type": "github" }, "original": { @@ -305,6 +305,22 @@ "type": "github" } }, + "fidget-nvim": { + "flake": false, + "locked": { + "lastModified": 1676661245, + "narHash": "sha256-f49AwromG0rHZ5i1q4i6GJgLNtusa8QpciljL0dgSJo=", + "owner": "j-hui", + "repo": "fidget.nvim", + "rev": "688b4fec4517650e29c3e63cfbb6e498b3112ba1", + "type": "github" + }, + "original": { + "owner": "j-hui", + "repo": "fidget.nvim", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -341,11 +357,11 @@ "gesture-nvim": { "flake": false, "locked": { - "lastModified": 1675384642, - "narHash": "sha256-HxVWZopV3wx6ANefuowrdbSQpQriYHV43r187t7UJXQ=", + "lastModified": 1677239871, + "narHash": "sha256-hc0nFK7cC4A8kttQ4BrSDzeFlQyHUHWOo0MgT7ayoJU=", "owner": "notomo", "repo": "gesture.nvim", - "rev": "902a97219e126a08aea6016994c50eea485bcd79", + "rev": "b1024dbe2ee4dd5f7bc6293e3d6f2898e793594c", "type": "github" }, "original": { @@ -405,11 +421,11 @@ "indent-blankline": { "flake": false, "locked": { - "lastModified": 1674709281, - "narHash": "sha256-EZ5h4Gj942L9MaykWAprjLb/ZYr2JptQi16Ym5SyWfw=", + "lastModified": 1676854912, + "narHash": "sha256-dBm0vnza+fBYxlgUDR1/57GZ+kd7CUVgkQIcZEFWl9k=", "owner": "lukas-reineke", "repo": "indent-blankline.nvim", - "rev": "8299fe7703dfff4b1752aeed271c3b95281a952d", + "rev": "018bd04d80c9a73d399c1061fa0c3b14a7614399", "type": "github" }, "original": { @@ -562,11 +578,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1676390054, - "narHash": "sha256-w0KvrM+9WIEYr0juDh4Vs39ed2IaT0T696fp9pZ7i1I=", + "lastModified": 1677436111, + "narHash": "sha256-m3nz83arjowVttdaHXqZukN+sMFuIRviFSSARpUByhk=", "owner": "oxalica", "repo": "nil", - "rev": "944d5c335531778a1d7b54a97bf7fb5ec0c3e976", + "rev": "6723d2982d33e9d698ae5c3b0cfcccd9292b4eff", "type": "github" }, "original": { @@ -577,11 +593,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1676549890, - "narHash": "sha256-sq/WcOEAl7gWrrfGkWdnyYazRyTf+enEim/o6LOQzI8=", + "lastModified": 1677413016, + "narHash": "sha256-dwvL0VK5iyxXPQzJOPzYmuVinh/R9hwRu7eYq6Bf6ag=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8c66bd1b68f4708c90dcc97c6f7052a5a7b33257", + "rev": "84e33aea0f7a8375c92458c5b6cad75fa1dd561b", "type": "github" }, "original": { @@ -692,11 +708,11 @@ "null-ls": { "flake": false, "locked": { - "lastModified": 1676570563, - "narHash": "sha256-Ez6tMCY3XZyNKNvZru/5YpebvnGZjDs5KbWVt5ycMpI=", + "lastModified": 1676936752, + "narHash": "sha256-uGyXBh1SpNpOkUlZpQ0RWRTMW6x3uhg4x07hmjkpSro=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "a82aa08c0063843926947f3688b0e61fd71db680", + "rev": "689cdd78f70af20a37b5309ebc287ac645ae4f76", "type": "github" }, "original": { @@ -708,11 +724,11 @@ "nvim-autopairs": { "flake": false, "locked": { - "lastModified": 1676622615, - "narHash": "sha256-wKO4uCMZW0ec35BS8Y9kfz3RJr6As8/Om3TuILGptSs=", + "lastModified": 1677213588, + "narHash": "sha256-6XVJQnXgvD/TasbXrZkF6hNzgqMG35VYRPcMWDE2qEU=", "owner": "windwp", "repo": "nvim-autopairs", - "rev": "bde7a1b4534e0a4c2451a738379cd628ba65eba7", + "rev": "6a5faeabdbcc86cfbf1561ae430a451a72126e81", "type": "github" }, "original": { @@ -741,11 +757,11 @@ "nvim-cmp": { "flake": false, "locked": { - "lastModified": 1676555588, - "narHash": "sha256-VnPhbkhoYcPKt30D4GmAeEa+w7tbxswOcUbwdmIwQBQ=", + "lastModified": 1677479977, + "narHash": "sha256-cFX19DqWSwkki8TDfEBca1EV81PIPTx92rCpNUslaL8=", "owner": "hrsh7th", "repo": "nvim-cmp", - "rev": "ea9eaff5739856f3187d228d2c1181ea49fd4697", + "rev": "01f697a68905f9dcae70960a9eb013695a17f9a2", "type": "github" }, "original": { @@ -821,11 +837,11 @@ "nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1676472489, - "narHash": "sha256-DnvQ8gDqvkYcDwxQzQiIlLpiBI7xmVJ8J9VYCeWXwfc=", + "lastModified": 1677244101, + "narHash": "sha256-QD9CmFKjuabyzYsvooYOY8eKX8TIxcewfExrgQM2SjU=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "649137cbc53a044bffde36294ce3160cb18f32c7", + "rev": "62856b20751b748841b0f3ec5a10b1e2f6a6dbc9", "type": "github" }, "original": { @@ -853,11 +869,11 @@ "nvim-notify": { "flake": false, "locked": { - "lastModified": 1674034105, - "narHash": "sha256-zPSlenKjuZ8Xygu/KuU9+bSf5uUjSDK9HOTWnpUk1jo=", + "lastModified": 1677143076, + "narHash": "sha256-nwXUoncjtaHv2gbJnr0R8e+2JCewRpcU0Uh1DnWQEBg=", "owner": "rcarriga", "repo": "nvim-notify", - "rev": "bdd647f61a05c9b8a57c83b78341a0690e9c29d7", + "rev": "9c987081390753b625e2d94e749e80e9b4a3e082", "type": "github" }, "original": { @@ -885,11 +901,11 @@ "nvim-tree-lua": { "flake": false, "locked": { - "lastModified": 1676413452, - "narHash": "sha256-ttCTJsuO86jDrWsDTpQzg/uESHPYhyo1oF+2bJFI7E0=", + "lastModified": 1677490090, + "narHash": "sha256-3fTVcc6ImtmDy5/UBr2NAvnCrOIbdLeObl6Y7w0vefI=", "owner": "nvim-tree", "repo": "nvim-tree.lua", - "rev": "08a0aa1a3b7411ee0a7887c8818528b1558cef96", + "rev": "59bcb01d3bf58b810b9c48db56e558f3857110ad", "type": "github" }, "original": { @@ -933,11 +949,11 @@ "nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1676326872, - "narHash": "sha256-BmxnyHdNe7/egXNRz91YOcsvnc9fyK2jlYiqGhkaXSk=", + "lastModified": 1677455337, + "narHash": "sha256-iIDTJVj5WUhELunX9Qz+Y2KltbxGdCFeFm1P0Nd+9GM=", "owner": "kyazdani42", "repo": "nvim-web-devicons", - "rev": "bb6d4fd1e010300510172b173ab5205d37af084f", + "rev": "0f23feca2bd08549b779c838b6b1308d1e76df03", "type": "github" }, "original": { @@ -997,11 +1013,11 @@ "plenary-nvim": { "flake": false, "locked": { - "lastModified": 1675102817, - "narHash": "sha256-XxyAeN+kt8Cvt8aklVXyjqS4QRaP/0RE6+tPdoGGxPc=", + "lastModified": 1676797549, + "narHash": "sha256-z5JHuQcF1EvySnRBywl6EOrp8aRO0nd2dnkXJg2ge58=", "owner": "nvim-lua", "repo": "plenary.nvim", - "rev": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9", + "rev": "253d34830709d690f013daf2853a9d21ad7accab", "type": "github" }, "original": { @@ -1082,6 +1098,7 @@ "crates-nvim": "crates-nvim", "dashboard-nvim": "dashboard-nvim", "dressing-nvim": "dressing-nvim", + "fidget-nvim": "fidget-nvim", "flake-parts": "flake-parts", "flake-utils": "flake-utils", "gesture-nvim": "gesture-nvim", @@ -1169,11 +1186,11 @@ "rust-tools": { "flake": false, "locked": { - "lastModified": 1675562213, - "narHash": "sha256-SIVfaBTGil3gYa3VK1l8EXQqLILO2WbHBkOp+zQBSmo=", + "lastModified": 1676929960, + "narHash": "sha256-Cuk/vdoviB9ibt2rrkNRmNFy4S+6czhbExmIjTJRdZM=", "owner": "simrat39", "repo": "rust-tools.nvim", - "rev": "bd1aa99ffb911a1cf99b3fcf3b44c0391c57e3ef", + "rev": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f", "type": "github" }, "original": { @@ -1250,11 +1267,11 @@ "telescope": { "flake": false, "locked": { - "lastModified": 1675149856, - "narHash": "sha256-L4Kw94CUy6N7zcyy9INuR/O0fxQ7sp0IvGd/u7fHxMA=", + "lastModified": 1677414372, + "narHash": "sha256-QmyVJ/LZFtb/qqD5Q5fHsqAGgqaOT9XkVoLyOcqM14w=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "203bf5609137600d73e8ed82703d6b0e320a5f36", + "rev": "a3f17d3baf70df58b9d3544ea30abe52a7a832c2", "type": "github" }, "original": { @@ -1323,11 +1340,11 @@ "toggleterm-nvim": { "flake": false, "locked": { - "lastModified": 1676636241, - "narHash": "sha256-Hx21QM/6xzAokwreYRpjIWtGFy0BoaB+YxJzBogQ2d0=", + "lastModified": 1677405147, + "narHash": "sha256-CB/X+Y0kdHn4rMiwGrMr9GqyD5hhqcFFvC3zV1gmI7w=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "557664818f6af78de6192f0ce8bc2e887bf4943a", + "rev": "31d38d11390bcd35a568fcc65a79b7d6ec89de62", "type": "github" }, "original": { @@ -1355,11 +1372,11 @@ "trouble": { "flake": false, "locked": { - "lastModified": 1676550720, - "narHash": "sha256-nJmjl1K+PKDdojLGM5vc/VAH4Ysdy+HKihitcwahGIA=", + "lastModified": 1676905505, + "narHash": "sha256-afrw6Rigo3EZWOUK2sR0TtE31ktcwOMsQa5AT95I9S0=", "owner": "folke", "repo": "trouble.nvim", - "rev": "3bd029284d368cf70cc6fb4a5cbb9ae2231c239d", + "rev": "3b754285635a66a93aeb15fa71a23417d8997217", "type": "github" }, "original": { @@ -1417,11 +1434,11 @@ "vim-markdown": { "flake": false, "locked": { - "lastModified": 1669286150, - "narHash": "sha256-5q/s/ypZku4Iviq+eGip6hSWs0Ei3FrnX3IL3WV/FHw=", + "lastModified": 1677235033, + "narHash": "sha256-q4OE2tUoA0i6m3CbyzCYfjGsPNaTbU9/deM4DBu36GY=", "owner": "preservim", "repo": "vim-markdown", - "rev": "df4be8626e2c5b2a42eb60e1f100fce469b81f7d", + "rev": "5d3d1b6cbdc4be0b4c6105c1ab1f769d76d3c68f", "type": "github" }, "original": { From e09ccfd014f6dc63fa0565d3398b6a4b9418fb66 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:25:23 +0300 Subject: [PATCH 10/29] feat: apply new module format to nvimtree --- modules/filetree/default.nix | 9 +- modules/filetree/nvimtree-lua/config.nix | 131 ++++++++++++++++++ modules/filetree/nvimtree-lua/default.nix | 6 + .../nvimtree-lua.nix} | 116 ++++++---------- 4 files changed, 178 insertions(+), 84 deletions(-) create mode 100644 modules/filetree/nvimtree-lua/config.nix create mode 100644 modules/filetree/nvimtree-lua/default.nix rename modules/filetree/{nvimtreelua.nix => nvimtree-lua/nvimtree-lua.nix} (78%) diff --git a/modules/filetree/default.nix b/modules/filetree/default.nix index 18441b5..c9a44c3 100644 --- a/modules/filetree/default.nix +++ b/modules/filetree/default.nix @@ -1,10 +1,5 @@ -{ - pkgs, - lib, - config, - ... -}: { +_: { imports = [ - ./nvimtreelua.nix + ./nvimtree-lua ]; } diff --git a/modules/filetree/nvimtree-lua/config.nix b/modules/filetree/nvimtree-lua/config.nix new file mode 100644 index 0000000..fd72530 --- /dev/null +++ b/modules/filetree/nvimtree-lua/config.nix @@ -0,0 +1,131 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.filetree.nvimTreeLua; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["nvim-tree-lua"]; + + vim.nnoremap = { + "" = ":NvimTreeToggle"; + "tr" = ":NvimTreeRefresh"; + "tg" = ":NvimTreeFindFile"; + "tf" = ":NvimTreeFocus"; + }; + + vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' + local function open_nvim_tree(data) + local IGNORED_FT = { + "markdown", + } + + -- buffer is a real file on the disk + local real_file = vim.fn.filereadable(data.file) == 1 + + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + + -- &ft + local filetype = vim.bo[data.buf].ft + + -- only files please + if not real_file and not no_name then + return + end + + -- skip ignored filetypes + if vim.tbl_contains(IGNORED_FT, filetype) then + return + end + + -- open the tree but don't focus it + require("nvim-tree.api").tree.toggle({ focus = false }) + end + + -- Open on startup has been deprecated + -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup + -- use a nix eval to dynamically insert the open on startup function + ${ + # FIXME: this function is actually obslete due to the existence of the dashboard, I need to find an alternative logic + if (cfg.openOnSetup) + then '' + vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + '' + else "" + } + + require'nvim-tree'.setup({ + sort_by = ${"'" + cfg.sortBy + "'"}, + disable_netrw = ${boolToString cfg.disableNetRW}, + hijack_netrw = ${boolToString cfg.hijackNetRW}, + hijack_cursor = ${boolToString cfg.hijackCursor}, + open_on_tab = ${boolToString cfg.openTreeOnNewTab}, + sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd}, + update_focused_file = { + enable = ${boolToString cfg.updateFocusedFile.enable}, + update_cwd = ${boolToString cfg.updateFocusedFile.update_cwd}, + }, + + view = { + width = ${toString cfg.view.width}, + side = ${"'" + cfg.view.side + "'"}, + adaptive_size = ${boolToString cfg.view.adaptiveSize}, + hide_root_folder = ${boolToString cfg.view.hideRootFolder}, + }, + git = { + enable = ${boolToString cfg.git.enable}, + ignore = ${boolToString cfg.git.ignore}, + }, + + filesystem_watchers = { + enable = ${boolToString cfg.filesystemWatchers.enable}, + }, + + actions = { + open_file = { + quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, + resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, + window_picker = { + enable = ${boolToString cfg.actions.openFile.windowPicker.enable}, + chars = ${toString cfg.actions.openFile.windowPicker.chars}, + }, + }, + expand_all = { + exclude = { + ${builtins.concatStringsSep "\n" (builtins.map (s: "\"" + s + "\",") cfg.actions.expandAll.exclude)} + }, + } + }, + + renderer = { + highlight_git = ${boolToString cfg.renderer.higlightGit}, + highlight_opened_files = ${"'" + cfg.renderer.highlightOpenedFiles + "'"}, + indent_markers = { + enable = ${boolToString cfg.renderer.indentMarkers}, + }, + -- TODO: those two + add_trailing = ${boolToString cfg.renderer.trailingSlash}, + group_empty = ${boolToString cfg.renderer.groupEmptyFolders}, + }, + + system_open = { + cmd = ${"'" + cfg.systemOpenCmd + "'"}, + }, + diagnostics = { + enable = ${boolToString cfg.lspDiagnostics}, + }, + filters = { + dotfiles = ${boolToString cfg.hideDotFiles}, + custom = { + ${builtins.concatStringsSep "\n" (builtins.map (s: "\"" + s + "\",") cfg.hideFiles)} + }, + }, + }) + ''; + }; +} diff --git a/modules/filetree/nvimtree-lua/default.nix b/modules/filetree/nvimtree-lua/default.nix new file mode 100644 index 0000000..a041720 --- /dev/null +++ b/modules/filetree/nvimtree-lua/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./nvimtree-lua.nix + ]; +} diff --git a/modules/filetree/nvimtreelua.nix b/modules/filetree/nvimtree-lua/nvimtree-lua.nix similarity index 78% rename from modules/filetree/nvimtreelua.nix rename to modules/filetree/nvimtree-lua/nvimtree-lua.nix index 2aa0792..cf3ee4f 100644 --- a/modules/filetree/nvimtreelua.nix +++ b/modules/filetree/nvimtree-lua/nvimtree-lua.nix @@ -15,6 +15,12 @@ in { description = "Enable nvim-tree-lua"; }; + sortBy = mkOption { + default = "name"; + description = "Sort by name or extension"; + type = types.enum ["name" "extension" "modification_time" "case_sensitive"]; + }; + treeSide = mkOption { default = "left"; description = "Side the tree will appear on left or right"; @@ -132,7 +138,7 @@ in { }; hijackCursor = mkOption { - default = true; + default = false; description = "Hijack the cursor in the tree to put it at the start of the filename"; type = types.bool; }; @@ -211,6 +217,38 @@ in { description = "Quit the tree when opening a file"; type = types.bool; }; + windowPicker = { + enable = mkEnableOption "Window picker"; + + chars = mkOption { + default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + description = "A string of chars used as identifiers by the window picker"; + type = types.str; + }; + + /* + # FIXME: Can't get this to place the list items in a lua table + exclude = { + fileType = mkOption { + default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"]; + description = "File types to exclude from window picker"; + type = with types; listOf str; + }; + buftype = mkOption { + default = ["nofile" "terminal" "help"]; + description = "Buffer types to exclude from window picker"; + type = with types; listOf str; + }; + }; + */ + }; + }; + expandAll = { + exclude = mkOption { + default = []; + description = "Exclude files from expand all"; + type = with types; listOf str; + }; }; }; @@ -280,7 +318,6 @@ in { type = types.bool; }; }; - glyphs = { default = mkOption { default = ""; @@ -377,79 +414,4 @@ in { }; }; }; - - config = mkIf cfg.enable { - vim.startPlugins = ["nvim-tree-lua"]; - - vim.nnoremap = { - "" = ":NvimTreeToggle"; - "tr" = ":NvimTreeRefresh"; - "tg" = ":NvimTreeFindFile"; - "tf" = ":NvimTreeFocus"; - }; - - vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' - require'nvim-tree'.setup({ - disable_netrw = ${boolToString cfg.disableNetRW}, - hijack_netrw = ${boolToString cfg.hijackNetRW}, - hijack_cursor = ${boolToString cfg.hijackCursor}, - open_on_tab = ${boolToString cfg.openTreeOnNewTab}, - -- FIXME: Open on startup has been deprecated - -- needs an alternative, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup3 - -- open_on_setup = ${boolToString cfg.openOnSetup}, - -- open_on_setup_file = ${boolToString cfg.openOnSetup}, - sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd}, - update_focused_file = { - enable = ${boolToString cfg.updateFocusedFile.enable}, - update_cwd = ${boolToString cfg.updateFocusedFile.update_cwd}, - }, - - view = { - width = ${toString cfg.view.width}, - side = ${"'" + cfg.view.side + "'"}, - adaptive_size = ${boolToString cfg.view.adaptiveSize}, - hide_root_folder = ${boolToString cfg.view.hideRootFolder}, - }, - git = { - enable = ${boolToString cfg.git.enable}, - ignore = ${boolToString cfg.git.ignore}, - }, - - filesystem_watchers = { - enable = ${boolToString cfg.filesystemWatchers.enable}, - }, - - actions = { - open_file = { - quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, - resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, - }, - }, - - renderer = { - highlight_git = ${boolToString cfg.renderer.higlightGit}, - highlight_opened_files = ${"'" + cfg.renderer.highlightOpenedFiles + "'"}, - indent_markers = { - enable = ${boolToString cfg.renderer.indentMarkers}, - }, - -- TODO: those two - add_trailing = ${boolToString cfg.renderer.trailingSlash}, - group_empty = ${boolToString cfg.renderer.groupEmptyFolders}, - }, - - system_open = { - cmd = ${"'" + cfg.systemOpenCmd + "'"}, - }, - diagnostics = { - enable = ${boolToString cfg.lspDiagnostics}, - }, - filters = { - dotfiles = ${boolToString cfg.hideDotFiles}, - custom = { - ${builtins.concatStringsSep "\n" (builtins.map (s: "\"" + s + "\",") cfg.hideFiles)} - }, - }, - }) - ''; - }; } From 067b523897d1fe30300c9b51da691a5171ebad95 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:25:39 +0300 Subject: [PATCH 11/29] feat: apply new module format to lsp plugins --- modules/lsp/{lsp.nix => config.nix} | 0 modules/lsp/default.nix | 16 +++--- .../{lightbulb.nix => lightbulb/config.nix} | 6 --- modules/lsp/lightbulb/default.nix | 6 +++ modules/lsp/lightbulb/lightbulb.nix | 16 ++++++ .../config.nix} | 10 ++-- modules/lsp/lsp-signature/default.nix | 6 +++ modules/lsp/lsp-signature/lsp-signature.nix | 16 ++++++ modules/lsp/lspsaga/config.nix | 52 +++++++++++++++++++ modules/lsp/lspsaga/default.nix | 6 +++ modules/lsp/{ => lspsaga}/lspsaga.nix | 0 modules/lsp/module.nix | 16 ++++++ .../config.nix} | 6 --- modules/lsp/nvim-code-action-menu/default.nix | 6 +++ .../nvim-code-action-menu.nix | 16 ++++++ .../lsp/{trouble.nix => trouble/config.nix} | 6 --- modules/lsp/trouble/default.nix | 6 +++ modules/lsp/trouble/trouble.nix | 16 ++++++ 18 files changed, 175 insertions(+), 31 deletions(-) rename modules/lsp/{lsp.nix => config.nix} (100%) rename modules/lsp/{lightbulb.nix => lightbulb/config.nix} (78%) create mode 100644 modules/lsp/lightbulb/default.nix create mode 100644 modules/lsp/lightbulb/lightbulb.nix rename modules/lsp/{lsp-signature.nix => lsp-signature/config.nix} (66%) create mode 100644 modules/lsp/lsp-signature/default.nix create mode 100644 modules/lsp/lsp-signature/lsp-signature.nix create mode 100644 modules/lsp/lspsaga/config.nix create mode 100644 modules/lsp/lspsaga/default.nix rename modules/lsp/{ => lspsaga}/lspsaga.nix (100%) create mode 100644 modules/lsp/module.nix rename modules/lsp/{nvim-code-action-menu.nix => nvim-code-action-menu/config.nix} (71%) create mode 100644 modules/lsp/nvim-code-action-menu/default.nix create mode 100644 modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix rename modules/lsp/{trouble.nix => trouble/config.nix} (86%) create mode 100644 modules/lsp/trouble/default.nix create mode 100644 modules/lsp/trouble/trouble.nix diff --git a/modules/lsp/lsp.nix b/modules/lsp/config.nix similarity index 100% rename from modules/lsp/lsp.nix rename to modules/lsp/config.nix diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 00c751d..0caa22c 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -5,11 +5,15 @@ ... }: { imports = [ - ./lsp.nix - ./lspsaga.nix - ./nvim-code-action-menu.nix - ./trouble.nix - ./lsp-signature.nix - ./lightbulb.nix + # nvim lsp support + ./config.nix + ./module.nix + + # lsp plugins + ./lspsaga + ./nvim-code-action-menu + ./trouble + ./lsp-signature + ./lightbulb ]; } diff --git a/modules/lsp/lightbulb.nix b/modules/lsp/lightbulb/config.nix similarity index 78% rename from modules/lsp/lightbulb.nix rename to modules/lsp/lightbulb/config.nix index cbd7622..f8b628f 100644 --- a/modules/lsp/lightbulb.nix +++ b/modules/lsp/lightbulb/config.nix @@ -8,12 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - lightbulb = { - enable = mkEnableOption "lightbulb for code actions. Requires emoji font"; - }; - }; - config = mkIf (cfg.enable && cfg.lightbulb.enable) { vim.startPlugins = ["nvim-lightbulb"]; diff --git a/modules/lsp/lightbulb/default.nix b/modules/lsp/lightbulb/default.nix new file mode 100644 index 0000000..883944a --- /dev/null +++ b/modules/lsp/lightbulb/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lightbulb.nix + ./config.nix + ]; +} diff --git a/modules/lsp/lightbulb/lightbulb.nix b/modules/lsp/lightbulb/lightbulb.nix new file mode 100644 index 0000000..0caef2b --- /dev/null +++ b/modules/lsp/lightbulb/lightbulb.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + lightbulb = { + enable = mkEnableOption "lightbulb for code actions. Requires emoji font"; + }; + }; +} diff --git a/modules/lsp/lsp-signature.nix b/modules/lsp/lsp-signature/config.nix similarity index 66% rename from modules/lsp/lsp-signature.nix rename to modules/lsp/lsp-signature/config.nix index 1d77040..7296a2c 100644 --- a/modules/lsp/lsp-signature.nix +++ b/modules/lsp/lsp-signature/config.nix @@ -8,14 +8,10 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - lspSignature = { - enable = mkEnableOption "lsp signature viewer"; - }; - }; - config = mkIf (cfg.enable && cfg.lspSignature.enable) { - vim.startPlugins = ["lsp-signature"]; + vim.startPlugins = [ + "lsp-signature" + ]; vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere '' -- Enable lsp signature viewer diff --git a/modules/lsp/lsp-signature/default.nix b/modules/lsp/lsp-signature/default.nix new file mode 100644 index 0000000..0449a9e --- /dev/null +++ b/modules/lsp/lsp-signature/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lsp-signature.nix + ./config.nix + ]; +} diff --git a/modules/lsp/lsp-signature/lsp-signature.nix b/modules/lsp/lsp-signature/lsp-signature.nix new file mode 100644 index 0000000..c954454 --- /dev/null +++ b/modules/lsp/lsp-signature/lsp-signature.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + lspSignature = { + enable = mkEnableOption "lsp signature viewer"; + }; + }; +} diff --git a/modules/lsp/lspsaga/config.nix b/modules/lsp/lspsaga/config.nix new file mode 100644 index 0000000..db8ac6b --- /dev/null +++ b/modules/lsp/lspsaga/config.nix @@ -0,0 +1,52 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + config = mkIf (cfg.enable && cfg.lspsaga.enable) { + vim.startPlugins = ["lspsaga"]; + + vim.vnoremap = { + "ca" = ":lua require('lspsaga.codeaction').range_code_action()"; + }; + + vim.nnoremap = + { + "lf" = "lua require'lspsaga.provider'.lsp_finder()"; + "lh" = "lua require('lspsaga.hover').render_hover_doc()"; + "" = "lua require('lspsaga.action').smart_scroll_with_saga(1)"; + "" = "lua require('lspsaga.action').smart_scroll_with_saga(-1)"; + "lr" = "lua require'lspsaga.rename'.rename()"; + "ld" = "lua require'lspsaga.provider'.preview_definition()"; + "ll" = "lua require'lspsaga.diagnostic'.show_line_diagnostics()"; + "lc" = "lua require'lspsaga.diagnostic'.show_cursor_diagnostics()"; + "lp" = "lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()"; + "ln" = "lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()"; + } + // ( + if (!cfg.nvimCodeActionMenu.enable) + then { + "ca" = "lua require('lspsaga.codeaction').code_action()"; + } + else {} + ) + // ( + if (!cfg.lspSignature.enable) + then { + "ls" = "lua require('lspsaga.signaturehelp').signature_help()"; + } + else {} + ); + + vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere '' + -- Enable lspsaga + local saga = require 'lspsaga' + saga.init_lsp_saga() + ''; + }; +} diff --git a/modules/lsp/lspsaga/default.nix b/modules/lsp/lspsaga/default.nix new file mode 100644 index 0000000..29cf580 --- /dev/null +++ b/modules/lsp/lspsaga/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./lspsaga.nix + ./config.nix + ]; +} diff --git a/modules/lsp/lspsaga.nix b/modules/lsp/lspsaga/lspsaga.nix similarity index 100% rename from modules/lsp/lspsaga.nix rename to modules/lsp/lspsaga/lspsaga.nix diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix new file mode 100644 index 0000000..513ec53 --- /dev/null +++ b/modules/lsp/module.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + /* + ... + */ + }; +} diff --git a/modules/lsp/nvim-code-action-menu.nix b/modules/lsp/nvim-code-action-menu/config.nix similarity index 71% rename from modules/lsp/nvim-code-action-menu.nix rename to modules/lsp/nvim-code-action-menu/config.nix index ac8b8d6..e814af1 100644 --- a/modules/lsp/nvim-code-action-menu.nix +++ b/modules/lsp/nvim-code-action-menu/config.nix @@ -8,12 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - nvimCodeActionMenu = { - enable = mkEnableOption "nvim code action menu"; - }; - }; - config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) { vim.startPlugins = ["nvim-code-action-menu"]; diff --git a/modules/lsp/nvim-code-action-menu/default.nix b/modules/lsp/nvim-code-action-menu/default.nix new file mode 100644 index 0000000..665cf92 --- /dev/null +++ b/modules/lsp/nvim-code-action-menu/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./nvim-code-action-menu.nix + ./config.nix + ]; +} diff --git a/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix b/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix new file mode 100644 index 0000000..4b7a3be --- /dev/null +++ b/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + nvimCodeActionMenu = { + enable = mkEnableOption "nvim code action menu"; + }; + }; +} diff --git a/modules/lsp/trouble.nix b/modules/lsp/trouble/config.nix similarity index 86% rename from modules/lsp/trouble.nix rename to modules/lsp/trouble/config.nix index a96ce5d..d3efd30 100644 --- a/modules/lsp/trouble.nix +++ b/modules/lsp/trouble/config.nix @@ -8,12 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - trouble = { - enable = mkEnableOption "trouble diagnostics viewer"; - }; - }; - config = mkIf (cfg.enable && cfg.trouble.enable) { vim.startPlugins = ["trouble"]; diff --git a/modules/lsp/trouble/default.nix b/modules/lsp/trouble/default.nix new file mode 100644 index 0000000..3a5d2cb --- /dev/null +++ b/modules/lsp/trouble/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./trouble.nix + ./config.nix + ]; +} diff --git a/modules/lsp/trouble/trouble.nix b/modules/lsp/trouble/trouble.nix new file mode 100644 index 0000000..63334f0 --- /dev/null +++ b/modules/lsp/trouble/trouble.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp; +in { + options.vim.lsp = { + trouble = { + enable = mkEnableOption "trouble diagnostics viewer"; + }; + }; +} From 4434d9e05388fb62b80876bc6a5254495900c180 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:26:00 +0300 Subject: [PATCH 12/29] feat: apply new module format to markdown plugins --- modules/markdown/config.nix | 13 ++++++++++ modules/markdown/default.nix | 2 ++ modules/markdown/glow/config.nix | 16 ++++++++---- modules/markdown/glow/default.nix | 42 ++++--------------------------- modules/markdown/glow/glow.nix | 18 +++++++++++++ modules/markdown/module.nix | 20 +++++++++++++++ 6 files changed, 69 insertions(+), 42 deletions(-) create mode 100644 modules/markdown/config.nix create mode 100644 modules/markdown/glow/glow.nix create mode 100644 modules/markdown/module.nix diff --git a/modules/markdown/config.nix b/modules/markdown/config.nix new file mode 100644 index 0000000..ace4eaf --- /dev/null +++ b/modules/markdown/config.nix @@ -0,0 +1,13 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; { + config = { + vim.markdown = { + enable = mkDefault false; + }; + }; +} diff --git a/modules/markdown/default.nix b/modules/markdown/default.nix index 8b7e31e..2a0a1e5 100644 --- a/modules/markdown/default.nix +++ b/modules/markdown/default.nix @@ -6,5 +6,7 @@ }: { imports = [ ./glow + ./config.nix + ./module.nix ]; } diff --git a/modules/markdown/glow/config.nix b/modules/markdown/glow/config.nix index 72b0007..4ad906b 100644 --- a/modules/markdown/glow/config.nix +++ b/modules/markdown/glow/config.nix @@ -4,11 +4,17 @@ lib, ... }: -with lib; { - config = { - vim.markdown = { - enable = mkDefault false; - glow.enable = mkDefault false; +with lib; let + cfg = config.vim.markdown.glow; +in { + config = (mkIf cfg.enable) { + vim.startPlugins = ["glow-nvim"]; + vim.globals = { + "glow_binary_path" = "${pkgs.glow}/bin"; }; + + vim.configRC.glow = nvim.dag.entryAnywhere '' + autocmd FileType markdown noremap p :Glow + ''; }; } diff --git a/modules/markdown/glow/default.nix b/modules/markdown/glow/default.nix index e658446..9b128a3 100644 --- a/modules/markdown/glow/default.nix +++ b/modules/markdown/glow/default.nix @@ -1,38 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.markdown; -in { - options.vim.markdown = { - enable = mkEnableOption "markdown tools and plugins"; - - glow.enable = mkOption { - type = types.bool; - default = true; - description = "Enable markdown preview in neovim with glow"; - }; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - ( - if cfg.glow.enable - then "glow-nvim" - else null - ) - ]; - - vim.globals = mkIf (cfg.glow.enable) { - "glow_binary_path" = "${pkgs.glow}/bin"; - }; - - vim.configRC.glow = mkIf (cfg.glow.enable) (nvim.dag.entryAnywhere '' - autocmd FileType markdown noremap p :Glow - ''); - }; +_: { + imports = [ + ./glow.nix + ./config.nix + ]; } diff --git a/modules/markdown/glow/glow.nix b/modules/markdown/glow/glow.nix new file mode 100644 index 0000000..be1c0c3 --- /dev/null +++ b/modules/markdown/glow/glow.nix @@ -0,0 +1,18 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.markdown; +in { + options.vim.markdown = { + glow.enable = mkOption { + type = types.bool; + default = false; + description = "Enable markdown preview in neovim with glow"; + }; + }; +} diff --git a/modules/markdown/module.nix b/modules/markdown/module.nix new file mode 100644 index 0000000..4292173 --- /dev/null +++ b/modules/markdown/module.nix @@ -0,0 +1,20 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.markdown; +in { + options.vim.markdown = { + enable = mkEnableOption "markdown tools and plugins"; + }; + + config = mkIf (cfg.enable) { + /* + ... + */ + }; +} From d93b005f2c6d4c22e9c4a350005389a42192de34 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:26:16 +0300 Subject: [PATCH 13/29] feat: apply new module format to note-taking plugins --- modules/notes/mind-nvim/config.nix | 26 ++++++++++++ modules/notes/mind-nvim/default.nix | 34 +++------------ modules/notes/mind-nvim/mind-nvim.nix | 14 +++++++ modules/notes/obsidian/config.nix | 32 ++++++++++++++ modules/notes/obsidian/default.nix | 55 +++--------------------- modules/notes/obsidian/obsidian.nix | 30 ++++++++++++++ modules/notes/orgmode/config.nix | 40 ++++++++++++++++++ modules/notes/orgmode/default.nix | 60 +++------------------------ modules/notes/orgmode/orgmode.nix | 24 +++++++++++ 9 files changed, 181 insertions(+), 134 deletions(-) create mode 100644 modules/notes/mind-nvim/config.nix create mode 100644 modules/notes/mind-nvim/mind-nvim.nix create mode 100644 modules/notes/obsidian/config.nix create mode 100644 modules/notes/obsidian/obsidian.nix create mode 100644 modules/notes/orgmode/config.nix create mode 100644 modules/notes/orgmode/orgmode.nix diff --git a/modules/notes/mind-nvim/config.nix b/modules/notes/mind-nvim/config.nix new file mode 100644 index 0000000..2baf0ee --- /dev/null +++ b/modules/notes/mind-nvim/config.nix @@ -0,0 +1,26 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.mind-nvim; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "mind-nvim" + ]; + + vim.nnoremap = { + "om" = ":MindOpenMain"; + "op" = ":MindOpenProject"; + "oc" = ":MindClose"; + }; + + vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere '' + require'mind'.setup() + ''; + }; +} diff --git a/modules/notes/mind-nvim/default.nix b/modules/notes/mind-nvim/default.nix index 4b0211f..e136b9d 100644 --- a/modules/notes/mind-nvim/default.nix +++ b/modules/notes/mind-nvim/default.nix @@ -1,30 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.notes.mind-nvim; -in { - options.vim.notes.mind-nvim = { - enable = mkEnableOption "The power of trees at your fingertips. "; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "mind-nvim" - ]; - - vim.nnoremap = { - "om" = ":MindOpenMain"; - "op" = ":MindOpenProject"; - "oc" = ":MindClose"; - }; - - vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere '' - require'mind'.setup() - ''; - }; +_: { + imports = [ + ./mind-nvim.nix + ./config.nix + ]; } diff --git a/modules/notes/mind-nvim/mind-nvim.nix b/modules/notes/mind-nvim/mind-nvim.nix new file mode 100644 index 0000000..14e81c5 --- /dev/null +++ b/modules/notes/mind-nvim/mind-nvim.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.mind-nvim; +in { + options.vim.notes.mind-nvim = { + enable = mkEnableOption "The power of trees at your fingertips. "; + }; +} diff --git a/modules/notes/obsidian/config.nix b/modules/notes/obsidian/config.nix new file mode 100644 index 0000000..279a8b1 --- /dev/null +++ b/modules/notes/obsidian/config.nix @@ -0,0 +1,32 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.obsidian; + auto = config.vim.autocomplete; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "obsidian-nvim" + "vim-markdown" + "tabular" + ]; + + vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere '' + require("obsidian").setup({ + dir = "${cfg.dir}", + completion = { + nvim_cmp = ${ + if (auto.type == "nvim-cmp") + then "true" + else "false" + } + } + }) + ''; + }; +} diff --git a/modules/notes/obsidian/default.nix b/modules/notes/obsidian/default.nix index f52ac02..d73bfc2 100644 --- a/modules/notes/obsidian/default.nix +++ b/modules/notes/obsidian/default.nix @@ -1,51 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.notes.obsidian; - auto = config.vim.autocomplete; -in { - options.vim.notes = { - obsidian = { - enable = mkEnableOption "Complementary neovim plugins for Obsidian editor"; - dir = mkOption { - type = types.str; - default = "~/my-vault"; - description = "Obsidian vault directory"; - }; - - completion = { - nvim_cmp = mkOption { - # if using nvim-cmp, otherwise set to false - type = types.bool; - description = "If using nvim-cmp, otherwise set to false"; - }; - }; - }; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "obsidian-nvim" - "vim-markdown" - "tabular" - ]; - - vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere '' - require("obsidian").setup({ - dir = "${cfg.dir}", - completion = { - nvim_cmp = ${ - if (auto.type == "nvim-cmp") - then "true" - else "false" - } - } - }) - ''; - }; +_: { + imports = [ + ./obsidian.nix + ./config.nix + ]; } diff --git a/modules/notes/obsidian/obsidian.nix b/modules/notes/obsidian/obsidian.nix new file mode 100644 index 0000000..186b5d3 --- /dev/null +++ b/modules/notes/obsidian/obsidian.nix @@ -0,0 +1,30 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.obsidian; + auto = config.vim.autocomplete; +in { + options.vim.notes = { + obsidian = { + enable = mkEnableOption "Complementary neovim plugins for Obsidian editor"; + dir = mkOption { + type = types.str; + default = "~/my-vault"; + description = "Obsidian vault directory"; + }; + + completion = { + nvim_cmp = mkOption { + # if using nvim-cmp, otherwise set to false + type = types.bool; + description = "If using nvim-cmp, otherwise set to false"; + }; + }; + }; + }; +} diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix new file mode 100644 index 0000000..f623db3 --- /dev/null +++ b/modules/notes/orgmode/config.nix @@ -0,0 +1,40 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.orgmode; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "orgmode-nvim" + ]; + + vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere '' + -- Load custom treesitter grammar for org filetype + require('orgmode').setup_ts_grammar() + + -- Treesitter configuration + require('nvim-treesitter.configs').setup { + + -- If TS highlights are not enabled at all, or disabled via `disable` prop, + -- highlighting will fallback to default Vim syntax highlighting + highlight = { + enable = true, + -- Required for spellcheck, some LaTex highlights and + -- code block highlights that do not have ts grammar + additional_vim_regex_highlighting = {'org'}, + }, + ensure_installed = {'org'}, -- Or run :TSUpdate org + } + + require('orgmode').setup({ + org_agenda_files = ${cfg.orgAgendaFiles}, + org_default_notes_file = '${cfg.orgDefaultNotesFile}', + }) + ''; + }; +} diff --git a/modules/notes/orgmode/default.nix b/modules/notes/orgmode/default.nix index f45b2ab..299c754 100644 --- a/modules/notes/orgmode/default.nix +++ b/modules/notes/orgmode/default.nix @@ -1,56 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.notes.orgmode; -in { - options.vim.notes = { - orgmode = { - enable = mkEnableOption "Neovim plugin for Emac Orgmode. Get the best of both worlds."; - orgAgendaFiles = mkOption { - type = types.str; - default = "{'~/Dropbox/org/*', '~/my-orgs/**/*'}"; - description = "List of org files to be used as agenda files."; - }; - orgDefaultNotesFile = mkOption { - type = types.str; - default = "~/Dropbox/org/refile.org"; - description = "Default org file to be used for notes."; - }; - }; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "orgmode-nvim" - ]; - - vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere '' - -- Load custom treesitter grammar for org filetype - require('orgmode').setup_ts_grammar() - - -- Treesitter configuration - require('nvim-treesitter.configs').setup { - - -- If TS highlights are not enabled at all, or disabled via `disable` prop, - -- highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = {'org'}, - }, - ensure_installed = {'org'}, -- Or run :TSUpdate org - } - - require('orgmode').setup({ - org_agenda_files = ${cfg.orgAgendaFiles}, - org_default_notes_file = '${cfg.orgDefaultNotesFile}', - }) - ''; - }; +_: { + imports = [ + ./orgmode.nix + ./config.nix + ]; } diff --git a/modules/notes/orgmode/orgmode.nix b/modules/notes/orgmode/orgmode.nix new file mode 100644 index 0000000..c3d799a --- /dev/null +++ b/modules/notes/orgmode/orgmode.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notes.orgmode; +in { + options.vim.notes.orgmode = { + enable = mkEnableOption "Neovim plugin for Emac Orgmode. Get the best of both worlds."; + orgAgendaFiles = mkOption { + type = types.str; + default = "{'~/Dropbox/org/*', '~/my-orgs/**/*'}"; + description = "List of org files to be used as agenda files."; + }; + orgDefaultNotesFile = mkOption { + type = types.str; + default = "~/Dropbox/org/refile.org"; + description = "Default org file to be used for notes."; + }; + }; +} From 4d1e7bcbe681bf2983e8733dff748bdbb016166d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:26:31 +0300 Subject: [PATCH 14/29] feat: apply new module format to notification plugins --- modules/notifications/default.nix | 2 +- modules/notifications/nvim-notify.nix | 34 -------------- modules/notifications/nvim-notify/config.nix | 31 +++++++++++++ modules/notifications/nvim-notify/default.nix | 6 +++ .../notifications/nvim-notify/nvim-notify.nix | 45 +++++++++++++++++++ 5 files changed, 83 insertions(+), 35 deletions(-) delete mode 100644 modules/notifications/nvim-notify.nix create mode 100644 modules/notifications/nvim-notify/config.nix create mode 100644 modules/notifications/nvim-notify/default.nix create mode 100644 modules/notifications/nvim-notify/nvim-notify.nix diff --git a/modules/notifications/default.nix b/modules/notifications/default.nix index e978f42..aa5a73b 100644 --- a/modules/notifications/default.nix +++ b/modules/notifications/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./nvim-notify.nix + ./nvim-notify ]; } diff --git a/modules/notifications/nvim-notify.nix b/modules/notifications/nvim-notify.nix deleted file mode 100644 index 777d507..0000000 --- a/modules/notifications/nvim-notify.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.notify.nvim-notify; -in { - options.vim.notify.nvim-notify = { - enable = mkEnableOption "Enable nvim-notify plugin"; - }; - - config = mkIf cfg.enable { - vim.startPlugins = ["nvim-notify"]; - - vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere '' - require('notify').setup { - stages = 'fade_in_slide_out', - timeout = 1000, - background_colour = '#000000', - position = 'top_right', - icons = { - ERROR = '', - WARN = '', - INFO = '', - DEBUG = '', - TRACE = '', - }, - } - ''; - }; -} diff --git a/modules/notifications/nvim-notify/config.nix b/modules/notifications/nvim-notify/config.nix new file mode 100644 index 0000000..58fb303 --- /dev/null +++ b/modules/notifications/nvim-notify/config.nix @@ -0,0 +1,31 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notify.nvim-notify; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["nvim-notify"]; + + vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere '' + require('notify').setup { + stages = "${cfg.stages}", + timeout = ${toString cfg.timeout}, + background_colour = "${cfg.background_colour}", + position = "${cfg.position}", + icons = { + ERROR = "${cfg.icons.ERROR}", + WARN = "${cfg.icons.WARN}", + INFO = "${cfg.icons.INFO}", + DEBUG = "${cfg.icons.DEBUG}", + TRACE = "${cfg.icons.TRACE}", + }, + + } + ''; + }; +} diff --git a/modules/notifications/nvim-notify/default.nix b/modules/notifications/nvim-notify/default.nix new file mode 100644 index 0000000..0d4c39d --- /dev/null +++ b/modules/notifications/nvim-notify/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./nvim-notify.nix + ]; +} diff --git a/modules/notifications/nvim-notify/nvim-notify.nix b/modules/notifications/nvim-notify/nvim-notify.nix new file mode 100644 index 0000000..8aab984 --- /dev/null +++ b/modules/notifications/nvim-notify/nvim-notify.nix @@ -0,0 +1,45 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notify.nvim-notify; +in { + options.vim.notify.nvim-notify = { + enable = mkEnableOption "Enable nvim-notify plugin"; + stages = mkOption { + type = types.enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; + default = "fade_in_slide_out"; + description = "The stages of the notification"; + }; + timeout = mkOption { + type = types.int; + default = 1000; + description = "The timeout of the notification"; + }; + background_colour = mkOption { + type = types.str; + default = "#000000"; + description = "The background colour of the notification"; + }; + position = mkOption { + type = types.enum ["top_left" "top_right" "bottom_left" "bottom_right"]; + default = "top_right"; + description = "The position of the notification"; + }; + icons = mkOption { + type = types.attrsOf types.str; + default = { + ERROR = ""; + WARN = ""; + INFO = ""; + DEBUG = ""; + TRACE = ""; + }; + description = "The icons of the notification"; + }; + }; +} From 97899667db987c37b658c7ca21be9a1580d40a72 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:26:47 +0300 Subject: [PATCH 15/29] feat: apply new module format to rich-presence plugins --- modules/rich-presence/default.nix | 5 +++ .../rich-presence/presence-nvim/config.nix | 41 +++++++++++++++++++ .../presence-nvim}/default.nix | 1 + .../presence-nvim}/presence-nvim.nix | 31 -------------- 4 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 modules/rich-presence/default.nix create mode 100644 modules/rich-presence/presence-nvim/config.nix rename modules/{presence => rich-presence/presence-nvim}/default.nix (74%) rename modules/{presence => rich-presence/presence-nvim}/presence-nvim.nix (63%) diff --git a/modules/rich-presence/default.nix b/modules/rich-presence/default.nix new file mode 100644 index 0000000..ef16a42 --- /dev/null +++ b/modules/rich-presence/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./presence-nvim + ]; +} diff --git a/modules/rich-presence/presence-nvim/config.nix b/modules/rich-presence/presence-nvim/config.nix new file mode 100644 index 0000000..351074b --- /dev/null +++ b/modules/rich-presence/presence-nvim/config.nix @@ -0,0 +1,41 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.presence.presence-nvim; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["presence-nvim"]; + + vim.luaConfigRC.presence-nvim = nvim.dag.entryAnywhere '' + -- Description of each option can be found in https://github.com/andweeb/presence.nvim + require("presence").setup({ + -- General options + auto_update = true, + neovim_image_text = "${cfg.image_text}", + main_image = "${cfg.main_image}", + client_id = "${cfg.client_id}", + log_level = nil, + debounce_timeout = 10, + enable_line_number = "${boolToString cfg.enable_line_number}", + blacklist = {}, + buttons = "${boolToString cfg.buttons}", + file_assets = {}, + show_time = "${boolToString cfg.show_time}", + + -- Rich Presence text options + editing_text = "${cfg.rich_presence.editing_text}", + file_explorer_text = "${cfg.rich_presence.file_explorer_text}", + git_commit_text = "${cfg.rich_presence.git_commit_text}", + plugin_manager_text = "${cfg.rich_presence.plugin_manager_text}", + reading_text = "${cfg.rich_presence.reading_text}", + workspace_text = "${cfg.rich_presence.workspace_text}", + line_number_text = "${cfg.rich_presence.line_number_text}", + }) + ''; + }; +} diff --git a/modules/presence/default.nix b/modules/rich-presence/presence-nvim/default.nix similarity index 74% rename from modules/presence/default.nix rename to modules/rich-presence/presence-nvim/default.nix index bc4e28b..e263c3a 100644 --- a/modules/presence/default.nix +++ b/modules/rich-presence/presence-nvim/default.nix @@ -1,5 +1,6 @@ _: { imports = [ + ./config.nix ./presence-nvim.nix ]; } diff --git a/modules/presence/presence-nvim.nix b/modules/rich-presence/presence-nvim/presence-nvim.nix similarity index 63% rename from modules/presence/presence-nvim.nix rename to modules/rich-presence/presence-nvim/presence-nvim.nix index 7d27733..c3f80ff 100644 --- a/modules/presence/presence-nvim.nix +++ b/modules/rich-presence/presence-nvim/presence-nvim.nix @@ -96,35 +96,4 @@ in { }; }; }; - - config = mkIf cfg.enable { - vim.startPlugins = ["presence-nvim"]; - - vim.luaConfigRC.presence-nvim = nvim.dag.entryAnywhere '' - -- Description of each option can be found in https://github.com/andweeb/presence.nvim - require("presence").setup({ - -- General options - auto_update = true, - neovim_image_text = "${cfg.image_text}", - main_image = "${cfg.main_image}", - client_id = "${cfg.client_id}", - log_level = nil, - debounce_timeout = 10, - enable_line_number = "${boolToString cfg.enable_line_number}", - blacklist = {}, - buttons = "${boolToString cfg.buttons}", - file_assets = {}, - show_time = "${boolToString cfg.show_time}", - - -- Rich Presence text options - editing_text = "${cfg.rich_presence.editing_text}", - file_explorer_text = "${cfg.rich_presence.file_explorer_text}", - git_commit_text = "${cfg.rich_presence.git_commit_text}", - plugin_manager_text = "${cfg.rich_presence.plugin_manager_text}", - reading_text = "${cfg.rich_presence.reading_text}", - workspace_text = "${cfg.rich_presence.workspace_text}", - line_number_text = "${cfg.rich_presence.line_number_text}", - }) - ''; - }; } From d5082e5ef24a97cd3245389e750d13e8e82c46aa Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:28:06 +0300 Subject: [PATCH 16/29] feat: apply new module format to snippet plugins --- modules/snippets/default.nix | 9 ++------- modules/snippets/vsnip/config.nix | 14 ++++++++++++++ modules/snippets/vsnip/default.nix | 5 +++++ modules/snippets/{ => vsnip}/vsnip.nix | 4 ---- 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 modules/snippets/vsnip/config.nix create mode 100644 modules/snippets/vsnip/default.nix rename modules/snippets/{ => vsnip}/vsnip.nix (72%) diff --git a/modules/snippets/default.nix b/modules/snippets/default.nix index dd88e3c..cde3f7c 100644 --- a/modules/snippets/default.nix +++ b/modules/snippets/default.nix @@ -1,10 +1,5 @@ -{ - pkgs, - lib, - config, - ... -}: { +_: { imports = [ - ./vsnip.nix + ./vsnip ]; } diff --git a/modules/snippets/vsnip/config.nix b/modules/snippets/vsnip/config.nix new file mode 100644 index 0000000..b175328 --- /dev/null +++ b/modules/snippets/vsnip/config.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.snippets.vsnip; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["vim-vsnip"]; + }; +} diff --git a/modules/snippets/vsnip/default.nix b/modules/snippets/vsnip/default.nix new file mode 100644 index 0000000..fee36eb --- /dev/null +++ b/modules/snippets/vsnip/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./vsnip.nix + ]; +} diff --git a/modules/snippets/vsnip.nix b/modules/snippets/vsnip/vsnip.nix similarity index 72% rename from modules/snippets/vsnip.nix rename to modules/snippets/vsnip/vsnip.nix index 671671c..1049651 100644 --- a/modules/snippets/vsnip.nix +++ b/modules/snippets/vsnip/vsnip.nix @@ -11,8 +11,4 @@ in { options.vim.snippets.vsnip = { enable = mkEnableOption "Enable vim-vsnip"; }; - - config = mkIf cfg.enable { - vim.startPlugins = ["vim-vsnip"]; - }; } From 211344d65cd8c45c9b44d6c925949ffa48d4852b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:28:18 +0300 Subject: [PATCH 17/29] feat: apply new module format to tabline plugins --- modules/tabline/default.nix | 9 ++------- .../config.nix} | 4 ---- modules/tabline/nvim-bufferline/default.nix | 6 ++++++ .../tabline/nvim-bufferline/nvim-bufferline.nix | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 11 deletions(-) rename modules/tabline/{nvim-bufferline.nix => nvim-bufferline/config.nix} (97%) create mode 100644 modules/tabline/nvim-bufferline/default.nix create mode 100644 modules/tabline/nvim-bufferline/nvim-bufferline.nix diff --git a/modules/tabline/default.nix b/modules/tabline/default.nix index 4d16dfb..539302e 100644 --- a/modules/tabline/default.nix +++ b/modules/tabline/default.nix @@ -1,10 +1,5 @@ -{ - pkgs, - lib, - config, - ... -}: { +_: { imports = [ - ./nvim-bufferline.nix + ./nvim-bufferline ]; } diff --git a/modules/tabline/nvim-bufferline.nix b/modules/tabline/nvim-bufferline/config.nix similarity index 97% rename from modules/tabline/nvim-bufferline.nix rename to modules/tabline/nvim-bufferline/config.nix index fca433f..0d132c0 100644 --- a/modules/tabline/nvim-bufferline.nix +++ b/modules/tabline/nvim-bufferline/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.tabline.nvimBufferline; in { - options.vim.tabline.nvimBufferline = { - enable = mkEnableOption "nvim-bufferline-lua"; - }; - config = mkIf cfg.enable ( let mouse = { diff --git a/modules/tabline/nvim-bufferline/default.nix b/modules/tabline/nvim-bufferline/default.nix new file mode 100644 index 0000000..8fe4868 --- /dev/null +++ b/modules/tabline/nvim-bufferline/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./nvim-bufferline.nix + ./config.nix + ]; +} diff --git a/modules/tabline/nvim-bufferline/nvim-bufferline.nix b/modules/tabline/nvim-bufferline/nvim-bufferline.nix new file mode 100644 index 0000000..e9d897b --- /dev/null +++ b/modules/tabline/nvim-bufferline/nvim-bufferline.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.tabline.nvimBufferline; +in { + options.vim.tabline.nvimBufferline = { + enable = mkEnableOption "nvim-bufferline-lua"; + }; +} From 848fc5f57cddf631f5f8825e4331321fdf12dbdb Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:28:28 +0300 Subject: [PATCH 18/29] feat: apply new module format to UI plugins --- modules/ui/default.nix | 2 +- modules/ui/{noice.nix => noice/config.nix} | 4 ---- modules/ui/noice/default.nix | 6 ++++++ modules/ui/noice/noice.nix | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) rename modules/ui/{noice.nix => noice/config.nix} (96%) create mode 100644 modules/ui/noice/default.nix create mode 100644 modules/ui/noice/noice.nix diff --git a/modules/ui/default.nix b/modules/ui/default.nix index 26bc186..8f72316 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./noice.nix + ./noice ]; } diff --git a/modules/ui/noice.nix b/modules/ui/noice/config.nix similarity index 96% rename from modules/ui/noice.nix rename to modules/ui/noice/config.nix index 394d0e4..9a57137 100644 --- a/modules/ui/noice.nix +++ b/modules/ui/noice/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.ui.noice; in { - options.vim.ui.noice = { - enable = mkEnableOption "noice-nvim"; - }; - config = mkIf cfg.enable { vim.startPlugins = [ "noice-nvim" diff --git a/modules/ui/noice/default.nix b/modules/ui/noice/default.nix new file mode 100644 index 0000000..e808738 --- /dev/null +++ b/modules/ui/noice/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./noice.nix + ./config.nix + ]; +} diff --git a/modules/ui/noice/noice.nix b/modules/ui/noice/noice.nix new file mode 100644 index 0000000..a88f8ed --- /dev/null +++ b/modules/ui/noice/noice.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.ui.noice; +in { + options.vim.ui.noice = { + enable = mkEnableOption "noice-nvim"; + }; +} From cbf1490308bca91b9f8348cfda4785d9be365a55 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:28:37 +0300 Subject: [PATCH 19/29] feat: apply new module format to terminal plugins --- modules/terminal/default.nix | 2 +- .../{toggleterm.nix => toggleterm/config.nix} | 14 ----------- modules/terminal/toggleterm/default.nix | 6 +++++ modules/terminal/toggleterm/toggleterm.nix | 24 +++++++++++++++++++ 4 files changed, 31 insertions(+), 15 deletions(-) rename modules/terminal/{toggleterm.nix => toggleterm/config.nix} (68%) create mode 100644 modules/terminal/toggleterm/default.nix create mode 100644 modules/terminal/toggleterm/toggleterm.nix diff --git a/modules/terminal/default.nix b/modules/terminal/default.nix index 228f3ff..c8bbc22 100644 --- a/modules/terminal/default.nix +++ b/modules/terminal/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./toggleterm.nix + ./toggleterm ]; } diff --git a/modules/terminal/toggleterm.nix b/modules/terminal/toggleterm/config.nix similarity index 68% rename from modules/terminal/toggleterm.nix rename to modules/terminal/toggleterm/config.nix index 7c7f5b5..89ed51c 100644 --- a/modules/terminal/toggleterm.nix +++ b/modules/terminal/toggleterm/config.nix @@ -8,20 +8,6 @@ with lib; with builtins; let cfg = config.vim.terminal.toggleterm; in { - options.vim.terminal.toggleterm = { - enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command"; - direction = mkOption { - type = types.enum ["horizontal" "vertical" "tab" "float"]; - default = "float"; - description = "Direction of the terminal"; - }; - enable_winbar = mkOption { - type = types.bool; - default = false; - description = "Enable winbar"; - }; - }; - config = mkIf cfg.enable { vim.startPlugins = [ "toggleterm-nvim" diff --git a/modules/terminal/toggleterm/default.nix b/modules/terminal/toggleterm/default.nix new file mode 100644 index 0000000..a540f3f --- /dev/null +++ b/modules/terminal/toggleterm/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./toggleterm.nix + ./config.nix + ]; +} diff --git a/modules/terminal/toggleterm/toggleterm.nix b/modules/terminal/toggleterm/toggleterm.nix new file mode 100644 index 0000000..3383780 --- /dev/null +++ b/modules/terminal/toggleterm/toggleterm.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.terminal.toggleterm; +in { + options.vim.terminal.toggleterm = { + enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command"; + direction = mkOption { + type = types.enum ["horizontal" "vertical" "tab" "float"]; + default = "horizontal"; + description = "Direction of the terminal"; + }; + enable_winbar = mkOption { + type = types.bool; + default = false; + description = "Enable winbar"; + }; + }; +} From f081bb916f6a3900128167daba8eb02d6a89a440 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:28:48 +0300 Subject: [PATCH 20/29] feat: apply new module format to session plugins --- modules/session/default.nix | 2 +- .../config.nix} | 4 ---- modules/session/nvim-session-manager/default.nix | 6 ++++++ .../nvim-session-manager/nvim-session-manager.nix | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) rename modules/session/{nvim-session-manager.nix => nvim-session-manager/config.nix} (74%) create mode 100644 modules/session/nvim-session-manager/default.nix create mode 100644 modules/session/nvim-session-manager/nvim-session-manager.nix diff --git a/modules/session/default.nix b/modules/session/default.nix index 3a2da67..b984f72 100644 --- a/modules/session/default.nix +++ b/modules/session/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./nvim-session-manager.nix + ./nvim-session-manager ]; } diff --git a/modules/session/nvim-session-manager.nix b/modules/session/nvim-session-manager/config.nix similarity index 74% rename from modules/session/nvim-session-manager.nix rename to modules/session/nvim-session-manager/config.nix index 29dd21d..4319b6c 100644 --- a/modules/session/nvim-session-manager.nix +++ b/modules/session/nvim-session-manager/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.session.nvim-session-manager; in { - options.vim.session.nvim-session-manager = { - enable = mkEnableOption "Enable nvim-session-manager"; - }; - config = mkIf cfg.enable { vim.startPlugins = ["nvim-session-manager"]; diff --git a/modules/session/nvim-session-manager/default.nix b/modules/session/nvim-session-manager/default.nix new file mode 100644 index 0000000..607c453 --- /dev/null +++ b/modules/session/nvim-session-manager/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./nvim-session-manager.nix + ./config.nix + ]; +} diff --git a/modules/session/nvim-session-manager/nvim-session-manager.nix b/modules/session/nvim-session-manager/nvim-session-manager.nix new file mode 100644 index 0000000..af7ca32 --- /dev/null +++ b/modules/session/nvim-session-manager/nvim-session-manager.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.session.nvim-session-manager; +in { + options.vim.session.nvim-session-manager = { + enable = mkEnableOption "Enable nvim-session-manager"; + }; +} From 7149c92d1e2b14840f4697dec8c53c1bf5c6785c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:29:01 +0300 Subject: [PATCH 21/29] feat: apply new module format to minimap plugins --- modules/minimap/codewindow/codewindow.nix | 14 ++++++++++++++ .../{codewindow.nix => codewindow/config.nix} | 4 ---- modules/minimap/codewindow/default.nix | 6 ++++++ modules/minimap/default.nix | 4 ++-- .../{minimap-vim.nix => minimap-vim/config.nix} | 4 ---- modules/minimap/minimap-vim/default.nix | 6 ++++++ modules/minimap/minimap-vim/minimap-vim.nix | 14 ++++++++++++++ 7 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 modules/minimap/codewindow/codewindow.nix rename modules/minimap/{codewindow.nix => codewindow/config.nix} (81%) create mode 100644 modules/minimap/codewindow/default.nix rename modules/minimap/{minimap-vim.nix => minimap-vim/config.nix} (68%) create mode 100644 modules/minimap/minimap-vim/default.nix create mode 100644 modules/minimap/minimap-vim/minimap-vim.nix diff --git a/modules/minimap/codewindow/codewindow.nix b/modules/minimap/codewindow/codewindow.nix new file mode 100644 index 0000000..629a478 --- /dev/null +++ b/modules/minimap/codewindow/codewindow.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.minimap.codewindow; +in { + options.vim.minimap.codewindow = { + enable = mkEnableOption "Enable minimap-vim plugin"; + }; +} diff --git a/modules/minimap/codewindow.nix b/modules/minimap/codewindow/config.nix similarity index 81% rename from modules/minimap/codewindow.nix rename to modules/minimap/codewindow/config.nix index 099bc6d..c3f7dd5 100644 --- a/modules/minimap/codewindow.nix +++ b/modules/minimap/codewindow/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.minimap.codewindow; in { - options.vim.minimap.codewindow = { - enable = mkEnableOption "Enable minimap-vim plugin"; - }; - config = mkIf cfg.enable { vim.startPlugins = [ "codewindow-nvim" diff --git a/modules/minimap/codewindow/default.nix b/modules/minimap/codewindow/default.nix new file mode 100644 index 0000000..f3f8a9a --- /dev/null +++ b/modules/minimap/codewindow/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./codewindow.nix + ./config.nix + ]; +} diff --git a/modules/minimap/default.nix b/modules/minimap/default.nix index 0007404..5222d6d 100644 --- a/modules/minimap/default.nix +++ b/modules/minimap/default.nix @@ -5,7 +5,7 @@ ... }: { imports = [ - ./minimap-vim.nix - ./codewindow.nix + ./minimap-vim + ./codewindow ]; } diff --git a/modules/minimap/minimap-vim.nix b/modules/minimap/minimap-vim/config.nix similarity index 68% rename from modules/minimap/minimap-vim.nix rename to modules/minimap/minimap-vim/config.nix index f2f9609..15f1761 100644 --- a/modules/minimap/minimap-vim.nix +++ b/modules/minimap/minimap-vim/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.minimap.minimap-vim; in { - options.vim.minimap.minimap-vim = { - enable = mkEnableOption "Enable minimap-vim plugin"; - }; - config = mkIf cfg.enable { vim.startPlugins = [ pkgs.code-minimap diff --git a/modules/minimap/minimap-vim/default.nix b/modules/minimap/minimap-vim/default.nix new file mode 100644 index 0000000..889184e --- /dev/null +++ b/modules/minimap/minimap-vim/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./minimap-vim.nix + ./config.nix + ]; +} diff --git a/modules/minimap/minimap-vim/minimap-vim.nix b/modules/minimap/minimap-vim/minimap-vim.nix new file mode 100644 index 0000000..54fea92 --- /dev/null +++ b/modules/minimap/minimap-vim/minimap-vim.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.minimap.minimap-vim; +in { + options.vim.minimap.minimap-vim = { + enable = mkEnableOption "Enable minimap-vim plugin"; + }; +} From 88ce2926c57e7cf17447593056e1e29916dde2f7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:29:46 +0300 Subject: [PATCH 22/29] feat: rename presence -> rich-presence --- modules/modules.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/modules.nix b/modules/modules.nix index da02dcf..107291c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -23,7 +23,7 @@ ./dashboard ./notifications ./utility - ./presence + ./rich-presence ./notes ./terminal ./ui From 940dfcdef9d454de9f67cf8c7f78686a7ea512c5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:30:12 +0300 Subject: [PATCH 23/29] feat: add fidget-nvim to flake inputs --- flake.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flake.nix b/flake.nix index 36a224f..778509b 100644 --- a/flake.nix +++ b/flake.nix @@ -289,6 +289,11 @@ flake = false; }; + fidget-nvim = { + url = "github:j-hui/fidget.nvim"; + flake = false; + }; + # Markdown glow-nvim = { url = "github:ellisonleao/glow.nvim"; From 729276c4c567e3116f83996f5a34adacb2d38ebb Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 10:13:56 +0300 Subject: [PATCH 24/29] feat: apply new module format to utility plugins new file: modules/utility/binds/cheatsheet/cheatsheet.nix new file: modules/utility/binds/cheatsheet/config.nix modified: modules/utility/binds/cheatsheet/default.nix modified: modules/utility/binds/default.nix new file: modules/utility/binds/which-key/config.nix modified: modules/utility/binds/which-key/default.nix new file: modules/utility/binds/which-key/which-key.nix renamed: modules/utility/colorizer.nix -> modules/utility/colorizer/colorizer.nix new file: modules/utility/colorizer/config.nix new file: modules/utility/colorizer/default.nix modified: modules/utility/default.nix modified: modules/utility/gestures/default.nix renamed: modules/utility/gestures/gesture-nvim.nix -> modules/utility/gestures/gesture-nvim/config.nix new file: modules/utility/gestures/gesture-nvim/default.nix new file: modules/utility/gestures/gesture-nvim/gesture-nvim.nix renamed: modules/utility/icon-picker.nix -> modules/utility/icon-picker/config.nix new file: modules/utility/icon-picker/default.nix new file: modules/utility/icon-picker/icon-picker.nix new file: modules/utility/telescope/config.nix modified: modules/utility/telescope/default.nix new file: modules/utility/telescope/telescope.nix renamed: modules/utility/venn.nix -> modules/utility/venn/config.nix new file: modules/utility/venn/default.nix new file: modules/utility/venn/venn.nix --- .../utility/binds/cheatsheet/cheatsheet.nix | 14 ++ modules/utility/binds/cheatsheet/config.nix | 18 +++ modules/utility/binds/cheatsheet/default.nix | 26 +-- modules/utility/binds/default.nix | 7 +- modules/utility/binds/which-key/config.nix | 115 ++++++++++++++ modules/utility/binds/which-key/default.nix | 122 +------------- modules/utility/binds/which-key/which-key.nix | 14 ++ modules/utility/{ => colorizer}/colorizer.nix | 10 -- modules/utility/colorizer/config.nix | 16 ++ modules/utility/colorizer/default.nix | 6 + modules/utility/default.nix | 7 +- modules/utility/gestures/default.nix | 2 +- .../config.nix} | 4 - .../utility/gestures/gesture-nvim/default.nix | 6 + .../gestures/gesture-nvim/gesture-nvim.nix | 14 ++ .../config.nix} | 4 - modules/utility/icon-picker/default.nix | 6 + modules/utility/icon-picker/icon-picker.nix | 14 ++ modules/utility/telescope/config.nix | 86 ++++++++++ modules/utility/telescope/default.nix | 94 +---------- modules/utility/telescope/telescope.nix | 14 ++ modules/utility/{venn.nix => venn/config.nix} | 4 - modules/utility/venn/default.nix | 6 + modules/utility/venn/venn.nix | 14 ++ modules/visuals/config.nix | 149 +++++++++++++++--- modules/visuals/visuals.nix | 144 ++--------------- 26 files changed, 503 insertions(+), 413 deletions(-) create mode 100644 modules/utility/binds/cheatsheet/cheatsheet.nix create mode 100644 modules/utility/binds/cheatsheet/config.nix create mode 100644 modules/utility/binds/which-key/config.nix create mode 100644 modules/utility/binds/which-key/which-key.nix rename modules/utility/{ => colorizer}/colorizer.nix (57%) create mode 100644 modules/utility/colorizer/config.nix create mode 100644 modules/utility/colorizer/default.nix rename modules/utility/gestures/{gesture-nvim.nix => gesture-nvim/config.nix} (94%) create mode 100644 modules/utility/gestures/gesture-nvim/default.nix create mode 100644 modules/utility/gestures/gesture-nvim/gesture-nvim.nix rename modules/utility/{icon-picker.nix => icon-picker/config.nix} (78%) create mode 100644 modules/utility/icon-picker/default.nix create mode 100644 modules/utility/icon-picker/icon-picker.nix create mode 100644 modules/utility/telescope/config.nix create mode 100644 modules/utility/telescope/telescope.nix rename modules/utility/{venn.nix => venn/config.nix} (93%) create mode 100644 modules/utility/venn/default.nix create mode 100644 modules/utility/venn/venn.nix diff --git a/modules/utility/binds/cheatsheet/cheatsheet.nix b/modules/utility/binds/cheatsheet/cheatsheet.nix new file mode 100644 index 0000000..aabee33 --- /dev/null +++ b/modules/utility/binds/cheatsheet/cheatsheet.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.binds.cheatsheet; +in { + options.vim.binds.cheatsheet = { + enable = mkEnableOption "Searchable cheatsheet for nvim using telescope"; + }; +} diff --git a/modules/utility/binds/cheatsheet/config.nix b/modules/utility/binds/cheatsheet/config.nix new file mode 100644 index 0000000..3aff60e --- /dev/null +++ b/modules/utility/binds/cheatsheet/config.nix @@ -0,0 +1,18 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.binds.cheatsheet; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = ["cheatsheet-nvim"]; + + vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere '' + require('cheatsheet').setup({}) + ''; + }; +} diff --git a/modules/utility/binds/cheatsheet/default.nix b/modules/utility/binds/cheatsheet/default.nix index 2e18691..700af5a 100644 --- a/modules/utility/binds/cheatsheet/default.nix +++ b/modules/utility/binds/cheatsheet/default.nix @@ -1,22 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.binds.cheatsheet; -in { - options.vim.binds.cheatsheet = { - enable = mkEnableOption "Searchable cheatsheet for nvim using telescope"; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = ["cheatsheet-nvim"]; - - vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere '' - require('cheatsheet').setup({}) - ''; - }; +_: { + imports = [ + ./cheatsheet.nix + ./config.nix + ]; } diff --git a/modules/utility/binds/default.nix b/modules/utility/binds/default.nix index 7c08cc6..229423b 100644 --- a/modules/utility/binds/default.nix +++ b/modules/utility/binds/default.nix @@ -1,9 +1,4 @@ -{ - config, - lib, - pkgs, - ... -}: { +_: { imports = [ ./which-key ./cheatsheet diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix new file mode 100644 index 0000000..2ff37d8 --- /dev/null +++ b/modules/utility/binds/which-key/config.nix @@ -0,0 +1,115 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.binds.whichKey; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = ["which-key"]; + + vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' + local wk = require("which-key") + wk.setup {} + + + wk.register({ + key_labels = { + [""] = "SPACE", + [""] = "SPACE", + [""] = "RETURN", + [""] = "TAB", + }, + + ${ + if config.vim.tabline.nvimBufferline.enable + then '' + -- Buffer + ["b"] = { name = "+Buffer" }, + ["bm"] = { name = "BufferLineMove" }, + ["bs"] = { name = "BufferLineSort" }, + ["bsi"] = { name = "BufferLineSortById" }, + + '' + else "" + } + + ${ + if config.vim.telescope.enable + then '' + ["f"] = { name = "+Telescope" }, + -- Telescope + ["fl"] = { name = "Telescope LSP" }, + ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group + ["fv"] = { name = "Telescope Git" }, + ["fvc"] = { name = "Commits" }, + '' + else "" + } + + ${ + if config.vim.lsp.trouble.enable + then '' + -- Trouble + ["lw"] = { name = "Workspace" }, + ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group + ["l"] = { name = "+Trouble" }, + '' + else "" + } + + ${ + if config.vim.lsp.nvimCodeActionMenu.enable + then '' + -- Parent Groups + ["c"] = { name = "+CodeAction" }, + '' + else "" + } + + ${ + if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable + then '' + -- Minimap + ["m"] = { name = "+Minimap" }, -- TODO: remap both minimap plugins' keys to be the same + '' + else "" + } + + ${ + if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable + then '' + -- Notes + ["o"] = { name = "+Notes" }, + -- TODO: options for other note taking plugins and their individual binds + -- TODO: move all note-taker binds under leader + o + '' + else "" + } + + ${ + if config.vim.filetree.nvimTreeLua.enable + then '' + -- NvimTree + ["t"] = { name = "+NvimTree" }, + '' + else "" + } + + ${ + if config.vim.git.gitsigns.enable + then '' + -- Git + ["g"] = { name = "+Gitsigns" }, + '' + else "" + } + + }) + + ''; + }; +} diff --git a/modules/utility/binds/which-key/default.nix b/modules/utility/binds/which-key/default.nix index 1479105..20c9cdf 100644 --- a/modules/utility/binds/which-key/default.nix +++ b/modules/utility/binds/which-key/default.nix @@ -1,118 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.binds.whichKey; -in { - options.vim.binds.whichKey = { - enable = mkEnableOption "which-key menu"; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = ["which-key"]; - - vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' - require("which-key").setup {} - - local wk = require("which-key") - wk.register({ - key_labels = { - [""] = "SPACE", - [""] = "SPACE", - [""] = "RETURN", - [""] = "TAB", - }, - - ${ - if config.vim.tabline.nvimBufferline.enable - then '' - -- Buffer - ["b"] = { name = "+Buffer" }, - ["bm"] = { name = "BufferLineMove" }, - ["bs"] = { name = "BufferLineSort" }, - ["bsi"] = { name = "BufferLineSortById" }, - - '' - else "" - } - - ${ - if config.vim.telescope.enable - then '' - ["f"] = { name = "+Telescope" }, - -- Telescope - ["fl"] = { name = "Telescope LSP" }, - ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group - ["fv"] = { name = "Telescope Git" }, - ["fvc"] = { name = "Commits" }, - '' - else "" - } - - ${ - if config.vim.lsp.trouble.enable - then '' - -- Trouble - ["lw"] = { name = "Workspace" }, - ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group - ["l"] = { name = "+Trouble" }, - '' - else "" - } - - ${ - if config.vim.lsp.nvimCodeActionMenu.enable - then '' - -- Parent Groups - ["c"] = { name = "+CodeAction" }, - '' - else "" - } - - ${ - if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable - then '' - -- Minimap - ["m"] = { name = "+Minimap" }, - '' - else "" - } - - ${ - if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable - then '' - -- Notes - ["o"] = { name = "+Notes" }, - -- TODO: options for other note taking plugins and their individual binds - -- TODO: move all note-taker binds under leader + o - '' - else "" - } - - ${ - if config.vim.filetree.nvimTreeLua.enable - then '' - -- NvimTree - ["t"] = { name = "+NvimTree" }, - '' - else "" - } - - ${ - if config.vim.git.gitsigns.enable - then '' - -- Git - ["g"] = { name = "+Gitsigns" }, - '' - else "" - } - - }) - - ''; - }; +_: { + imports = [ + ./which-key.nix + ./config.nix + ]; } diff --git a/modules/utility/binds/which-key/which-key.nix b/modules/utility/binds/which-key/which-key.nix new file mode 100644 index 0000000..f26b38b --- /dev/null +++ b/modules/utility/binds/which-key/which-key.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.binds.whichKey; +in { + options.vim.binds.whichKey = { + enable = mkEnableOption "which-key menu"; + }; +} diff --git a/modules/utility/colorizer.nix b/modules/utility/colorizer/colorizer.nix similarity index 57% rename from modules/utility/colorizer.nix rename to modules/utility/colorizer/colorizer.nix index 940ca7c..8d14c36 100644 --- a/modules/utility/colorizer.nix +++ b/modules/utility/colorizer/colorizer.nix @@ -11,14 +11,4 @@ in { options.vim.utility.colorizer = { enable = mkEnableOption "ccc color picker for neovim"; }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "colorizer" - ]; - - vim.configRC.ccc = - nvim.dag.entryAnywhere '' - ''; - }; } diff --git a/modules/utility/colorizer/config.nix b/modules/utility/colorizer/config.nix new file mode 100644 index 0000000..7f38479 --- /dev/null +++ b/modules/utility/colorizer/config.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.utility.colorizer; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "colorizer" + ]; + }; +} diff --git a/modules/utility/colorizer/default.nix b/modules/utility/colorizer/default.nix new file mode 100644 index 0000000..3b5b491 --- /dev/null +++ b/modules/utility/colorizer/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./colorizer.nix + ./config.nix + ]; +} diff --git a/modules/utility/default.nix b/modules/utility/default.nix index 0b6a21b..347e4d7 100644 --- a/modules/utility/default.nix +++ b/modules/utility/default.nix @@ -3,8 +3,9 @@ _: { ./binds ./gestures ./telescope - ./colorizer.nix - ./venn.nix - ./icon-picker.nix + ./colorizer + ./icon-picker + ./telescope + ./venn ]; } diff --git a/modules/utility/gestures/default.nix b/modules/utility/gestures/default.nix index 4dfa40a..1e6eb96 100644 --- a/modules/utility/gestures/default.nix +++ b/modules/utility/gestures/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./gesture-nvim.nix + ./gesture-nvim ]; } diff --git a/modules/utility/gestures/gesture-nvim.nix b/modules/utility/gestures/gesture-nvim/config.nix similarity index 94% rename from modules/utility/gestures/gesture-nvim.nix rename to modules/utility/gestures/gesture-nvim/config.nix index b8aa4ce..def0cfb 100644 --- a/modules/utility/gestures/gesture-nvim.nix +++ b/modules/utility/gestures/gesture-nvim/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.gestures.gesture-nvim; in { - options.vim.gestures.gesture-nvim = { - enable = mkEnableOption "Enable GitHub Copilot"; - }; - config = mkIf cfg.enable { vim.startPlugins = ["gesture-nvim"]; diff --git a/modules/utility/gestures/gesture-nvim/default.nix b/modules/utility/gestures/gesture-nvim/default.nix new file mode 100644 index 0000000..27e7e09 --- /dev/null +++ b/modules/utility/gestures/gesture-nvim/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./gesture-nvim.nix + ./config.nix + ]; +} diff --git a/modules/utility/gestures/gesture-nvim/gesture-nvim.nix b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix new file mode 100644 index 0000000..6a7dbbf --- /dev/null +++ b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.gestures.gesture-nvim; +in { + options.vim.gestures.gesture-nvim = { + enable = mkEnableOption "Enable gesture-nvim plugin"; + }; +} diff --git a/modules/utility/icon-picker.nix b/modules/utility/icon-picker/config.nix similarity index 78% rename from modules/utility/icon-picker.nix rename to modules/utility/icon-picker/config.nix index c43d2cd..e146dfd 100644 --- a/modules/utility/icon-picker.nix +++ b/modules/utility/icon-picker/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.utility.icon-picker; in { - options.vim.utility.icon-picker = { - enable = mkEnableOption "Nerdfonts icon picker for nvim"; - }; - config = mkIf (cfg.enable) { vim.startPlugins = [ "icon-picker-nvim" diff --git a/modules/utility/icon-picker/default.nix b/modules/utility/icon-picker/default.nix new file mode 100644 index 0000000..b998e08 --- /dev/null +++ b/modules/utility/icon-picker/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./icon-picker.nix + ./config.nix + ]; +} diff --git a/modules/utility/icon-picker/icon-picker.nix b/modules/utility/icon-picker/icon-picker.nix new file mode 100644 index 0000000..902b3c3 --- /dev/null +++ b/modules/utility/icon-picker/icon-picker.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.utility.icon-picker; +in { + options.vim.utility.icon-picker = { + enable = mkEnableOption "Nerdfonts icon picker for nvim"; + }; +} diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix new file mode 100644 index 0000000..c56d91e --- /dev/null +++ b/modules/utility/telescope/config.nix @@ -0,0 +1,86 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.telescope; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "telescope" + ]; + + vim.nnoremap = + { + "ff" = " Telescope find_files"; + "fg" = " Telescope live_grep"; + "fb" = " Telescope buffers"; + "fh" = " Telescope help_tags"; + "ft" = " Telescope"; + + "fvcw" = " Telescope git_commits"; + "fvcb" = " Telescope git_bcommits"; + "fvb" = " Telescope git_branches"; + "fvs" = " Telescope git_status"; + "fvx" = " Telescope git_stash"; + } + // ( + if config.vim.lsp.enable + then { + "flsb" = " Telescope lsp_document_symbols"; + "flsw" = " Telescope lsp_workspace_symbols"; + + "flr" = " Telescope lsp_references"; + "fli" = " Telescope lsp_implementations"; + "flD" = " Telescope lsp_definitions"; + "flt" = " Telescope lsp_type_definitions"; + "fld" = " Telescope diagnostics"; + } + else {} + ) + // ( + if config.vim.treesitter.enable + then { + "fs" = " Telescope treesitter"; + } + else {} + ); + + vim.luaConfigRC.telescope = nvim.dag.entryAnywhere '' + local telescope = require('telescope') + telescope.setup { + defaults = { + vimgrep_arguments = { + "${pkgs.ripgrep}/bin/rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case" + }, + pickers = { + find_command = { + "${pkgs.fd}/bin/fd", + }, + }, + } + } + + ${ + if config.vim.ui.noice.enable + then "telescope.load_extension('noice')" + else null + } + + ${ + if config.vim.notify.nvim-notify.enable + then "telescope.load_extension('notify')" + else null + } + ''; + }; +} diff --git a/modules/utility/telescope/default.nix b/modules/utility/telescope/default.nix index 82452fe..c7a3819 100644 --- a/modules/utility/telescope/default.nix +++ b/modules/utility/telescope/default.nix @@ -1,90 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.telescope; -in { - options.vim.telescope = { - enable = mkEnableOption "enable telescope"; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "telescope" - ]; - - vim.nnoremap = - { - "ff" = " Telescope find_files"; - "fg" = " Telescope live_grep"; - "fb" = " Telescope buffers"; - "fh" = " Telescope help_tags"; - "ft" = " Telescope"; - - "fvcw" = " Telescope git_commits"; - "fvcb" = " Telescope git_bcommits"; - "fvb" = " Telescope git_branches"; - "fvs" = " Telescope git_status"; - "fvx" = " Telescope git_stash"; - } - // ( - if config.vim.lsp.enable - then { - "flsb" = " Telescope lsp_document_symbols"; - "flsw" = " Telescope lsp_workspace_symbols"; - - "flr" = " Telescope lsp_references"; - "fli" = " Telescope lsp_implementations"; - "flD" = " Telescope lsp_definitions"; - "flt" = " Telescope lsp_type_definitions"; - "fld" = " Telescope diagnostics"; - } - else {} - ) - // ( - if config.vim.treesitter.enable - then { - "fs" = " Telescope treesitter"; - } - else {} - ); - - vim.luaConfigRC.telescope = nvim.dag.entryAnywhere '' - local telescope = require('telescope') - telescope.setup { - defaults = { - vimgrep_arguments = { - "${pkgs.ripgrep}/bin/rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case" - }, - pickers = { - find_command = { - "${pkgs.fd}/bin/fd", - }, - }, - } - } - - ${ - if config.vim.ui.noice.enable - then "telescope.load_extension('noice')" - else null - } - - ${ - if config.vim.notify.nvim-notify.enable - then "telescope.load_extension('notify')" - else null - } - ''; - }; +_: { + imports = [ + ./telescope.nix + ./config.nix + ]; } diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix new file mode 100644 index 0000000..2b43e00 --- /dev/null +++ b/modules/utility/telescope/telescope.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.telescope; +in { + options.vim.telescope = { + enable = mkEnableOption "enable telescope"; + }; +} diff --git a/modules/utility/venn.nix b/modules/utility/venn/config.nix similarity index 93% rename from modules/utility/venn.nix rename to modules/utility/venn/config.nix index b1c9ffa..22d47b3 100644 --- a/modules/utility/venn.nix +++ b/modules/utility/venn/config.nix @@ -8,10 +8,6 @@ with lib; with builtins; let cfg = config.vim.utility.venn-nvim; in { - options.vim.utility.venn-nvim = { - enable = mkEnableOption "draw ASCII diagrams in Neovim"; - }; - config = mkIf (cfg.enable) { vim.startPlugins = [ "venn-nvim" diff --git a/modules/utility/venn/default.nix b/modules/utility/venn/default.nix new file mode 100644 index 0000000..de4dff0 --- /dev/null +++ b/modules/utility/venn/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./venn.nix + ]; +} diff --git a/modules/utility/venn/venn.nix b/modules/utility/venn/venn.nix new file mode 100644 index 0000000..93f13b4 --- /dev/null +++ b/modules/utility/venn/venn.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.utility.venn-nvim; +in { + options.vim.utility.venn-nvim = { + enable = mkEnableOption "draw ASCII diagrams in Neovim"; + }; +} diff --git a/modules/visuals/config.nix b/modules/visuals/config.nix index 7231c86..1835d46 100644 --- a/modules/visuals/config.nix +++ b/modules/visuals/config.nix @@ -4,30 +4,137 @@ lib, ... }: -with lib; { - config = { - vim.visuals = { - enable = mkDefault false; +with lib; let + cfg = config.vim.visuals; +in { + config = mkIf cfg.enable { + vim.startPlugins = [ + ( + if cfg.nvimWebDevicons.enable + then "nvim-web-devicons" + else null + ) + ( + if cfg.lspkind.enable + then "lspkind" + else null + ) + ( + if cfg.cursorWordline.enable + then "nvim-cursorline" + else null + ) + ( + if cfg.indentBlankline.enable + then "indent-blankline" + else null + ) + ( + if cfg.scrollBar.enable + then "scrollbar-nvim" + else null + ) + ( + if cfg.smoothScroll.enable + then "cinnamon-nvim" + else null + ) + ( + if cfg.cellularAutomaton.enable + then "cellular-automaton" + else null + ) + ]; - nvimWebDevicons.enable = mkDefault false; - lspkind.enable = mkDefault false; + vim.luaConfigRC.visuals = nvim.dag.entryAnywhere '' + ${ + if cfg.lspkind.enable + then "require'lspkind'.init()" + else "" + } + ${ + if cfg.indentBlankline.enable + then '' + -- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 + vim.wo.colorcolumn = "99999" + vim.opt.list = true - scrollBar = { - enable = mkDefault false; - }; - cursorWordline = { - enable = mkDefault false; - lineTimeout = mkDefault 500; - }; + ${ + if cfg.indentBlankline.eolChar == "" + then "" + else ''vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })'' + } - indentBlankline = { - enable = mkDefault false; - listChar = mkDefault "│"; - fillChar = mkDefault "⋅"; - eolChar = mkDefault "↴"; - showCurrContext = mkDefault true; - }; - }; + ${ + if cfg.indentBlankline.fillChar == "" + then "" + else ''vim.opt.listchars:append({ space = "${cfg.indentBlankline.fillChar}"})'' + } + + require("indent_blankline").setup { + char = "${cfg.indentBlankline.listChar}", + show_current_context = ${boolToString cfg.indentBlankline.showCurrContext}, + show_end_of_line = true, + } + '' + else "" + } + + ${ + if cfg.cursorWordline.enable + then "vim.g.cursorline_timeout = ${toString cfg.cursorWordline.lineTimeout}" + else "" + } + + ${ + if cfg.scrollBar.enable + then "require('scrollbar').setup{ + excluded_filetypes = { + 'prompt', + 'TelescopePrompt', + 'noice', + 'NvimTree', + 'alpha' + }, + }" + else "" + } + ${ + if cfg.smoothScroll.enable + then "require('cinnamon').setup()" + else "" + } + ${ + if cfg.cellularAutomaton.enable + then '' + local config = { + fps = 50, + name = 'slide', + } + + -- init function is invoked only once at the start + -- config.init = function (grid) + -- + -- end + + -- update function + config.update = function (grid) + for i = 1, #grid do + local prev = grid[i][#(grid[i])] + for j = 1, #(grid[i]) do + grid[i][j], prev = prev, grid[i][j] + end + end + return true + end + + require("cellular-automaton").register_animation(config) + + vim.keymap.set("n", "fml", "CellularAutomaton make_it_rain") + '' + else "" + } + ''; }; } diff --git a/modules/visuals/visuals.nix b/modules/visuals/visuals.nix index a186378..6b3a121 100644 --- a/modules/visuals/visuals.nix +++ b/modules/visuals/visuals.nix @@ -12,26 +12,31 @@ in { enable = mkOption { type = types.bool; description = "visual enhancements"; + default = false; }; nvimWebDevicons.enable = mkOption { type = types.bool; description = "enable dev icons. required for certain plugins [nvim-web-devicons]"; + default = false; }; lspkind.enable = mkOption { type = types.bool; description = "enable vscode-like pictograms for lsp [lspkind]"; + default = false; }; scrollBar.enable = mkOption { type = types.bool; description = "enable scrollbar [scrollbar.nvim]"; + default = false; }; smoothScroll.enable = mkOption { type = types.bool; description = "enable smooth scrolling [cinnamon-nvim]"; + default = false; }; cellularAutomaton.enable = mkOption { @@ -44,6 +49,7 @@ in { enable = mkOption { type = types.bool; description = "enable word and delayed line highlight [nvim-cursorline]"; + default = false; }; lineTimeout = mkOption { @@ -56,160 +62,32 @@ in { enable = mkOption { type = types.bool; description = "enable indentation guides [indent-blankline]"; + default = false; }; listChar = mkOption { type = types.str; description = "Character for indentation line"; + default = "│"; }; fillChar = mkOption { type = types.str; description = "Character to fill indents"; + default = "⋅"; }; eolChar = mkOption { type = types.str; description = "Character at end of line"; + default = "↴"; }; showCurrContext = mkOption { type = types.bool; description = "Highlight current context from treesitter"; + default = true; }; }; }; - - config = - mkIf cfg.enable - { - vim.startPlugins = [ - ( - if cfg.nvimWebDevicons.enable - then "nvim-web-devicons" - else null - ) - ( - if cfg.lspkind.enable - then "lspkind" - else null - ) - ( - if cfg.cursorWordline.enable - then "nvim-cursorline" - else null - ) - ( - if cfg.indentBlankline.enable - then "indent-blankline" - else null - ) - ( - if cfg.scrollBar.enable - then "scrollbar-nvim" - else null - ) - ( - if cfg.smoothScroll.enable - then "cinnamon-nvim" - else null - ) - ( - if cfg.cellularAutomaton.enable - then "cellular-automaton" - else null - ) - ]; - - vim.luaConfigRC.visuals = nvim.dag.entryAnywhere '' - ${ - if cfg.lspkind.enable - then "require'lspkind'.init()" - else "" - } - ${ - if cfg.indentBlankline.enable - then '' - -- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 - vim.wo.colorcolumn = "99999" - vim.opt.list = true - - - ${ - if cfg.indentBlankline.eolChar == "" - then "" - else ''vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })'' - } - - ${ - if cfg.indentBlankline.fillChar == "" - then "" - else ''vim.opt.listchars:append({ space = "${cfg.indentBlankline.fillChar}"})'' - } - - require("indent_blankline").setup { - char = "${cfg.indentBlankline.listChar}", - show_current_context = ${boolToString cfg.indentBlankline.showCurrContext}, - show_end_of_line = true, - } - '' - else "" - } - - ${ - if cfg.cursorWordline.enable - then "vim.g.cursorline_timeout = ${toString cfg.cursorWordline.lineTimeout}" - else "" - } - - ${ - if cfg.scrollBar.enable - then "require('scrollbar').setup{ - excluded_filetypes = { - 'prompt', - 'TelescopePrompt', - 'noice', - 'NvimTree', - 'alpha' - }, - }" - else "" - } - ${ - if cfg.smoothScroll.enable - then "require('cinnamon').setup()" - else "" - } - ${ - if cfg.cellularAutomaton.enable - then '' - local config = { - fps = 50, - name = 'slide', - } - - -- init function is invoked only once at the start - -- config.init = function (grid) - -- - -- end - - -- update function - config.update = function (grid) - for i = 1, #grid do - local prev = grid[i][#(grid[i])] - for j = 1, #(grid[i]) do - grid[i][j], prev = prev, grid[i][j] - end - end - return true - end - - require("cellular-automaton").register_animation(config) - - vim.keymap.set("n", "fml", "CellularAutomaton make_it_rain") - '' - else "" - } - ''; - }; } From 476991b5ef0a6d8be96aeaa511afe1104305d4f9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 10:19:40 +0300 Subject: [PATCH 25/29] feat: feat: update flake inputs (28/02/2023) --- flake.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 5736be9..390eb4f 100644 --- a/flake.lock +++ b/flake.lock @@ -593,11 +593,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1677413016, - "narHash": "sha256-dwvL0VK5iyxXPQzJOPzYmuVinh/R9hwRu7eYq6Bf6ag=", + "lastModified": 1677468890, + "narHash": "sha256-V4MPvt4PKaHSInRLWpaF8ICdC91SH+5bdd0FGxalJIg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "84e33aea0f7a8375c92458c5b6cad75fa1dd561b", + "rev": "3f19c04354dec3903f614eae09327a04d297835d", "type": "github" }, "original": { @@ -692,11 +692,11 @@ "nui-nvim": { "flake": false, "locked": { - "lastModified": 1675269986, - "narHash": "sha256-4vf+eqT7e638VeWfmh23K8EslJXyR6ZK6arvaeVgWlw=", + "lastModified": 1677566469, + "narHash": "sha256-xHpNGJ8ikTMiWHAtqaZg5IVKSngH/k0LN7WaOHl2iz8=", "owner": "MunifTanjim", "repo": "nui.nvim", - "rev": "d147222a1300901656f3ebd5b95f91732785a329", + "rev": "0dc148c6ec06577fcf06cbab3b7dac96d48ba6be", "type": "github" }, "original": { @@ -901,11 +901,11 @@ "nvim-tree-lua": { "flake": false, "locked": { - "lastModified": 1677490090, - "narHash": "sha256-3fTVcc6ImtmDy5/UBr2NAvnCrOIbdLeObl6Y7w0vefI=", + "lastModified": 1677535813, + "narHash": "sha256-ltSVa+VKD9mFcYF3q49nUT81cCQdbKvCWxm7H8tJNiI=", "owner": "nvim-tree", "repo": "nvim-tree.lua", - "rev": "59bcb01d3bf58b810b9c48db56e558f3857110ad", + "rev": "362ecbeed69fae91a287004619decadcb6f7c113", "type": "github" }, "original": { @@ -949,11 +949,11 @@ "nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1677455337, - "narHash": "sha256-iIDTJVj5WUhELunX9Qz+Y2KltbxGdCFeFm1P0Nd+9GM=", + "lastModified": 1677551712, + "narHash": "sha256-WHymlANhUr/4Trxs0P/huCVRyOHTns1drfFS0hBm2GA=", "owner": "kyazdani42", "repo": "nvim-web-devicons", - "rev": "0f23feca2bd08549b779c838b6b1308d1e76df03", + "rev": "c2c2317f356c8b7da0252f5da758f71bb60bb6b2", "type": "github" }, "original": { @@ -1516,11 +1516,11 @@ "which-key": { "flake": false, "locked": { - "lastModified": 1676049352, - "narHash": "sha256-8tFsz6y6l+0UX7H0g9t0Fvuio8aARJzFWqZc6MuPJuQ=", + "lastModified": 1677566975, + "narHash": "sha256-FlhL0QIB4yj+okxp4MfzAOPsvl7ZdSwKSAc0RUXoC9o=", "owner": "folke", "repo": "which-key.nvim", - "rev": "5224c261825263f46f6771f1b644cae33cd06995", + "rev": "6e190f4732a0f2fc517036f2fcf7727893bc5329", "type": "github" }, "original": { From 1ca507569d5f9034ab970e83173bb3eb177beb81 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 10:54:35 +0300 Subject: [PATCH 26/29] feat: update lsp config --- modules/lsp/config.nix | 55 ------------------------------------------ modules/lsp/module.nix | 55 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 58 deletions(-) diff --git a/modules/lsp/config.nix b/modules/lsp/config.nix index acec921..581556e 100644 --- a/modules/lsp/config.nix +++ b/modules/lsp/config.nix @@ -8,61 +8,6 @@ with lib; with builtins; let cfg = config.vim.lsp; in { - options.vim.lsp = { - enable = mkEnableOption "neovim lsp support"; - formatOnSave = mkEnableOption "Format on save"; - nix = { - enable = mkEnableOption "Nix LSP"; - server = mkOption { - type = with types; enum ["rnix" "nil"]; - default = "nil"; - description = "Which LSP to use"; - }; - - pkg = mkOption { - type = types.package; - default = - if (cfg.nix.server == "rnix") - then pkgs.rnix-lsp - else pkgs.nil; - description = "The LSP package to use"; - }; - - formatter = mkOption { - type = with types; enum ["nixpkgs-fmt" "alejandra"]; - default = "alejandra"; - description = "Which nix formatter to use"; - }; - }; - rust = { - enable = mkEnableOption "Rust LSP"; - rustAnalyzerOpts = mkOption { - type = types.str; - default = '' - ["rust-analyzer"] = { - experimental = { - procAttrMacros = true, - }, - }, - ''; - description = "options to pass to rust analyzer"; - }; - }; - python = mkEnableOption "Python LSP"; - clang = { - enable = mkEnableOption "C language LSP"; - c_header = mkEnableOption "C syntax header files"; - cclsOpts = mkOption { - type = types.str; - default = ""; - }; - }; - sql = mkEnableOption "SQL Language LSP"; - go = mkEnableOption "Go language LSP"; - ts = mkEnableOption "TS language LSP"; - zig.enable = mkEnableOption "Zig language LSP"; - }; - config = mkIf cfg.enable ( let writeIf = cond: msg: diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix index 513ec53..42ed054 100644 --- a/modules/lsp/module.nix +++ b/modules/lsp/module.nix @@ -9,8 +9,57 @@ with builtins; let cfg = config.vim.lsp; in { options.vim.lsp = { - /* - ... - */ + enable = mkEnableOption "neovim lsp support"; + formatOnSave = mkEnableOption "Format on save"; + nix = { + enable = mkEnableOption "Nix LSP"; + server = mkOption { + type = with types; enum ["rnix" "nil"]; + default = "nil"; + description = "Which LSP to use"; + }; + + pkg = mkOption { + type = types.package; + default = + if (cfg.nix.server == "rnix") + then pkgs.rnix-lsp + else pkgs.nil; + description = "The LSP package to use"; + }; + + formatter = mkOption { + type = with types; enum ["nixpkgs-fmt" "alejandra"]; + default = "alejandra"; + description = "Which nix formatter to use"; + }; + }; + rust = { + enable = mkEnableOption "Rust LSP"; + rustAnalyzerOpts = mkOption { + type = types.str; + default = '' + ["rust-analyzer"] = { + experimental = { + procAttrMacros = true, + }, + }, + ''; + description = "options to pass to rust analyzer"; + }; + }; + python = mkEnableOption "Python LSP"; + clang = { + enable = mkEnableOption "C language LSP"; + c_header = mkEnableOption "C syntax header files"; + cclsOpts = mkOption { + type = types.str; + default = ""; + }; + }; + sql = mkEnableOption "SQL Language LSP"; + go = mkEnableOption "Go language LSP"; + ts = mkEnableOption "TS language LSP"; + zig.enable = mkEnableOption "Zig language LSP"; }; } From 7339f64dd84c070b7706cf74afe2c03833b1862d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 10:54:48 +0300 Subject: [PATCH 27/29] dev: attempt to use the zig overlay instead of nixpkgs/zig --- flake.lock | 176 +++++++++++++++++++++++++++++++++++++-- flake.nix | 7 ++ flake/legacyPackages.nix | 3 + 3 files changed, 178 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index 390eb4f..e95038e 100644 --- a/flake.lock +++ b/flake.lock @@ -321,6 +321,38 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -354,6 +386,36 @@ "type": "github" } }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gesture-nvim": { "flake": false, "locked": { @@ -567,6 +629,50 @@ "type": "github" } }, + "neovim-flake": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "dir": "contrib", + "lastModified": 1677463842, + "narHash": "sha256-MgUEDPza573qKV59nRqrykLblPKBZu+DAIUqg9Pl5wU=", + "owner": "neovim", + "repo": "neovim", + "rev": "2c9fbe34b20266ef5ab54f6ed14fb38eef60430d", + "type": "github" + }, + "original": { + "dir": "contrib", + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-nightly-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "neovim-flake": "neovim-flake", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1677485761, + "narHash": "sha256-C04OWgNrCxPGUiT7Px/vZd42vfwRY6/EjHwHNUSHv7g=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "aad4d8be05012055861b097b8019311fe62635bf", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, "nil": { "inputs": { "flake-utils": [ @@ -593,11 +699,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1677468890, - "narHash": "sha256-V4MPvt4PKaHSInRLWpaF8ICdC91SH+5bdd0FGxalJIg=", + "lastModified": 1677383253, + "narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3f19c04354dec3903f614eae09327a04d297835d", + "rev": "9952d6bc395f5841262b006fbace8dd7e143b634", "type": "github" }, "original": { @@ -626,6 +732,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1677468890, + "narHash": "sha256-V4MPvt4PKaHSInRLWpaF8ICdC91SH+5bdd0FGxalJIg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3f19c04354dec3903f614eae09327a04d297835d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1656753965, "narHash": "sha256-BCrB3l0qpJokOnIVc3g2lHiGhnjUi0MoXiw6t1o8H1E=", @@ -641,7 +763,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1655400192, "narHash": "sha256-49OBVVRgb9H/PSmNT9W61+NRdDbuSJVuDDflwXlaUKU=", @@ -657,6 +779,22 @@ "type": "github" } }, + "nixpkgs_5": { + "locked": { + "lastModified": 1661151577, + "narHash": "sha256-++S0TuJtuz9IpqP8rKktWyHZKpgdyrzDFUXVY07MTRI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "54060e816971276da05970a983487a25810c38a7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nmd": { "flake": false, "locked": { @@ -1061,7 +1199,7 @@ "rnix-lsp": { "inputs": { "naersk": "naersk", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "utils": "utils" }, "locked": { @@ -1113,8 +1251,9 @@ "lualine": "lualine", "mind-nvim": "mind-nvim", "minimap-vim": "minimap-vim", + "neovim-nightly-overlay": "neovim-nightly-overlay", "nil": "nil", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nmd": "nmd", "noice-nvim": "noice-nvim", "nui-nvim": "nui-nvim", @@ -1155,7 +1294,8 @@ "vim-markdown": "vim-markdown", "vim-startify": "vim-startify", "vim-vsnip": "vim-vsnip", - "which-key": "which-key" + "which-key": "which-key", + "zig": "zig" } }, "rust-overlay": { @@ -1300,7 +1440,7 @@ "tidalcycles": { "inputs": { "dirt-samples-src": "dirt-samples-src", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "superdirt-src": "superdirt-src", "tidal-src": "tidal-src", "utils": "utils_2", @@ -1528,6 +1668,26 @@ "repo": "which-key.nvim", "type": "github" } + }, + "zig": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1677457546, + "narHash": "sha256-R2k5sOzf6dEg/PbMfZNYFjmJQY1Hbd/4sc8H36I3EAM=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "2b07e4e3e3eb07134ac61049abdc1da1ff6c5516", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 778509b..aafbfc1 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ outputs = { nixpkgs, flake-parts, + zig, ... } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { @@ -47,12 +48,18 @@ flake-parts.url = "github:hercules-ci/flake-parts"; flake-utils.url = "github:numtide/flake-utils"; + # TODO: neovim nightly + neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; + # For generating documentation website nmd = { url = "gitlab:rycee/nmd"; flake = false; }; + # TODO: get zig from the zig overlay instead of nixpkgs + zig.url = "github:mitchellh/zig-overlay"; + # LSP plugins nvim-lspconfig = { # url = "github:neovim/nvim-lspconfig?ref=v0.1.3"; diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix index d6fb73c..bd284be 100644 --- a/flake/legacyPackages.nix +++ b/flake/legacyPackages.nix @@ -9,9 +9,12 @@ overlays = [ inputs.tidalcycles.overlays.default inputs.self.overlays.default + inputs.neovim-nightly-overlay.overlay + inputs.zig.overlays.default (_: _: { rnix-lsp = inputs'.rnix-lsp.defaultPackage; nil = inputs'.nil.packages.default; + zig = inputs'.zig.packages.default; }) ]; }; From 72b00868303723d3ee8aaac34f75b8c4142c8e2d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 12:01:56 +0300 Subject: [PATCH 28/29] dev: temporarily deprecate darwin builds --- modules/tidal/config.nix | 23 +++++++++++ modules/tidal/default.nix | 1 + modules/tidal/tidal.nix | 13 ------- modules/treesitter/config.nix | 65 +++++++++++++++++++++++++++++++ modules/treesitter/treesitter.nix | 55 -------------------------- 5 files changed, 89 insertions(+), 68 deletions(-) create mode 100644 modules/tidal/config.nix create mode 100644 modules/treesitter/config.nix diff --git a/modules/tidal/config.nix b/modules/tidal/config.nix new file mode 100644 index 0000000..7c748e5 --- /dev/null +++ b/modules/tidal/config.nix @@ -0,0 +1,23 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.tidal; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + # From tidalcycles flake + pkgs.vimPlugins.vim-tidal + ]; + + vim.globals = { + "tidal_target" = "terminal"; + "tidal_flash_duration" = 150; + "tidal_sc_enable" = cfg.openSC; + }; + }; +} diff --git a/modules/tidal/default.nix b/modules/tidal/default.nix index 4b07c0d..9ef675f 100644 --- a/modules/tidal/default.nix +++ b/modules/tidal/default.nix @@ -6,5 +6,6 @@ }: { imports = [ ./tidal.nix + ./config.nix ]; } diff --git a/modules/tidal/tidal.nix b/modules/tidal/tidal.nix index 6b6c27e..5db5bbb 100644 --- a/modules/tidal/tidal.nix +++ b/modules/tidal/tidal.nix @@ -23,17 +23,4 @@ in { default = true; }; }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - # From tidalcycles flake - pkgs.vimPlugins.vim-tidal - ]; - - vim.globals = { - "tidal_target" = "terminal"; - "tidal_flash_duration" = 150; - "tidal_sc_enable" = cfg.openSC; - }; - }; } diff --git a/modules/treesitter/config.nix b/modules/treesitter/config.nix new file mode 100644 index 0000000..b7c2638 --- /dev/null +++ b/modules/treesitter/config.nix @@ -0,0 +1,65 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.treesitter; +in { + config = mkIf cfg.enable ( + let + writeIf = cond: msg: + if cond + then msg + else ""; + in { + vim.startPlugins = [ + "nvim-treesitter" + ( + if cfg.autotagHtml + then "nvim-ts-autotag" + else null + ) + ]; + + # For some reason treesitter highlighting does not work on start if this is set before syntax on + vim.configRC.treesitter = writeIf cfg.fold (nvim.dag.entryBefore ["basic"] '' + " Tree-sitter based folding + set foldmethod=expr + set foldexpr=nvim_treesitter#foldexpr() + set nofoldenable + ''); + + vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere '' + -- Treesitter config + require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + disable = {}, + }, + + auto_install = false, + ensure_installed = {}, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + + ${writeIf cfg.autotagHtml '' + autotag = { + enable = true, + }, + ''} + } + ''; + } + ); +} diff --git a/modules/treesitter/treesitter.nix b/modules/treesitter/treesitter.nix index d6acd2d..c206336 100644 --- a/modules/treesitter/treesitter.nix +++ b/modules/treesitter/treesitter.nix @@ -55,59 +55,4 @@ in { ''; }; }; - - config = mkIf cfg.enable ( - let - writeIf = cond: msg: - if cond - then msg - else ""; - in { - vim.startPlugins = [ - "nvim-treesitter" - ( - if cfg.autotagHtml - then "nvim-ts-autotag" - else null - ) - ]; - - # For some reason treesitter highlighting does not work on start if this is set before syntax on - vim.configRC.treesitter = writeIf cfg.fold (nvim.dag.entryBefore ["basic"] '' - " Tree-sitter based folding - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() - set nofoldenable - ''); - - vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere '' - -- Treesitter config - require'nvim-treesitter.configs'.setup { - highlight = { - enable = true, - disable = {}, - }, - - auto_install = false, - ensure_installed = {}, - - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, - - ${writeIf cfg.autotagHtml '' - autotag = { - enable = true, - }, - ''} - } - ''; - } - ); } From 4f161e678bda9548d0d89f3bc1189a1d7e7ba79a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 12:10:55 +0300 Subject: [PATCH 29/29] dev: temporarily deprecate darwin builds --- flake.nix | 11 ++++++++++- modules/treesitter/default.nix | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index aafbfc1..7736d8a 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,16 @@ ... } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { - systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + systems = [ + "x86_64-linux" + "aarch64-linux" + /* + FIXME: zig compiler - therefore the maximal version - is broken on darwin + see https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/zig/0.10.nix#L70 + "x86_64-darwin" + "aarch64-darwin" + */ + ]; imports = [ # add lib to module args diff --git a/modules/treesitter/default.nix b/modules/treesitter/default.nix index 5f52900..3b5bf20 100644 --- a/modules/treesitter/default.nix +++ b/modules/treesitter/default.nix @@ -7,5 +7,6 @@ imports = [ ./treesitter.nix ./context.nix + ./config.nix ]; }