Author:ptrace Comitter:ptrace Date:2025-08-23 12:13:50 UTC

go

diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4871fd5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ test.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c058e4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ The MIT License (MIT) Copyright (c) 2025 adam@p-trace.com, key.p-trace.com, Key ID: E766CB298A6D1E64 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1a3741 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ # Proc-List Shows all procedures for Jai inside the current buffer and jumps to them. ## Install & Setup ```lua use {     "worstprgr/proclist", branch = 'stable',     config = function()         require("proclist").setup({ key = "<leader>q" })     end } ``` ## Caveat Very buggy, I didn't put much effort in it. diff --git a/lua/proclist/init.lua b/lua/proclist/init.lua new file mode 100644 index 0000000..647f430 --- /dev/null +++ b/lua/proclist/init.lua @@ -0,0 +1,90 @@ local Proclist = {} function Proclist.trim(s)     return s:match("^%s*(.-)%s*$") end function Proclist.remove_braces(s)     return s:gsub("[%{%}]", "") end function Proclist.show_matches(matches)     local buf = vim.api.nvim_create_buf(false, true)     local display = {}     for _, match in ipairs(matches) do         table.insert(display, match.line_number .. ": " .. match.text)     end     vim.api.nvim_buf_set_lines(buf, 0, -1, false, display)     local width = math.floor(vim.o.columns * 0.5)     local height = math.min(#matches, math.floor(vim.o.lines * 0.3))     local row = math.floor((vim.o.lines - height) / 2)     local col = math.floor((vim.o.columns - width) / 2)     local win = vim.api.nvim_open_win(buf, true, {         relative = "editor",         width = width,         height = height,         row = row,         col = col,         style = "minimal",         border = "rounded",     })     vim.api.nvim_buf_set_option(buf, "modifiable", false)     vim.api.nvim_win_set_option(win, "cursorline", true)     local opts = { nowait = true, noremap = true, silent = true }     vim.api.nvim_buf_set_keymap(buf, "n", "<Esc>", "<cmd>close<CR>", opts)     vim.api.nvim_buf_set_keymap(buf, "n", "q", "<cmd>close<CR>", opts)     vim.api.nvim_buf_set_keymap(buf, "n", "<CR>", "", {         noremap = true, silent = true,         callback = function()             local line = vim.api.nvim_win_get_cursor(win)[1]             vim.api.nvim_win_close(win, true)             local target = matches[line]             if target then                 vim.api.nvim_win_set_cursor(0, {target.line_number, 0})             end         end     }) end function Proclist.list()     local buf = vim.api.nvim_get_current_buf()     local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)     local start_pattern = "\\w\\s*::\\s*("     local matches = {}     local i = 1     while i <= #lines do         local line = lines[i]         if vim.fn.match(line, start_pattern) >= 0 then             local start_line = i             local func_line = Proclist.trim(line)             while not func_line:find("{") and i < #lines do                 i = i + 1                 func_line = func_line .. " " .. Proclist.trim(lines[i])             end             local cleaned = Proclist.trim(Proclist.remove_braces(func_line))             table.insert(matches, { line_number = start_line, text = cleaned })         end         i = i + 1     end     Proclist.show_matches(matches) end function Proclist.setup(opts)     opts = opts or {}     local key = opts.key or "<leader>q"     vim.keymap.set("n", key, Proclist.list, { noremap = true, silent = true }) end return Proclist