addet plugin telesnip and some other changes
This commit is contained in:
parent
84adb02beb
commit
ad33734063
9 changed files with 258 additions and 161 deletions
3
init.lua
3
init.lua
|
@ -1,5 +1,8 @@
|
||||||
require("pika.core")
|
require("pika.core")
|
||||||
require("pika.lazy")
|
require("pika.lazy")
|
||||||
|
vim.api.nvim_create_user_command("Snippets", function()
|
||||||
|
require("telesnip").snippet_picker()
|
||||||
|
end, {})
|
||||||
|
|
||||||
-- ─< Call the function to set the desired colorscheme >────────────────────────────────
|
-- ─< Call the function to set the desired colorscheme >────────────────────────────────
|
||||||
-- ╭──────────────────────────────────────────────────────╮
|
-- ╭──────────────────────────────────────────────────────╮
|
||||||
|
|
|
@ -17,6 +17,7 @@ map("v", "<S-c>", "gc", { desc = "comment toggle", remap = true })
|
||||||
|
|
||||||
-- ─< cmd line >────────────────────────────────────────────────────────────────────────
|
-- ─< cmd line >────────────────────────────────────────────────────────────────────────
|
||||||
vim.api.nvim_set_keymap("n", ":", "<cmd>FineCmdline<CR>", { noremap = true })
|
vim.api.nvim_set_keymap("n", ":", "<cmd>FineCmdline<CR>", { noremap = true })
|
||||||
|
map("n", "T", "<cmd>FineCmdline<CR>")
|
||||||
|
|
||||||
-- ─< Terminal >────────────────────────────────────────────────────────────────────────
|
-- ─< Terminal >────────────────────────────────────────────────────────────────────────
|
||||||
map("t", "<C-x>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" })
|
map("t", "<C-x>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" })
|
||||||
|
|
|
@ -3,25 +3,16 @@ return {
|
||||||
{ "luisiacc/gruvbox-baby" },
|
{ "luisiacc/gruvbox-baby" },
|
||||||
{ "zootedb0t/citruszest.nvim" },
|
{ "zootedb0t/citruszest.nvim" },
|
||||||
-- { "catppuccin/nvim", name = "catppuccin" },
|
-- { "catppuccin/nvim", name = "catppuccin" },
|
||||||
-- { "rose-pine/neovim" },
|
-- { "rose-pine/neovim" , name = "rose-pine" },
|
||||||
{ "jacoborus/tender.vim" },
|
{ "jacoborus/tender.vim" },
|
||||||
{ "sontungexpt/witch" },
|
{ "sontungexpt/witch" },
|
||||||
{ 'AlexvZyl/nordic.nvim' },
|
{ "AlexvZyl/nordic.nvim" },
|
||||||
{ "eldritch-theme/eldritch.nvim" },
|
{ "eldritch-theme/eldritch.nvim" },
|
||||||
{ 'kartikp10/noctis.nvim' },
|
{ "kartikp10/noctis.nvim" },
|
||||||
{ 'shrikecode/kyotonight.vim' },
|
{ "shrikecode/kyotonight.vim" },
|
||||||
{
|
{ "uloco/bluloco.nvim", dependencies = { "rktjmp/lush.nvim" } },
|
||||||
'uloco/bluloco.nvim',
|
|
||||||
lazy = false,
|
|
||||||
dependencies = { 'rktjmp/lush.nvim' },
|
|
||||||
config = function()
|
|
||||||
-- your optional config goes here, see below.
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ribru17/bamboo.nvim",
|
"ribru17/bamboo.nvim",
|
||||||
lazy = false,
|
|
||||||
-- priority = 1000, -- Make sure to load this before all the other start plugins.
|
|
||||||
config = function()
|
config = function()
|
||||||
require("bamboo").setup({
|
require("bamboo").setup({
|
||||||
-- ────────────────────────────< optional configuration here >─────────────────────────
|
-- ────────────────────────────< optional configuration here >─────────────────────────
|
||||||
|
|
|
@ -2,5 +2,5 @@ return {
|
||||||
"nvim-lua/plenary.nvim", -- lua functions that many plugins use
|
"nvim-lua/plenary.nvim", -- lua functions that many plugins use
|
||||||
"christoomey/vim-tmux-navigator", -- tmux & split window navigation
|
"christoomey/vim-tmux-navigator", -- tmux & split window navigation
|
||||||
"dstein64/nvim-scrollview",
|
"dstein64/nvim-scrollview",
|
||||||
{ 'echasnovski/mini.surround', version = false },
|
"folke/lsp-colors.nvim",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
return {
|
return {
|
||||||
"echasnovski/mini.pairs",
|
"echasnovski/mini.pairs",
|
||||||
name = "mini-pairs",
|
name = "mini-pairs",
|
||||||
|
lazy = false,
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = {
|
opts = {
|
||||||
modes = { insert = true, command = true, terminal = false },
|
modes = { insert = true, command = true, terminal = false },
|
||||||
|
|
|
@ -44,11 +44,25 @@ return {
|
||||||
{
|
{
|
||||||
"nvim-neo-tree/neo-tree.nvim",
|
"nvim-neo-tree/neo-tree.nvim",
|
||||||
opts = function()
|
opts = function()
|
||||||
|
-- Set the keymap when the Neo-tree buffer is opened
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "neo-tree",
|
||||||
|
callback = function()
|
||||||
|
vim.api.nvim_buf_set_keymap(
|
||||||
|
0,
|
||||||
|
"n",
|
||||||
|
"<leader>cd",
|
||||||
|
"<cmd>FineCmdline Neotree dir=<CR>",
|
||||||
|
{ noremap = true, silent = true }
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
})
|
||||||
return {
|
return {
|
||||||
sources = { "filesystem", "buffers", "git_status" },
|
sources = { "filesystem", "buffers", "git_status" },
|
||||||
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
|
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
|
||||||
close_if_last_window = true,
|
close_if_last_window = false,
|
||||||
popup_border_style = "rounded",
|
popup_border_style = "rounded",
|
||||||
|
use_float = true,
|
||||||
enable_git_status = true,
|
enable_git_status = true,
|
||||||
enable_diagnostics = true,
|
enable_diagnostics = true,
|
||||||
filesystem = {
|
filesystem = {
|
||||||
|
@ -88,7 +102,7 @@ return {
|
||||||
staged = "",
|
staged = "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
branch = "v3.x",
|
branch = "v3.x",
|
||||||
|
@ -97,5 +111,5 @@ return {
|
||||||
"nvim-tree/nvim-web-devicons",
|
"nvim-tree/nvim-web-devicons",
|
||||||
"3rd/image.nvim",
|
"3rd/image.nvim",
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
return{
|
|
||||||
{
|
|
||||||
'renerocksai/telekasten.nvim',
|
|
||||||
dependencies = {'nvim-telescope/telescope.nvim'}
|
|
||||||
},
|
|
||||||
}
|
|
78
lua/telesnip/init.lua
Normal file
78
lua/telesnip/init.lua
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function get_snippets()
|
||||||
|
local snippets = {}
|
||||||
|
local base_path = vim.fn.stdpath("config") .. "/lua/telesnip/snippets/"
|
||||||
|
local languages = { "bash", "lua", "fish" } -- Extend this as needed
|
||||||
|
|
||||||
|
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)
|
||||||
|
-- Read the snippet file content
|
||||||
|
local lines = vim.fn.readfile(entry.path)
|
||||||
|
|
||||||
|
-- Set the buffer's lines
|
||||||
|
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines)
|
||||||
|
|
||||||
|
-- Get file extension for syntax highlighting
|
||||||
|
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", "<CR>", function(prompt_bufnr)
|
||||||
|
local selection = require("telescope.actions.state").get_selected_entry()
|
||||||
|
local snippet_content = vim.fn.readfile(selection.path)
|
||||||
|
local current_buf = vim.api.nvim_get_current_buf()
|
||||||
|
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
|
||||||
|
-- Insert snippet content at the current line
|
||||||
|
vim.api.nvim_buf_set_lines(current_buf, row - 1, row - 1, false, snippet_content)
|
||||||
|
|
||||||
|
-- Check if the user is in normal mode, and switch to insert mode
|
||||||
|
if vim.fn.mode() == "n" then
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("i", true, false, true), "n", true)
|
||||||
|
end
|
||||||
|
require("telescope.actions").close(prompt_bufnr)
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
15
lua/telesnip/snippets/bash/check_root.sh
Normal file
15
lua/telesnip/snippets/bash/check_root.sh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# 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
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue