diff --git a/home/modules/neovim/default.nix b/home/modules/neovim/default.nix index fc5367ee..2efffc4c 100644 --- a/home/modules/neovim/default.nix +++ b/home/modules/neovim/default.nix @@ -94,7 +94,7 @@ in { performance.byteCompileLua = { enable = true; configs = true; - initLua = true; + initLua = false; # When debugging init.lua turn this off nvimRuntime = true; plugins = true; }; @@ -133,11 +133,13 @@ in { end ''; } + { desc = "Highlight yanked regions"; event = ["TextYankPost"]; callback.__raw = "function() vim.highlight.on_yank() end"; } + { desc = "Resize splits when Neovim is resized by the WM"; event = ["VimResized"]; @@ -149,12 +151,14 @@ in { end ''; } + { desc = "Disable conceal in JSON files"; event = ["FileType"]; pattern = ["json" "jsonc" "json5"]; # Disable conceal for these filetypes callback.__raw = "function() vim.opt_local.conceallevel = 0 end"; } + { desc = "Attach JDTLS to Java files"; event = ["FileType"]; @@ -176,12 +180,16 @@ in { end ''; } + { + # TODO: This breaks if the preview buffer does not refer to a file, + # e.g. when showing previous notifications desc = "Enable line wrapping in telescope preview"; event = ["User"]; pattern = ["TelescopePreviewerLoaded"]; callback.__raw = '' function(args) + print(vim.inspect(args)) if args.data.bufname:match("*.csv") then vim.wo.wrap = false else @@ -235,6 +243,30 @@ in { }; }; + catppuccin = { + name = "catppuccin"; + pkg = pkgs.vimPlugins.catppuccin-nvim; + lazy = false; + priority = 1000; + config = '' + function(_, opts) + require("catppuccin").setup(opts) + + vim.cmd([[ + let $BAT_THEME = "catppuccin" + colorscheme catppuccin + ]]) + end + ''; + opts = { + flavour = "mocha"; # latte, frappe, macchiato, mocha + background = { + light = "latte"; + dark = "mocha"; + }; + }; + }; + # NOTE: In LazyVim require("clang_extensions").setup(opts) is called where opts is the server definition from lspconfig... clangd-extensions = rec { name = "clangd_extensions"; @@ -1014,10 +1046,40 @@ in { }) end ''; - opts = { + opts = let + bubbles = '' + (function() + -- Wrap this in an immediately invoked function and require catppuccin + -- because we need "colors" in the scope. + -- For this, the catppuccin plugin must be installed, + -- just setting the neovim colorscheme isn't enough. + local colors = require("catppuccin.palettes").get_palette("mocha") + + -- Use :lua print(vim.inspect(require("catppuccin.palettes").get_palette("mocha"))) to list colors + return { + normal = { + a = { fg = colors.base, bg = colors.lavender }, + b = { fg = colors.text, bg = colors.crust }, + c = { fg = colors.text }, + }, + + insert = { a = { fg = colors.base, bg = colors.blue } }, + visual = { a = { fg = colors.base, bg = colors.teal } }, + replace = { a = { fg = colors.base, bg = colors.red } }, + + inactive = { + a = { fg = colors.text, bg = colors.base }, + b = { fg = colors.text, bg = colors.base }, + c = { fg = colors.text }, + }, + } + end)() + ''; + in { extensions = ["fzf" "neo-tree" "toggleterm" "trouble"]; options = { + theme.__raw = bubbles; always_divide_middle = true; globalstatus = true; ignore_focus = ["neo-tree"]; @@ -1025,7 +1087,6 @@ in { left = ""; right = ""; }; - component_separators = { left = ""; right = ""; @@ -1033,18 +1094,33 @@ in { }; sections = { - lualine_a = ["mode"]; - lualine_b = ["branch" "diff" "diagnostics"]; - lualine_c.__raw = "{{ 'filename', path = 1, }}"; + # lualine_a = ["mode"]; + # lualine_a.__raw = ''{ { "mode", separator = { left = "" }, right_padding = 2, } }''; + lualine_a.__raw = ''{ { "mode", separator = {}, } }''; + lualine_b.__raw = ''{ "branch", "diff", "diagnostics", { "filename", path = 1, } }''; + lualine_c.__raw = ''{}''; # Use __raw: Nixvim does nothing with "[]", so the default config would be used - lualine_x = ["filetype" "encoding" "fileformat"]; - lualine_y = ["progress" "searchcount" "selectioncount"]; + lualine_x.__raw = ''{}''; + lualine_y = ["filetype" "encoding" "fileformat"]; + # lualine_z = ["location"]; + # lualine_z.__raw = ''{ { "location", separator = { right = "" }, left_padding = 2, } }''; + lualine_z.__raw = ''{ { "location", separator = {}, } }''; + }; + + inactive_sections = { + lualine_a = []; + lualine_b = ["filename"]; + lualine_c = []; + lualine_x = []; + lualine_y = []; lualine_z = ["location"]; }; + # Using tabby for this # tabline = { - # lualine_a = ["buffers"]; - # lualine_z = ["tabs"]; + # lualine_a = ["hostname"]; + # lualine_b = ["tabs"]; # buffers + # lualine_x = ["windows"]; # }; }; }; @@ -1325,6 +1401,12 @@ in { }; }; + quickfix-reflector = { + name = "quickfix-reflector"; + pkg = pkgs.vimPlugins.quickfix-reflector-vim; + lazy = false; + }; + rainbow-delimiters = { name = "rainbow-delimiters"; pkg = pkgs.vimPlugins.rainbow-delimiters-nvim; @@ -1338,7 +1420,6 @@ in { # Don't call setup! - # TODO: Configure this in depth init = '' function() vim.g.rustaceanvim = { @@ -1383,12 +1464,72 @@ in { ''; }; + scope = rec { + name = "scope"; + pkg = pkgs.vimPlugins.scope-nvim; + lazy = false; + config = mkDefaultConfig name; + }; + sleuth = { name = "sleuth"; pkg = pkgs.vimPlugins.vim-sleuth; lazy = false; }; + tabby = rec { + name = "tabby"; + pkg = pkgs.vimPlugins.tabby-nvim; + lazy = true; + event = ["BufReadPost" "BufNewFile"]; + dependencies = [web-devicons]; + config = mkDefaultConfig name; + opts = { + line.__raw = '' + function(line) + local colors = require("catppuccin.palettes").get_palette("mocha") + + local base = { fg = colors.base, bg = colors.base } + local crust = { fg = colors.crust, bg = colors.crust } + local text = { fg = colors.text, bg = colors.crust } + local lavender = { fg = colors.lavender, bg = colors.lavender } + + local numtabs = vim.call("tabpagenr", "$") + + return { + -- Head + { + { " NEOVIM ", hl = { fg = colors.base, bg = colors.lavender } }, + + -- The separator gets a foreground and background fill (each have fg + bg). + -- line.sep("", lavender, lavender), + }, + + -- Tabs + line.tabs().foreach(function(tab) + -- Switch out the start separator instead of the ending one because the last separator is different + local hl = tab.is_current() and { fg = colors.lavender, bg = colors.crust, style = "bold" } or text + local sep_start = tab.number() == 1 and "" or "" + local sep_end = tab.number() == numtabs and "" or "" + + return { + line.sep(sep_start, lavender, crust), + tab.number(), + tab.name(), + line.sep(sep_end, crust, base), + hl = hl, + margin = " ", + } + end), + + -- Background + hl = base, + } + end + ''; + }; + }; + _plenary = { name = "plenary"; # For telescope pkg = pkgs.vimPlugins.plenary-nvim; @@ -1401,6 +1542,20 @@ in { lazy = true; }; + _telescope-tabs = { + name = "telescope-tabs"; + pkg = pkgs.vimUtils.buildVimPlugin { + name = "telescope-tabs"; + src = pkgs.fetchFromGitHub { + owner = "LukasPietzschmann"; + repo = "telescope-tabs"; + rev = "0a678eefcb71ebe5cb0876aa71dd2e2583d27fd3"; + sha256 = "sha256-IvxZVHPtApnzUXIQzklT2C2kAxgtAkBUq3GNxwgPdPY="; + }; + }; + lazy = true; + }; + _telescope-undo = { name = "telescope-undo"; pkg = pkgs.vimPlugins.telescope-undo-nvim; @@ -1421,6 +1576,7 @@ in { dependencies = [ _plenary _telescope-fzf-native + _telescope-tabs _telescope-undo _telescope-ui-select ]; @@ -1429,7 +1585,7 @@ in { "undo" "ui-select" "fzf" - # "lazygit" + "telescope-tabs" ]; in '' function(_, opts) @@ -1449,10 +1605,20 @@ in { }; mappings = { i = { + # TODO: This mappings throws an error. + # Doesn't matter if defined as function or like " = "which_key";. + "" = {__raw = ''function(...) return require("telescope.actions").which_key(...) end'';}; "" = {__raw = ''function(...) return require("telescope.actions").close(...) end'';}; }; }; }; + pickers = { + buffers = { + # See :h telescope.builtin.buffers() for opts + ignore_current_buffer = true; + sort_mru = true; + }; + }; }; }; @@ -1760,6 +1926,7 @@ in { autopairs # Automatic closing brackets/parens bbye # Delete buffer without closing the window or split better-escape # Escape to normal mode using "jk" + catppuccin # Colortheme (also add this here to access palettes) clangd-extensions # blink-cmp # Auto completion popups # TODO: Try this instead of cmp @@ -1793,7 +1960,7 @@ in { luasnip # Snippets ltex-extra # Additional ltex lsp support, e.g. for add-to-dictionary action - markview # Markdown support # TODO: Disable in help buffers + confiure a bit more + markview # Markdown support # TODO: Disable in help buffers (?) + confiure a bit more # narrow-region # Open a buffer restricted to the selection navbuddy # Structural file view @@ -1801,9 +1968,12 @@ in { noice # Modern UI overhaul, e.g. floating cmdline obsidian # Integration with Obsidian.md oil # File manager + quickfix-reflector # Make the quickfix list editable and saveable to apply changes rainbow-delimiters # Bracket/Paren colorization rustaceanvim # Rust integration + scope # Buffers scoped to tabpages sleuth # Heuristically set indent depth + tabby # Nicer tabline (only showing tabpages) telescope # Option picker frontend todo-comments # Highlight TODOs toggleterm # Integrated terminal diff --git a/home/modules/neovim/mappings.nix b/home/modules/neovim/mappings.nix index 3a2591e1..af709f11 100644 --- a/home/modules/neovim/mappings.nix +++ b/home/modules/neovim/mappings.nix @@ -197,13 +197,13 @@ mode = "i"; key = ""; action = ""; - options.desc = "Delete Previous Word"; # TODO: Breaks backspace multiline cursor? + options.desc = "Delete Previous Word"; # TODO: Breaks backspace in although i binding? } { mode = "i"; key = ""; action = ""; - options.desc = "Delete Previous Word"; # TODO: Breaks backspace multiline cursor? + options.desc = "Delete Previous Word"; # TODO: Breaks backspace in although i binding? } # Clipboard @@ -257,6 +257,12 @@ action = "Telescope current_buffer_fuzzy_find"; options.desc = "Grep Buffer"; } + { + mode = "v"; + key = "?"; + action = "Telescope grep_string"; + options.desc = "Find Selection"; + } { mode = "n"; key = ";"; @@ -269,12 +275,6 @@ action = ""; options.desc = "Exit Visual Mode"; } - { - mode = "v"; - key = "?"; - action = "Telescope grep_string"; - options.desc = "Find Selection"; - } ]; leader = [ @@ -362,6 +362,12 @@ action = "ObsidianSearch"; options.desc = "Obsidian Note"; } + { + mode = "n"; + key = "Q"; + action = "cexpr []"; + options.desc = "Clear Quickfix List"; + } ]; leader-help = [ @@ -449,18 +455,23 @@ action = "+buffers"; } { - # See :h telescope.builtin.buffers() for sorting opts mode = "n"; key = "bb"; - action = "Telescope buffers ignore_current_buffer=false sort_mru=true"; + action = "Telescope buffers"; options.desc = "List Buffers"; } { mode = "n"; key = ""; - action = "Telescope buffers ignore_current_buffer=false sort_mru=true"; + action = "Telescope buffers"; options.desc = "List Buffers"; } + { + mode = "n"; + key = ""; + action = "Telescope telescope-tabs list_tabs"; + options.desc = "List Tabpages"; + } { mode = "n"; key = "R"; diff --git a/home/modules/neovim/vim_opts.nix b/home/modules/neovim/vim_opts.nix index c2c1d3c7..695cee62 100644 --- a/home/modules/neovim/vim_opts.nix +++ b/home/modules/neovim/vim_opts.nix @@ -1,8 +1,4 @@ -{ - lib, - mylib, - ... -}: { +_: { showmode = false; # Status line already shows this backspace = ["indent" "eol" "start"]; termguicolors = true; # Required by multiple plugins @@ -14,8 +10,8 @@ formatexpr = "v:lua.require('conform').formatexpr()"; laststatus = 3; # Global statusline winblend = 30; # Floating popup transparency - sessionoptions = ["buffers" "curdir" "tabpages" "winsize" "help" "globals" "skiprtp" "folds"]; - showtabline = 0; # Disable tabline + sessionoptions = ["buffers" "curdir" "folds" "globals" "help" "skiprtp" "tabpages" "winsize"]; # What should be saved when creating a session + showtabline = 2; # Disable tabline with 0, show for > 1 with 1, always show with 2 conceallevel = 2; # Cursor