diff --git a/modules/features/neovim/_kanagawa-theme.nix b/modules/features/neovim/_kanagawa-theme.nix index 5af73f4..31dd8fc 100644 --- a/modules/features/neovim/_kanagawa-theme.nix +++ b/modules/features/neovim/_kanagawa-theme.nix @@ -1,6 +1,7 @@ { themeName }: '' require("kanagawa").setup({ + dimInactive = true, colors = { theme = { all = { @@ -37,6 +38,24 @@ DiagnosticVirtualTextInfo = makeDiagnosticColor(theme.diag.info), DiagnosticVirtualTextWarn = makeDiagnosticColor(theme.diag.warning), 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, }) diff --git a/modules/features/neovim/default.nix b/modules/features/neovim/default.nix index 3942511..0675322 100644 --- a/modules/features/neovim/default.nix +++ b/modules/features/neovim/default.nix @@ -78,9 +78,6 @@ in kanagawa-nvim nvim-treesitter.withAllGrammars nvim-treesitter-textobjects - telescope-nvim - telescope-fzf-native-nvim - telescope-ui-select-nvim ]; }; @@ -99,6 +96,7 @@ in data = with pkgs.vimPlugins; [ nvim-lspconfig lazydev-nvim + nvim-navic trouble-nvim typst-preview-nvim ]; @@ -124,6 +122,8 @@ in lazy = true; data = with pkgs.vimPlugins; [ lualine-nvim + bufferline-nvim + gitsigns-nvim zen-mode-nvim which-key-nvim ]; @@ -135,10 +135,18 @@ in 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) - # We put these in `settings` so they appear in require('nix-info').settings + # 4. Values exposed to Lua through require("nix-info").settings. settings = { # Hostname/ConfigDir needed for nixd nixdExtras = { diff --git a/modules/features/neovim/lua-config/lua/options.lua b/modules/features/neovim/lua-config/lua/options.lua index 619dc96..8743adc 100644 --- a/modules/features/neovim/lua-config/lua/options.lua +++ b/modules/features/neovim/lua-config/lua/options.lua @@ -1,137 +1,76 @@ --- Set 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.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.shiftwidth = 2 vim.o.tabstop = 2 vim.o.softtabstop = 2 --- Make line numbers default 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 --- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = "a" --- Don't show the mode, since it's already in the status line vim.o.showmode = false 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.o.clipboard = "unnamedplus" end) --- Enable break indent vim.o.breakindent = true --- Save undo history 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.smartcase = true --- Keep signcolumn on by default vim.o.signcolumn = "yes" --- Decrease update time vim.o.updatetime = 250 --- Decrease mapped sequence wait time vim.o.timeoutlen = 300 --- Configure how new splits should be opened vim.o.splitright = 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.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } --- Preview substitutions live, as you type! vim.o.inccommand = "split" --- Show which line your cursor is on vim.o.cursorline = true --- Minimal number of screen lines to keep above and below the cursor. 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.winborder = "rounded" --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` vim.keymap.set("n", "", "nohlsearch") --- Diagnostic keymaps vim.keymap.set("n", "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 , 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 to exit terminal mode vim.keymap.set("t", "", "", { desc = "Exit terminal mode" }) --- TIP: Disable arrow keys in normal mode -- vim.keymap.set('n', '', 'echo "Use h to move!!"') -- vim.keymap.set('n', '', 'echo "Use l to move!!"') -- vim.keymap.set('n', '', 'echo "Use k to move!!"') -- vim.keymap.set('n', '', 'echo "Use j to move!!"') --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands vim.keymap.set("n", "", "", { desc = "Move focus to the left window" }) vim.keymap.set("n", "", "", { desc = "Move focus to the right window" }) vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) vim.keymap.set("n", "", "", { 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", "", "H", { desc = "Move window to the left" }) -- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "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", { 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() vim.hl.on_yank() end, diff --git a/modules/features/neovim/lua-config/lua/plugins/completion.lua b/modules/features/neovim/lua-config/lua/plugins/completion.lua index 49268a4..d2ad212 100644 --- a/modules/features/neovim/lua-config/lua/plugins/completion.lua +++ b/modules/features/neovim/lua-config/lua/plugins/completion.lua @@ -53,8 +53,12 @@ require("lz.n").load({ documentation = { auto_show = true, auto_show_delay_ms = 500, + window = { + border = "rounded", + }, }, menu = { + border = "rounded", draw = { columns = { { "kind_icon" }, { "label", gap = 1 } }, components = { @@ -98,6 +102,9 @@ require("lz.n").load({ signature = { enabled = true, + window = { + border = "rounded", + }, }, }) end, diff --git a/modules/features/neovim/lua-config/lua/plugins/core.lua b/modules/features/neovim/lua-config/lua/plugins/core.lua index 296a1b1..1449537 100644 --- a/modules/features/neovim/lua-config/lua/plugins/core.lua +++ b/modules/features/neovim/lua-config/lua/plugins/core.lua @@ -3,13 +3,8 @@ require("lz.n").load({ "mini.nvim", event = { "BufReadPre", "BufNewFile" }, after = function() - -- Better Around/Inside textobjects require("mini.ai").setup({ n_lines = 500 }) - - -- Add/delete/replace surroundings (brackets, quotes, etc.) require("mini.surround").setup() - - -- Auto-pairs (replaces nvim-autopairs) require("mini.pairs").setup() local files = require("mini.files") @@ -27,9 +22,7 @@ require("lz.n").load({ local hipatterns = require("mini.hipatterns") hipatterns.setup({ highlighters = { - -- Highlight hex color strings (#rrggbb) using that 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" }, hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, @@ -43,7 +36,7 @@ require("lz.n").load({ }) vim.api.nvim_create_autocmd("FileType", { - pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" }, + pattern = { "help", "Trouble" }, callback = function() vim.b.miniindentscope_disable = true end, @@ -62,4 +55,3 @@ require("lz.n").load({ event = "BufEnter", }, }) - diff --git a/modules/features/neovim/lua-config/lua/plugins/formatting.lua b/modules/features/neovim/lua-config/lua/plugins/formatting.lua index a4df311..14d6948 100644 --- a/modules/features/neovim/lua-config/lua/plugins/formatting.lua +++ b/modules/features/neovim/lua-config/lua/plugins/formatting.lua @@ -17,9 +17,6 @@ require("lz.n").load({ require("conform").setup({ notify_on_error = true, 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 } if disable_filetypes[vim.bo[bufnr].filetype] then return nil @@ -32,11 +29,7 @@ require("lz.n").load({ end, formatters_by_ft = { lua = { "stylua" }, - -- Conform can also run multiple formatters sequentially 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 = { stylua = { diff --git a/modules/features/neovim/lua-config/lua/plugins/lsp.lua b/modules/features/neovim/lua-config/lua/plugins/lsp.lua index 8e004ba..ccedea1 100644 --- a/modules/features/neovim/lua-config/lua/plugins/lsp.lua +++ b/modules/features/neovim/lua-config/lua/plugins/lsp.lua @@ -19,7 +19,20 @@ require("lz.n").load({ after = function() require("lazydev").setup({ 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, @@ -31,10 +44,75 @@ require("lz.n").load({ require("lz.n").trigger_load("lazydev.nvim") end, after = function() - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + local telescope_plugins = { + "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) - -- Get the client and buffer from the event arguments [cite: 119] local client = vim.lsp.get_client_by_id(args.data.client_id) local bufnr = args.buf @@ -43,23 +121,30 @@ require("lz.n").load({ vim.keymap.set(mode, keys, func, { buffer = bufnr, desc = "LSP: " .. desc }) end - -- Standard LSP functions map("rn", vim.lsp.buf.rename, "[R]e[n]ame") map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") map("K", vim.lsp.buf.hover, "Hover Documentation") - -- Telescope Mappings - map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") - map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - map("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") - map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") - map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") + map("gd", telescope_picker("lsp_definitions"), "[G]oto [D]efinition") + map("gr", telescope_picker("lsp_references"), "[G]oto [R]eferences") + map("gI", telescope_picker("lsp_implementations"), "[G]oto [I]mplementation") + map("D", telescope_picker("lsp_type_definitions"), "Type [D]efinition") + map("ds", telescope_picker("lsp_document_symbols"), "[D]ocument [S]ymbols") + map("ws", telescope_picker("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 - 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" }, { buffer = bufnr, group = highlight_augroup, @@ -73,15 +158,14 @@ require("lz.n").load({ }) 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) 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 - -- Inlay Hints if client and client:supports_method("textDocument/inlayHint", bufnr) then vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) map("th", function() @@ -91,10 +175,9 @@ require("lz.n").load({ end, }) - -- 1. Setup Diagnostics (Visuals) vim.diagnostic.config({ severity_sort = true, - -- underline = { severity = vim.diagnostic.severity.ERROR }, + underline = true, signs = { text = { [vim.diagnostic.severity.ERROR] = " ", @@ -103,19 +186,13 @@ require("lz.n").load({ [vim.diagnostic.severity.HINT] = "󰠠 ", }, }, - virtual_text = { + virtual_text = false, + virtual_lines = { + current_line = true, + }, + float = { + border = "rounded", 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 = { runtime = { version = "LuaJIT" }, signatureHelp = { enabled = true }, - diagnostics = { globals = { "nixCats", "vim" } }, + diagnostics = { globals = { "vim" } }, telemetry = { enabled = false }, completion = { callSnippet = "Replace" }, }, @@ -134,7 +211,6 @@ require("lz.n").load({ local settings = require("nix-info").settings - -- Nix vim.lsp.config("nixd", { settings = { nixd = { @@ -149,19 +225,11 @@ require("lz.n").load({ }) vim.lsp.enable("nixd") - -- Dafny vim.lsp.enable("dafny") - - -- TypeScript/JS vim.lsp.enable("ts_ls") - - -- Rust vim.lsp.enable("rust_analyzer") - - -- Python vim.lsp.enable("ty") vim.lsp.enable("ruff") - vim.lsp.enable("astro") vim.lsp.config("tinymist", { @@ -184,6 +252,9 @@ require("lz.n").load({ after = function() require("trouble").setup({ focus = true, + preview = { + border = "rounded", + }, }) end, }, diff --git a/modules/features/neovim/lua-config/lua/plugins/telescope.lua b/modules/features/neovim/lua-config/lua/plugins/telescope.lua index 62e2e10..aa4224d 100644 --- a/modules/features/neovim/lua-config/lua/plugins/telescope.lua +++ b/modules/features/neovim/lua-config/lua/plugins/telescope.lua @@ -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("sh", "help_tags", "[S]earch [H]elp") +map_picker("sk", "keymaps", "[S]earch [K]eymaps") +map_picker("sf", "find_files", "[S]earch [F]iles") +map_picker("ss", "builtin", "[S]earch [S]elect Telescope") +map_picker("sw", "grep_string", "[S]earch current [W]ord") +map_picker("sg", "live_grep", "[S]earch by [G]rep") +map_picker("sd", "diagnostics", "[S]earch [D]iagnostics") +map_picker("sr", "resume", "[S]earch [R]esume") +map_picker("s.", "oldfiles", '[S]earch Recent Files ("." for repeat)') +map_picker("", "buffers", "[ ] Find existing buffers") +map_picker("sn", "find_files", "[S]earch [N]eovim files", { cwd = vim.fn.stdpath("config") }) + +vim.keymap.set("n", "sp", function() + load_telescope() + require("telescope").extensions.projects.projects({}) +end, { desc = "[S]earch [P]rojects" }) + +vim.keymap.set("n", "/", 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", "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({ { "project.nvim", - event = { "VimEnter" }, -- Load early to set root correctly + event = "VimEnter", after = function() require("project").setup({ - -- 1. Automagically change directory to project root manual_mode = false, - - -- LSP detection lsp = { enabled = true }, - - -- Files/folders that indicate a root patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "flake.nix" }, - - -- Show hidden files in telescope show_hidden = true, - - -- When the project scope changes, change the directory scope_chdir = "global", }) end, }, + { + "telescope-fzf-native.nvim", + }, + { + "telescope-ui-select.nvim", + }, { "telescope.nvim", - event = "VimEnter", + cmd = "Telescope", before = function() require("lz.n").trigger_load("project.nvim") end, @@ -33,6 +80,8 @@ require("lz.n").load({ require("telescope").setup({ defaults = { path_display = { "truncate" }, + border = true, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, layout_strategy = "horizontal", layout_config = { prompt_position = "top", @@ -40,9 +89,9 @@ require("lz.n").load({ sorting_strategy = "ascending", mappings = { i = { - [""] = actions.move_selection_previous, -- Move up with Ctrl-k - [""] = actions.move_selection_next, -- Move down with Ctrl-j - [""] = actions.send_selected_to_qflist + actions.open_qflist, -- Send to quickfix + [""] = actions.move_selection_previous, + [""] = actions.move_selection_next, + [""] = 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, "fzf") pcall(require("telescope").load_extension, "ui-select") - - -- See `:help telescope.builtin` - local builtin = require("telescope.builtin") - vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp" }) - vim.keymap.set("n", "sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" }) - vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) - vim.keymap.set("n", "ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" }) - vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) - vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) - vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) - vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]esume" }) - vim.keymap.set("n", "s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) - vim.keymap.set("n", "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", "/", 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", "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", "sn", function() - builtin.find_files({ cwd = vim.fn.stdpath("config") }) - end, { desc = "[S]earch [N]eovim files" }) end, }, -}) \ No newline at end of file +}) diff --git a/modules/features/neovim/lua-config/lua/plugins/ui.lua b/modules/features/neovim/lua-config/lua/plugins/ui.lua index c9dd4aa..b433e64 100644 --- a/modules/features/neovim/lua-config/lua/plugins/ui.lua +++ b/modules/features/neovim/lua-config/lua/plugins/ui.lua @@ -19,22 +19,137 @@ require("lz.n").load({ "lualine.nvim", event = "VimEnter", after = function() + local filename = { + "filename", + path = 1, + symbols = { + modified = "●", + readonly = "", + unnamed = "[No Name]", + }, + } + require("lualine").setup({ options = { icons_enabled = true, - globalstatus = true, + globalstatus = false, component_separators = "", section_separators = "", + theme = "kanagawa", }, sections = { lualine_a = { "mode" }, - lualine_b = { "branch", "diagnostics" }, - lualine_c = { "filename" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { filename }, lualine_x = { "lsp_status" }, lualine_y = { "progress" }, 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", "bn", "BufferLineCycleNext", { desc = "[B]uffer [N]ext" }) + vim.keymap.set("n", "bp", "BufferLineCyclePrev", { desc = "[B]uffer [P]revious" }) + vim.keymap.set("n", "bb", "BufferLinePick", { desc = "[B]uffer [B]rowse" }) + vim.keymap.set("n", "bd", "bdelete", { 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 "" + 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 "" + end, "Previous git hunk", { expr = true }) + + map("n", "hp", gs.preview_hunk, "Git [H]unk [P]review") + map("n", "hs", gs.stage_hunk, "Git [H]unk [S]tage") + map("n", "hr", gs.reset_hunk, "Git [H]unk [R]eset") + map("n", "hu", gs.undo_stage_hunk, "Git [H]unk [U]ndo stage") + map("n", "hS", gs.stage_buffer, "Git [H]unk [S]tage buffer") + map("n", "hR", gs.reset_buffer, "Git [H]unk [R]eset buffer") + map("v", "hs", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "Git [H]unk [S]tage") + map("v", "hr", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "Git [H]unk [R]eset") + end, }) end, }, @@ -62,15 +177,12 @@ require("lz.n").load({ preset = "modern", delay = 200, icons = { - -- set icon mappings to true if you have a Nerd Font 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 = {}, }, - -- Document existing key chains spec = { + { "b", group = "[B]uffer" }, { "s", group = "[S]earch" }, { "t", group = "[T]oggle" }, { "h", group = "Git [H]unk", mode = { "n", "v" } }, @@ -78,4 +190,4 @@ require("lz.n").load({ }) end, }, -}) \ No newline at end of file +})