diff --git a/.config/nvim/after/plugin/hoogle.lua b/.config/nvim/after/plugin/hoogle.lua index 56e3b1d..88e9814 100644 --- a/.config/nvim/after/plugin/hoogle.lua +++ b/.config/nvim/after/plugin/hoogle.lua @@ -1,10 +1,3 @@ -local pickers = require("telescope.pickers") -local finders = require("telescope.finders") -local conf = require("telescope.config").values -local previewers = require("telescope.previewers") -local actions = require("telescope.actions") -local action_state = require("telescope.actions.state") - local STOP_WORDS = { ["a"] = true, ["an"] = true, @@ -35,9 +28,6 @@ local function parse_query_mode(raw_query) return "type", vim.trim((query:gsub("^type:%s*", "", 1))) end - -- Heuristic: - -- - Queries that look like signatures/operators stay in type mode. - -- - Everything else defaults to text mode so plain-language search works. local looks_like_type = query:match("::") or query:match("->") or query:match("=>") @@ -169,8 +159,8 @@ local function hoogle_picker(query) return end - local results = {} - for _, entry in ipairs(decoded) do + local items = {} + for idx, entry in ipairs(decoded) do local signature = entry.item or "" local docs = entry.docs or "" local url = entry.url @@ -185,7 +175,9 @@ local function hoogle_picker(query) display = display .. " - " .. docs_one_line end - table.insert(results, { + table.insert(items, { + idx = idx, + text = signature .. " " .. (docs or ""), signature = signature, docs = docs, url = url, @@ -193,54 +185,36 @@ local function hoogle_picker(query) }) end - pickers.new({}, { - prompt_title = ("Hoogle (%s): %s"):format(mode, normalized_query), - finder = finders.new_table({ - results = results, - entry_maker = function(entry) - return { - value = entry, - display = entry.display, - ordinal = entry.signature .. " " .. (entry.docs or ""), - } - end, - }), - sorter = conf.generic_sorter({}), - previewer = previewers.new_buffer_previewer({ - define_preview = function(self, entry) - local value = entry.value or {} - local preview_lines = { value.signature or "" } - - if value.docs and value.docs ~= "" then - table.insert(preview_lines, "") - vim.list_extend(preview_lines, vim.split(value.docs, "\n", { plain = true })) - else - table.insert(preview_lines, "") - table.insert(preview_lines, "No documentation available.") - end - - if value.url and value.url ~= "" then - table.insert(preview_lines, "") - table.insert(preview_lines, value.url) - end - - vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, preview_lines) - end, - }), - attach_mappings = function(prompt_bufnr, map) - local function open_result() - local selection = action_state.get_selected_entry() - actions.close(prompt_bufnr) - if selection and selection.value and selection.value.url then - vim.ui.open(selection.value.url) - end - end - - map("i", "", open_result) - map("n", "", open_result) - return true + Snacks.picker.pick({ + source = "hoogle", + title = ("Hoogle (%s): %s"):format(mode, normalized_query), + items = items, + format = function(item) + return { { item.display, "SnacksPickerLabel" } } end, - }):find() + preview = function(ctx) + local item = ctx.item + local lines = { item.signature or "" } + if item.docs and item.docs ~= "" then + table.insert(lines, "") + vim.list_extend(lines, vim.split(item.docs, "\n", { plain = true })) + else + table.insert(lines, "") + table.insert(lines, "No documentation available.") + end + if item.url and item.url ~= "" then + table.insert(lines, "") + table.insert(lines, item.url) + end + vim.api.nvim_buf_set_lines(ctx.buf, 0, -1, false, lines) + end, + confirm = function(picker, item) + picker:close() + if item and item.url then + vim.ui.open(item.url) + end + end, + }) end vim.api.nvim_create_user_command("Hoogle", function(opts) @@ -256,4 +230,3 @@ end, { desc = "Hoogle current word" }) vim.keymap.set("n", "ht", function() vim.cmd("Hoogle " .. vim.fn.input("Hoogle type/text > ")) end, { desc = "Hoogle query" }) - diff --git a/.config/nvim/after/plugin/lspconfig.lua b/.config/nvim/after/plugin/lspconfig.lua index 0ec8b2d..486a24d 100644 --- a/.config/nvim/after/plugin/lspconfig.lua +++ b/.config/nvim/after/plugin/lspconfig.lua @@ -56,7 +56,7 @@ vim.api.nvim_create_autocmd('LspAttach', { callback = function(event) local opts = { buffer = event.buf } - vim.keymap.set('n', 'gd', function() require('telescope.builtin').lsp_definitions() end, opts) + vim.keymap.set('n', 'gd', function() Snacks.picker.lsp_definitions() end, opts) vim.keymap.set('n', 'K', function() vim.lsp.buf.hover() end, opts) vim.keymap.set('n', 'vws', function() vim.lsp.buf.workspace_symbol() end, opts) vim.keymap.set('n', 'vd', function() vim.diagnostic.open_float() end, opts) diff --git a/.config/nvim/after/plugin/mason-lspconfig.lua b/.config/nvim/after/plugin/mason-lspconfig.lua deleted file mode 100644 index d3a3e50..0000000 --- a/.config/nvim/after/plugin/mason-lspconfig.lua +++ /dev/null @@ -1,6 +0,0 @@ -require('mason').setup {} -require("mason-lspconfig").setup { - ensure_installed = { "lua_ls", - "cssls", - "eslint" }, -} diff --git a/.config/nvim/after/plugin/snacks.lua b/.config/nvim/after/plugin/snacks.lua index d6001fd..8ed33f5 100644 --- a/.config/nvim/after/plugin/snacks.lua +++ b/.config/nvim/after/plugin/snacks.lua @@ -18,5 +18,73 @@ require("snacks").setup { enabled = true, char = "│" } - } + }, + picker = { + enabled = true, + ui_select = true, + formatters = { + file = { + truncate = "left", + min_width = 160, + }, + }, + }, + dashboard = { + enabled = true, + }, + terminal = { + enabled = true, + }, } + +local picker = Snacks.picker +vim.keymap.set('n', 'pf', function() picker.files() end) +vim.keymap.set('n', 'p', function() picker.git_files() end) +vim.keymap.set('n', 'sw', function() picker.lsp_workspace_symbols() end) +vim.keymap.set('n', 'ps', function() + picker.grep({ search = vim.fn.input("Grep > "), live = false }) +end) + +local term_buf + +local function find_term_win() + if not (term_buf and vim.api.nvim_buf_is_valid(term_buf)) then return end + for _, w in ipairs(vim.api.nvim_list_wins()) do + if vim.api.nvim_win_get_buf(w) == term_buf then return w end + end +end + +local function toggle_term(fullscreen) + local win_opts = fullscreen and { + position = "float", + width = 0.98, + height = 0.98, + border = "rounded", + } or { + position = "bottom", + height = 0.2, + border = "none", + } + + local existing = find_term_win() + if existing then + local is_float = vim.api.nvim_win_get_config(existing).relative ~= "" + vim.api.nvim_win_close(existing, true) + if is_float == fullscreen then return end + end + + if term_buf and vim.api.nvim_buf_is_valid(term_buf) then + Snacks.win(vim.tbl_extend("force", win_opts, { + buf = term_buf, + enter = true, + bo = { filetype = "snacks_terminal" }, + })) + vim.cmd.startinsert() + else + local term = Snacks.terminal.toggle(nil, { win = win_opts }) + if term then term_buf = term.buf end + end +end + +vim.keymap.set({ "n", "t" }, "tt", function() toggle_term(false) end, { desc = "Terminal (split)" }) +vim.keymap.set({ "n", "t" }, "tT", function() toggle_term(true) end, { desc = "Terminal (fullscreen)" }) diff --git a/.config/nvim/after/plugin/telescope.lua b/.config/nvim/after/plugin/telescope.lua deleted file mode 100644 index d8bbeee..0000000 --- a/.config/nvim/after/plugin/telescope.lua +++ /dev/null @@ -1,17 +0,0 @@ -require('telescope').setup { - extensions = { - ["ui_select"] = { - require('telescope.themes').get_dropdown { - } - } - } -} -require('telescope').load_extension('ui-select') - -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'pf', builtin.find_files, {}) -vim.keymap.set('n', 'p', builtin.git_files, {}) -vim.keymap.set('n', 'sw', 'Telescope lsp_workspace_symbols', {}) -vim.keymap.set('n', 'ps', function() - builtin.grep_string({ search = vim.fn.input("Grep > ") }); -end) diff --git a/.config/nvim/lua/wicked/lazy.lua b/.config/nvim/lua/wicked/lazy.lua index 47d2f09..e720da6 100644 --- a/.config/nvim/lua/wicked/lazy.lua +++ b/.config/nvim/lua/wicked/lazy.lua @@ -18,10 +18,6 @@ vim.opt.rtp:prepend(lazypath) -- Setup lazy.nvim require("lazy").setup({ spec = { - { - 'nvim-telescope/telescope.nvim', - dependencies = { 'nvim-lua/plenary.nvim' } - }, { 'neanias/everforest-nvim', config = function() @@ -92,7 +88,6 @@ require("lazy").setup({ }, }, 'tpope/vim-surround', - 'nvim-telescope/telescope-ui-select.nvim', 'sphamba/smear-cursor.nvim', { "folke/persistence.nvim", @@ -123,7 +118,6 @@ require("lazy").setup({ "folke/snacks.nvim", 'lewis6991/gitsigns.nvim', 'tpope/vim-projectionist', - 'williamboman/mason-lspconfig.nvim', { "NeogitOrg/neogit", dependencies = { @@ -131,16 +125,6 @@ require("lazy").setup({ }, config = true }, - { - 'nvimdev/dashboard-nvim', - event = 'VimEnter', - config = function() - require('dashboard').setup { - -- config - } - end, - dependencies = { { 'nvim-tree/nvim-web-devicons' } } - }, 'neovim/nvim-lspconfig', { 'nvim-lualine/lualine.nvim',