update: fish, yazi, nvim

This commit is contained in:
2026-07-29 02:07:13 +02:00
parent 7cd7d746e7
commit 340b955bc5
30 changed files with 1345 additions and 710 deletions
-1
View File
@@ -7,7 +7,6 @@ default_roles:
- yazi
desktop_roles:
- ags
- alacritty
- discord
- hypr
+29 -12
View File
@@ -21,6 +21,13 @@ if test -d ~/.local/bin
end
end
# Add ~/go/bin to PATH
if test -d ~/go/bin
if not contains -- ~/go/bin $PATH
set -p PATH ~/go/bin
end
end
## Plugin configuration
# Set settings for https://github.com/franciscolourenco/done
set -U __done_min_cmd_duration 10000
@@ -39,7 +46,7 @@ end
## Functions
# Fish command history
function history
builtin history --show-time='%F %T '
builtin history --reverse --show-time='%F %T '
end
function ba --argument filename
@@ -54,7 +61,7 @@ function cp_bar
kill $cpid &> /dev/null
end
function unzip -a input_file
function unzipc -a input_file
if test -z "$input_file"
echo "Usage: unzip <filename.zip>"
return 1
@@ -70,7 +77,7 @@ function unzip -a input_file
command unzip "$input_file" -d "$folder_name" && echo "File '$input_file' successfully extracted to '$folder_name/'"
end
function untar -a input_file
function untarc -a input_file
if test -z "$input_file"
echo "Usage: untar <filename.zip>"
return 1
@@ -114,13 +121,21 @@ function mvn-run -a mainClass -d "Run your current maven project"
end
# Yazi wrapper
function ya
set tmp (mktemp -t "yazi-cwd.XXXXX")
yazi $argv --cwd-file="$tmp"
if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
cd "$cwd"
function y
set tmp (mktemp -t "yazi-cwd.XXXXXX")
yazi $argv --cwd-file="$tmp"
if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
builtin cd -- "$cwd"
end
rm -f -- "$tmp"
end
# Convert webm to opus
function w2o
for f in *.webm
ffmpeg -i "$f" -map 0:a:0 -c:a copy (path change-extension opus "$f")
and rm "$f"
end
rm -f -- "$tmp"
end
## Aliases
@@ -155,7 +170,7 @@ alias nano=nvim
alias cls='clear'
alias please='sudo'
alias ip='ip -color'
alias wip=curl https://ipinfo.io/ip
alias wip='curl https://ipinfo.io/ip'
alias mkdirs='mkdir --parents'
alias grubup="sudo update-grub"
alias fixpacman="sudo rm /var/lib/pacman/db.lck"
@@ -178,8 +193,10 @@ alias bigpkg="expac -H M '%m\t%n' | sort -h | nl" # Sort installed packages ac
alias gitpkg='pacman -Q | grep -i "\-git" | wc -l' # List amount of -git packages
alias cleanup='sudo pacman -Rns (pacman -Qtdq)' # Cleanup orphaned packages
alias jctl="journalctl -p 3 -xb" # Get the error messages from journalctl
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl" # Recent installed packages
alias h="cliphist list | fzf | cliphist decode | wl-copy"
alias ripp="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl" # Recent installed packages
alias ch="cliphist list | fzf | cliphist decode | wl-copy"
alias dirsize="du -h --max-depth=1"
# Get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
+3
View File
@@ -0,0 +1,3 @@
{
"format.enable": false
}
+20
View File
@@ -0,0 +1,20 @@
{
"neodev": {
"library": {
"enabled": true,
"plugins": true
}
},
"neoconf": {
"plugins": {
"lua_ls": {
"enabled": true
}
}
},
"lspconfig": {
"lua_ls": {
"Lua.format.enable": false
}
}
}
+7
View File
@@ -0,0 +1,7 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
collapse_simple_statement = "Always"
+34
View File
@@ -0,0 +1,34 @@
# AstroNvim Template
**NOTE:** This is for AstroNvim v6+
A template for getting started with [AstroNvim](https://github.com/AstroNvim/AstroNvim)
## 🛠️ Installation
#### Make a backup of your current nvim and shared folder
```shell
mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak
mv ~/.local/state/nvim ~/.local/state/nvim.bak
mv ~/.cache/nvim ~/.cache/nvim.bak
```
#### Create a new user repository from this template
Press the "Use this template" button above to create a new repository to store your user configuration.
You can also just clone this repository directly if you do not want to track your user configuration in GitHub.
#### Clone the repository
```shell
git clone https://github.com/<your_user>/<your_repository> ~/.config/nvim
```
#### Start Neovim
```shell
nvim
```
+21 -628
View File
@@ -1,634 +1,27 @@
--- Set Leader Key (Needs to be set before the plugins are loaded/required)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution
-- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk.
local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
--- Plugin Manager
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then
-- stylua: ignore
local result = vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
if vim.v.shell_error ~= 0 then
-- stylua: ignore
vim.api.nvim_echo({ { ("Error cloning lazy.nvim:\n%s\n"):format(result), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end
end
vim.opt.rtp:prepend(lazypath)
-- Add Plugins
require("lazy").setup({
-- Theme
{
"catppuccin/nvim",
name = "catppuccin.vim",
priority = 1000,
config = function()
vim.cmd.colorscheme("catppuccin-macchiato")
end,
},
-- Stats
{ 'wakatime/vim-wakatime', lazy = false },
-- Highlight
{ "RRethy/vim-illuminate" },
-- Comment visual regions/lines
{ "numToStr/Comment.nvim", opts = {} },
-- Autoclose brackets
{ "m4xshen/autoclose.nvim", opts = {} },
{ "windwp/nvim-ts-autotag", opts = {}, lazy = false }, -- Doesn't work?
-- Surround selection
"tpope/vim-surround",
-- Add indentation guides
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {},
},
-- Status line
{
"nvim-lualine/lualine.nvim",
opts = {
options = {
icons_enabled = true,
theme = "palenight",
component_separators = "|",
section_separators = "",
},
},
},
-- Debug
{
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio"
},
opts = {}
},
{ "theHamsta/nvim-dap-virtual-text", opts = {} },
-- LSP
{
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ "williamboman/mason.nvim", config = true },
"williamboman/mason-lspconfig.nvim",
-- Useful status updates for LSP
{ "j-hui/fidget.nvim", tag = "legacy", opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
"folke/neodev.nvim",
},
},
-- Autocomplete
{
"hrsh7th/nvim-cmp",
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
-- Adds LSP completion capabilities
'hrsh7th/cmp-nvim-lsp',
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
-- Ai cmp
'tzachar/cmp-ai'
},
},
{ 'tzachar/cmp-ai', dependencies = 'nvim-lua/plenary.nvim' },
-- Show available command
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {}
},
-- Fuzzy Finder (files, lsp, etc)
{
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"nvim-lua/plenary.nvim",
{
'nvim-telescope/telescope-fzf-native.nvim',
-- NOTE: If you are having trouble with this installation,
-- refer to the README for telescope-fzf-native for more instructions.
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
end,
},
},
},
-- Highlight, edit, and navigate code
{
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
},
build = ':TSUpdate',
},
-- Git
"tpope/vim-fugitive",
--"tpope/vim-rhubarb",
{
"lewis6991/gitsigns.nvim",
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
on_attach = function(bufnr)
vim.keymap.set("n", "<leader>hp", require("gitsigns").preview_hunk, { buffer = bufnr, desc = "Preview git hunk" })
-- don't override the built-in and fugitive keymaps
local gs = package.loaded.gitsigns
vim.keymap.set({ "n", "v" }, "]c", function()
if vim.wo.diff then return "]c" end
vim.schedule(function() gs.next_hunk() end)
return "<Ignore>"
end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" })
vim.keymap.set({ "n", "v" }, "[c", function()
if vim.wo.diff then return "[c" end
vim.schedule(function() gs.prev_hunk() end)
return "<Ignore>"
end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
end,
},
},
})
-- Tab
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
--- Show line numbers
vim.opt.number = true
--- Relative line numbers
vim.opt.relativenumber = true
--- Go to next/previous line
vim.opt.whichwrap = "<,>,[,]"
--- Enable mouse
vim.opt.mouse = "a"
--- Sync clipboard with OS
vim.opt.clipboard = "unnamedplus"
--- Enable break indent
vim.opt.breakindent = true
--- Save undo history
vim.opt.undofile = true
--- Case-insensetive search
vim.opt.ignorecase = true
vim.opt.smartcase = true
--- Keep signcolum
vim.wo.signcolumn = "yes"
--- Set completeopt to have a better completion experience
vim.opt.completeopt = "menuone,noselect"
--- [[ Basic Keymaps ]]
-- Center view when jumping have the view
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- Center view when search
vim.keymap.set("n", "n", "nzz")
vim.keymap.set("n", "N", "Nzz")
-- Create file or directory
vim.keymap.set('n', '<Leader>cf', [[:e <C-R>=expand("%:h") .. '/'<CR>]],
{ desc = "[f] Create file", noremap = true })
vim.keymap.set('n', '<Leader>cd', [[:!mkdir <C-R>=expand("%:p:h") .. '/'<CR>]],
{ desc = "[d] Create directory", noremap = true })
-- Open explorer
vim.keymap.set("n", "<leader>oe", ":Ex<CR>", { desc = "[e] Open the explorer" })
-- Keymaps for better default experience
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
-- Remap for dealing with word wrap
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Change Tab/Window Focus
vim.keymap.set("n", "<C-h>", "<C-W>h")
vim.keymap.set("n", "<C-j>", "<C-W>j")
vim.keymap.set("n", "<C-k>", "<C-W>k")
vim.keymap.set("n", "<C-l>", "<C-W>l")
--- Debug
local dap, dapui, dapvs = require("dap"), require("dapui"), require('dap.ext.vscode')
vim.keymap.set("n", "<Leader>b", dap.toggle_breakpoint, { desc = "[b] Debug toggle breakpoint" })
vim.keymap.set("n", "<Leader>dc", dap.continue, { desc = "[c] Debug Continue/Start" })
vim.keymap.set("n", "<Leader>n", dap.step_over, { desc = "[n] Debug step over" })
vim.keymap.set("n", "<Leader>N", dap.step_into, { desc = "[N] Debug step into" })
vim.keymap.set("n", "<Leader>m", dap.step_out, { desc = "[m] Debug step out" })
vim.keymap.set("n", "<Leader>dt", dapui.toggle, { desc = "[t] Debug toggle view" })
vim.keymap.set("n", "<Leader>dl", function()
dapvs.load_launchjs("launch.json", { cppdbg = { 'c', 'cpp' } })
end,
{ desc = "[l] Debug load launch config" })
dap.listeners.before.attach.dapui_config = function()
dapui.open()
-- validate that lazy is available
if not pcall(require, "lazy") then
-- stylua: ignore
vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
-- dap.listeners.before.event_terminated.dapui_config = function()
-- dapui.close()
-- end
--
-- dap.listeners.before.event_exited.dapui_config = function()
-- dapui.close()
-- end
dap.adapters.cppdbg = {
id = "cppdbg",
type = "executable",
command = "/home/pa/dap/c/extension/debugAdapters/bin/OpenDebugAD7",
}
dap.configurations.c = {
{
name = "Launch file",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
args = function()
local s = vim.fn.input('Args: ')
local t = {}
for word in s:gmatch("%S+") do
table.insert(t, word)
end
return t
end,
cwd = '${workspaceFolder}',
stopAtEntry = true,
},
-- {
-- name = 'Attach to gdbserver :1234',
-- type = 'cppdbg',
-- request = 'launch',
-- MIMode = 'gdb',
-- miDebuggerServerAddress = 'localhost:1234',
-- miDebuggerPath = '/usr/bin/gdb',
-- cwd = '${workspaceFolder}',
-- program = function()
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- end,
-- },
}
--- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = "*",
})
--- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
require("telescope").setup {
defaults = {
mappings = {
i = {
["<C-u>"] = false,
["<C-d>"] = false,
},
},
},
}
-- Enable telescope fzf native, if installed
pcall(require("telescope").load_extension, "fzf")
-- See `:help telescope.builtin`
vim.keymap.set("n", "<leader>?", require("telescope.builtin").oldfiles, { desc = "[?] Find recently opened files" })
vim.keymap.set("n", "<leader><space>", require("telescope.builtin").buffers, { desc = "[ ] Find existing buffers" })
vim.keymap.set("n", "<leader>/", function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = "[/] Fuzzily search in current buffer" })
vim.keymap.set("n", "<leader>gf", require("telescope.builtin").git_files, { desc = "Search [G]it [F]iles" })
vim.keymap.set("n", "<leader>sf", require("telescope.builtin").find_files, { desc = "[S]earch [F]iles" })
vim.keymap.set("n", "<leader>sh", require("telescope.builtin").help_tags, { desc = "[S]earch [H]elp" })
vim.keymap.set("n", "<leader>sw", require("telescope.builtin").grep_string, { desc = "[S]earch current [W]ord" })
vim.keymap.set("n", "<leader>sg", require("telescope.builtin").live_grep, { desc = "[S]earch by [G]rep" })
vim.keymap.set("n", "<leader>sd", require("telescope.builtin").diagnostics, { desc = "[S]earch [D]iagnostics" })
vim.keymap.set("n", "<leader>sr", require("telescope.builtin").resume, { desc = "[S]earch [R]esume" })
--- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter`
-- Defer Treesitter setup after first render to improve startup time of "nvim {filename}"
vim.defer_fn(function()
require("nvim-treesitter.configs").setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { "c", "cpp", "go", "lua", "python", "rust", "tsx", "javascript", "typescript", "vimdoc", "vim" },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<c-space>",
node_incremental = "<c-space>",
scope_incremental = "<c-s>",
node_decremental = "<M-space>",
},
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
},
}
end, 0)
-- Diagnostic keymaps
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" })
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
--- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
-- Sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
desc = "LSP: " .. desc
end
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
nmap("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
-- See `:help K` for why this keymap
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>f", vim.lsp.buf.format, "[F]ormat")
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders")
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()
end, { desc = "Format current buffer with LSP" })
-- Auto format on save
vim.cmd [[autocmd BufWritePre <buffer> lua vim.lsp.buf.format()]]
-- or vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
end
-- document existing key chains
require("which-key").register({
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
["<leader>h"] = { name = "More git", _ = "which_key_ignore" },
["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
})
-- Enable the following language servers
-- If you want to override the default filetypes that your language server will attach to you can
-- define the property "filetypes" to the map in question.
local servers = {
rust_analyzer = {},
lemminx = {},
yamlls = {},
bashls = {},
jsonls = {},
clangd = {},
cssls = {},
jdtls = {
java = {
maven = { downloadSources = true }
}
},
html = {},
lua_ls = {
Lua = {
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
checkThirdParty = false
},
telemetry = { enable = false },
diagnostics = {
globals = { "vim" }
}
},
},
}
-- Setup neovim lua configuration
require("neodev").setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
-- Ensure the servers above are installed
local mason_lspconfig = require "mason-lspconfig"
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
mason_lspconfig.setup_handlers {
function(server_name)
require("lspconfig")[server_name].setup {
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
}
end
}
--- [[ Configure nvim-cmp ]]
-- See `:help cmp`
local cmp = require "cmp"
local luasnip = require "luasnip"
require("luasnip.loaders.from_vscode").lazy_load()
luasnip.config.setup {}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete {},
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
-- { name = "cmp_ai" },
},
}
-- local cmp_ai = require('cmp_ai.config')
-- cmp_ai:setup({
-- max_lines = 100,
-- provider = 'Ollama',
-- provider_options = {
-- model = 'mistral',
-- },
-- notify = true,
-- notify_callback = function(msg)
-- vim.notify(msg)
-- end,
-- run_on_every_keystroke = true,
-- ignored_file_types = {
-- -- default is not to ignore
-- -- uncomment to ignore in lua:
-- -- lua = true
-- },
-- })
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
-- notify_callback = function(msg)
-- vim.notify(msg)
-- end,
-- run_on_every_keystroke = true,
-- ignored_file_types = {
-- -- default is not to ignore
-- -- uncomment to ignore in lua:
-- -- lua = true
-- },
-- })
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
require "lazy_setup"
require "polish"
+16
View File
@@ -0,0 +1,16 @@
-- if true then return {} end
-- AstroCommunity: import any community modules here
-- We import this file in `lazy_setup.lua` before the `plugins/` folder.
-- This guarantees that the specs are processed before any user plugins.
---@type LazySpec
return {
"AstroNvim/astrocommunity",
{ import = "astrocommunity.pack.lua" },
{ import = "astrocommunity.media.vim-wakatime" },
{ import = "astrocommunity.search.grug-far-nvim" },
{ import = "astrocommunity.lsp.nvim-java" },
{ import = "astrocommunity.pack.vue" },
{ import = "astrocommunity.git.diffview-nvim" },
}
+32
View File
@@ -0,0 +1,32 @@
require("lazy").setup({
{
"AstroNvim/AstroNvim",
version = "^6", -- Remove version tracking to elect for nightly AstroNvim
import = "astronvim.plugins",
opts = { -- AstroNvim options must be set here with the `import` key
mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up
maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up
icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available)
pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override
update_notifications = true, -- Enable/disable notification about running `:Lazy update` twice to update pinned plugins
},
},
{ import = "community" },
{ import = "plugins" },
} --[[@as LazySpec]], {
-- Configure any other `lazy.nvim` configuration options here
install = { colorscheme = { "astrotheme", "habamax" } },
ui = { backdrop = 100 },
performance = {
rtp = {
-- disable some rtp plugins, add more to your liking
disabled_plugins = {
"gzip",
"netrwPlugin",
"tarPlugin",
"tohtml",
"zipPlugin",
},
},
},
} --[[@as LazyConfig]])
@@ -0,0 +1,85 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- AstroCore provides a central place to modify mappings, vim options, autocommands, and more!
-- Configuration documentation can be found with `:h astrocore`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
---@type LazySpec
return {
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
-- Configure core features of AstroNvim
features = {
large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter
autopairs = true, -- enable autopairs at start
cmp = true, -- enable completion at start
diagnostics = { virtual_text = true, virtual_lines = false }, -- diagnostic settings on startup
highlighturl = true, -- highlight URLs at start
notifications = true, -- enable notifications at start
},
-- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
diagnostics = {
virtual_text = true,
underline = true,
},
-- passed to `vim.filetype.add`
filetypes = {
-- see `:h vim.filetype.add` for usage
extension = {
foo = "fooscript",
},
filename = {
[".foorc"] = "fooscript",
},
pattern = {
[".*/etc/foo/.*"] = "fooscript",
},
},
-- vim options can be configured here
options = {
opt = { -- vim.opt.<key>
relativenumber = true, -- sets vim.opt.relativenumber
number = true, -- sets vim.opt.number
spell = false, -- sets vim.opt.spell
signcolumn = "yes", -- sets vim.opt.signcolumn to yes
wrap = false, -- sets vim.opt.wrap
},
g = { -- vim.g.<key>
-- configure global vim variables (vim.g)
-- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup`
-- This can be found in the `lua/lazy_setup.lua` file
},
},
-- Mappings can be configured through AstroCore as well.
-- NOTE: keycodes follow the casing in the vimdocs. For example, `<Leader>` must be capitalized
mappings = {
-- first key is the mode
n = {
-- second key is the lefthand side of the map
-- navigate buffer tabs
["]b"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" },
["[b"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" },
-- mappings seen under group name "Buffer"
["<Leader>bd"] = {
function()
require("astroui.status.heirline").buffer_picker(
function(bufnr) require("astrocore.buffer").close(bufnr) end
)
end,
desc = "Close buffer from tabline",
},
-- tables with just a `desc` key will be registered with which-key if it's installed
-- this is useful for naming menus
-- ["<Leader>b"] = { desc = "Buffers" },
-- setting a mapping to false will disable it
-- ["<C-S>"] = false,
},
},
},
}
+110
View File
@@ -0,0 +1,110 @@
-- if true then return {} end
-- AstroLSP allows you to customize the features in AstroNvim's LSP configuration engine
-- Configuration documentation can be found with `:h astrolsp`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
---@type LazySpec
return {
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
-- Configuration table of features provided by AstroLSP
features = {
codelens = true, -- enable/disable codelens refresh on start
inlay_hints = false, -- enable/disable inlay hints on start
semantic_tokens = true, -- enable/disable semantic token highlighting
},
-- customize lsp formatting options
formatting = {
-- control auto formatting on save
format_on_save = {
enabled = true, -- enable or disable format on save globally
allow_filetypes = { -- enable format on save for specified filetypes only
-- "go",
},
ignore_filetypes = { -- disable format on save for specified filetypes
-- "python",
},
},
disabled = { -- disable formatting capabilities for the listed language servers
-- disable lua_ls formatting capability if you want to use StyLua to format your lua code
-- "lua_ls",
},
timeout_ms = 1000, -- default format timeout
-- filter = function(client) -- fully override the default formatting function
-- return true
-- end
},
-- enable servers that you already have installed without mason
servers = {
"ccls",
},
-- customize language server configuration passed to `vim.lsp.config`
-- client specific configuration can also go in `lsp/` in your configuration root (see `:h lsp-config`)
config = {
clangd = {
enabled = false,
},
ccls = {
cmd = { "ccls" },
filetypes = { "cpp", "c" },
},
},
-- customize how language servers are attached
handlers = {
-- a function with the key `*` modifies the default handler, functions takes the server name as the parameter
-- ["*"] = function(server) vim.lsp.enable(server) end
-- the key is the server that is being setup with `vim.lsp.config`
-- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server
},
-- Configure buffer local auto commands to add when attaching a language server
autocmds = {
-- first key is the `augroup` to add the auto commands to (:h augroup)
lsp_codelens_refresh = {
-- Optional condition to create/delete auto command group
-- can either be a string of a client capability or a function of `fun(client, bufnr): boolean`
-- condition will be resolved for each client on each execution and if it ever fails for all clients,
-- the auto commands will be deleted for that buffer
cond = "textDocument/codeLens",
-- cond = function(client, bufnr) return client.name == "lua_ls" end,
-- list of auto commands to set
{
-- events to trigger
event = { "InsertLeave", "BufEnter" },
-- the rest of the autocmd options (:h nvim_create_autocmd)
desc = "Refresh codelens (buffer)",
callback = function(args)
if require("astrolsp").config.features.codelens then vim.lsp.codelens.enable(true, { bufnr = args.buf }) end
end,
},
},
},
-- mappings to be set up on attaching of a language server
mappings = {
n = {
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
gD = {
function() vim.lsp.buf.declaration() end,
desc = "Declaration of current symbol",
cond = "textDocument/declaration",
},
["<Leader>uY"] = {
function() require("astrolsp.toggles").buffer_semantic_tokens() end,
desc = "Toggle LSP semantic highlight (buffer)",
cond = function(client)
return client:supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil
end,
},
},
},
-- A custom `on_attach` function to be run after the default `on_attach` function
-- takes two parameters `client` and `bufnr` (`:h lsp-attach`)
on_attach = function(client, bufnr)
-- this would disable semanticTokensProvider for all clients
-- client.server_capabilities.semanticTokensProvider = nil
end,
},
}
+39
View File
@@ -0,0 +1,39 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- AstroUI provides the basis for configuring the AstroNvim User Interface
-- Configuration documentation can be found with `:h astroui`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
---@type LazySpec
return {
"AstroNvim/astroui",
---@type AstroUIOpts
opts = {
-- change colorscheme
colorscheme = "astrodark",
-- AstroUI allows you to easily modify highlight groups easily for any and all colorschemes
highlights = {
init = { -- this table overrides highlights in all themes
-- Normal = { bg = "#000000" },
},
astrodark = { -- a table of overrides/changes when applying the astrotheme theme
-- Normal = { bg = "#000000" },
},
},
-- Icons can be configured throughout the interface
icons = {
-- configure the loading of the lsp in the status line
LSPLoading1 = "",
LSPLoading2 = "",
LSPLoading3 = "",
LSPLoading4 = "",
LSPLoading5 = "",
LSPLoading6 = "",
LSPLoading7 = "",
LSPLoading8 = "",
LSPLoading9 = "",
LSPLoading10 = "",
},
},
}
+83
View File
@@ -0,0 +1,83 @@
return {
{
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
mappings = {
n = {
["<Leader><space>"] = {
function() require("snacks").picker.buffers() end,
desc = "Find buffers",
},
["<Leader>F"] = {
function()
require("snacks").picker.files {
hidden = true,
ignored = true,
}
end,
desc = "Find buffers",
},
["<Leader>ss"] = {
function()
local aerial_avail, aerial = pcall(require, "aerial")
if aerial_avail and aerial.snacks_picker then
aerial.snacks_picker()
else
require("snacks").picker.lsp_symbols()
end
end,
desc = "Search symbols",
},
["<Leader>fj"] = {
"<cmd>%!jq .<CR>",
desc = "Format Json",
},
["<Leader>w"] = {
"<cmd>:noautocmd w<CR>",
desc = "Save Fileeee",
},
-- quick save
-- ["<C-s>"] = { ":w!<cr>", desc = "Save File" },
-- Git
["<Leader>vd"] = {
"<cmd>DiffviewOpen<CR>",
desc = "Diffview",
},
["<Leader>vD"] = {
"<cmd>DiffviewOpen HEAD^!<CR>",
desc = "Diffview Last Commit",
},
["<Leader>vl"] = {
function()
require("snacks").picker.git_log {
confirm = function(picker, item)
picker:close()
vim.cmd("DiffviewOpen " .. item.commit .. "^!")
end,
}
end,
silent = true,
desc = "Diff Commit",
},
["<Leader>vh"] = {
"<cmd>DiffviewFileHistory %<CR>",
desc = "File History",
},
["<Leader>vH"] = {
"<cmd>DiffviewFileHistory<CR>",
desc = "Repo History",
},
["<Leader>vr"] = {
"<cmd>DiffviewRefresh<CR>",
desc = "Diffview Refresh",
},
["<Leader>vc"] = {
"<cmd>DiffviewClose<CR>",
desc = "Diffview Close",
},
},
},
},
},
}
+45
View File
@@ -0,0 +1,45 @@
-- if true then return {} end
-- Customize Mason
---@type LazySpec
return {
-- use mason-tool-installer for automatically installing Mason packages
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
-- overrides `require("mason-tool-installer").setup(...)`
opts = {
-- Make sure to use the names found in `:Mason`
ensure_installed = {
-- install language servers
"lua-language-server",
"angular-language-server",
"typescript-language-server",
"gopls",
"html-lsp",
"css-lsp",
"c3-lsp",
"json-lsp",
"shellcheck",
-- "clangd",
-- "cmake-language-server",
"csharp-language-server",
"dockerfile-language-server",
-- "docker-compose-language-service",
"kotlin-language-server",
"postgres-language-server",
"python-lsp-server",
"rust-analyzer",
-- install formatters
"stylua",
-- install debuggers
"debugpy",
-- install any other package
"tree-sitter-cli",
},
},
},
}
+11
View File
@@ -0,0 +1,11 @@
return {
"nvim-neo-tree/neo-tree.nvim",
opts = {
filesystem = {
filtered_items = {
hide_dotfiles = false,
hide_gitignored = false,
},
},
},
}
+24
View File
@@ -0,0 +1,24 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- Customize None-ls sources
---@type LazySpec
return {
"nvimtools/none-ls.nvim",
opts = function(_, opts)
-- opts variable is the default configuration table for the setup function call
-- local null_ls = require "null-ls"
-- Check supported formatters and linters
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
-- Only insert new sources, do not replace the existing ones
-- (If you wish to replace, use `opts.sources = {}` instead of the `list_insert_unique` function)
opts.sources = require("astrocore").list_insert_unique(opts.sources, {
-- Set a formatter
-- null_ls.builtins.formatting.stylua,
-- null_ls.builtins.formatting.prettier,
})
end,
}
@@ -0,0 +1,67 @@
-- if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- Customize Treesitter
-- --------------------
-- Treesitter customizations are handled with AstroCore
-- as nvim-treesitter simply provides a download utility for parsers
-- :TSInstall all
---@type LazySpec
return {
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
treesitter = {
highlight = true, -- enable/disable treesitter based highlighting
indent = true, -- enable/disable treesitter based indentation
auto_install = true, -- enable/disable automatic installation of detected languages
ensure_installed = {
"asm",
"angular",
"arduino",
"bash",
"c",
"c3",
"c_sharp",
"cmake",
"cpp",
"css",
"csv",
"dart",
"dockerfile",
"fish",
"gitignore",
"go",
"graphql",
"html",
"hyprlang",
"java",
"javadoc",
"javascript",
"jq",
"json",
"kitty",
"kotlin",
"latex",
"linkerscript",
"llvm",
"lua",
"luadoc",
"make",
"markdown",
"markdown_inline",
"nasm",
"nginx",
"ninja",
"nix",
"odin",
"pascal",
"perl",
"php",
"pioasm",
"vim",
"vimdoc",
},
},
},
}
+90
View File
@@ -0,0 +1,90 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- You can also add or configure plugins by creating files in this `plugins/` folder
-- PLEASE REMOVE THE EXAMPLES YOU HAVE NO INTEREST IN BEFORE ENABLING THIS FILE
-- Here are some examples:
---@type LazySpec
return {
-- == Examples of Adding Plugins ==
"andweeb/presence.nvim",
{
"ray-x/lsp_signature.nvim",
event = "BufRead",
config = function() require("lsp_signature").setup() end,
},
-- == Examples of Overriding Plugins ==
-- customize dashboard options
{
"folke/snacks.nvim",
opts = {
dashboard = {
preset = {
header = table.concat({
" █████ ███████ ████████ ██████ ██████ ",
"██ ██ ██ ██ ██ ██ ██ ██",
"███████ ███████ ██ ██████ ██ ██",
"██ ██ ██ ██ ██ ██ ██ ██",
"██ ██ ███████ ██ ██ ██ ██████ ",
"",
"███  ██ ██  ██ ██ ███  ███",
"████  ██ ██  ██ ██ ████  ████",
"██ ██  ██ ██  ██ ██ ██ ████ ██",
"██  ██ ██  ██  ██  ██ ██  ██  ██",
"██   ████   ████   ██ ██      ██",
}, "\n"),
},
},
},
},
-- You can disable default plugins as follows:
{ "max397574/better-escape.nvim", enabled = false },
-- You can also easily customize additional setup of plugins that is outside of the plugin's setup call
{
"L3MON4D3/LuaSnip",
config = function(plugin, opts)
-- add more custom luasnip configuration such as filetype extend or custom snippets
local luasnip = require "luasnip"
luasnip.filetype_extend("javascript", { "javascriptreact" })
-- include the default astronvim config that calls the setup call
require "astronvim.plugins.configs.luasnip"(plugin, opts)
end,
},
{
"windwp/nvim-autopairs",
config = function(plugin, opts)
require "astronvim.plugins.configs.nvim-autopairs"(plugin, opts) -- include the default astronvim config that calls the setup call
-- add more custom autopairs configuration such as custom rules
local npairs = require "nvim-autopairs"
local Rule = require "nvim-autopairs.rule"
local cond = require "nvim-autopairs.conds"
npairs.add_rules(
{
Rule("$", "$", { "tex", "latex" })
-- don't add a pair if the next character is %
:with_pair(cond.not_after_regex "%%")
-- don't add a pair if the previous character is xxx
:with_pair(
cond.not_before_regex("xxx", 3)
)
-- don't move right when repeat character
:with_move(cond.none())
-- don't delete if the next character is xx
:with_del(cond.not_after_regex "xx")
-- disable adding a newline when you press <cr>
:with_cr(cond.none()),
},
-- disable for .vim files, but it work for another filetypes
Rule("a", "a", "-vim")
)
end,
},
}
+5
View File
@@ -0,0 +1,5 @@
if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- This will run last in the setup process.
-- This is just pure lua so anything that doesn't
-- fit in the normal config locations above can go here
+6
View File
@@ -0,0 +1,6 @@
---
base: lua51
globals:
vim:
any: true
+8
View File
@@ -0,0 +1,8 @@
std = "neovim"
[rules]
global_usage = "allow"
if_same_then_else = "allow"
incorrect_standard_library_use = "allow"
mixed_table = "allow"
multiple_statements = "allow"
View File
+21 -6
View File
@@ -15,11 +15,26 @@ run = "cd ~/.dotfiles/"
desc = "DOTFILES"
[[mgr.prepend_keymap]]
on = [ "b", "s" ]
run = "plugin bookmark -- save"
desc = "Save Bookmark"
on = [ "o", "n" ]
run = "shell \"nvim\" --block"
desc = "Open NeoVim"
[[mgr.prepend_keymap]]
on = [ "b", "j" ]
run = "plugin bookmark -- jump"
desc = "Jump to Bookmark"
on = [ "m" ]
run = "plugin bookmarks save"
desc = "Save current position as a bookmark"
[[mgr.prepend_keymap]]
on = [ "'" ]
run = "plugin bookmarks jump"
desc = "Jump to a bookmark"
[[mgr.prepend_keymap]]
on = [ "b", "d" ]
run = "plugin bookmarks delete"
desc = "Delete a bookmark"
[[mgr.prepend_keymap]]
on = [ "b", "D" ]
run = "plugin bookmarks delete_all"
desc = "Delete all bookmarks"
+7
View File
@@ -0,0 +1,7 @@
[[plugin.deps]]
use = "dedukun/bookmarks"
rev = "9ef1254"
hash = "92fbb5483657fa7976cdf4e0104e18e0"
[flavor]
deps = []
@@ -1,9 +0,0 @@
MIT
Copyright 2025 Keule2
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.
@@ -1,15 +0,0 @@
# General
Simple plugin to create a tmp bookmark and jump to it.
# Usage
```toml
[[mgr.prepend_keymap]]
on = [ "b", "s" ]
run = "plugin bookmark -- save"
desc = "Save Bookmark"
[[mgr.prepend_keymap]]
on = [ "b", "j" ]
run = "plugin bookmark -- jump"
desc = "Jump to Bookmark"
```
@@ -1,39 +0,0 @@
local temp_dir = os.getenv("TEMP") or os.getenv("TMP") or "/tmp"
local file_name = temp_dir .. "/bookmark.yazi"
local save_bookmark = ya.sync(function(state, idx)
local folder = tostring(cx.active.current.cwd)
local file = io.open(file_name, "w")
if file then
file:write(folder)
file:close()
ya.notify { title = "Saved Bookmark", content = folder, timeout = 3, level = "info" }
end
end)
local jump_bookmark = ya.sync(function(state, idx)
local file = io.open(file_name, "r")
if file then
local line = file:read("*line")
file:close()
ya.manager_emit("cd", { line })
ya.manager_emit("arrow", { -99999999 })
end
end)
return {
entry = function(_, job)
local action = job.args[1]
if not action then
return
end
if action == "save" then
save_bookmark()
elseif action == "jump" then
jump_bookmark()
end
end
}
@@ -0,0 +1,19 @@
Copyright (c) 2024 dedukun
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.
@@ -0,0 +1,158 @@
# bookmarks.yazi
A [Yazi](https://github.com/sxyazi/yazi) plugin that adds the basic functionality of [vi-like marks](https://neovim.io/doc/user/motion.html#mark-motions).
https://github.com/dedukun/bookmarks.yazi/assets/25795432/9a9fe345-dd06-442e-99f1-8475ab22fad5
## Requirements
- [Yazi](https://github.com/sxyazi/yazi) v25.4.8+
## Features
- Create/delete bookmarks
- Custom Notifications
- `''` to go back to the previous folder
- Bookmarks persistence
## Installation
```sh
ya pkg add dedukun/bookmarks
```
## Import/Export bookmarks
This plugin uses [Yazi's DDS](https://yazi-rs.github.io/docs/dds/) for bookmark persistence, as such,
the bookmarks are saved in DDS's state file (`~/.local/state/yazi/.dds` on Linux and `C:\Users\USERNAME\AppData\Roaming\yazi\state\.dds` on Windows)
**_NOTE:_** This system may be used by other plugins that you have installed, so this file might have more data than just the bookmarks.
## Configuration
Add this to your `keymap.toml`:
```toml
# If your yazi version is lower than v25.5.28, repleace "mgr" by "manager".
[[mgr.prepend_keymap]]
on = [ "m" ]
run = "plugin bookmarks save"
desc = "Save current position as a bookmark"
[[mgr.prepend_keymap]]
on = [ "'" ]
run = "plugin bookmarks jump"
desc = "Jump to a bookmark"
[[mgr.prepend_keymap]]
on = [ "b", "d" ]
run = "plugin bookmarks delete"
desc = "Delete a bookmark"
[[mgr.prepend_keymap]]
on = [ "b", "D" ]
run = "plugin bookmarks delete_all"
desc = "Delete all bookmarks"
```
---
Additionally there are configurations that can be done using the plugin's `setup` function in Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`.
The following are the default configurations:
```lua
-- ~/.config/yazi/init.lua
require("bookmarks"):setup({
last_directory = { enable = false, persist = false, mode="dir" },
persist = "none",
desc_format = "full",
file_pick_mode = "hover",
custom_desc_input = false,
show_keys = false,
notify = {
enable = false,
timeout = 1,
message = {
new = "New bookmark '<key>' -> '<folder>'",
delete = "Deleted bookmark in '<key>'",
delete_all = "Deleted all bookmarks",
},
},
})
```
### `last_directory`
When enabled, a new bookmark is automatically created in `'` which allows the user to jump back to
the last directory.
There's also the option to enable persistence to this automatic bookmark.
Finally, there's a `mode` option with the following options:
| Value | Description |
| ------ | ------------------------------------------------------------ |
| `jump` | It saves the position before the last used mark |
| `mark` | It saves the last created mark |
| `dir` | Default, it saves the last visited directory (old behaviour) |
### `persist`
When enabled the bookmarks will persist, i.e. if you close and reopen Yazi they will still be
present.
There are three possible values for this option:
| Value | Description |
| ------ | -------------------------------------------------------------------------------------------------------------------- |
| `none` | The default value, i.e., no persistance |
| `all` | All the bookmarks are saved in persistent memory |
| `vim` | This mode emulates the vim global marks, i.e., only the bookmarks in upper case (A-Z) are saved to persistent memory |
### `desc_format`
The format for the bookmark description.
There are two possible values for this option:
| Value | Description |
| -------- | ----------------------------------------------------------------------------------------------- |
| `full` | The default, it shows the full path of the bookmark, i.e., the parent folder + the hovered file |
| `parent` | Only shows the parent folder of the bookmark |
### `file_pick_mode`
The mode for choosing which directory to bookmark.
There are two possible values for this option:
| Value | Description |
| -------- | ------------------------------------------------------------------- |
| `hover` | The default, it uses the path of the hovered file for new bookmarks |
| `parent` | Uses the path of the parent folder for new bookmarks |
### `notify`
When enabled, notifications will be shown when the user creates a new bookmark and deletes one or
all saved bookmarks.
By default the notification has a 1 second timeout that can be changed with `notify.timeout`.
Furthermore, you can customize the notification messages with `notify.message`.
For the `new` and `delete` messages, the `<key>` and `<folder>` keywords can be used, which will be replaced by the respective new/deleted bookmark's associated key and folder.
### `custom_desc_input`
When enabled, user can change description for new bookmark before it is saved.
By default the custom description input is filled with path.
### `show_keys`
When enabled, saving a new bookmark will display a list of all available keys.
If a key already has a saved bookmark, its description will be shown.
This helps prevent accidental overwriting of existing bookmarks.
By default no information is shown.
@@ -0,0 +1,405 @@
--- @since 25.4.8
-- stylua: ignore
local SUPPORTED_KEYS = {
{ on = "0", desc = "Free" }, { on = "1", desc = "Free" }, { on = "2", desc = "Free" }, { on = "3", desc = "Free" }, { on = "4", desc = "Free"},
{ on = "5", desc = "Free" }, { on = "6", desc = "Free" }, { on = "7", desc = "Free" }, { on = "8", desc = "Free" }, { on = "9", desc = "Free"},
{ on = "A", desc = "Free" }, { on = "B", desc = "Free" }, { on = "C", desc = "Free" }, { on = "D", desc = "Free" }, { on = "E", desc = "Free"},
{ on = "F", desc = "Free" }, { on = "G", desc = "Free" }, { on = "H", desc = "Free" }, { on = "I", desc = "Free" }, { on = "J", desc = "Free"},
{ on = "K", desc = "Free" }, { on = "L", desc = "Free" }, { on = "M", desc = "Free" }, { on = "N", desc = "Free" }, { on = "O", desc = "Free"},
{ on = "P", desc = "Free" }, { on = "Q", desc = "Free" }, { on = "R", desc = "Free" }, { on = "S", desc = "Free" }, { on = "T", desc = "Free"},
{ on = "U", desc = "Free" }, { on = "V", desc = "Free" }, { on = "W", desc = "Free" }, { on = "X", desc = "Free" }, { on = "Y", desc = "Free"}, { on = "Z", desc = "Free" },
{ on = "a", desc = "Free" }, { on = "b", desc = "Free" }, { on = "c", desc = "Free" }, { on = "d", desc = "Free" }, { on = "e", desc = "Free"},
{ on = "f", desc = "Free" }, { on = "g", desc = "Free" }, { on = "h", desc = "Free" }, { on = "i", desc = "Free" }, { on = "j", desc = "Free"},
{ on = "k", desc = "Free" }, { on = "l", desc = "Free" }, { on = "m", desc = "Free" }, { on = "n", desc = "Free" }, { on = "o", desc = "Free"},
{ on = "p", desc = "Free" }, { on = "q", desc = "Free" }, { on = "r", desc = "Free" }, { on = "s", desc = "Free" }, { on = "t", desc = "Free"},
{ on = "u", desc = "Free" }, { on = "v", desc = "Free" }, { on = "w", desc = "Free" }, { on = "x", desc = "Free" }, { on = "y", desc = "Free"}, { on = "z", desc = "Free" },
}
local _send_notification = ya.sync(
function(state, message)
ya.notify {
title = "Bookmarks",
content = message,
timeout = state.notify.timeout,
}
end
)
local _get_real_index = ya.sync(function(state, idx)
for key, value in pairs(state.bookmarks) do
if value.on == SUPPORTED_KEYS[idx].on then
return key
end
end
return nil
end)
local _get_bookmark_file = ya.sync(function(state)
local folder = cx.active.current
if state.file_pick_mode == "parent" or not folder.hovered then
return { url = folder.cwd, is_parent = true }
end
return { url = folder.hovered.url, is_parent = false }
end)
local _generate_description = ya.sync(function(state, file)
-- if this is true, we don't have information about the folder, so just return the folder url
if file.is_parent then
return tostring(file.url)
end
if state.desc_format == "parent" then
return tostring(file.url.parent)
end
-- full description
return tostring(file.url)
end)
local _load_state = ya.sync(function(state)
ps.sub_remote("@bookmarks", function(body)
if not state.bookmarks and body then
state.bookmarks = {}
for _, value in pairs(body) do
table.insert(state.bookmarks, value)
end
end
end)
end)
local _save_state = ya.sync(function(state, bookmarks)
if not bookmarks then
ps.pub_to(0, "@bookmarks", nil)
return
end
local save_state = {}
if state.persist == "all" then
save_state = bookmarks
else -- VIM mode
local idx = 1
for _, value in pairs(bookmarks) do
-- Only save bookmarks in upper case keys
if string.match(value.on, "%u") then
save_state[idx] = value
idx = idx + 1
end
end
end
ps.pub_to(0, "@bookmarks", save_state)
end)
local _load_last = ya.sync(function(state)
ps.sub_remote("@bookmarks-last", function(body)
state.last_dir = body
if state.last_mode ~= "dir" then
ps.unsub_remote("@bookmarks-last")
end
end)
end)
local _save_last = ya.sync(function(state, persist, imediate)
local file = _get_bookmark_file()
local curr = {
on = "'",
desc = _generate_description(file),
path = tostring(file.url),
is_parent = file.is_parent,
}
if imediate then
state.curr_dir = nil
state.last_dir = curr
else
state.last_dir = state.curr_dir
state.curr_dir = curr
end
if persist and state.last_dir then
ps.pub_to(0, "@bookmarks-last", state.last_dir)
end
end)
local get_last_mode = ya.sync(function(state) return state.last_mode end)
local save_last_dir = ya.sync(function(state)
ps.sub("cd", function() _save_last(state.last_persist, false) end)
ps.sub("hover", function()
local file = _get_bookmark_file()
state.curr_dir.desc = _generate_description(file)
state.curr_dir.path = tostring(file.url)
end)
end)
local save_last_jump = ya.sync(function(state) _save_last(state.last_persist, true) end)
local save_last_mark = ya.sync(function(state) _save_last(state.last_persist, true) end)
local _is_show_keys_enabled = ya.sync(function(state) return state.show_keys end)
local _is_custom_desc_input_enabled = ya.sync(function(state) return state.custom_desc_input end)
-- ***********************************************
-- **============= C O M M A N D S =============**
-- ***********************************************
local get_updated_keys = ya.sync(function(state, keys)
if state.bookmarks then
for _, bookmarks_value in pairs(state.bookmarks) do
for _, keys_value in pairs(keys) do
if keys_value.on == bookmarks_value.on then
keys_value.desc = bookmarks_value.desc
end
end
end
end
return keys
end)
local save_bookmark = ya.sync(function(state, idx, custom_desc)
local file = _get_bookmark_file()
state.bookmarks = state.bookmarks or {}
local _idx = _get_real_index(idx)
if not _idx then
_idx = #state.bookmarks + 1
end
local bookmark_desc = tostring(_generate_description(file))
if custom_desc then
bookmark_desc = tostring(custom_desc)
end
state.bookmarks[_idx] = {
on = SUPPORTED_KEYS[idx].on,
desc = bookmark_desc,
path = tostring(file.url),
is_parent = file.is_parent,
}
-- Custom sorting function
table.sort(state.bookmarks, function(a, b)
local key_a, key_b = a.on, b.on
-- Numbers first
if key_a:match("%d") and not key_b:match("%d") then
return true
elseif key_b:match("%d") and not key_a:match("%d") then
return false
end
-- Uppercase before lowercase
if key_a:match("%u") and key_b:match("%l") then
return true
elseif key_b:match("%u") and key_a:match("%l") then
return false
end
-- Regular alphabetical sorting
return key_a < key_b
end)
if state.persist then
_save_state(state.bookmarks)
end
if state.notify and state.notify.enable then
local message = state.notify.message.new
message, _ = message:gsub("<key>", state.bookmarks[_idx].on)
message, _ = message:gsub("<folder>", state.bookmarks[_idx].desc)
_send_notification(message)
end
if get_last_mode() == "mark" then
save_last_mark()
end
end)
local all_bookmarks = ya.sync(function(state, append_last_dir)
local bookmarks = {}
if state.bookmarks then
for _, value in pairs(state.bookmarks) do
table.insert(bookmarks, value)
end
end
if append_last_dir and state.last_dir then
table.insert(bookmarks, state.last_dir)
end
return bookmarks
end)
local delete_bookmark = ya.sync(function(state, idx)
if state.notify and state.notify.enable then
local message = state.notify.message.delete
message, _ = message:gsub("<key>", state.bookmarks[idx].on)
message, _ = message:gsub("<folder>", state.bookmarks[idx].desc)
_send_notification(message)
end
table.remove(state.bookmarks, idx)
if state.persist then
_save_state(state.bookmarks)
end
end)
local delete_all_bookmarks = ya.sync(function(state)
state.bookmarks = nil
if state.persist then
_save_state(nil)
end
if state.notify and state.notify.enable then
_send_notification(state.notify.message.delete_all)
end
end)
return {
entry = function(_, job)
local action = job.args[1]
if not action then
return
end
if action == "save" then
if _is_show_keys_enabled() then
SUPPORTED_KEYS = get_updated_keys(SUPPORTED_KEYS)
end
local key = ya.which { cands = SUPPORTED_KEYS, silent = not _is_show_keys_enabled() }
if key then
if _is_custom_desc_input_enabled() then
local value, event = ya.input {
title = "Save with custom description:",
position = { "top-center", y = 3, w = 60 },
value = tostring(_get_bookmark_file().url),
}
if event ~= 1 then
return
end
save_bookmark(key, value)
return
end
save_bookmark(key)
end
return
end
if action == "delete_all" then
return delete_all_bookmarks()
end
local bookmarks = all_bookmarks(action == "jump")
local selected = #bookmarks > 0 and ya.which { cands = bookmarks }
if not selected then
return
end
if action == "jump" then
if get_last_mode() == "jump" then
save_last_jump()
end
if bookmarks[selected].is_parent then
ya.mgr_emit("cd", { bookmarks[selected].path })
else
ya.mgr_emit("reveal", { bookmarks[selected].path })
end
elseif action == "delete" then
delete_bookmark(selected)
end
end,
setup = function(state, args)
if not args then
return
end
if type(args.last_directory) == "table" then
if args.last_directory.enable then
if args.last_directory.mode == "mark" then
state.last_persist = args.last_directory.persist
state.last_mode = "mark"
elseif args.last_directory.mode == "jump" then
state.last_persist = args.last_directory.persist
state.last_mode = "jump"
elseif args.last_directory.mode == "dir" then
state.last_persist = args.last_directory.persist
state.last_mode = "dir"
save_last_dir()
else
-- default
state.last_persist = args.last_directory.persist
state.last_mode = "dir"
save_last_dir()
end
if args.last_directory.persist then
_load_last()
end
end
end
if args.persist == "all" or args.persist == "vim" then
state.persist = args.persist
_load_state()
end
if args.desc_format == "parent" then
state.desc_format = "parent"
else
state.desc_format = "full"
end
if args.file_pick_mode == "parent" then
state.file_pick_mode = "parent"
else
state.file_pick_mode = "hover"
end
if type(args.custom_desc_input) == "boolean" then
state.custom_desc_input = args.custom_desc_input
end
if type(args.show_keys) == "boolean" then
state.show_keys = args.show_keys
end
state.notify = {
enable = false,
timeout = 1,
message = {
new = "New bookmark '<key>' -> '<folder>'",
delete = "Deleted bookmark in '<key>'",
delete_all = "Deleted all bookmarks",
},
}
if type(args.notify) == "table" then
if type(args.notify.enable) == "boolean" then
state.notify.enable = args.notify.enable
end
if type(args.notify.timeout) == "number" then
state.notify.timeout = args.notify.timeout
end
if type(args.notify.message) == "table" then
if type(args.notify.message.new) == "string" then
state.notify.message.new = args.notify.message.new
end
if type(args.notify.message.delete) == "string" then
state.notify.message.delete = args.notify.message.delete
end
if type(args.notify.message.delete_all) == "string" then
state.notify.message.delete_all = args.notify.message.delete_all
end
end
end
end,
}