From 5f861b3ed18ec9005bff6a3cf734de17bd6dbb51 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 Feb 2023 03:55:19 +0300 Subject: [PATCH] feat: UI overhaul --- flake.nix | 27 +++++++++++++- modules/lib/types-plugin.nix | 2 ++ modules/modules.nix | 1 + modules/telescope/default.nix | 13 ++++++- modules/ui/default.nix | 5 +++ modules/ui/noice.nix | 67 +++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 modules/ui/default.nix create mode 100644 modules/ui/noice.nix diff --git a/flake.nix b/flake.nix index 1d29d3f..0874f1f 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,7 @@ viAlias = true; vimAlias = true; }; + vim.lsp = { enable = true; formatOnSave = true; @@ -61,6 +62,7 @@ formatter = "alejandra"; }; }; + vim.visuals = { enable = true; nvimWebDevicons.enable = true; @@ -79,20 +81,24 @@ lineTimeout = 0; }; }; + vim.statusline.lualine = { enable = true; theme = "catppuccin"; }; + vim.theme = { enable = true; name = "catppuccin"; style = "mocha"; }; vim.autopairs.enable = true; + vim.autocomplete = { enable = true; type = "nvim-cmp"; }; + vim.filetree = { nvimTreeLua = { enable = true; @@ -101,7 +107,10 @@ }; }; }; - vim.tabline.nvimBufferline.enable = true; + + vim.tabline = { + nvimBufferline.enable = true; + }; vim.treesitter = { enable = true; @@ -155,6 +164,10 @@ vim.terminal = { toggleterm.enable = true; }; + + vim.ui = { + noice.enable = true; + }; }; }; @@ -547,6 +560,12 @@ flake = false; }; + # UI44444 + noice-nvim = { + url = "github:folke/noice.nvim"; + flake = false; + }; + # Dependencies plenary-nvim = { # (required by crates-nvim) @@ -571,5 +590,11 @@ url = "github:godlygeek/tabular"; flake = false; }; + + nui-nvim = { + # (required by obsidian-nvim) + url = "github:MunifTanjim/nui.nvim"; + flake = false; + }; }; } diff --git a/modules/lib/types-plugin.nix b/modules/lib/types-plugin.nix index 30d08c9..4b52b19 100644 --- a/modules/lib/types-plugin.nix +++ b/modules/lib/types-plugin.nix @@ -60,6 +60,8 @@ with lib; let "vim-markdown" "tabular" "toggleterm-nvim" + "noice-nvim" + "nui-nvim" ]; # You can either use the name of the plugin or a package. pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); diff --git a/modules/modules.nix b/modules/modules.nix index d4203ca..54d32c4 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -28,6 +28,7 @@ ./presence ./notes ./terminal + ./ui ]; pkgsModule = {config, ...}: { diff --git a/modules/telescope/default.nix b/modules/telescope/default.nix index 90961ba..82452fe 100644 --- a/modules/telescope/default.nix +++ b/modules/telescope/default.nix @@ -73,7 +73,18 @@ in { }, } } - telescope.load_extension('notify') + + ${ + 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/ui/default.nix b/modules/ui/default.nix new file mode 100644 index 0000000..26bc186 --- /dev/null +++ b/modules/ui/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./noice.nix + ]; +} diff --git a/modules/ui/noice.nix b/modules/ui/noice.nix new file mode 100644 index 0000000..394d0e4 --- /dev/null +++ b/modules/ui/noice.nix @@ -0,0 +1,67 @@ +{ + pkgs, + config, + lib, + ... +}: +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" + "nui-nvim" + ]; + + vim.luaConfigRC.noice-nvim = nvim.dag.entryAnywhere '' + require("noice").setup({ + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + + signature = { + enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out + }, + }, + + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + + format = { + cmdline = { pattern = "^:", icon = "", lang = "vim" }, + search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" }, + search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" }, + filter = { pattern = "^:%s*!", icon = "", lang = "bash" }, + lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" }, + help = { pattern = "^:%s*he?l?p?%s+", icon = "" }, + input = {}, + }, + + -- Hide written messages + routes = { + { + filter = { + event = "msg_show", + kind = "", + find = "written", + }, + opts = { skip = true }, + }, + }, + }) + ''; + }; +}