1

Neovim: Add tabby, quickfix-reflector, scope + update lualine config

This commit is contained in:
2024-10-12 17:32:00 +02:00
parent 4eddef07be
commit b57c88a93f
3 changed files with 208 additions and 31 deletions

View File

@ -94,7 +94,7 @@ in {
performance.byteCompileLua = { performance.byteCompileLua = {
enable = true; enable = true;
configs = true; configs = true;
initLua = true; initLua = false; # When debugging init.lua turn this off
nvimRuntime = true; nvimRuntime = true;
plugins = true; plugins = true;
}; };
@ -133,11 +133,13 @@ in {
end end
''; '';
} }
{ {
desc = "Highlight yanked regions"; desc = "Highlight yanked regions";
event = ["TextYankPost"]; event = ["TextYankPost"];
callback.__raw = "function() vim.highlight.on_yank() end"; callback.__raw = "function() vim.highlight.on_yank() end";
} }
{ {
desc = "Resize splits when Neovim is resized by the WM"; desc = "Resize splits when Neovim is resized by the WM";
event = ["VimResized"]; event = ["VimResized"];
@ -149,12 +151,14 @@ in {
end end
''; '';
} }
{ {
desc = "Disable conceal in JSON files"; desc = "Disable conceal in JSON files";
event = ["FileType"]; event = ["FileType"];
pattern = ["json" "jsonc" "json5"]; # Disable conceal for these filetypes pattern = ["json" "jsonc" "json5"]; # Disable conceal for these filetypes
callback.__raw = "function() vim.opt_local.conceallevel = 0 end"; callback.__raw = "function() vim.opt_local.conceallevel = 0 end";
} }
{ {
desc = "Attach JDTLS to Java files"; desc = "Attach JDTLS to Java files";
event = ["FileType"]; event = ["FileType"];
@ -176,12 +180,16 @@ in {
end 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"; desc = "Enable line wrapping in telescope preview";
event = ["User"]; event = ["User"];
pattern = ["TelescopePreviewerLoaded"]; pattern = ["TelescopePreviewerLoaded"];
callback.__raw = '' callback.__raw = ''
function(args) function(args)
print(vim.inspect(args))
if args.data.bufname:match("*.csv") then if args.data.bufname:match("*.csv") then
vim.wo.wrap = false vim.wo.wrap = false
else 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... # NOTE: In LazyVim require("clang_extensions").setup(opts) is called where opts is the server definition from lspconfig...
clangd-extensions = rec { clangd-extensions = rec {
name = "clangd_extensions"; name = "clangd_extensions";
@ -1014,10 +1046,40 @@ in {
}) })
end 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"]; extensions = ["fzf" "neo-tree" "toggleterm" "trouble"];
options = { options = {
theme.__raw = bubbles;
always_divide_middle = true; always_divide_middle = true;
globalstatus = true; globalstatus = true;
ignore_focus = ["neo-tree"]; ignore_focus = ["neo-tree"];
@ -1025,7 +1087,6 @@ in {
left = ""; left = "";
right = ""; right = "";
}; };
component_separators = { component_separators = {
left = ""; left = "";
right = ""; right = "";
@ -1033,18 +1094,33 @@ in {
}; };
sections = { sections = {
lualine_a = ["mode"]; # lualine_a = ["mode"];
lualine_b = ["branch" "diff" "diagnostics"]; # lualine_a.__raw = ''{ { "mode", separator = { left = "" }, right_padding = 2, } }'';
lualine_c.__raw = "{{ 'filename', path = 1, }}"; 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_x.__raw = ''{}'';
lualine_y = ["progress" "searchcount" "selectioncount"]; 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"]; lualine_z = ["location"];
}; };
# Using tabby for this
# tabline = { # tabline = {
# lualine_a = ["buffers"]; # lualine_a = ["hostname"];
# lualine_z = ["tabs"]; # 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 = { rainbow-delimiters = {
name = "rainbow-delimiters"; name = "rainbow-delimiters";
pkg = pkgs.vimPlugins.rainbow-delimiters-nvim; pkg = pkgs.vimPlugins.rainbow-delimiters-nvim;
@ -1338,7 +1420,6 @@ in {
# Don't call setup! # Don't call setup!
# TODO: Configure this in depth
init = '' init = ''
function() function()
vim.g.rustaceanvim = { vim.g.rustaceanvim = {
@ -1383,12 +1464,72 @@ in {
''; '';
}; };
scope = rec {
name = "scope";
pkg = pkgs.vimPlugins.scope-nvim;
lazy = false;
config = mkDefaultConfig name;
};
sleuth = { sleuth = {
name = "sleuth"; name = "sleuth";
pkg = pkgs.vimPlugins.vim-sleuth; pkg = pkgs.vimPlugins.vim-sleuth;
lazy = false; 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 = { _plenary = {
name = "plenary"; # For telescope name = "plenary"; # For telescope
pkg = pkgs.vimPlugins.plenary-nvim; pkg = pkgs.vimPlugins.plenary-nvim;
@ -1401,6 +1542,20 @@ in {
lazy = true; 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 = { _telescope-undo = {
name = "telescope-undo"; name = "telescope-undo";
pkg = pkgs.vimPlugins.telescope-undo-nvim; pkg = pkgs.vimPlugins.telescope-undo-nvim;
@ -1421,6 +1576,7 @@ in {
dependencies = [ dependencies = [
_plenary _plenary
_telescope-fzf-native _telescope-fzf-native
_telescope-tabs
_telescope-undo _telescope-undo
_telescope-ui-select _telescope-ui-select
]; ];
@ -1429,7 +1585,7 @@ in {
"undo" "undo"
"ui-select" "ui-select"
"fzf" "fzf"
# "lazygit" "telescope-tabs"
]; ];
in '' in ''
function(_, opts) function(_, opts)
@ -1449,10 +1605,20 @@ in {
}; };
mappings = { mappings = {
i = { i = {
# TODO: This mappings throws an error.
# Doesn't matter if defined as function or like "<C-h"> = "which_key";.
"<C-h>" = {__raw = ''function(...) return require("telescope.actions").which_key(...) end'';};
"<Esc>" = {__raw = ''function(...) return require("telescope.actions").close(...) end'';}; "<Esc>" = {__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 autopairs # Automatic closing brackets/parens
bbye # Delete buffer without closing the window or split bbye # Delete buffer without closing the window or split
better-escape # Escape to normal mode using "jk" better-escape # Escape to normal mode using "jk"
catppuccin # Colortheme (also add this here to access palettes)
clangd-extensions clangd-extensions
# blink-cmp # Auto completion popups # TODO: Try this instead of cmp # blink-cmp # Auto completion popups # TODO: Try this instead of cmp
@ -1793,7 +1960,7 @@ in {
luasnip # Snippets luasnip # Snippets
ltex-extra # Additional ltex lsp support, e.g. for add-to-dictionary action 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 # narrow-region # Open a buffer restricted to the selection
navbuddy # Structural file view navbuddy # Structural file view
@ -1801,9 +1968,12 @@ in {
noice # Modern UI overhaul, e.g. floating cmdline noice # Modern UI overhaul, e.g. floating cmdline
obsidian # Integration with Obsidian.md obsidian # Integration with Obsidian.md
oil # File manager oil # File manager
quickfix-reflector # Make the quickfix list editable and saveable to apply changes
rainbow-delimiters # Bracket/Paren colorization rainbow-delimiters # Bracket/Paren colorization
rustaceanvim # Rust integration rustaceanvim # Rust integration
scope # Buffers scoped to tabpages
sleuth # Heuristically set indent depth sleuth # Heuristically set indent depth
tabby # Nicer tabline (only showing tabpages)
telescope # Option picker frontend telescope # Option picker frontend
todo-comments # Highlight TODOs todo-comments # Highlight TODOs
toggleterm # Integrated terminal toggleterm # Integrated terminal

View File

@ -197,13 +197,13 @@
mode = "i"; mode = "i";
key = "<C-BS>"; key = "<C-BS>";
action = "<C-w>"; action = "<C-w>";
options.desc = "Delete Previous Word"; # TODO: Breaks backspace <C-v><S-i> multiline cursor? options.desc = "Delete Previous Word"; # TODO: Breaks backspace in <C-v><S-i> although i binding?
} }
{ {
mode = "i"; mode = "i";
key = "<M-BS>"; key = "<M-BS>";
action = "<C-w>"; action = "<C-w>";
options.desc = "Delete Previous Word"; # TODO: Breaks backspace <C-v><S-i> multiline cursor? options.desc = "Delete Previous Word"; # TODO: Breaks backspace in <C-v><S-i> although i binding?
} }
# Clipboard # Clipboard
@ -257,6 +257,12 @@
action = "<cmd>Telescope current_buffer_fuzzy_find<cr>"; action = "<cmd>Telescope current_buffer_fuzzy_find<cr>";
options.desc = "Grep Buffer"; options.desc = "Grep Buffer";
} }
{
mode = "v";
key = "?";
action = "<cmd>Telescope grep_string<cr>";
options.desc = "Find Selection";
}
{ {
mode = "n"; mode = "n";
key = ";"; key = ";";
@ -269,12 +275,6 @@
action = "<Esc>"; action = "<Esc>";
options.desc = "Exit Visual Mode"; options.desc = "Exit Visual Mode";
} }
{
mode = "v";
key = "?";
action = "<cmd>Telescope grep_string<cr>";
options.desc = "Find Selection";
}
]; ];
leader = [ leader = [
@ -362,6 +362,12 @@
action = "<cmd>ObsidianSearch<cr>"; action = "<cmd>ObsidianSearch<cr>";
options.desc = "Obsidian Note"; options.desc = "Obsidian Note";
} }
{
mode = "n";
key = "<leader>Q";
action = "<cmd>cexpr []<cr>";
options.desc = "Clear Quickfix List";
}
]; ];
leader-help = [ leader-help = [
@ -449,18 +455,23 @@
action = "+buffers"; action = "+buffers";
} }
{ {
# See :h telescope.builtin.buffers() for sorting opts
mode = "n"; mode = "n";
key = "<leader>bb"; key = "<leader>bb";
action = "<cmd>Telescope buffers ignore_current_buffer=false sort_mru=true<cr>"; action = "<cmd>Telescope buffers<cr>";
options.desc = "List Buffers"; options.desc = "List Buffers";
} }
{ {
mode = "n"; mode = "n";
key = "<leader><Space>"; key = "<leader><Space>";
action = "<cmd>Telescope buffers ignore_current_buffer=false sort_mru=true<cr>"; action = "<cmd>Telescope buffers<cr>";
options.desc = "List Buffers"; options.desc = "List Buffers";
} }
{
mode = "n";
key = "<leader><C-Space>";
action = "<cmd>Telescope telescope-tabs list_tabs<cr>";
options.desc = "List Tabpages";
}
{ {
mode = "n"; mode = "n";
key = "<leader>R"; key = "<leader>R";

View File

@ -1,8 +1,4 @@
{ _: {
lib,
mylib,
...
}: {
showmode = false; # Status line already shows this showmode = false; # Status line already shows this
backspace = ["indent" "eol" "start"]; backspace = ["indent" "eol" "start"];
termguicolors = true; # Required by multiple plugins termguicolors = true; # Required by multiple plugins
@ -14,8 +10,8 @@
formatexpr = "v:lua.require('conform').formatexpr()"; formatexpr = "v:lua.require('conform').formatexpr()";
laststatus = 3; # Global statusline laststatus = 3; # Global statusline
winblend = 30; # Floating popup transparency winblend = 30; # Floating popup transparency
sessionoptions = ["buffers" "curdir" "tabpages" "winsize" "help" "globals" "skiprtp" "folds"]; sessionoptions = ["buffers" "curdir" "folds" "globals" "help" "skiprtp" "tabpages" "winsize"]; # What should be saved when creating a session
showtabline = 0; # Disable tabline showtabline = 2; # Disable tabline with 0, show for > 1 with 1, always show with 2
conceallevel = 2; conceallevel = 2;
# Cursor # Cursor