diff --git a/.config/nvim/TODO.md b/.config/nvim/TODO.md index a4c9df1..f28cf26 100644 --- a/.config/nvim/TODO.md +++ b/.config/nvim/TODO.md @@ -2,16 +2,15 @@ lazy d1529f6 -- dressing to snacks.input + fzf-lua? -- telescope.nvim to fzf-lua? - ## Issues +- fzf-lua first time preview shows syntax not hl correctly - gf in terminal does not focus file (opens in background) - neotest output does not auto-scroll in edgy ## Plugins +- render-markdown.nvim - https://github.com/MagicDuck/grug-far.nvim - https://github.com/folke/persistence.nvim (nvim-lastplace captured by persist?) - https://github.com/folke/todo-comments.nvim diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 51fc646..cad0ba9 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -17,7 +17,12 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +-- https://github.com/folke/lazy.nvim require("lazy").setup({ + change_detection = { + enabled = true, + notify = false, + }, checker = { enabled = true }, dev = { path = "~/Developer", diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index c1319bc..ecccf3e 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,38 +1,36 @@ { "blink.cmp": { "branch": "main", "commit": "1cc3b1a908fbcfd15451c4772759549724f38524" }, "conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" }, - "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, "edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "2eaa30537365f6889c850bd46ef6f18ddf8fac70" }, + "fzf-lua": { "branch": "main", "commit": "8efb28fd24e9d55694460d0ac8fa147d7276d984" }, + "gitsigns.nvim": { "branch": "main", "commit": "abcd00a7d5bc1a9470cb21b023c575acade3e4db" }, "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "lush.nvim": { "branch": "main", "commit": "45a79ec4acb5af783a6a29673a999ce37f00497e" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "bac6c8bb77fe0a872719ea43c39e35c7c695f05e" }, - "neo-tree.nvim": { "branch": "main", "commit": "e6645ecfcba3e064446a6def1c10d788c9873f51" }, + "mini.nvim": { "branch": "main", "commit": "3a3178419ce9947f55708966dabf030eca40735a" }, + "neo-tree.nvim": { "branch": "main", "commit": "5185ab7d46f54322bf16d9ef7b1d34708302e2ab" }, "neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" }, "neotest-elixir": { "branch": "master", "commit": "c5067bcc3ec6a0bba7b5694fa15aeb17f16aeb3c" }, "neotest-vitest": { "branch": "main", "commit": "3e338b77700853f725856c37ff5a3cf9295bffae" }, "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, - "nvim-dap": { "branch": "master", "commit": "b768c8d0ce6da614ac17ed097bf2d94e35fe1a58" }, - "nvim-dap-ui": { "branch": "master", "commit": "e94d98649dccb6a3884b66aabc2e07beb279e535" }, + "nvim-dap": { "branch": "master", "commit": "99807078c5089ed30e0547aa4b52c5867933f426" }, + "nvim-dap-ui": { "branch": "master", "commit": "727c032a8f63899baccb42a1c26f27687e62fc5e" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, "nvim-lspconfig": { "branch": "master", "commit": "88157521e890fe7fdf18bee22438875edd6300a6" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-scrollbar": { "branch": "main", "commit": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49" }, - "nvim-treesitter": { "branch": "master", "commit": "8ca76960ae75e0a3bb231402558eb50e79433161" }, + "nvim-treesitter": { "branch": "master", "commit": "9ef2e37e1b3200004f872a536f0c8ed968b742e6" }, "nvim-treesitter-context": { "branch": "master", "commit": "d0dd7ce5a9d0be1f28086e818e52fdc5c78975df" }, "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "snacks.nvim": { "branch": "main", "commit": "14e89401da348f5d14509fca164fb7bcec83e597" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, - "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" }, + "snacks.nvim": { "branch": "main", "commit": "d2b2b7bcbf9814d61f2e8049affed750509f44e3" }, "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, "ts-comments.nvim": { "branch": "main", "commit": "872dcfa0418f4a33b7437fb4d9f4e89f2f000d74" }, "twoslash-queries.nvim": { "branch": "main", "commit": "b92622c7b71eceefabd02eef24236041069904b1" }, diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index a3a9b9e..1d701f2 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -26,7 +26,7 @@ local opt = vim.opt opt.autowrite = true -- Enable auto write opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard opt.completeopt = "menu,menuone,noselect" -opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions +opt.conceallevel = 0 -- Set to `2` to hide * markup for bold and italic, but not markers with substitutions opt.confirm = true -- Confirm to save changes before exiting modified buffer opt.cursorline = true -- Enable highlighting of the current line opt.expandtab = true -- Use spaces instead of tabs diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 79b8157..c64e31c 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -1,8 +1,18 @@ local core = require("config") local icons = core.icons -local have_make = vim.fn.executable("make") == 1 -local have_cmake = vim.fn.executable("cmake") == 1 +local open = function(command, opts) + return function() + opts = opts or {} + if opts.cmd == nil and command == "git_files" and opts.show_untracked then + opts.cmd = "git ls-files --exclude-standard --cached --others" + end + if not opts.cwd and opts.root ~= false then + opts.cwd = require("util.root").get({ buf = opts.buf }) + end + return require("fzf-lua")[command](opts) + end +end return { -- blink.cmp (https://github.com/saghen/blink.cmp) @@ -211,22 +221,6 @@ return { end, }, - -- dressing.nvim (https://github.com/stevearc/dressing.nvim) - { - "stevearc/dressing.nvim", - lazy = true, - init = function() - vim.ui.select = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.select(...) - end - vim.ui.input = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.input(...) - end - end, - }, - -- edgy.nvim (https://github.com/folke/edgy.nvim) { "folke/edgy.nvim", @@ -429,6 +423,280 @@ return { }, }, + -- fzf-lua (https://github.com/ibhagwan/fzf-lua) + { + "ibhagwan/fzf-lua", + cmd = "FzfLua", + opts = function(_, _opts) + local fzf = require("fzf-lua") + local config = fzf.config + local actions = fzf.actions + + -- Quickfix + config.defaults.keymap.builtin[""] = "preview-page-up" + config.defaults.keymap.builtin[""] = "preview-page-down" + config.defaults.keymap.fzf["ctrl-b"] = "preview-page-up" + config.defaults.keymap.fzf["ctrl-d"] = "half-page-down" + config.defaults.keymap.fzf["ctrl-f"] = "preview-page-down" + config.defaults.keymap.fzf["ctrl-q"] = "select-all+accept" + config.defaults.keymap.fzf["ctrl-u"] = "half-page-up" + config.defaults.keymap.fzf["ctrl-x"] = "jump" + + -- Trouble + if require("util.init").has("trouble.nvim") then + config.defaults.actions.files["ctrl-t"] = require("trouble.sources.fzf").actions.open + end + + -- Toggle root dir / cwd + config.defaults.actions.files["ctrl-r"] = function(_, ctx) + local o = vim.deepcopy(ctx.__call_opts) + o.root = o.root == false + o.cwd = nil + o.buf = ctx.__CTX.bufnr + open(ctx.__INFO.cmd, o) + end + config.defaults.actions.files["alt-c"] = config.defaults.actions.files["ctrl-r"] + config.set_action_helpstr(config.defaults.actions.files["ctrl-r"], "toggle-root-dir") + + local img_previewer ---@type string[]? + for _, v in ipairs({ + { cmd = "ueberzug", args = {} }, + { cmd = "chafa", args = { "{file}", "--format=symbols" } }, + { cmd = "viu", args = { "-b" } }, + }) do + if vim.fn.executable(v.cmd) == 1 then + img_previewer = vim.list_extend({ v.cmd }, v.args) + break + end + end + + return { + "default-title", + defaults = { + -- formatter = "path.filename_first", + formatter = "path.dirname_first", + }, + files = { + cwd_prompt = false, + actions = { + ["alt-i"] = { actions.toggle_ignore }, + ["alt-h"] = { actions.toggle_hidden }, + }, + file_icons = false, + git_icons = false, + fzf_opts = { + ["--history"] = vim.fn.stdpath("data") .. "/fzf-lua-files-history", + }, + }, + fzf_colors = false, + fzf_opts = { + ["--no-scrollbar"] = true, + }, + grep = { + actions = { + ["alt-i"] = { actions.toggle_ignore }, + ["alt-h"] = { actions.toggle_hidden }, + }, + file_icons = false, + fzf_opts = { + ["--history"] = vim.fn.stdpath("data") .. "/fzf-lua-grep-history", + }, + }, + lsp = { + symbols = { + symbol_hl = function(s) + return "TroubleIcon" .. s + end, + symbol_fmt = function(s) + return s:lower() .. "\t" + end, + child_prefix = false, + }, + code_actions = { + previewer = vim.fn.executable("delta") == 1 and "codeaction_native" or nil, + }, + }, + previewers = { + builtin = { + syntax = true, + treesitter = { + enabled = true, + disabled = {}, + -- nvim-treesitter-context config options + context = { + max_lines = 3, + mode = "cursor", + multiwindow = true, + }, + }, + extensions = { + ["gif"] = img_previewer, + ["jpeg"] = img_previewer, + ["jpg"] = img_previewer, + ["png"] = img_previewer, + ["webp"] = img_previewer, + }, + ueberzug_scaler = "fit_contain", + }, + }, + -- Custom LazyVim option to configure vim.ui.select + ui_select = function(fzf_opts, items) + return vim.tbl_deep_extend("force", fzf_opts, { + prompt = " ", + winopts = { + title = " " .. vim.trim((fzf_opts.prompt or "Select"):gsub("%s*:%s*$", "")) .. " ", + title_pos = "center", + }, + }, fzf_opts.kind == "codeaction" and { + winopts = { + layout = "vertical", + -- height is number of items minus 15 lines for the preview, with a max of 80% screen height + height = math.floor(math.min(vim.o.lines * 0.8 - 16, #items + 2) + 0.5) + 16, + width = 0.5, + preview = not vim.tbl_isempty(require("util.lsp").get_clients({ bufnr = 0, name = "vtsls" })) and { + layout = "vertical", + vertical = "down:15,border-top", + hidden = "hidden", + } or { + layout = "vertical", + vertical = "down:15,border-top", + }, + }, + } or { + winopts = { + width = 0.5, + -- height is number of items, with a max of 80% screen height + height = math.floor(math.min(vim.o.lines * 0.8, #items + 2) + 0.5), + }, + }) + end, + winopts = { + width = 0.8, + height = 0.8, + row = 0.5, + col = 0.5, + preview = { + scrollbar = "float", + scrollchars = { "┃", "" }, + }, + treesitter = { + enabled = true, + fzf_colors = { ["hl"] = "-1:reverse", ["hl+"] = "-1:reverse" }, + }, + }, + } + end, + config = function(_, opts) + if opts[1] == "default-title" then + -- use the same prompt for all pickers for profile `default-title` and + -- profiles that use `default-title` as base profile + local function fix(t) + t.prompt = t.prompt ~= nil and " " or nil + for _, v in pairs(t) do + if type(v) == "table" then + fix(v) + end + end + return t + end + opts = vim.tbl_deep_extend("force", fix(require("fzf-lua.profiles.default-title")), opts) + opts[1] = nil + end + require("fzf-lua").setup(opts) + end, + init = function() + require("util.init").on_very_lazy(function() + vim.ui.select = function(...) + require("lazy").load({ plugins = { "fzf-lua" } }) + local opts = require("util.init").opts("fzf-lua") or {} + require("fzf-lua").register_ui_select(opts.ui_select or nil) + return vim.ui.select(...) + end + end) + end, + keys = { + { "", "", ft = "fzf", mode = "t", nowait = true }, + { "", "", ft = "fzf", mode = "t", nowait = true }, + { + ",", + "FzfLua buffers sort_mru=true sort_lastused=true", + desc = "Switch Buffer", + }, + { "/", open("live_grep"), desc = "Grep (Root Dir)" }, + { ":", "FzfLua command_history", desc = "Command History" }, + { "", open("files"), desc = "Find Files (Root Dir)" }, + -- find + { "fb", "FzfLua buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, + { "fc", open("files", { cwd = vim.fn.stdpath("config") }), desc = "Find Config File" }, + { "ff", open("files"), desc = "Find Files (Root Dir)" }, + { "fF", open("files", { root = false }), desc = "Find Files (cwd)" }, + { "fg", "FzfLua git_files", desc = "Find Files (git-files)" }, + { "fr", "FzfLua oldfiles", desc = "Recent" }, + { "fR", open("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, + -- git + { "gc", "FzfLua git_commits", desc = "Commits" }, + { "gs", "FzfLua git_status", desc = "Status" }, + -- search + { 's"', "FzfLua registers", desc = "Registers" }, + { "sa", "FzfLua autocmds", desc = "Auto Commands" }, + { "sb", "FzfLua grep_curbuf", desc = "Buffer" }, + { "sc", "FzfLua command_history", desc = "Command History" }, + { "sC", "FzfLua commands", desc = "Commands" }, + { "sd", "FzfLua diagnostics_document", desc = "Document Diagnostics" }, + { "sD", "FzfLua diagnostics_workspace", desc = "Workspace Diagnostics" }, + { "sg", open("live_grep"), desc = "Grep (Root Dir)" }, + { "sG", open("live_grep", { root = false }), desc = "Grep (cwd)" }, + { "sh", "FzfLua help_tags", desc = "Help Pages" }, + { "sH", "FzfLua highlights", desc = "Search Highlight Groups" }, + { "sj", "FzfLua jumps", desc = "Jumplist" }, + { "sk", "FzfLua keymaps", desc = "Key Maps" }, + { "sl", "FzfLua loclist", desc = "Location List" }, + { "sM", "FzfLua man_pages", desc = "Man Pages" }, + { "sm", "FzfLua marks", desc = "Jump to Mark" }, + { "sR", "FzfLua resume", desc = "Resume" }, + { "sq", "FzfLua quickfix", desc = "Quickfix List" }, + { "sw", open("grep_cword"), desc = "Word (Root Dir)" }, + { "sW", open("grep_cword", { root = false }), desc = "Word (cwd)" }, + { "sw", open("grep_visual"), mode = "v", desc = "Selection (Root Dir)" }, + { "sW", open("grep_visual", { root = false }), mode = "v", desc = "Selection (cwd)" }, + { "uC", open("colorschemes"), desc = "Colorscheme with Preview" }, + { + "ss", + function() + require("fzf-lua").lsp_document_symbols({ + regex_filter = function(entry, ctx) + if ctx.symbols_filter == nil then + ctx.symbols_filter = core.get_kind_filter(ctx.bufnr) or false + end + if ctx.symbols_filter == false then + return true + end + return vim.tbl_contains(ctx.symbols_filter, entry.kind) + end, + }) + end, + desc = "Goto Symbol", + }, + { + "sS", + function() + require("fzf-lua").lsp_live_workspace_symbols({ + regex_filter = function(entry, ctx) + if ctx.symbols_filter == nil then + ctx.symbols_filter = core.get_kind_filter(ctx.bufnr) or false + end + if ctx.symbols_filter == false then + return true + end + return vim.tbl_contains(ctx.symbols_filter, entry.kind) + end, + }) + end, + desc = "Goto Symbol (Workspace)", + }, + }, + }, + -- lualine.nvim (https://github.com/nvim-lualine/lualine.nvim) { "nvim-lualine/lualine.nvim", @@ -441,7 +709,7 @@ return { } require("lualine").setup({ - extensions = { "neo-tree", "lazy" }, + extensions = { "neo-tree", "lazy", "fzf" }, options = { always_divide_middle = true, component_separators = "", @@ -947,7 +1215,7 @@ return { { "snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" }, { "snh", function() require("noice").cmd("history") end, desc = "Noice History" }, { "sna", function() require("noice").cmd("all") end, desc = "Noice All" }, - { "snt", function() require("noice").cmd("pick") end, desc = "Noice Picker (Telescope/FzfLua)" }, + { "snt", function() require("noice").cmd("pick") end, desc = "Noice Picker (FzfLua)" }, { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll Forward", mode = {"i", "n", "s"} }, { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll Backward", mode = {"i", "n", "s"}}, }, @@ -1642,7 +1910,7 @@ return { config = function() local scrollbar = require("scrollbar") scrollbar.setup({ - excluded_filetypes = { "neo-tree", "prompt", "TelescopePrompt", "noice", "notify" }, + excluded_filetypes = { "fzf_preview", "neo-tree", "noice", "notify", "prompt" }, handlers = { cursor = false, diagnostic = true, @@ -1856,212 +2124,6 @@ return { end, }, - -- telescope (https://github.com/nvim-telescope/telescope.nvim) - { - "nvim-telescope/telescope.nvim", - cmd = { "Telescope" }, - version = false, -- telescope did only one release, so use HEAD for now - dependencies = { - -- https://github.com/nvim-lua/plenary.nvim - "nvim-lua/plenary.nvim", - -- https://github.com/nvim-telescope/telescope-fzf-native.nvim - { - "nvim-telescope/telescope-fzf-native.nvim", - build = have_make and "make" - or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", - enabled = have_make or have_cmake, - config = function(plugin) - require("util.init").on_load("telescope.nvim", function() - local ok, err = pcall(require("telescope").load_extension, "fzf") - if not ok then - local lib = plugin.dir .. "/build/libfzf." .. (require("util.init").is_win() and "dll" or "so") - if not vim.uv.fs_stat(lib) then - require("util.init").warn("`telescope-fzf-native.nvim` not built. Rebuilding...") - require("lazy").build({ plugins = { plugin }, show = false }):wait(function() - require("util.init").info("Rebuilding `telescope-fzf-native.nvim` done.\nPlease restart Neovim.") - end) - else - require("util.init").error("Failed to load `telescope-fzf-native.nvim`:\n" .. err) - end - end - end) - end, - }, - }, - -- stylua: ignore - keys = { - { - ",", - "Telescope buffers sort_mru=true sort_lastused=true", - desc = "Switch Buffer", - }, - { "/", " Telescope live_grep", desc = "Grep" }, - { ":", "Telescope command_history", desc = "Command History" }, - -- find - { "fb", "Telescope buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, - { "ff", "Telescope find_files", desc = "Find Files" }, - -- { "fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" }, - { "fg", "Telescope git_files", desc = "Find Files (git-files)" }, - { "fr", "Telescope oldfiles", desc = "Recent" }, - -- { "fR", LazyVim.pick("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, - -- git - { "gc", "Telescope git_commits", desc = "Commits" }, - { "gs", "Telescope git_status", desc = "Status" }, - -- search - { 's"', "Telescope registers", desc = "Registers" }, - { "sa", "Telescope autocommands", desc = "Auto Commands" }, - { "sb", "Telescope current_buffer_fuzzy_find", desc = "Buffer" }, - { "sc", "Telescope command_history", desc = "Command History" }, - { "sC", "Telescope commands", desc = "Commands" }, - { "sd", "Telescope diagnostics bufnr=0", desc = "Document Diagnostics" }, - { "sD", "Telescope diagnostics", desc = "Workspace Diagnostics" }, - { "sg", "Telescope live_grep", desc = "Grep" }, - -- { "sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" }, - { "sh", "Telescope help_tags", desc = "Help Pages" }, - { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, - { "sj", "Telescope jumplist", desc = "Jumplist" }, - { "sk", "Telescope keymaps", desc = "Key Maps" }, - { "sl", "Telescope loclist", desc = "Location List" }, - { "sM", "Telescope man_pages", desc = "Man Pages" }, - { "sm", "Telescope marks", desc = "Jump to Mark" }, - { "so", "Telescope vim_options", desc = "Options" }, - { "sR", "Telescope resume", desc = "Resume" }, - { "sq", "Telescope quickfix", desc = "Quickfix List" }, - { "sw", function () require('telescope.builtin').grep_string({ word_match = "-w" }) end, desc = "Word" }, - -- { "sW", LazyVim.pick("grep_string", { root = false, word_match = "-w" }), desc = "Word (cwd)" }, - { "sw", "Telescope grep_string", mode = "v", desc = "Selection" }, - -- { "sW", LazyVim.pick("grep_string", { root = false }), mode = "v", desc = "Selection (cwd)" }, - { "uC", function () require('telescope.builtin').colorscheme({ enable_preview = true }) end, desc = "Colorscheme with Preview" }, - { - "ss", - function() - require("telescope.builtin").lsp_document_symbols({ - symbols = require("util.init").get_kind_filter(), - }) - end, - desc = "Goto Symbol", - }, - { - "sS", - function() - require("telescope.builtin").lsp_dynamic_workspace_symbols({ - symbols = require("util.init").get_kind_filter(), - }) - end, - desc = "Goto Symbol (Workspace)", - }, - }, - opts = function() - local actions = require("telescope.actions") - - local open_with_trouble = function(...) - return require("trouble.sources.telescope").open(...) - end - - local function find_command() - if 1 == vim.fn.executable("rg") then - return { "rg", "--files", "--color", "never", "-g", "!.git" } - elseif 1 == vim.fn.executable("fd") then - return { "fd", "--type", "f", "--color", "never", "-E", ".git" } - elseif 1 == vim.fn.executable("fdfind") then - return { "fdfind", "--type", "f", "--color", "never", "-E", ".git" } - elseif 1 == vim.fn.executable("find") and vim.fn.has("win32") == 0 then - return { "find", ".", "-type", "f" } - elseif 1 == vim.fn.executable("where") then - return { "where", "/r", ".", "*" } - end - end - - local function flash(prompt_bufnr) - require("flash").jump({ - pattern = "^", - label = { after = { 0, 0 } }, - search = { - mode = "search", - exclude = { - function(win) - return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "TelescopeResults" - end, - }, - }, - action = function(match) - local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr) - picker:set_selection(match.pos[1] - 1) - end, - }) - end - - return { - defaults = { - border = true, - borderchars = { - prompt = { "─", "│", " ", "│", "╭", "╮", "│", "│" }, - results = { "─", "│", "─", "│", "├", "┤", "╯", "╰" }, - preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - }, - get_selection_window = function() - require("edgy").goto_main() - return 0 - end, - git_worktrees = core.worktrees, - mappings = { - i = { - [""] = open_with_trouble, - [""] = actions.preview_scrolling_down, - [""] = actions.preview_scrolling_up, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = flash, - }, - n = { - q = actions.close, - s = flash, - }, - }, - layout_strategy = "center", - layout_config = { - height = function(_, _, max_lines) - return math.min(max_lines, 15) - end, - preview_cutoff = 1, - width = function(_, max_columns, _) - return math.min(max_columns, 80) - end, - }, - preview = { - treesitter = true, - }, - prompt_prefix = icons.misc.PromptPrefix .. " ", - results_title = false, - selection_caret = "→ ", - sorting_strategy = "ascending", - vimgrep_arguments = { - "rg", - "--color=never", - "--column", - "-g", - "!.git", - "--hidden", - "--line-number", - "--no-heading", - "--smart-case", - "--with-filename", - }, - }, - pickers = { - find_files = { - find_command = find_command, - hidden = true, - }, - buffers = { - ignore_current_buffer = true, - sort_lastused = true, - }, - }, - } - end, - }, - -- trouble.nvim (https://github.com/folke/trouble.nvim) { "folke/trouble.nvim", diff --git a/.config/nvim/lua/util/keymaps.lua b/.config/nvim/lua/util/keymaps.lua index 2a2ecda..8d60cc4 100644 --- a/.config/nvim/lua/util/keymaps.lua +++ b/.config/nvim/lua/util/keymaps.lua @@ -11,10 +11,10 @@ function M.get() -- stylua: ignore M._keys = { { "cl", "LspInfo", desc = "Lsp Info" }, - { "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" }, - { "gr", "Telescope lsp_references", desc = "References", nowait = true }, - { "gI", function() require("telescope.builtin").lsp_implementations({ reuse_win = true }) end, desc = "Goto Implementation" }, - { "gy", function() require("telescope.builtin").lsp_type_definitions({ reuse_win = true }) end, desc = "Goto T[y]pe Definition" }, + { "gd", "FzfLua lsp_definitions jump_to_single_result=true ignore_current_line=true", desc = "Goto Definition", has = "definition" }, + { "gr", "FzfLua lsp_references jump_to_single_result=true ignore_current_line=true", desc = "References", nowait = true }, + { "gI", "FzfLua lsp_implementations jump_to_single_result=true ignore_current_line=true", desc = "Goto Implementation" }, + { "gy", "FzfLua lsp_typedefs jump_to_single_result=true ignore_current_line=true", desc = "Goto T[y]pe Definition" }, { "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" }, { "\\", function() return vim.lsp.buf.hover() end, desc = "Hover" }, { "gK", function() return vim.lsp.buf.signature_help() end, desc = "Signature Help", has = "signatureHelp" }, diff --git a/.config/nvim/lua/util/root.lua b/.config/nvim/lua/util/root.lua index bf10ca9..ed0ecc0 100644 --- a/.config/nvim/lua/util/root.lua +++ b/.config/nvim/lua/util/root.lua @@ -48,7 +48,6 @@ function M.detectors.lsp(buf) end, roots) end ----@param patterns string[]|string function M.detectors.pattern(buf, patterns) patterns = type(patterns) == "string" and { patterns } or patterns local path = M.bufpath(buf) or vim.uv.cwd()