feat: UI improvements

This commit is contained in:
2026-04-26 00:49:37 +02:00
parent 3cbfe566e4
commit c61efc6f5c
9 changed files with 339 additions and 188 deletions
@@ -1,6 +1,7 @@
{ themeName }: { themeName }:
'' ''
require("kanagawa").setup({ require("kanagawa").setup({
dimInactive = true,
colors = { colors = {
theme = { theme = {
all = { all = {
@@ -37,6 +38,24 @@
DiagnosticVirtualTextInfo = makeDiagnosticColor(theme.diag.info), DiagnosticVirtualTextInfo = makeDiagnosticColor(theme.diag.info),
DiagnosticVirtualTextWarn = makeDiagnosticColor(theme.diag.warning), DiagnosticVirtualTextWarn = makeDiagnosticColor(theme.diag.warning),
DiagnosticVirtualTextError = makeDiagnosticColor(theme.diag.error), DiagnosticVirtualTextError = makeDiagnosticColor(theme.diag.error),
DiagnosticVirtualLinesHint = makeDiagnosticColor(theme.diag.hint),
DiagnosticVirtualLinesInfo = makeDiagnosticColor(theme.diag.info),
DiagnosticVirtualLinesWarn = makeDiagnosticColor(theme.diag.warning),
DiagnosticVirtualLinesError = makeDiagnosticColor(theme.diag.error),
FloatBorder = { fg = theme.ui.float.fg_border, bg = theme.ui.float.bg },
NormalFloat = { fg = theme.ui.float.fg, bg = theme.ui.float.bg },
WinBar = { fg = theme.ui.fg_dim, bg = "NONE" },
WinBarNC = { fg = theme.ui.nontext, bg = theme.ui.bg_dim },
BufferLineFill = { bg = theme.ui.bg_m3 },
BufferLineBackground = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 },
BufferLineBufferSelected = { fg = theme.ui.fg, bg = theme.ui.bg, bold = true },
BufferLineModified = { fg = theme.vcs.changed, bg = theme.ui.bg_m3 },
BufferLineModifiedSelected = { fg = theme.vcs.changed, bg = theme.ui.bg },
BufferLineDiagnostic = { fg = theme.ui.nontext, bg = theme.ui.bg_m3 },
BufferLineDiagnosticSelected = { fg = theme.ui.fg_dim, bg = theme.ui.bg },
} }
end, end,
}) })
+13 -5
View File
@@ -78,9 +78,6 @@ in
kanagawa-nvim kanagawa-nvim
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects nvim-treesitter-textobjects
telescope-nvim
telescope-fzf-native-nvim
telescope-ui-select-nvim
]; ];
}; };
@@ -99,6 +96,7 @@ in
data = with pkgs.vimPlugins; [ data = with pkgs.vimPlugins; [
nvim-lspconfig nvim-lspconfig
lazydev-nvim lazydev-nvim
nvim-navic
trouble-nvim trouble-nvim
typst-preview-nvim typst-preview-nvim
]; ];
@@ -124,6 +122,8 @@ in
lazy = true; lazy = true;
data = with pkgs.vimPlugins; [ data = with pkgs.vimPlugins; [
lualine-nvim lualine-nvim
bufferline-nvim
gitsigns-nvim
zen-mode-nvim zen-mode-nvim
which-key-nvim which-key-nvim
]; ];
@@ -135,10 +135,18 @@ in
project-nvim project-nvim
]; ];
}; };
telescope = {
lazy = true;
data = with pkgs.vimPlugins; [
telescope-nvim
telescope-fzf-native-nvim
telescope-ui-select-nvim
];
};
}; };
# 4. Passing Data to Lua (Replacing nixCats.extra) # 4. Values exposed to Lua through require("nix-info").settings.
# We put these in `settings` so they appear in require('nix-info').settings
settings = { settings = {
# Hostname/ConfigDir needed for nixd # Hostname/ConfigDir needed for nixd
nixdExtras = { nixdExtras = {
@@ -1,137 +1,76 @@
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
vim.o.expandtab = true vim.o.expandtab = true
vim.o.shiftwidth = 2 vim.o.shiftwidth = 2
vim.o.tabstop = 2 vim.o.tabstop = 2
vim.o.softtabstop = 2 vim.o.softtabstop = 2
-- Make line numbers default
vim.o.number = true vim.o.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true -- vim.o.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = "a" vim.o.mouse = "a"
-- Don't show the mode, since it's already in the status line
vim.o.showmode = false vim.o.showmode = false
vim.opt.shortmess:append("Wc") vim.opt.shortmess:append("Wc")
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.schedule(function() vim.schedule(function()
vim.o.clipboard = "unnamedplus" vim.o.clipboard = "unnamedplus"
end) end)
-- Enable break indent
vim.o.breakindent = true vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true vim.o.undofile = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true vim.o.ignorecase = true
vim.o.smartcase = true vim.o.smartcase = true
-- Keep signcolumn on by default
vim.o.signcolumn = "yes" vim.o.signcolumn = "yes"
-- Decrease update time
vim.o.updatetime = 250 vim.o.updatetime = 250
-- Decrease mapped sequence wait time
vim.o.timeoutlen = 300 vim.o.timeoutlen = 300
-- Configure how new splits should be opened
vim.o.splitright = true vim.o.splitright = true
vim.o.splitbelow = true vim.o.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
--
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
-- See `:help lua-options`
-- and `:help lua-options-guide`
vim.o.list = true vim.o.list = true
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" } vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" }
-- Preview substitutions live, as you type!
vim.o.inccommand = "split" vim.o.inccommand = "split"
-- Show which line your cursor is on
vim.o.cursorline = true vim.o.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.o.scrolloff = 10 vim.o.scrolloff = 10
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)
-- See `:help 'confirm'`
vim.o.confirm = true vim.o.confirm = true
vim.o.winborder = "rounded"
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>") vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
-- Diagnostic keymaps
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" }) vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
--
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- or just use <C-\><C-n> to exit terminal mode
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" }) vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>') -- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>') -- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>') -- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>') -- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" }) vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" }) vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" }) vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" }) vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" }) -- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" }) -- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" }) -- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.hl.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text", desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), group = vim.api.nvim_create_augroup("lux-highlight-yank", { clear = true }),
callback = function() callback = function()
vim.hl.on_yank() vim.hl.on_yank()
end, end,
@@ -53,8 +53,12 @@ require("lz.n").load({
documentation = { documentation = {
auto_show = true, auto_show = true,
auto_show_delay_ms = 500, auto_show_delay_ms = 500,
window = {
border = "rounded",
},
}, },
menu = { menu = {
border = "rounded",
draw = { draw = {
columns = { { "kind_icon" }, { "label", gap = 1 } }, columns = { { "kind_icon" }, { "label", gap = 1 } },
components = { components = {
@@ -98,6 +102,9 @@ require("lz.n").load({
signature = { signature = {
enabled = true, enabled = true,
window = {
border = "rounded",
},
}, },
}) })
end, end,
@@ -3,13 +3,8 @@ require("lz.n").load({
"mini.nvim", "mini.nvim",
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
after = function() after = function()
-- Better Around/Inside textobjects
require("mini.ai").setup({ n_lines = 500 }) require("mini.ai").setup({ n_lines = 500 })
-- Add/delete/replace surroundings (brackets, quotes, etc.)
require("mini.surround").setup() require("mini.surround").setup()
-- Auto-pairs (replaces nvim-autopairs)
require("mini.pairs").setup() require("mini.pairs").setup()
local files = require("mini.files") local files = require("mini.files")
@@ -27,9 +22,7 @@ require("lz.n").load({
local hipatterns = require("mini.hipatterns") local hipatterns = require("mini.hipatterns")
hipatterns.setup({ hipatterns.setup({
highlighters = { highlighters = {
-- Highlight hex color strings (#rrggbb) using that color
hex_color = hipatterns.gen_highlighter.hex_color(), hex_color = hipatterns.gen_highlighter.hex_color(),
-- Highlight TODOs, FIXMEs, etc. (replaces todo-comments.nvim)
fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" }, fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" },
hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" },
todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" },
@@ -43,7 +36,7 @@ require("lz.n").load({
}) })
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" }, pattern = { "help", "Trouble" },
callback = function() callback = function()
vim.b.miniindentscope_disable = true vim.b.miniindentscope_disable = true
end, end,
@@ -62,4 +55,3 @@ require("lz.n").load({
event = "BufEnter", event = "BufEnter",
}, },
}) })
@@ -17,9 +17,6 @@ require("lz.n").load({
require("conform").setup({ require("conform").setup({
notify_on_error = true, notify_on_error = true,
format_on_save = function(bufnr) format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true } local disable_filetypes = { c = true, cpp = true }
if disable_filetypes[vim.bo[bufnr].filetype] then if disable_filetypes[vim.bo[bufnr].filetype] then
return nil return nil
@@ -32,11 +29,7 @@ require("lz.n").load({
end, end,
formatters_by_ft = { formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },
-- Conform can also run multiple formatters sequentially
python = { "ruff_fix", "ruff_format", "ruff_organize_imports" }, python = { "ruff_fix", "ruff_format", "ruff_organize_imports" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
}, },
formatters = { formatters = {
stylua = { stylua = {
@@ -19,7 +19,20 @@ require("lz.n").load({
after = function() after = function()
require("lazydev").setup({ require("lazydev").setup({
library = { library = {
{ words = { "nixCats", "settings" }, path = "nix-info" }, { words = { "nix%-info", "settings" }, path = "nix-info" },
},
})
end,
},
{
"nvim-navic",
after = function()
require("nvim-navic").setup({
highlight = true,
separator = " > ",
depth_limit = 5,
lsp = {
auto_attach = false,
}, },
}) })
end, end,
@@ -31,10 +44,75 @@ require("lz.n").load({
require("lz.n").trigger_load("lazydev.nvim") require("lz.n").trigger_load("lazydev.nvim")
end, end,
after = function() after = function()
vim.api.nvim_create_autocmd("LspAttach", { local telescope_plugins = {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), "project.nvim",
"telescope.nvim",
"telescope-fzf-native.nvim",
"telescope-ui-select.nvim",
}
local telescope_picker = function(picker)
return function()
require("lz.n").trigger_load(telescope_plugins)
require("telescope.builtin")[picker]()
end
end
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
vim.lsp.handlers["textDocument/signatureHelp"] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
local navic_excluded_filetypes = {
[""] = true,
help = true,
minifiles = true,
TelescopePrompt = true,
Trouble = true,
}
local function navic_enabled(bufnr)
return vim.bo[bufnr].buftype == "" and not navic_excluded_filetypes[vim.bo[bufnr].filetype]
end
_G.lux_navic_location = function()
local ok, navic = pcall(require, "nvim-navic")
if not ok or not navic.is_available() then
return ""
end
return navic.get_location()
end
local function update_winbar(winid, bufnr)
if not vim.api.nvim_win_is_valid(winid) then
return
end
local is_float = vim.api.nvim_win_get_config(winid).relative ~= ""
local winbar = ""
if not is_float and vim.b[bufnr].lux_navic_attached and navic_enabled(bufnr) then
winbar = "%{%v:lua.lux_navic_location()%}"
end
vim.api.nvim_set_option_value("winbar", winbar, { win = winid })
end
local function update_winbars_for_buffer(bufnr)
for _, winid in ipairs(vim.fn.win_findbuf(bufnr)) do
update_winbar(winid, bufnr)
end
end
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "WinEnter" }, {
group = vim.api.nvim_create_augroup("lux-navic-winbar", { clear = true }),
callback = function(args)
update_winbar(vim.api.nvim_get_current_win(), args.buf)
end,
})
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lux-lsp-attach", { clear = true }),
callback = function(args) callback = function(args)
-- Get the client and buffer from the event arguments [cite: 119]
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)
local bufnr = args.buf local bufnr = args.buf
@@ -43,23 +121,30 @@ require("lz.n").load({
vim.keymap.set(mode, keys, func, { buffer = bufnr, desc = "LSP: " .. desc }) vim.keymap.set(mode, keys, func, { buffer = bufnr, desc = "LSP: " .. desc })
end end
-- Standard LSP functions
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
map("K", vim.lsp.buf.hover, "Hover Documentation") map("K", vim.lsp.buf.hover, "Hover Documentation")
-- Telescope Mappings map("gd", telescope_picker("lsp_definitions"), "[G]oto [D]efinition")
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") map("gr", telescope_picker("lsp_references"), "[G]oto [R]eferences")
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") map("gI", telescope_picker("lsp_implementations"), "[G]oto [I]mplementation")
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") map("<leader>D", telescope_picker("lsp_type_definitions"), "Type [D]efinition")
map("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") map("<leader>ds", telescope_picker("lsp_document_symbols"), "[D]ocument [S]ymbols")
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") map("<leader>ws", telescope_picker("lsp_dynamic_workspace_symbols"), "[W]orkspace [S]ymbols")
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
if client and client:supports_method("textDocument/documentSymbol", bufnr) and navic_enabled(bufnr) then
require("lz.n").trigger_load("nvim-navic")
local ok, navic = pcall(require, "nvim-navic")
if ok then
navic.attach(client, bufnr)
vim.b[bufnr].lux_navic_attached = true
update_winbars_for_buffer(bufnr)
end
end
-- Highlight references (Document Highlight)
if client and client:supports_method("textDocument/documentHighlight", bufnr) then if client and client:supports_method("textDocument/documentHighlight", bufnr) then
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) local highlight_augroup = vim.api.nvim_create_augroup("lux-lsp-highlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = bufnr, buffer = bufnr,
group = highlight_augroup, group = highlight_augroup,
@@ -73,15 +158,14 @@ require("lz.n").load({
}) })
vim.api.nvim_create_autocmd("LspDetach", { vim.api.nvim_create_autocmd("LspDetach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), group = vim.api.nvim_create_augroup("lux-lsp-detach", { clear = true }),
callback = function(event) callback = function(event)
vim.lsp.buf.clear_references() vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event.buf }) vim.api.nvim_clear_autocmds({ group = "lux-lsp-highlight", buffer = event.buf })
end, end,
}) })
end end
-- Inlay Hints
if client and client:supports_method("textDocument/inlayHint", bufnr) then if client and client:supports_method("textDocument/inlayHint", bufnr) then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
map("<leader>th", function() map("<leader>th", function()
@@ -91,10 +175,9 @@ require("lz.n").load({
end, end,
}) })
-- 1. Setup Diagnostics (Visuals)
vim.diagnostic.config({ vim.diagnostic.config({
severity_sort = true, severity_sort = true,
-- underline = { severity = vim.diagnostic.severity.ERROR }, underline = true,
signs = { signs = {
text = { text = {
[vim.diagnostic.severity.ERROR] = "", [vim.diagnostic.severity.ERROR] = "",
@@ -103,19 +186,13 @@ require("lz.n").load({
[vim.diagnostic.severity.HINT] = "󰠠 ", [vim.diagnostic.severity.HINT] = "󰠠 ",
}, },
}, },
virtual_text = { virtual_text = false,
virtual_lines = {
current_line = true,
},
float = {
border = "rounded",
source = "if_many", source = "if_many",
spacing = 4,
prefix = "",
format = function(diagnostic)
local diagnostic_message = {
[vim.diagnostic.severity.ERROR] = diagnostic.message,
[vim.diagnostic.severity.WARN] = diagnostic.message,
[vim.diagnostic.severity.INFO] = diagnostic.message,
[vim.diagnostic.severity.HINT] = diagnostic.message,
}
return diagnostic_message[diagnostic.severity]
end,
}, },
}) })
@@ -124,7 +201,7 @@ require("lz.n").load({
Lua = { Lua = {
runtime = { version = "LuaJIT" }, runtime = { version = "LuaJIT" },
signatureHelp = { enabled = true }, signatureHelp = { enabled = true },
diagnostics = { globals = { "nixCats", "vim" } }, diagnostics = { globals = { "vim" } },
telemetry = { enabled = false }, telemetry = { enabled = false },
completion = { callSnippet = "Replace" }, completion = { callSnippet = "Replace" },
}, },
@@ -134,7 +211,6 @@ require("lz.n").load({
local settings = require("nix-info").settings local settings = require("nix-info").settings
-- Nix
vim.lsp.config("nixd", { vim.lsp.config("nixd", {
settings = { settings = {
nixd = { nixd = {
@@ -149,19 +225,11 @@ require("lz.n").load({
}) })
vim.lsp.enable("nixd") vim.lsp.enable("nixd")
-- Dafny
vim.lsp.enable("dafny") vim.lsp.enable("dafny")
-- TypeScript/JS
vim.lsp.enable("ts_ls") vim.lsp.enable("ts_ls")
-- Rust
vim.lsp.enable("rust_analyzer") vim.lsp.enable("rust_analyzer")
-- Python
vim.lsp.enable("ty") vim.lsp.enable("ty")
vim.lsp.enable("ruff") vim.lsp.enable("ruff")
vim.lsp.enable("astro") vim.lsp.enable("astro")
vim.lsp.config("tinymist", { vim.lsp.config("tinymist", {
@@ -184,6 +252,9 @@ require("lz.n").load({
after = function() after = function()
require("trouble").setup({ require("trouble").setup({
focus = true, focus = true,
preview = {
border = "rounded",
},
}) })
end, end,
}, },
@@ -1,29 +1,76 @@
local telescope_plugins = {
"project.nvim",
"telescope.nvim",
"telescope-fzf-native.nvim",
"telescope-ui-select.nvim",
}
local function load_telescope()
require("lz.n").trigger_load(telescope_plugins)
return require("telescope.builtin")
end
local function map_picker(lhs, picker, desc, opts)
vim.keymap.set("n", lhs, function()
load_telescope()[picker](opts or {})
end, { desc = desc })
end
map_picker("<leader>sh", "help_tags", "[S]earch [H]elp")
map_picker("<leader>sk", "keymaps", "[S]earch [K]eymaps")
map_picker("<leader>sf", "find_files", "[S]earch [F]iles")
map_picker("<leader>ss", "builtin", "[S]earch [S]elect Telescope")
map_picker("<leader>sw", "grep_string", "[S]earch current [W]ord")
map_picker("<leader>sg", "live_grep", "[S]earch by [G]rep")
map_picker("<leader>sd", "diagnostics", "[S]earch [D]iagnostics")
map_picker("<leader>sr", "resume", "[S]earch [R]esume")
map_picker("<leader>s.", "oldfiles", '[S]earch Recent Files ("." for repeat)')
map_picker("<leader><leader>", "buffers", "[ ] Find existing buffers")
map_picker("<leader>sn", "find_files", "[S]earch [N]eovim files", { cwd = vim.fn.stdpath("config") })
vim.keymap.set("n", "<leader>sp", function()
load_telescope()
require("telescope").extensions.projects.projects({})
end, { desc = "[S]earch [P]rojects" })
vim.keymap.set("n", "<leader>/", function()
local builtin = load_telescope()
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
winblend = 10,
previewer = false,
}))
end, { desc = "[/] Fuzzily search in current buffer" })
vim.keymap.set("n", "<leader>s/", function()
load_telescope().live_grep({
grep_open_files = true,
prompt_title = "Live Grep in Open Files",
})
end, { desc = "[S]earch [/] in Open Files" })
require("lz.n").load({ require("lz.n").load({
{ {
"project.nvim", "project.nvim",
event = { "VimEnter" }, -- Load early to set root correctly event = "VimEnter",
after = function() after = function()
require("project").setup({ require("project").setup({
-- 1. Automagically change directory to project root
manual_mode = false, manual_mode = false,
-- LSP detection
lsp = { enabled = true }, lsp = { enabled = true },
-- Files/folders that indicate a root
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "flake.nix" }, patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "flake.nix" },
-- Show hidden files in telescope
show_hidden = true, show_hidden = true,
-- When the project scope changes, change the directory
scope_chdir = "global", scope_chdir = "global",
}) })
end, end,
}, },
{
"telescope-fzf-native.nvim",
},
{
"telescope-ui-select.nvim",
},
{ {
"telescope.nvim", "telescope.nvim",
event = "VimEnter", cmd = "Telescope",
before = function() before = function()
require("lz.n").trigger_load("project.nvim") require("lz.n").trigger_load("project.nvim")
end, end,
@@ -33,6 +80,8 @@ require("lz.n").load({
require("telescope").setup({ require("telescope").setup({
defaults = { defaults = {
path_display = { "truncate" }, path_display = { "truncate" },
border = true,
borderchars = { "", "", "", "", "", "", "", "" },
layout_strategy = "horizontal", layout_strategy = "horizontal",
layout_config = { layout_config = {
prompt_position = "top", prompt_position = "top",
@@ -40,9 +89,9 @@ require("lz.n").load({
sorting_strategy = "ascending", sorting_strategy = "ascending",
mappings = { mappings = {
i = { i = {
["<C-k>"] = actions.move_selection_previous, -- Move up with Ctrl-k ["<C-k>"] = actions.move_selection_previous,
["<C-j>"] = actions.move_selection_next, -- Move down with Ctrl-j ["<C-j>"] = actions.move_selection_next,
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, -- Send to quickfix ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
}, },
}, },
}, },
@@ -53,49 +102,10 @@ require("lz.n").load({
}, },
}) })
-- Enable Telescope extensions if they are installed require("lz.n").trigger_load({ "telescope-fzf-native.nvim", "telescope-ui-select.nvim" })
pcall(require("telescope").load_extension, "projects") pcall(require("telescope").load_extension, "projects")
pcall(require("telescope").load_extension, "fzf") pcall(require("telescope").load_extension, "fzf")
pcall(require("telescope").load_extension, "ui-select") pcall(require("telescope").load_extension, "ui-select")
-- See `:help telescope.builtin`
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp" })
vim.keymap.set("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
vim.keymap.set("n", "<leader>sp", function()
require("telescope").extensions.projects.projects({})
end, { desc = "[S]earch [P]rojects" })
-- Slightly advanced example of overriding default behavior and theme
vim.keymap.set("n", "<leader>/", function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
winblend = 10,
previewer = false,
}))
end, { desc = "[/] Fuzzily search in current buffer" })
-- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set("n", "<leader>s/", function()
builtin.live_grep({
grep_open_files = true,
prompt_title = "Live Grep in Open Files",
})
end, { desc = "[S]earch [/] in Open Files" })
-- Shortcut for searching your Neovim configuration files
vim.keymap.set("n", "<leader>sn", function()
builtin.find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "[S]earch [N]eovim files" })
end, end,
}, },
}) })
@@ -19,22 +19,137 @@ require("lz.n").load({
"lualine.nvim", "lualine.nvim",
event = "VimEnter", event = "VimEnter",
after = function() after = function()
local filename = {
"filename",
path = 1,
symbols = {
modified = "",
readonly = "",
unnamed = "[No Name]",
},
}
require("lualine").setup({ require("lualine").setup({
options = { options = {
icons_enabled = true, icons_enabled = true,
globalstatus = true, globalstatus = false,
component_separators = "", component_separators = "",
section_separators = "", section_separators = "",
theme = "kanagawa",
}, },
sections = { sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch", "diagnostics" }, lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" }, lualine_c = { filename },
lualine_x = { "lsp_status" }, lualine_x = { "lsp_status" },
lualine_y = { "progress" }, lualine_y = { "progress" },
lualine_z = { "location" }, lualine_z = { "location" },
}, },
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { filename },
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
})
end,
},
{
"bufferline.nvim",
event = "VimEnter",
before = function()
require("lz.n").trigger_load("mini.nvim")
end,
after = function()
require("bufferline").setup({
options = {
mode = "buffers",
numbers = "none",
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level)
local icon = level:match("error") and "" or level:match("warning") and "" or ""
return " " .. icon .. count
end,
always_show_bufferline = true,
show_buffer_close_icons = false,
show_close_icon = false,
separator_style = "thin",
sort_by = "insert_after_current",
offsets = {
{
filetype = "minifiles",
text = "Files",
separator = true,
},
},
},
})
vim.keymap.set("n", "<leader>bn", "<cmd>BufferLineCycleNext<cr>", { desc = "[B]uffer [N]ext" })
vim.keymap.set("n", "<leader>bp", "<cmd>BufferLineCyclePrev<cr>", { desc = "[B]uffer [P]revious" })
vim.keymap.set("n", "<leader>bb", "<cmd>BufferLinePick<cr>", { desc = "[B]uffer [B]rowse" })
vim.keymap.set("n", "<leader>bd", "<cmd>bdelete<cr>", { desc = "[B]uffer [D]elete" })
end,
},
{
"gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
after = function()
require("gitsigns").setup({
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged_enable = true,
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local map = function(mode, lhs, rhs, desc, opts)
opts = opts or {}
opts.buffer = bufnr
opts.desc = desc
vim.keymap.set(mode, lhs, rhs, opts)
end
map("n", "]h", function()
if vim.wo.diff then
return "]h"
end
vim.schedule(function()
gs.nav_hunk("next")
end)
return "<Ignore>"
end, "Next git hunk", { expr = true })
map("n", "[h", function()
if vim.wo.diff then
return "[h"
end
vim.schedule(function()
gs.nav_hunk("prev")
end)
return "<Ignore>"
end, "Previous git hunk", { expr = true })
map("n", "<leader>hp", gs.preview_hunk, "Git [H]unk [P]review")
map("n", "<leader>hs", gs.stage_hunk, "Git [H]unk [S]tage")
map("n", "<leader>hr", gs.reset_hunk, "Git [H]unk [R]eset")
map("n", "<leader>hu", gs.undo_stage_hunk, "Git [H]unk [U]ndo stage")
map("n", "<leader>hS", gs.stage_buffer, "Git [H]unk [S]tage buffer")
map("n", "<leader>hR", gs.reset_buffer, "Git [H]unk [R]eset buffer")
map("v", "<leader>hs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, "Git [H]unk [S]tage")
map("v", "<leader>hr", function()
gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, "Git [H]unk [R]eset")
end,
}) })
end, end,
}, },
@@ -62,15 +177,12 @@ require("lz.n").load({
preset = "modern", preset = "modern",
delay = 200, delay = 200,
icons = { icons = {
-- set icon mappings to true if you have a Nerd Font
mappings = true, mappings = true,
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
keys = {}, keys = {},
}, },
-- Document existing key chains
spec = { spec = {
{ "<leader>b", group = "[B]uffer" },
{ "<leader>s", group = "[S]earch" }, { "<leader>s", group = "[S]earch" },
{ "<leader>t", group = "[T]oggle" }, { "<leader>t", group = "[T]oggle" },
{ "<leader>h", group = "Git [H]unk", mode = { "n", "v" } }, { "<leader>h", group = "Git [H]unk", mode = { "n", "v" } },
@@ -78,4 +190,4 @@ require("lz.n").load({
}) })
end, end,
}, },
}) })