diff --git a/init.lua b/init.lua index 19e0153..6e5b64a 100644 --- a/init.lua +++ b/init.lua @@ -1,17 +1,9 @@ require("pika.core") require("pika.lazy") -vim.api.nvim_create_user_command("Snippets", function() - require("telesnip").snippet_picker() -end, {}) -- ─< Call the function to set the desired colorscheme >──────────────────────────────── -- ╭──────────────────────────────────────────────────────╮ -- │ themes are under ./lua/pika/plugins/colorschemes.lua │ -- ╰──────────────────────────────────────────────────────╯ --- ─< Function to apply the colorscheme >─────────────────────────────────────────────── -local function apply_colorscheme(name) - vim.cmd.colorscheme(name) -end - -apply_colorscheme("bluloco") +vim.cmd.colorscheme("oldworld") diff --git a/lua/pika/core/keymaps.lua b/lua/pika/core/keymaps.lua index ff23fe4..0772dd6 100644 --- a/lua/pika/core/keymaps.lua +++ b/lua/pika/core/keymaps.lua @@ -6,6 +6,7 @@ nomap("i", "", "") nomap("n", "", "") nomap("n", "q", "") nomap("v", "q", "") +nomap("v", "S", "") local map = vim.keymap.set @@ -16,7 +17,7 @@ map("n", "", "gcc", { desc = "comment toggle", remap = true }) map("v", "", "gc", { desc = "comment toggle", remap = true }) -- ─< telesnip >──────────────────────────────────────────────────────────────────────── -map("n", "sp", ":Snippets", { desc = "Snippets with telescope", remap = true }) +-- map("n", "S", ":Snippets", { desc = "Snippets with telescope", remap = true }) -- ─< cmd line >──────────────────────────────────────────────────────────────────────── vim.api.nvim_set_keymap("n", ":", "FineCmdline", { noremap = true }) diff --git a/lua/pika/plugins/telesnip.lua b/lua/pika/plugins/telesnip.lua new file mode 100644 index 0000000..7ce9ffc --- /dev/null +++ b/lua/pika/plugins/telesnip.lua @@ -0,0 +1,16 @@ +-- Example assuming you're configuring your plugin in lazy.nvim +return { + "https://git.k4li.de/pika/telesnip.nvim", + config = function() + -- Load your plugin + local telesnip = require("telesnip") + + -- Define the :Snippets command + vim.api.nvim_create_user_command("Snippets", function() + telesnip.snippet_picker() + end, {}) + + -- Optional: Set up a keybinding if desired + vim.keymap.set("n", "S", ":Snippets", { desc = "Open Snippet Picker" }) + end, +} diff --git a/lua/pika/plugins/todo-nvim.lua b/lua/pika/plugins/todo-nvim.lua new file mode 100644 index 0000000..52e52b6 --- /dev/null +++ b/lua/pika/plugins/todo-nvim.lua @@ -0,0 +1,9 @@ +return { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, +} diff --git a/lua/telesnip/init.lua b/lua/telesnip/init.lua deleted file mode 100644 index 2b5e9cf..0000000 --- a/lua/telesnip/init.lua +++ /dev/null @@ -1,71 +0,0 @@ -local M = {} - -local function get_snippets() - local snippets = {} - local base_path = vim.fn.stdpath("config") .. "/lua/telesnip/snippets/" - local languages = vim.fn.readdir(base_path) - - for _, lang in ipairs(languages) do - local path = base_path .. lang - local files = vim.fn.glob(path .. "/*", false, true) - for _, file in ipairs(files) do - local snippet_name = vim.fn.fnamemodify(file, ":t") - table.insert(snippets, { - name = snippet_name, - path = file, - language = lang, - }) - end - end - - return snippets -end - -M.snippet_picker = function() - local snippets = get_snippets() - - local opts = require("telescope.themes").get_dropdown({}) - require("telescope.pickers") - .new(opts, { - prompt_title = "Snippets", - finder = require("telescope.finders").new_table({ - results = snippets, - entry_maker = function(entry) - return { - value = entry, - display = entry.name, - ordinal = entry.name, - path = entry.path, - } - end, - }), - sorter = require("telescope.config").values.generic_sorter(opts), - previewer = require("telescope.previewers").new_buffer_previewer({ - define_preview = function(self, entry) - local lines = vim.fn.readfile(entry.path) - vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines) - local ext = vim.fn.fnamemodify(entry.path, ":e") - vim.api.nvim_buf_set_option(self.state.bufnr, "filetype", ext) - end, - }), - attach_mappings = function(_, map) - map("i", "", function(prompt_bufnr) - local selection = require("telescope.actions.state").get_selected_entry() - local snippet_content = vim.fn.readfile(selection.path) - - -- Close Telescope prompt - require("telescope.actions").close(prompt_bufnr) - - -- Insert snippet directly into the buffer - vim.api.nvim_put(snippet_content, "l", true, true) - - -- Notify user - print("Snippet inserted.") - end) - return true - end, - }) - :find() -end - -return M diff --git a/lua/telesnip/init.lua.old b/lua/telesnip/init.lua.old deleted file mode 100644 index 155f82d..0000000 --- a/lua/telesnip/init.lua.old +++ /dev/null @@ -1,102 +0,0 @@ -local M = {} - -local function get_snippets() - local snippets = {} - local base_path = vim.fn.stdpath("config") .. "/lua/telesnip/snippets/" - local languages = vim.fn.readdir(base_path) - - print("Base path: " .. base_path) - print("Languages found: " .. vim.inspect(languages)) - - for _, lang in ipairs(languages) do - local path = base_path .. lang - local files = vim.fn.glob(path .. "/*", false, true) - print("Files found for " .. lang .. ": " .. vim.inspect(files)) - for _, file in ipairs(files) do - local snippet_name = vim.fn.fnamemodify(file, ":t") - table.insert(snippets, { - name = snippet_name, - path = file, - language = lang, - }) - end - end - - print("Snippets found: " .. vim.inspect(snippets)) - return snippets -end - -M.snippet_picker = function() - local snippets = get_snippets() - - local opts = require("telescope.themes").get_dropdown({}) - require("telescope.pickers") - .new(opts, { - prompt_title = "Snippets", - finder = require("telescope.finders").new_table({ - results = snippets, - entry_maker = function(entry) - return { - value = entry, - display = entry.name, - ordinal = entry.name, - path = entry.path, - } - end, - }), - sorter = require("telescope.config").values.generic_sorter(opts), - previewer = require("telescope.previewers").new_buffer_previewer({ - define_preview = function(self, entry) - local lines = vim.fn.readfile(entry.path) - vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines) - local ext = vim.fn.fnamemodify(entry.path, ":e") - vim.api.nvim_buf_set_option(self.state.bufnr, "filetype", ext) - end, - }), - attach_mappings = function(_, map) - map("i", "", function(prompt_bufnr) - print("Mapping triggered") - local selection = require("telescope.actions.state").get_selected_entry() - print("Selected entry: " .. vim.inspect(selection)) - - local snippet_content = vim.fn.readfile(selection.path) - print("Snippet content (raw): " .. vim.inspect(snippet_content)) - print("Snippet content (formatted):") - for i, line in ipairs(snippet_content) do - print(string.format("%d: %s", i, line)) - end - - local current_buf = vim.api.nvim_get_current_buf() - local win = vim.api.nvim_get_current_win() - local cursor = vim.api.nvim_win_get_cursor(win) - local row, col = cursor[1] - 1, cursor[2] - - print(string.format("Inserting at buffer %d, row %d, col %d", current_buf, row, col)) - - -- Insert snippet content at the current cursor position - vim.api.nvim_buf_set_text(current_buf, row, col, row, col, snippet_content) - - -- Move cursor to the end of the inserted snippet - local new_row = row + #snippet_content - local new_col = #snippet_content[#snippet_content] - vim.api.nvim_win_set_cursor(win, { new_row, new_col }) - - print(string.format("Cursor moved to row %d, col %d", new_row, new_col)) - - -- Close Telescope prompt - require("telescope.actions").close(prompt_bufnr) - - -- Schedule entering insert mode - vim.schedule(function() - vim.cmd("stopinsert") - vim.cmd("startinsert!") - print("Entered insert mode") - end) - end) - return true - end, - }) - :find() -end - -return M diff --git a/lua/telesnip/snippets/bash/check_root.sh b/lua/telesnip/snippets/bash/check_root.sh deleted file mode 100644 index 7710618..0000000 --- a/lua/telesnip/snippets/bash/check_root.sh +++ /dev/null @@ -1,15 +0,0 @@ -# Check if the user is root and set sudo variable if necessary -check_root() { - if [[ "${EUID}" -ne 0 ]]; then - if command_exists sudo; then - echo_binfo "User is not root. Using sudo for privileged operations." - _sudo="sudo" - else - echo_error "No sudo found and you're not root! Can't install packages." - return 1 - fi - else - echo_binfo "Root access confirmed." - _sudo="" - fi -} diff --git a/lua/telesnip/snippets/bash/command_exists.sh b/lua/telesnip/snippets/bash/command_exists.sh deleted file mode 100644 index 98ded58..0000000 --- a/lua/telesnip/snippets/bash/command_exists.sh +++ /dev/null @@ -1,4 +0,0 @@ -# ─< Check if the given command exists silently >───────────────────────────────────────── -command_exists() { - command -v "$@" >/dev/null 2>&1 -} diff --git a/lua/telesnip/snippets/bash/get_ip.sh b/lua/telesnip/snippets/bash/get_ip.sh deleted file mode 100644 index a5f2bf9..0000000 --- a/lua/telesnip/snippets/bash/get_ip.sh +++ /dev/null @@ -1,4 +0,0 @@ -# ─< get the current ip as a 1 line >───────────────────────────────────────────────────── -get_ip() { - command ip a | command grep 'inet ' | command grep -v '127.0.0.1' | command awk '{print $2}' | command cut -d/ -f1 | head -n 1 -} diff --git a/lua/telesnip/snippets/bash/info_error.sh b/lua/telesnip/snippets/bash/info_error.sh deleted file mode 100644 index c52511b..0000000 --- a/lua/telesnip/snippets/bash/info_error.sh +++ /dev/null @@ -1,4 +0,0 @@ -# ─< Helper functions >───────────────────────────────────────────────────────────────── -function echo_error() { echo -e "\033[0;1;31mError: \033[0;31m\t${*}\033[0m"; } -function echo_binfo() { echo -e "\033[0;1;34mINFO: \033[0;34m\t${*}\033[0m"; } -function echo_info() { echo -e "\033[0;1;35mInfo: \033[0;35m${*}\033[0m"; } diff --git a/lua/telesnip/snippets/bash/silentexec.sh b/lua/telesnip/snippets/bash/silentexec.sh deleted file mode 100644 index 87e34a6..0000000 --- a/lua/telesnip/snippets/bash/silentexec.sh +++ /dev/null @@ -1,4 +0,0 @@ -# ─< Silent execution >───────────────────────────────────────────────────────────────── -silentexec() { - "$@" >/dev/null 2>&1 -}