diff --git a/.config/nvim/after/plugin/codecompanion.lua b/.config/nvim/after/plugin/codecompanion.lua index 21a6651..ffdd2f2 100644 --- a/.config/nvim/after/plugin/codecompanion.lua +++ b/.config/nvim/after/plugin/codecompanion.lua @@ -29,7 +29,38 @@ require('codecompanion').setup({ interactions = { chat = { adapter = "codex", - model = "gpt-5" + model = "gpt-5", + + keymaps = { + yolo_mode = false, + }, + + tools = { + ["insert_edit_into_file"] = { + opts = { + require_approval_before = { + buffer = true, -- ask before editing current buffer + file = true, -- ask before editing files + }, + require_confirmation_after = true, + allowed_in_yolo_mode = false, + }, + }, + ["create_file"] = { + opts = { + require_approval_before = true, + require_cmd_approval = true, + allowed_in_yolo_mode = false, + }, + }, + ["delete_file"] = { + opts = { + require_approval_before = true, + require_cmd_approval = true, + allowed_in_yolo_mode = false, + }, + }, + }, }, } }) diff --git a/.config/nvim/after/plugin/hoogle.lua b/.config/nvim/after/plugin/hoogle.lua index 4ee417f..a28f18b 100644 --- a/.config/nvim/after/plugin/hoogle.lua +++ b/.config/nvim/after/plugin/hoogle.lua @@ -1,6 +1,7 @@ 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") @@ -36,7 +37,7 @@ local function hoogle_picker(query) return end - local cmd = { "hoogle", "--count=200" } + local cmd = { "hoogle", "--count=200", "--json" } if mode == "text" then table.insert(cmd, "--text") end @@ -48,17 +49,73 @@ local function hoogle_picker(query) return end + local decoded = nil + local ok, parsed = pcall(vim.json.decode, table.concat(lines, "\n")) + if ok and type(parsed) == "table" then + decoded = parsed + else + vim.notify("hoogle returned unexpected output", vim.log.levels.ERROR) + return + end + local results = {} - for _, line in ipairs(lines) do - if line ~= "" and not line:match("^%d+ results found") then - table.insert(results, line) + for _, entry in ipairs(decoded) do + local signature = entry.item or "" + local docs = entry.docs or "" + local url = entry.url + local docs_one_line = vim.trim((docs:gsub("%s+", " "))) + + if #docs_one_line > 140 then + docs_one_line = docs_one_line:sub(1, 137) .. "..." end + + local display = signature + if docs_one_line ~= "" then + display = display .. " - " .. docs_one_line + end + + table.insert(results, { + signature = signature, + docs = docs, + url = url, + display = display, + }) end pickers.new({}, { prompt_title = ("Hoogle (%s): %s"):format(mode, normalized_query), - finder = finders.new_table({ results = results, }), + 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() diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 0038c64..de9e056 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -9,7 +9,6 @@ "gitlinker.nvim": { "branch": "master", "commit": "bbe2a1254fc8fce21f3bbf9a020266a1c49799f7" }, "gitsigns.nvim": { "branch": "main", "commit": "9f3c6dd7868bcc116e9c1c1929ce063b978fa519" }, "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, - "hererocks": { "branch": "master", "commit": "3db37265c3839cbd4d27fc73f92fa7b58bc3a76f" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "a324581a3c83fdacdb9804b79de1cbe00ce18550" }, @@ -29,7 +28,7 @@ "oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" }, "persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "render-markdown.nvim": { "branch": "main", "commit": "1c958131c083c8557ea499fdb08c88b8afb05c4e" }, + "render-markdown.nvim": { "branch": "main", "commit": "1641b434bda26e0f4e3610985b3357fc213cf834" }, "roslyn.nvim": { "branch": "main", "commit": "7deb9bb5b6afcb3c03c70741c6d364ffd8b59bda" }, "smear-cursor.nvim": { "branch": "main", "commit": "c85bdbb25db096fbcf616bc4e1357bd61fe2c199" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },