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" })
|
||||||
|
|
|
@ -1,46 +1,37 @@
|
||||||
return {
|
return {
|
||||||
{ "folke/tokyonight.nvim" },
|
{ "folke/tokyonight.nvim" },
|
||||||
{ "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,
|
"ribru17/bamboo.nvim",
|
||||||
dependencies = { 'rktjmp/lush.nvim' },
|
config = function()
|
||||||
config = function()
|
require("bamboo").setup({
|
||||||
-- your optional config goes here, see below.
|
-- ────────────────────────────< optional configuration here >─────────────────────────
|
||||||
end,
|
code_style = {
|
||||||
},
|
comments = { italic = false, bold = true },
|
||||||
{
|
conditionals = { italic = true },
|
||||||
"ribru17/bamboo.nvim",
|
keywords = { bold = true },
|
||||||
lazy = false,
|
functions = {},
|
||||||
-- priority = 1000, -- Make sure to load this before all the other start plugins.
|
namespaces = { italic = true },
|
||||||
config = function()
|
parameters = { italic = true },
|
||||||
require("bamboo").setup({
|
strings = {},
|
||||||
-- ────────────────────────────< optional configuration here >─────────────────────────
|
variables = { bold = true },
|
||||||
code_style = {
|
},
|
||||||
comments = { italic = false, bold = true },
|
-- ─< Custom Highlights -- >────────────────────────────────────────────────────────────
|
||||||
conditionals = { italic = true },
|
colors = {}, -- Override default colors
|
||||||
keywords = { bold = true },
|
highlights = { -- Override highlight groups
|
||||||
functions = {},
|
["@comment"] = { fg = "#555653" },
|
||||||
namespaces = { italic = true },
|
},
|
||||||
parameters = { italic = true },
|
})
|
||||||
strings = {},
|
end,
|
||||||
variables = { bold = true },
|
},
|
||||||
},
|
|
||||||
-- ─< Custom Highlights -- >────────────────────────────────────────────────────────────
|
|
||||||
colors = {}, -- Override default colors
|
|
||||||
highlights = { -- Override highlight groups
|
|
||||||
["@comment"] = { fg = "#555653" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,20 +1,21 @@
|
||||||
return{
|
return {
|
||||||
"echasnovski/mini.pairs",
|
"echasnovski/mini.pairs",
|
||||||
name = "mini-pairs",
|
name = "mini-pairs",
|
||||||
event = "VeryLazy",
|
lazy = false,
|
||||||
opts = {
|
event = "VeryLazy",
|
||||||
modes = { insert = true, command = true, terminal = false },
|
opts = {
|
||||||
-- skip autopair when next character is one of these
|
modes = { insert = true, command = true, terminal = false },
|
||||||
skip_next = [=[[%w%%%'%[%"%.%`%$]]=],
|
-- skip autopair when next character is one of these
|
||||||
-- skip autopair when the cursor is inside these treesitter nodes
|
skip_next = [=[[%w%%%'%[%"%.%`%$]]=],
|
||||||
skip_ts = { "string" },
|
-- skip autopair when the cursor is inside these treesitter nodes
|
||||||
-- skip autopair when next character is closing pair
|
skip_ts = { "string" },
|
||||||
-- and there are more closing pairs than opening pairs
|
-- skip autopair when next character is closing pair
|
||||||
skip_unbalanced = true,
|
-- and there are more closing pairs than opening pairs
|
||||||
-- better deal with markdown code blocks
|
skip_unbalanced = true,
|
||||||
markdown = true,
|
-- better deal with markdown code blocks
|
||||||
},
|
markdown = true,
|
||||||
config = function()
|
},
|
||||||
require("mini-pairs")
|
config = function()
|
||||||
end,
|
require("mini-pairs")
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +1,115 @@
|
||||||
local function setup_open_file_indicators()
|
local function setup_open_file_indicators()
|
||||||
-- Table to store open buffers
|
-- Table to store open buffers
|
||||||
local open_buffers = {}
|
local open_buffers = {}
|
||||||
|
|
||||||
-- Function to update open_buffers table
|
-- Function to update open_buffers table
|
||||||
local function update_open_buffers()
|
local function update_open_buffers()
|
||||||
open_buffers = {}
|
open_buffers = {}
|
||||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
if vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted then
|
if vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted then
|
||||||
local file_path = vim.api.nvim_buf_get_name(buf)
|
local file_path = vim.api.nvim_buf_get_name(buf)
|
||||||
open_buffers[file_path] = true
|
open_buffers[file_path] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update open_buffers initially
|
-- Update open_buffers initially
|
||||||
update_open_buffers()
|
update_open_buffers()
|
||||||
|
|
||||||
-- Set up autocmds to update open_buffers and refresh Neo-tree
|
-- Set up autocmds to update open_buffers and refresh Neo-tree
|
||||||
local group = vim.api.nvim_create_augroup("NeoTreeOpenFileIndicator", { clear = true })
|
local group = vim.api.nvim_create_augroup("NeoTreeOpenFileIndicator", { clear = true })
|
||||||
vim.api.nvim_create_autocmd({"BufAdd", "BufDelete", "BufWipeout"}, {
|
vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete", "BufWipeout" }, {
|
||||||
group = group,
|
group = group,
|
||||||
callback = function()
|
callback = function()
|
||||||
update_open_buffers()
|
update_open_buffers()
|
||||||
if package.loaded["neo-tree.sources.manager"] then
|
if package.loaded["neo-tree.sources.manager"] then
|
||||||
require("neo-tree.sources.manager").refresh("filesystem")
|
require("neo-tree.sources.manager").refresh("filesystem")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Custom component to display open file indicator
|
-- Custom component to display open file indicator
|
||||||
local function open_file_indicator(config, node, state)
|
local function open_file_indicator(config, node, state)
|
||||||
local result = require("neo-tree.sources.common.components").icon(config, node, state)
|
local result = require("neo-tree.sources.common.components").icon(config, node, state)
|
||||||
if node.type == "file" and open_buffers[node:get_id()] then
|
if node.type == "file" and open_buffers[node:get_id()] then
|
||||||
result.text = result.text .. " "
|
result.text = result.text .. " "
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
return open_file_indicator
|
return open_file_indicator
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"nvim-neo-tree/neo-tree.nvim",
|
"nvim-neo-tree/neo-tree.nvim",
|
||||||
opts = function()
|
opts = function()
|
||||||
return {
|
-- Set the keymap when the Neo-tree buffer is opened
|
||||||
sources = { "filesystem", "buffers", "git_status" },
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
|
pattern = "neo-tree",
|
||||||
close_if_last_window = true,
|
callback = function()
|
||||||
popup_border_style = "rounded",
|
vim.api.nvim_buf_set_keymap(
|
||||||
enable_git_status = true,
|
0,
|
||||||
enable_diagnostics = true,
|
"n",
|
||||||
filesystem = {
|
"<leader>cd",
|
||||||
bind_to_cwd = false,
|
"<cmd>FineCmdline Neotree dir=<CR>",
|
||||||
follow_current_file = { enabled = true },
|
{ noremap = true, silent = true }
|
||||||
use_libuv_file_watcher = true,
|
)
|
||||||
components = {
|
end,
|
||||||
icon = setup_open_file_indicators(),
|
})
|
||||||
},
|
return {
|
||||||
},
|
sources = { "filesystem", "buffers", "git_status" },
|
||||||
window = {
|
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
|
||||||
mappings = {
|
close_if_last_window = false,
|
||||||
["l"] = "open",
|
popup_border_style = "rounded",
|
||||||
["o"] = "open",
|
use_float = true,
|
||||||
["C-v"] = "open_split",
|
enable_git_status = true,
|
||||||
["h"] = "close_node",
|
enable_diagnostics = true,
|
||||||
["<space>"] = "none",
|
filesystem = {
|
||||||
["O"] = {
|
bind_to_cwd = false,
|
||||||
function(state)
|
follow_current_file = { enabled = true },
|
||||||
require("lazy.util").open(state.tree:get_node().path, { system = true })
|
use_libuv_file_watcher = true,
|
||||||
end,
|
components = {
|
||||||
desc = "Open with System Application",
|
icon = setup_open_file_indicators(),
|
||||||
},
|
},
|
||||||
["P"] = { "toggle_preview", config = { use_float = true } },
|
},
|
||||||
},
|
window = {
|
||||||
},
|
mappings = {
|
||||||
default_component_configs = {
|
["l"] = "open",
|
||||||
indent = {
|
["o"] = "open",
|
||||||
with_expanders = true,
|
["C-v"] = "open_split",
|
||||||
expander_collapsed = "",
|
["h"] = "close_node",
|
||||||
expander_expanded = "",
|
["<space>"] = "none",
|
||||||
expander_highlight = "NeoTreeExpander",
|
["O"] = {
|
||||||
},
|
function(state)
|
||||||
git_status = {
|
require("lazy.util").open(state.tree:get_node().path, { system = true })
|
||||||
symbols = {
|
end,
|
||||||
unstaged = "",
|
desc = "Open with System Application",
|
||||||
staged = "",
|
},
|
||||||
},
|
["P"] = { "toggle_preview", config = { use_float = true } },
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
default_component_configs = {
|
||||||
end,
|
indent = {
|
||||||
branch = "v3.x",
|
with_expanders = true,
|
||||||
dependencies = {
|
expander_collapsed = "",
|
||||||
"nvim-lua/plenary.nvim",
|
expander_expanded = "",
|
||||||
"nvim-tree/nvim-web-devicons",
|
expander_highlight = "NeoTreeExpander",
|
||||||
"3rd/image.nvim",
|
},
|
||||||
},
|
git_status = {
|
||||||
}
|
symbols = {
|
||||||
|
unstaged = "",
|
||||||
|
staged = "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
branch = "v3.x",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
"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