Compare commits
2 Commits
0763449f80
...
ed1cc8eedf
| Author | SHA1 | Date | |
|---|---|---|---|
| ed1cc8eedf | |||
| 372f3a7720 |
@@ -70,6 +70,8 @@ dotfiles/
|
|||||||
|
|
||||||
### Extras
|
### Extras
|
||||||
|
|
||||||
|
- fzf
|
||||||
|
- tree-sitter-cli
|
||||||
- lesspipe
|
- lesspipe
|
||||||
- cbonsai
|
- cbonsai
|
||||||
|
|
||||||
@@ -125,7 +127,7 @@ sudo apt update && sudo apt install terraform
|
|||||||
sudo apt install alacritty zsh tmux stow zsh-syntax-highlighting less python3-libtmux cbonsai shfmt shellcheck lua-check
|
sudo apt install alacritty zsh tmux stow zsh-syntax-highlighting less python3-libtmux cbonsai shfmt shellcheck lua-check
|
||||||
|
|
||||||
# Homebrew packages
|
# Homebrew packages
|
||||||
brew install neovim stylua lua-language-server bash-language-server prettier terraform-ls tflint ruff markdownlint-cli2
|
brew install neovim stylua lua-language-server bash-language-server prettier terraform-ls tflint ruff markdownlint-cli2 fzf tree-sitter-cli
|
||||||
|
|
||||||
# Node packages
|
# Node packages
|
||||||
npm install --save-dev prettier prettier-plugin-go-template
|
npm install --save-dev prettier prettier-plugin-go-template
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
local bufnr = vim.api.nvim_get_current_buf()
|
|
||||||
-- vim.keymap.set("n", "<leader>a", function()
|
|
||||||
-- vim.cmd.RustLsp("codeAction") -- supports rust-analyzer's grouping
|
|
||||||
-- -- or vim.lsp.buf.codeAction() if you don't want grouping.
|
|
||||||
-- end, { silent = true, buffer = bufnr })
|
|
||||||
-- vim.keymap.set(
|
|
||||||
-- "n",
|
|
||||||
-- "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions
|
|
||||||
-- function()
|
|
||||||
-- vim.cmd.RustLsp({ "hover", "actions" })
|
|
||||||
-- end,
|
|
||||||
-- { silent = true, buffer = bufnr }
|
|
||||||
-- )
|
|
||||||
-- vim.keymap.set(
|
|
||||||
-- "n",
|
|
||||||
-- "<leader>?", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions
|
|
||||||
-- function()
|
|
||||||
-- vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
|
||||||
-- end,
|
|
||||||
-- { buffer = bufnr }
|
|
||||||
-- )
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
require("ink")
|
require("ink")
|
||||||
require("config.lazy")
|
require("plugins")
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ return {
|
|||||||
loadOutDirsFromCheck = true,
|
loadOutDirsFromCheck = true,
|
||||||
runBuildScripts = true,
|
runBuildScripts = true,
|
||||||
},
|
},
|
||||||
checkOnSave = true,
|
check = {
|
||||||
|
command = "clippy",
|
||||||
|
},
|
||||||
completion = {
|
completion = {
|
||||||
autoself = { enable = true },
|
autoself = { enable = true },
|
||||||
snippets = { enable = true },
|
|
||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
-- Bootstrap lazy.nvim
|
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
|
||||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|
||||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
|
||||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
|
||||||
if vim.v.shell_error ~= 0 then
|
|
||||||
vim.api.nvim_echo({
|
|
||||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
|
||||||
{ out, "WarningMsg" },
|
|
||||||
{ "\nPress any key to exit..." },
|
|
||||||
}, true, {})
|
|
||||||
vim.fn.getchar()
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
-- Setup lazy.nvim
|
|
||||||
require("lazy").setup({
|
|
||||||
spec = {
|
|
||||||
-- import your plugins
|
|
||||||
{ import = "plugins" },
|
|
||||||
},
|
|
||||||
-- Configure any other settings here. See the documentation for more details.
|
|
||||||
-- colorscheme that will be used when installing plugins.
|
|
||||||
install = { colorscheme = { "rose-pine" } },
|
|
||||||
-- automatically check for plugin updates
|
|
||||||
checker = {
|
|
||||||
enabled = false,
|
|
||||||
concurrency = nil,
|
|
||||||
notify = false,
|
|
||||||
frequency = 3600,
|
|
||||||
check_pinned = false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -1,28 +1,23 @@
|
|||||||
require("ink.remap")
|
require("ink.remap")
|
||||||
require("ink.lsp")
|
|
||||||
require("ink.tabline")
|
require("ink.tabline")
|
||||||
|
require("ink.lsp")
|
||||||
|
|
||||||
vim.opt.hlsearch = false -- do not highlight matches
|
|
||||||
vim.wo.number = true
|
|
||||||
vim.opt.relativenumber = true
|
|
||||||
vim.opt.mouse = "a"
|
|
||||||
vim.opt.clipboard = "unnamedplus"
|
|
||||||
vim.opt.breakindent = true -- Enable break indent
|
|
||||||
vim.opt.undofile = true -- Save undo history
|
|
||||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||||
|
|
||||||
|
vim.wo.number = true
|
||||||
|
vim.opt.relativenumber = true
|
||||||
vim.w.signcolumn = "yes" -- Keep signcolumn on by default
|
vim.w.signcolumn = "yes" -- Keep signcolumn on by default
|
||||||
vim.opt.updatetime = 250 -- Decrease update time
|
|
||||||
vim.opt.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds)
|
vim.opt.swapfile = false -- creates a swapfile
|
||||||
vim.opt.backup = false -- creates a backup file
|
vim.opt.undofile = true -- Save undo history
|
||||||
-- if a file is being edited by another program (or was written to file while editing with another program), it is not
|
-- if a file is being edited by another program (or was written to file while editing with another program), it is not
|
||||||
-- allowed to be edited
|
-- allowed to be edited
|
||||||
vim.opt.writebackup = false
|
vim.opt.writebackup = false
|
||||||
vim.opt.autoread = true -- reload files changed outside of neovim
|
|
||||||
vim.o.completeopt = "menuone,noinsert,popup,fuzzy"
|
vim.opt.mouse = "a"
|
||||||
vim.opt.termguicolors = true -- set termguicolors to enable highlight groups
|
vim.opt.clipboard = "unnamedplus"
|
||||||
vim.opt.whichwrap = "bs<>[]hl" -- which "horizontal" keys are allowed to travel to prev/next line
|
|
||||||
vim.o.wrap = true -- 1. Enable line wrapping by default
|
|
||||||
vim.o.linebreak = true -- 2. Break lines at word boundaries (improves readability)
|
vim.o.linebreak = true -- 2. Break lines at word boundaries (improves readability)
|
||||||
vim.o.showbreak = "↪ " -- 3. Add a visual indicator for wrapped lines
|
vim.o.showbreak = "↪ " -- 3. Add a visual indicator for wrapped lines
|
||||||
vim.opt.scrolloff = 4 -- minimal number of screen lines to keep above and below the cursor
|
vim.opt.scrolloff = 4 -- minimal number of screen lines to keep above and below the cursor
|
||||||
@@ -32,18 +27,28 @@ vim.opt.shiftwidth = 4 -- Number of spaces inserted when indenting
|
|||||||
vim.opt.tabstop = 4 -- A TAB character looks like 4 spaces
|
vim.opt.tabstop = 4 -- A TAB character looks like 4 spaces
|
||||||
vim.opt.softtabstop = 4 -- Number of spaces inserted instead of a TAB character
|
vim.opt.softtabstop = 4 -- Number of spaces inserted instead of a TAB character
|
||||||
vim.opt.expandtab = true -- Pressing the TAB key will insert spaces instead of a TAB character
|
vim.opt.expandtab = true -- Pressing the TAB key will insert spaces instead of a TAB character
|
||||||
|
vim.opt.breakindent = true -- Enable break indent
|
||||||
|
vim.opt.smartindent = true -- make indenting smarter again
|
||||||
|
vim.opt.whichwrap = "bs<>[]hl" -- which "horizontal" keys are allowed to travel to prev/next line
|
||||||
|
|
||||||
|
vim.opt.updatetime = 250 -- Decrease update time
|
||||||
|
vim.opt.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||||
|
|
||||||
|
vim.o.completeopt = "menuone,noinsert,popup,fuzzy"
|
||||||
|
-- Replicate blink's cmdline configuration
|
||||||
|
vim.opt.wildmode = "longest:full,full"
|
||||||
|
vim.opt.wildoptions = { "pum", "fuzzy" } -- Use a popup menu for cmdline with fuzzy matching
|
||||||
|
|
||||||
|
-- vim.keymap.set("i", "<C-Space>", "<C-x><C-o>", { desc = "Trigger LSP completion" })
|
||||||
|
-- Toggle signature help natively with <C-s> in insert mode (Neovim 0.11+ default)
|
||||||
|
|
||||||
vim.opt.cursorline = true
|
vim.opt.cursorline = true
|
||||||
|
|
||||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||||
vim.opt.splitright = true -- open new horizontal splits right
|
vim.opt.splitright = true -- open new horizontal splits right
|
||||||
vim.opt.swapfile = false -- creates a swapfile
|
|
||||||
vim.opt.smartindent = true -- make indenting smarter again
|
|
||||||
vim.opt.showtabline = 2 -- always show tabs
|
vim.opt.showtabline = 2 -- always show tabs
|
||||||
vim.opt.backspace = "indent,eol,start" -- allow backspace on
|
|
||||||
vim.opt.pumheight = 10 -- pop up menu height
|
vim.opt.pumheight = 10 -- pop up menu height
|
||||||
vim.wo.conceallevel = 0 -- so that `` is visible in markdown files
|
|
||||||
vim.opt.encoding = "utf-8" -- the encoding written to a file
|
|
||||||
vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages
|
|
||||||
vim.opt.autoindent = true
|
|
||||||
|
|
||||||
vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages
|
vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages
|
||||||
vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches
|
vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches
|
||||||
@@ -55,13 +60,9 @@ vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins fr
|
|||||||
-- Nice and simple folding:
|
-- Nice and simple folding:
|
||||||
vim.opt.foldenable = true
|
vim.opt.foldenable = true
|
||||||
vim.opt.foldlevel = 99
|
vim.opt.foldlevel = 99
|
||||||
vim.opt.foldmethod = "expr"
|
|
||||||
-- Default to treesitter folding
|
|
||||||
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
|
||||||
-- vim.opt.foldtext = "> "
|
|
||||||
vim.opt.fillchars:append({ fold = ">" })
|
vim.opt.fillchars:append({ fold = ">" })
|
||||||
|
|
||||||
vim.opt.incsearch = true -- search as characters are entered
|
-- vim.o.autocomplete = true -- Enables the overall completion feature.
|
||||||
|
|
||||||
-- Auto-reload buffers when files change on disk (e.g. from external tools or AI agents)
|
-- Auto-reload buffers when files change on disk (e.g. from external tools or AI agents)
|
||||||
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold" }, {
|
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold" }, {
|
||||||
@@ -101,44 +102,3 @@ vim.api.nvim_create_autocmd({ "VimEnter", "VimLeave" }, {
|
|||||||
--
|
--
|
||||||
-- Filetypes to enable spellcheck
|
-- Filetypes to enable spellcheck
|
||||||
local spell_types = { "text", "plaintex", "typst", "gitcommit", "markdown" }
|
local spell_types = { "text", "plaintex", "typst", "gitcommit", "markdown" }
|
||||||
|
|
||||||
-- add gotmpl filetypes for blueprint repos
|
|
||||||
-- *.ext.tmpl files use the filetype of ext (e.g. foo.json.tmpl -> json, bar.sh.tmpl -> bash)
|
|
||||||
vim.filetype.add({
|
|
||||||
extension = {
|
|
||||||
gotmpl = "gotmpl",
|
|
||||||
},
|
|
||||||
pattern = {
|
|
||||||
[".*/recipes/.*%.ya?ml"] = "gotmpl",
|
|
||||||
[".*%.tmpl$"] = function(path)
|
|
||||||
local name = vim.fn.fnamemodify(path, ":t")
|
|
||||||
local base = name:match("^(.+)%.tmpl$")
|
|
||||||
if base then
|
|
||||||
local ext = base:match("%.(%w+)$")
|
|
||||||
if ext then
|
|
||||||
if ext == "sh" then
|
|
||||||
return "bash"
|
|
||||||
end
|
|
||||||
return ext
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Set global spell option to false initially to disable it for all file types
|
|
||||||
vim.opt.spell = false
|
|
||||||
|
|
||||||
-- Create an augroup for spellcheck to group related autocommands
|
|
||||||
vim.api.nvim_create_augroup("Spellcheck", { clear = true })
|
|
||||||
|
|
||||||
-- Create an autocommand to enable spellcheck for specified file types
|
|
||||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
|
||||||
group = "Spellcheck", -- Grouping the command for easier management
|
|
||||||
pattern = spell_types, -- Only apply to these file types
|
|
||||||
callback = function()
|
|
||||||
vim.opt_local.spell = true -- Enable spellcheck for these file types
|
|
||||||
end,
|
|
||||||
desc = "Enable spellcheck for defined filetypes", -- Description for clarity
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
--- [[ LSP setup]]
|
-- [[ LSP setup ]]
|
||||||
---
|
-- You can consolidate your enable calls into a single table
|
||||||
|
vim.lsp.enable({
|
||||||
vim.lsp.enable("luals")
|
"luals",
|
||||||
vim.lsp.enable("rust")
|
"rust",
|
||||||
vim.lsp.enable("gopls")
|
"gopls",
|
||||||
vim.lsp.enable("bashls")
|
"bashls",
|
||||||
vim.lsp.enable("terraform")
|
"terraform",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Global capabilities override remains exactly the same
|
||||||
vim.lsp.config("*", {
|
vim.lsp.config("*", {
|
||||||
capabilities = {
|
capabilities = {
|
||||||
textDocument = {
|
textDocument = {
|
||||||
@@ -17,47 +19,69 @@ vim.lsp.config("*", {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[FOLDING SETUP
|
-- Add rounded borders to diagnostic floating windows
|
||||||
-- Prefer LSP folding if client supports it
|
vim.diagnostic.config({
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
float = { border = "rounded" },
|
||||||
callback = function(args)
|
|
||||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
||||||
if client ~= nil then
|
|
||||||
if client:supports_method("textDocument/foldingRange") then
|
|
||||||
local win = vim.api.nvim_get_current_win()
|
|
||||||
vim.wo[win].foldexpr = "v:lua.vim.lsp.foldexpr()"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
-- ]]
|
|
||||||
|
|
||||||
-- [[INLAY HINTS
|
-- Consolidate all LSP actions into a single LspAttach autocmd
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }),
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
||||||
if client.server_capabilities.inlayHintProvider then
|
|
||||||
vim.lsp.inlay_hint.enable(true, { bufnr = vim.fn.bufnr() })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- [[CODE ACTIONS
|
-- args.buf is the modern 0.12 standard. It guarantees you are acting
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
-- exactly on the buffer that triggered the attach.
|
||||||
callback = function(args)
|
local bufnr = args.buf
|
||||||
local bufnr = args.data.bufnr
|
|
||||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { buffer = bufnr, desc = "Code action (menu)" })
|
-- [[ INLAY HINTS ]]
|
||||||
vim.keymap.set("v", "<leader>ca", function()
|
if client:supports_method("textDocument/inlayHint") then
|
||||||
vim.lsp.buf.code_action({ context = { only = { "quickfix" } } })
|
-- Enable them by default when opening the file
|
||||||
end, { buffer = bufnr, desc = "Code action (selection)" })
|
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||||
-- Quickfix at cursor: apply single fix without menu when only one available
|
|
||||||
|
-- Create a buffer-local keymap to toggle them on/off
|
||||||
|
vim.keymap.set("n", "<leader>th", function()
|
||||||
|
local is_enabled = vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr })
|
||||||
|
vim.lsp.inlay_hint.enable(not is_enabled, { bufnr = bufnr })
|
||||||
|
end, { buffer = bufnr, desc = "Toggle Inlay Hints" })
|
||||||
|
end
|
||||||
|
-- [[ FOLDING SETUP ]]
|
||||||
|
if client:supports_method("textDocument/foldingRange") then
|
||||||
|
-- opt_local cleanly applies to the attached buffer without risking
|
||||||
|
-- applying to the wrong window if attached in the background
|
||||||
|
vim.opt_local.foldexpr = "v:lua.vim.lsp.foldexpr()"
|
||||||
|
vim.opt_local.foldmethod = "expr"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- [[ NAVIGATION ]]
|
||||||
|
vim.keymap.set("n", "gd", function()
|
||||||
|
require("fzf-lua").lsp_definitions()
|
||||||
|
end, { buffer = bufnr, desc = "Go to definition" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "gr", function()
|
||||||
|
require("fzf-lua").lsp_references()
|
||||||
|
end, { buffer = bufnr, desc = "Find references" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "gI", function()
|
||||||
|
require("fzf-lua").lsp_implementations()
|
||||||
|
end, { buffer = bufnr, desc = "Go to implementation" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = bufnr, desc = "Go to declaration" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "K", function()
|
||||||
|
vim.lsp.buf.hover({ border = "rounded", max_width = 120 })
|
||||||
|
end, { buffer = bufnr, desc = "Show documentation" })
|
||||||
|
|
||||||
|
-- [[ CODE ACTIONS ]]
|
||||||
|
-- Note: Neovim 0.11+ automatically maps 'gra' to code actions natively.
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>cf", function()
|
vim.keymap.set("n", "<leader>cf", function()
|
||||||
vim.lsp.buf.code_action({
|
vim.lsp.buf.code_action({
|
||||||
context = { only = { "quickfix" } },
|
context = { only = { "quickfix" } },
|
||||||
apply = true,
|
apply = true,
|
||||||
})
|
})
|
||||||
end, { buffer = bufnr, desc = "Apply fix at cursor" })
|
end, { buffer = bufnr, desc = "Apply fix at cursor" })
|
||||||
-- Organize imports (Rust: source.organizeImports.rust, Go: source.organizeImports)
|
|
||||||
vim.keymap.set("n", "<leader>ci", function()
|
vim.keymap.set("n", "<leader>ci", function()
|
||||||
vim.lsp.buf.code_action({
|
vim.lsp.buf.code_action({
|
||||||
context = {
|
context = {
|
||||||
@@ -68,3 +92,22 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
end, { buffer = bufnr, desc = "Organize imports" })
|
end, { buffer = bufnr, desc = "Organize imports" })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
-- group = vim.api.nvim_create_augroup("lsp_completion", { clear = true }),
|
||||||
|
-- callback = function(args)
|
||||||
|
-- local client_id = args.data.client_id
|
||||||
|
-- if not client_id then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- local client = vim.lsp.get_client_by_id(client_id)
|
||||||
|
-- if client and client:supports_method("textDocument/completion") then
|
||||||
|
-- -- Enable native LSP completion for this client + buffer
|
||||||
|
-- vim.lsp.completion.enable(true, client_id, args.buf, {
|
||||||
|
-- autotrigger = true, -- auto-show menu as you type (recommended)
|
||||||
|
-- -- You can also set { autotrigger = false } and trigger manually with <C-x><C-o>
|
||||||
|
-- })
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
|
-- })
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
|
||||||
-- loading lazy.nvim so that mappings are correct.
|
|
||||||
-- This is also a good place to setup other settings (vim.opt)
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.g.maplocalleader = "\\"
|
vim.g.maplocalleader = "\\"
|
||||||
-- (mode, key, command)
|
-- (mode, key, command)
|
||||||
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
|
|
||||||
-- vim.keymap.set("n", "<leader>pv", vim.cmd.Ex, { desc = "Open current directory" })
|
|
||||||
|
|
||||||
local function map(mode, lhs, rhs, opts)
|
local function map(mode, lhs, rhs, opts)
|
||||||
local options = { noremap = true, silent = true }
|
local options = { noremap = true, silent = true }
|
||||||
@@ -41,10 +36,10 @@ map("v", "p", '"_dP', { desc = "Paste without yanking underlying text" })
|
|||||||
|
|
||||||
map("n", "gl", "`.", { desc = "Jump to the last change in the file" })
|
map("n", "gl", "`.", { desc = "Jump to the last change in the file" })
|
||||||
|
|
||||||
map("n", "C-d", "<C-d>zz")
|
map("n", "<C-d>", "<C-d>zz")
|
||||||
map("n", "C-u", "<C-u>zz")
|
map("n", "<C-u>", "<C-u>zz")
|
||||||
map("n", "C-f", "<C-f>zz")
|
map("n", "<C-f>", "<C-f>zz")
|
||||||
map("n", "C-b", "<C-b>zz")
|
map("n", "<C-b>", "<C-b>zz")
|
||||||
|
|
||||||
-- map('n', '<C-f>', 'za', { desc = 'Toggle cursor fold' })
|
-- map('n', '<C-f>', 'za', { desc = 'Toggle cursor fold' })
|
||||||
-- map('n', '<C-down>', 'zm', { desc = 'Toggle all folds at cursor' })
|
-- map('n', '<C-down>', 'zm', { desc = 'Toggle all folds at cursor' })
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
--- @return string
|
|
||||||
local function tab_info()
|
local function tab_info()
|
||||||
local fname = vim.fn.expand("%:p")
|
local fname = vim.fn.expand("%:p")
|
||||||
if fname == "" then
|
if fname == "" then
|
||||||
|
|||||||
118
nvim/.config/nvim/lua/plugins/ai/init.lua
Normal file
118
nvim/.config/nvim/lua/plugins/ai/init.lua
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/olimorris/codecompanion.nvim" },
|
||||||
|
{ src = "https://github.com/nvim-lua/plenary.nvim" },
|
||||||
|
{
|
||||||
|
src = "https://github.com/saghen/blink.cmp",
|
||||||
|
version = vim.version.range("^1"),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local codecompanion = require("codecompanion")
|
||||||
|
-- Dynamically choose the adapter based on the environment variable
|
||||||
|
local active_adapter = os.getenv("GEMINI_API_KEY") and "gemini" or "kiro"
|
||||||
|
|
||||||
|
codecompanion.setup({
|
||||||
|
strategies = {
|
||||||
|
chat = { adapter = active_adapter },
|
||||||
|
inline = { adapter = active_adapter },
|
||||||
|
agent = { adapter = active_adapter },
|
||||||
|
},
|
||||||
|
adapters = {
|
||||||
|
gemini = function()
|
||||||
|
return require("codecompanion.adapters").extend("gemini", {
|
||||||
|
env = {
|
||||||
|
-- We read the API key from the environment variable.
|
||||||
|
-- You can also use "cmd:pass show gemini/api_key" or "cmd:cat ~/.gemini_api_key"
|
||||||
|
api_key = os.getenv("GEMINI_API_KEY") or "cmd:cat ~/.gemini_api_key",
|
||||||
|
},
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = "gemini-3.1-pro-preview",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
-- If 'kiro' is a custom CLI or local LLM, you must define it here.
|
||||||
|
-- This is a generic custom adapter stub for CodeCompanion:
|
||||||
|
kiro = function()
|
||||||
|
return require("codecompanion.adapters").extend("openai_compatible", {
|
||||||
|
name = "kiro",
|
||||||
|
env = {
|
||||||
|
url = "http://localhost:11434", -- Example endpoint
|
||||||
|
-- api_key = "...",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Optional: Keymaps for CodeCompanion
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true })
|
||||||
|
vim.cmd([[cab cc CodeCompanion]])
|
||||||
|
|
||||||
|
vim.cmd("packadd blink.cmp")
|
||||||
|
local blink = require("blink.cmp")
|
||||||
|
blink.setup({
|
||||||
|
keymap = { preset = "default" },
|
||||||
|
appearance = { nerd_font_variant = "mono" },
|
||||||
|
completion = {
|
||||||
|
menu = { border = "rounded" },
|
||||||
|
documentation = { auto_show = true, window = { border = "rounded" } },
|
||||||
|
},
|
||||||
|
|
||||||
|
cmdline = {
|
||||||
|
keymap = { ["<Tab>"] = { "show", "accept" } },
|
||||||
|
completion = { menu = { auto_show = true }, ghost_text = { enabled = true } },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- By removing `snippets = { preset = 'luasnip' }`, Blink natively
|
||||||
|
-- defaults to Neovim 0.11+ built-in `vim.snippet` API.
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
-- Added codecompanion, removed emoji
|
||||||
|
default = { "lsp", "path", "snippets", "buffer", "codecompanion" },
|
||||||
|
providers = {
|
||||||
|
cmdline = {
|
||||||
|
min_keyword_length = function(ctx)
|
||||||
|
if ctx.mode == "cmdline" and string.find(ctx.line, " ") == nil then
|
||||||
|
return 3
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- Wire up CodeCompanion to Blink
|
||||||
|
codecompanion = {
|
||||||
|
name = "CodeCompanion",
|
||||||
|
module = "codecompanion.providers.completion.blink",
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Ensure borders stay colored even after toggling light/dark themes
|
||||||
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { link = "Special" })
|
||||||
|
vim.api.nvim_set_hl(0, "BlinkCmpDocBorder", { link = "Special" })
|
||||||
|
vim.api.nvim_set_hl(0, "FloatBorder", { link = "Special" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities = blink.get_lsp_capabilities(capabilities)
|
||||||
|
|
||||||
|
-- Safely merge with existing global LSP capabilities so we don't overwrite settings from ink/lsp.lua
|
||||||
|
local existing_config = vim.lsp.config["*"]
|
||||||
|
if type(existing_config) == "table" and type(existing_config.capabilities) == "table" then
|
||||||
|
capabilities = vim.tbl_deep_extend("force", existing_config.capabilities, capabilities)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Apply to all natively loaded 0.12 LSP servers
|
||||||
|
vim.lsp.config("*", {
|
||||||
|
capabilities = capabilities,
|
||||||
|
-- Note: We DO NOT use vim.lsp.completion.enable() here because
|
||||||
|
-- Blink is taking over the UI rendering.
|
||||||
|
})
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
-- Avante.nvim: uses Cursor ACP when the agent binary is available,
|
|
||||||
-- otherwise falls back to the Gemini API (requires GEMINI_API_KEY).
|
|
||||||
local agent_path = os.getenv("HOME") .. "/.local/bin/agent"
|
|
||||||
local has_cursor_agent = vim.uv.fs_stat(agent_path) ~= nil
|
|
||||||
|
|
||||||
local provider = has_cursor_agent and "cursor" or "gemini"
|
|
||||||
|
|
||||||
return {
|
|
||||||
{
|
|
||||||
"yetone/avante.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
version = false,
|
|
||||||
build = "make",
|
|
||||||
opts = {
|
|
||||||
provider = provider,
|
|
||||||
mode = "agentic",
|
|
||||||
behaviour = {
|
|
||||||
auto_approve_tool_permissions = {
|
|
||||||
"web_search",
|
|
||||||
"fetch",
|
|
||||||
"view",
|
|
||||||
"ls",
|
|
||||||
"glob",
|
|
||||||
"grep",
|
|
||||||
"get_diagnostics",
|
|
||||||
"think",
|
|
||||||
"read_todos",
|
|
||||||
"read_file_toplevel_symbols",
|
|
||||||
"read_definitions",
|
|
||||||
},
|
|
||||||
auto_apply_diff_after_generation = false,
|
|
||||||
enable_fastapply = false,
|
|
||||||
},
|
|
||||||
acp_providers = {
|
|
||||||
cursor = {
|
|
||||||
command = agent_path,
|
|
||||||
args = { "acp" },
|
|
||||||
auth_method = "cursor_login",
|
|
||||||
env = {
|
|
||||||
HOME = os.getenv("HOME"),
|
|
||||||
PATH = os.getenv("PATH"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
providers = {
|
|
||||||
gemini = {
|
|
||||||
model = "gemini-2.5-flash",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function(_, opts)
|
|
||||||
require("avante").setup(opts)
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
pattern = "AvanteInput",
|
|
||||||
callback = function(args)
|
|
||||||
local buf = args.buf
|
|
||||||
local min_height = 5
|
|
||||||
local max_height = 20
|
|
||||||
|
|
||||||
local function resize_input()
|
|
||||||
local win = vim.fn.bufwinid(buf)
|
|
||||||
if win == -1 or not vim.api.nvim_win_is_valid(win) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local lines = vim.api.nvim_buf_line_count(buf)
|
|
||||||
local height = math.max(min_height, math.min(lines + 1, max_height))
|
|
||||||
vim.api.nvim_win_set_height(win, height)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, {
|
|
||||||
buffer = buf,
|
|
||||||
callback = resize_input,
|
|
||||||
})
|
|
||||||
resize_input()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
keys = {
|
|
||||||
{ "<C-\\>", "<cmd>AvanteToggle<cr>", mode = { "n", "v", "i" }, desc = "Toggle Avante Chat" },
|
|
||||||
{ "<leader>aa", "<cmd>AvanteAsk<cr>", desc = "Avante Ask" },
|
|
||||||
{ "<leader>ae", "<cmd>AvanteEdit<cr>", desc = "Avante Edit" },
|
|
||||||
{ "<leader>ar", "<cmd>AvanteRefresh<cr>", desc = "Avante Refresh" },
|
|
||||||
},
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
"MunifTanjim/nui.nvim",
|
|
||||||
"nvim-tree/nvim-web-devicons",
|
|
||||||
{
|
|
||||||
"MeanderingProgrammer/render-markdown.nvim",
|
|
||||||
opts = {
|
|
||||||
file_types = { "markdown", "Avante" },
|
|
||||||
},
|
|
||||||
ft = { "markdown", "Avante" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
return {
|
|
||||||
-- keymap helper
|
|
||||||
{ "folke/which-key.nvim", opts = {} },
|
|
||||||
{ -- undo tree
|
|
||||||
"mbbill/undotree",
|
|
||||||
opts = {},
|
|
||||||
keys = {
|
|
||||||
{ "<Leader>u", vim.cmd.UndotreeToggle, desc = "Toggle undo tree" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ -- minimal and fast autopairs
|
|
||||||
"echasnovski/mini.pairs",
|
|
||||||
event = "VeryLazy",
|
|
||||||
opts = {
|
|
||||||
modes = { insert = true, command = true, terminal = false },
|
|
||||||
-- skip autopair when next character is one of these
|
|
||||||
skip_next = [=[[%w%%%'%[%"%.%`%$]]=],
|
|
||||||
-- skip autopair when the cursor is inside these treesitter nodes
|
|
||||||
skip_ts = { "string" },
|
|
||||||
-- skip autopair when next character is closing pair
|
|
||||||
-- and there are more closing pairs than opening pairs
|
|
||||||
skip_unbalanced = true,
|
|
||||||
-- better deal with markdown code blocks
|
|
||||||
markdown = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ -- fugitive
|
|
||||||
"tpope/vim-fugitive",
|
|
||||||
keys = {
|
|
||||||
{ "<Leader>gs", vim.cmd.Git, desc = "Fugitive git command" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"folke/flash.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
---@type Flash.Config
|
|
||||||
opts = {},
|
|
||||||
keys = {
|
|
||||||
{
|
|
||||||
"zk",
|
|
||||||
mode = { "n", "x", "o" },
|
|
||||||
function()
|
|
||||||
require("flash").jump()
|
|
||||||
end,
|
|
||||||
desc = "Flash",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Zk",
|
|
||||||
mode = { "n", "x", "o" },
|
|
||||||
function()
|
|
||||||
require("flash").treesitter()
|
|
||||||
end,
|
|
||||||
desc = "Flash Treesitter",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"r",
|
|
||||||
mode = "o",
|
|
||||||
function()
|
|
||||||
require("flash").remote()
|
|
||||||
end,
|
|
||||||
desc = "Remote Flash",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"R",
|
|
||||||
mode = { "o", "x" },
|
|
||||||
function()
|
|
||||||
require("flash").treesitter_search()
|
|
||||||
end,
|
|
||||||
desc = "Treesitter Search",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<c-s>",
|
|
||||||
mode = { "c" },
|
|
||||||
function()
|
|
||||||
require("flash").toggle()
|
|
||||||
end,
|
|
||||||
desc = "Toggle Flash Search",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
75
nvim/.config/nvim/lua/plugins/basic/init.lua
Normal file
75
nvim/.config/nvim/lua/plugins/basic/init.lua
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/folke/which-key.nvim" },
|
||||||
|
{ src = "https://github.com/tpope/vim-fugitive" },
|
||||||
|
{ src = "https://github.com/stevearc/oil.nvim" },
|
||||||
|
{ src = "https://github.com/echasnovski/mini.icons" },
|
||||||
|
{ src = "https://github.com/yorickpeterse/nvim-jump" },
|
||||||
|
{ src = "https://github.com/ibhagwan/fzf-lua" },
|
||||||
|
})
|
||||||
|
require("which-key").setup({
|
||||||
|
preset = "helix",
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>gs", vim.cmd.Git, { desc = "Fugitive git command" })
|
||||||
|
|
||||||
|
require("oil").setup({
|
||||||
|
default_file_explorer = true,
|
||||||
|
view_options = {
|
||||||
|
show_hidden = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>pv", "<cmd>Oil<cr>", { desc = "Open current directory" })
|
||||||
|
vim.keymap.set({ "n", "x", "o" }, "<leader>f", require("jump").start, {})
|
||||||
|
|
||||||
|
local function get_project_root()
|
||||||
|
-- 1. Prioritize Terraform or nvim config project root (keeps search local to the TF module)
|
||||||
|
local tf_root = vim.fs.root(0, { ".terraform", ".terraform.lock.hcl" })
|
||||||
|
local nvim_root = vim.fs.root(0, { "nvim-pack-lock.json" })
|
||||||
|
|
||||||
|
-- 2. Fallback to Git root (prioritizes the top-level repo for Rust/Go/etc.)
|
||||||
|
local git_root = vim.fs.root(0, ".git")
|
||||||
|
|
||||||
|
-- 3. Fallback to language markers if not in a git repo
|
||||||
|
local lang_root = vim.fs.root(0, {
|
||||||
|
"Cargo.toml",
|
||||||
|
"go.mod",
|
||||||
|
"pyproject.toml",
|
||||||
|
"requirements.txt",
|
||||||
|
"pom.xml",
|
||||||
|
"build.gradle",
|
||||||
|
".luarc.json",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Chain them in the exact priority order you want
|
||||||
|
return tf_root or nvim_root or git_root or lang_root or vim.fn.getcwd()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>pf", function()
|
||||||
|
require("fzf-lua").files({ cwd = get_project_root() })
|
||||||
|
end, { desc = "Fuzzy find project files" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>ps", function()
|
||||||
|
require("fzf-lua").live_grep({ cwd = get_project_root() })
|
||||||
|
end, { desc = "Live grep project text" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader><space>", function()
|
||||||
|
require("fzf-lua").buffers()
|
||||||
|
end, { desc = "Fuzzy find open files" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>gf", function()
|
||||||
|
require("fzf-lua").git_files()
|
||||||
|
end, { desc = "Fuzzy find tracked Git files" })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
|
group = vim.api.nvim_create_augroup("AutoChdirProjectRoot", { clear = true }),
|
||||||
|
callback = function(args)
|
||||||
|
-- Only change directory for normal files
|
||||||
|
if vim.bo[args.buf].buftype == "" and vim.api.nvim_buf_get_name(args.buf) ~= "" then
|
||||||
|
local root = get_project_root()
|
||||||
|
if root and root ~= vim.fn.getcwd() then
|
||||||
|
vim.api.nvim_set_current_dir(root)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
return {
|
|
||||||
{
|
|
||||||
"L3MON4D3/LuaSnip",
|
|
||||||
version = "v2.*",
|
|
||||||
dependencies = {
|
|
||||||
"rafamadriz/friendly-snippets",
|
|
||||||
},
|
|
||||||
-- install jsregexp (optional!).
|
|
||||||
build = "make install_jsregexp",
|
|
||||||
config = function()
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local snippets_folder = vim.fn.stdpath("config") .. "/snippets"
|
|
||||||
-- Load all Lua files in the snippets directory except init.lua
|
|
||||||
local files = vim.fn.glob(snippets_folder .. "/*.lua", false, true)
|
|
||||||
for _, file in ipairs(files) do
|
|
||||||
local filename = vim.fn.fnamemodify(file, ":t")
|
|
||||||
-- Remove .lua extension to get the filetype
|
|
||||||
local ft = filename:match("(.+)%.lua$")
|
|
||||||
if ft then
|
|
||||||
-- Load the file which should return a table of snippets
|
|
||||||
local ok, snippets = pcall(dofile, file)
|
|
||||||
if ok and type(snippets) == "table" then
|
|
||||||
ls.add_snippets(ft, snippets)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"saghen/blink.cmp",
|
|
||||||
-- use a release tag to download pre-built binaries
|
|
||||||
version = "1.*",
|
|
||||||
dependencies = {
|
|
||||||
"moyiz/blink-emoji.nvim",
|
|
||||||
},
|
|
||||||
---@module 'blink.cmp'
|
|
||||||
---@type blink.cmp.Config
|
|
||||||
opts = {
|
|
||||||
enabled = function()
|
|
||||||
return vim.bo.filetype ~= "AvanteInput"
|
|
||||||
end,
|
|
||||||
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
|
||||||
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
|
||||||
-- 'enter' for enter to accept
|
|
||||||
-- 'none' for no mappings
|
|
||||||
--
|
|
||||||
-- All presets have the following mappings:
|
|
||||||
-- C-space: Open menu or open docs if already open
|
|
||||||
-- C-n/C-p or Up/Down: Select next/previous item
|
|
||||||
-- C-e: Hide menu
|
|
||||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
|
||||||
--
|
|
||||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
|
||||||
keymap = { preset = "default" },
|
|
||||||
|
|
||||||
appearance = {
|
|
||||||
nerd_font_variant = "mono",
|
|
||||||
},
|
|
||||||
|
|
||||||
-- (Default) Only show the documentation popup when manually triggered
|
|
||||||
completion = { documentation = { auto_show = true } },
|
|
||||||
cmdline = {
|
|
||||||
keymap = {
|
|
||||||
-- recommended, as the default keymap will only show and select the next item
|
|
||||||
["<Tab>"] = { "show", "accept" },
|
|
||||||
},
|
|
||||||
completion = {
|
|
||||||
menu = { auto_show = true },
|
|
||||||
ghost_text = { enabled = true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
snippets = { preset = "luasnip" },
|
|
||||||
-- Default list of enabled providers defined so that you can extend it
|
|
||||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
|
||||||
sources = {
|
|
||||||
default = { "lsp", "path", "snippets", "buffer", "emoji" },
|
|
||||||
providers = {
|
|
||||||
cmdline = {
|
|
||||||
min_keyword_length = function(ctx)
|
|
||||||
-- when typing a command, only show when the keyword is 3 characters or longer
|
|
||||||
if ctx.mode == "cmdline" and string.find(ctx.line, " ") == nil then
|
|
||||||
return 3
|
|
||||||
end
|
|
||||||
return 0
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
emoji = {
|
|
||||||
module = "blink-emoji",
|
|
||||||
name = "Emoji",
|
|
||||||
score_offset = 15, -- Tune by preference
|
|
||||||
opts = { insert = true }, -- Insert emoji (default) or complete its name
|
|
||||||
should_show_items = function()
|
|
||||||
return vim.tbl_contains(
|
|
||||||
-- Enable emoji completion only for git commits and markdown.
|
|
||||||
-- By default, enabled for all file-types.
|
|
||||||
{ "gitcommit", "markdown" },
|
|
||||||
vim.o.filetype
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
|
||||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
|
||||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
|
||||||
--
|
|
||||||
-- See the fuzzy documentation for more information
|
|
||||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
|
||||||
},
|
|
||||||
opts_extend = { "sources.default" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
return {
|
|
||||||
{
|
|
||||||
"stevearc/oil.nvim",
|
|
||||||
---@module 'oil'
|
|
||||||
---@type oil.SetupOpts
|
|
||||||
opts = {
|
|
||||||
default_file_explorer = true,
|
|
||||||
view_options = {
|
|
||||||
show_hidden = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- Optional dependencies
|
|
||||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
|
||||||
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
|
|
||||||
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
|
|
||||||
lazy = false,
|
|
||||||
keys = {
|
|
||||||
{ "<leader>pv", "<cmd>Oil<cr>", desc = "Open current directory" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
return {
|
|
||||||
-- heuristic indent
|
|
||||||
{ "tpope/vim-sleuth" },
|
|
||||||
{
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
build = ":TSUpdate",
|
|
||||||
config = function()
|
|
||||||
local configs = require("nvim-treesitter.configs")
|
|
||||||
--@diagnostic disable-next-line: missing-fields
|
|
||||||
configs.setup({
|
|
||||||
ensure_installed = {
|
|
||||||
"bash",
|
|
||||||
--"zsh",
|
|
||||||
"c",
|
|
||||||
"cmake",
|
|
||||||
"dockerfile",
|
|
||||||
"gitignore",
|
|
||||||
"go",
|
|
||||||
"gotmpl",
|
|
||||||
"java",
|
|
||||||
"json",
|
|
||||||
"lua",
|
|
||||||
"make",
|
|
||||||
"markdown",
|
|
||||||
"markdown_inline",
|
|
||||||
"python",
|
|
||||||
"query",
|
|
||||||
"regex",
|
|
||||||
"rust",
|
|
||||||
"terraform",
|
|
||||||
"vim",
|
|
||||||
"vimdoc",
|
|
||||||
"yaml",
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
|
||||||
sync_install = false,
|
|
||||||
|
|
||||||
-- Automatically install missing parsers when entering buffer
|
|
||||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
|
||||||
auto_install = true,
|
|
||||||
|
|
||||||
-- List of parsers to ignore installing (or "all")
|
|
||||||
ignore_install = { "javascript" },
|
|
||||||
|
|
||||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
|
||||||
-- parser_install_dir = "/some/path/to/store/parsers",
|
|
||||||
-- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
|
||||||
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
|
|
||||||
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
|
||||||
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
|
||||||
-- the name of the parser)
|
|
||||||
-- list of language that will be disabled
|
|
||||||
disable = {},
|
|
||||||
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
|
|
||||||
-- disable = function(lang, buf)
|
|
||||||
-- local max_filesize = 100 * 1024 -- 100 KB
|
|
||||||
-- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
|
||||||
-- if ok and stats and stats.size > max_filesize then
|
|
||||||
-- return true
|
|
||||||
-- end
|
|
||||||
-- end,
|
|
||||||
|
|
||||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
|
||||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
|
||||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
|
||||||
-- Instead of true it can also be a list of languages
|
|
||||||
additional_vim_regex_highlighting = false,
|
|
||||||
},
|
|
||||||
indent = {
|
|
||||||
enable = false,
|
|
||||||
disable = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"stevearc/conform.nvim",
|
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
|
||||||
config = function()
|
|
||||||
local conform = require("conform")
|
|
||||||
conform.setup({
|
|
||||||
formatters_by_ft = {
|
|
||||||
-- brew install stylua
|
|
||||||
lua = { "stylua" },
|
|
||||||
-- install rust
|
|
||||||
rust = { "rustfmt" },
|
|
||||||
-- brew install prettier
|
|
||||||
markdown = { "markdownlint-cli2" },
|
|
||||||
json = { "prettierd", "prettier" },
|
|
||||||
yaml = { "yamlfmt" },
|
|
||||||
-- install terraform
|
|
||||||
terraform = { "terraform_fmt" },
|
|
||||||
-- brew install shfmt
|
|
||||||
bash = { "shfmt" },
|
|
||||||
zsh = { "shfmt" },
|
|
||||||
sh = { "shfmt" },
|
|
||||||
-- brew install ruff
|
|
||||||
python = { "ruff" },
|
|
||||||
-- go install mvdan.cc/gofumpt@latest
|
|
||||||
go = { "gofumpt" },
|
|
||||||
},
|
|
||||||
formatters = {
|
|
||||||
prettier = {
|
|
||||||
prepend_args = { "--prose-wrap", "always" },
|
|
||||||
},
|
|
||||||
shfmt = {
|
|
||||||
prepend_args = { "-i", "4", "-ci" },
|
|
||||||
},
|
|
||||||
ruff = {
|
|
||||||
prepend_args = { "--extend-select", "I" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
format_on_save = {
|
|
||||||
lsp_fallback = true,
|
|
||||||
async = false,
|
|
||||||
timeout_ms = 3000,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
|
|
||||||
conform.format({
|
|
||||||
lsp_fallback = true,
|
|
||||||
async = false,
|
|
||||||
timeout_ms = 5000,
|
|
||||||
})
|
|
||||||
end, { desc = "Format file or range (in visual mode)" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
79
nvim/.config/nvim/lua/plugins/formatting/init.lua
Normal file
79
nvim/.config/nvim/lua/plugins/formatting/init.lua
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" },
|
||||||
|
{ src = "https://github.com/stevearc/conform.nvim" },
|
||||||
|
})
|
||||||
|
|
||||||
|
require("nvim-treesitter").install({
|
||||||
|
--"zsh",
|
||||||
|
"cmake",
|
||||||
|
"dockerfile",
|
||||||
|
"gitignore",
|
||||||
|
"go",
|
||||||
|
"gotmpl",
|
||||||
|
"java",
|
||||||
|
"json",
|
||||||
|
"make",
|
||||||
|
"regex",
|
||||||
|
"rust",
|
||||||
|
"terraform",
|
||||||
|
"yaml",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Default to treesitter folding
|
||||||
|
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||||
|
vim.opt.foldmethod = "expr"
|
||||||
|
vim.opt.foldtext = "> "
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, {
|
||||||
|
group = vim.api.nvim_create_augroup("LazyLoadConform", { clear = true }),
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("packadd conform.nvim")
|
||||||
|
local conform = require("conform")
|
||||||
|
conform.setup({
|
||||||
|
formatters_by_ft = {
|
||||||
|
-- brew install stylua
|
||||||
|
lua = { "stylua" },
|
||||||
|
-- install rust
|
||||||
|
rust = { "rustfmt" },
|
||||||
|
-- brew install prettier
|
||||||
|
markdown = { "markdownlint-cli2" },
|
||||||
|
json = { "prettierd", "prettier" },
|
||||||
|
yaml = { "yamlfmt" },
|
||||||
|
-- install terraform
|
||||||
|
terraform = { "terraform_fmt" },
|
||||||
|
-- brew install shfmt
|
||||||
|
bash = { "shfmt" },
|
||||||
|
zsh = { "shfmt" },
|
||||||
|
sh = { "shfmt" },
|
||||||
|
-- brew install ruff
|
||||||
|
python = { "ruff" },
|
||||||
|
-- go install mvdan.cc/gofumpt@latest
|
||||||
|
go = { "gofumpt" },
|
||||||
|
},
|
||||||
|
formatters = {
|
||||||
|
prettier = {
|
||||||
|
prepend_args = { "--prose-wrap", "always" },
|
||||||
|
},
|
||||||
|
shfmt = {
|
||||||
|
prepend_args = { "-i", "4", "-ci" },
|
||||||
|
},
|
||||||
|
ruff = {
|
||||||
|
prepend_args = { "--extend-select", "I" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
format_on_save = {
|
||||||
|
lsp_fallback = true,
|
||||||
|
async = false,
|
||||||
|
timeout_ms = 3000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
|
||||||
|
conform.format({
|
||||||
|
lsp_fallback = true,
|
||||||
|
async = false,
|
||||||
|
timeout_ms = 5000,
|
||||||
|
})
|
||||||
|
end, { desc = "Format file or range (in visual mode)" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
6
nvim/.config/nvim/lua/plugins/init.lua
Normal file
6
nvim/.config/nvim/lua/plugins/init.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require("plugins.basic")
|
||||||
|
require("plugins.tmux")
|
||||||
|
require("plugins.ui")
|
||||||
|
require("plugins.formatting")
|
||||||
|
require("plugins.linting")
|
||||||
|
require("plugins.ai")
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
return {
|
|
||||||
{
|
|
||||||
"mfussenegger/nvim-lint",
|
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
|
||||||
config = function()
|
|
||||||
local lint = require("lint")
|
|
||||||
lint.linters_by_ft = {
|
|
||||||
-- brew install luacheck
|
|
||||||
lua = { "luacheck" },
|
|
||||||
bash = { "shellcheck" },
|
|
||||||
sh = { "shellcheck" },
|
|
||||||
-- brew install tflint
|
|
||||||
terraform = { "tflint" },
|
|
||||||
-- brew install markdownlint-cli2
|
|
||||||
markdown = { "markdownlint-cli2" },
|
|
||||||
-- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0
|
|
||||||
go = { "golangcilint" },
|
|
||||||
}
|
|
||||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
|
||||||
group = lint_augroup,
|
|
||||||
callback = function()
|
|
||||||
lint.try_lint()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
vim.keymap.set("n", "<leader>l", function()
|
|
||||||
lint.try_lint()
|
|
||||||
end, { desc = "Trigger linting for current file" })
|
|
||||||
vim.keymap.set("n", "<leader>d", function()
|
|
||||||
if vim.diagnostic.config().virtual_lines then
|
|
||||||
vim.diagnostic.config({ virtual_lines = false })
|
|
||||||
else
|
|
||||||
vim.diagnostic.config({ virtual_lines = { current_line = true } })
|
|
||||||
end
|
|
||||||
end, { desc = "Toggle inline diagnostics" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
79
nvim/.config/nvim/lua/plugins/linting/init.lua
Normal file
79
nvim/.config/nvim/lua/plugins/linting/init.lua
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/mfussenegger/nvim-lint" },
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, {
|
||||||
|
group = vim.api.nvim_create_augroup("LazyLoadNvimLint", { clear = true }),
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("packadd lint.nvim")
|
||||||
|
local lint = require("lint")
|
||||||
|
lint.linters_by_ft = {
|
||||||
|
-- brew install luacheck
|
||||||
|
lua = { "luacheck" },
|
||||||
|
bash = { "shellcheck" },
|
||||||
|
sh = { "shellcheck" },
|
||||||
|
-- brew install tflint
|
||||||
|
terraform = { "tflint" },
|
||||||
|
-- brew install markdownlint-cli2
|
||||||
|
markdown = { "markdownlint-cli2" },
|
||||||
|
-- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0
|
||||||
|
go = { "golangcilint" },
|
||||||
|
}
|
||||||
|
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||||
|
group = lint_augroup,
|
||||||
|
callback = function()
|
||||||
|
lint.try_lint()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.keymap.set("n", "<leader>l", function()
|
||||||
|
lint.try_lint()
|
||||||
|
end, { desc = "Trigger linting for current file" })
|
||||||
|
vim.keymap.set("n", "<leader>d", function()
|
||||||
|
if vim.diagnostic.config().virtual_lines then
|
||||||
|
vim.diagnostic.config({ virtual_lines = false })
|
||||||
|
else
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_lines = {
|
||||||
|
current_line = true,
|
||||||
|
format = function(diagnostic)
|
||||||
|
local max_width = vim.api.nvim_win_get_width(0) - 15
|
||||||
|
max_width = math.max(max_width, 30)
|
||||||
|
local wrapped = ""
|
||||||
|
local current_len = 0
|
||||||
|
for word in diagnostic.message:gmatch("%S+") do
|
||||||
|
if current_len + #word + 1 > max_width and current_len > 0 then
|
||||||
|
wrapped = wrapped .. "\n" .. word
|
||||||
|
current_len = #word
|
||||||
|
else
|
||||||
|
wrapped = wrapped == "" and word or (wrapped .. " " .. word)
|
||||||
|
current_len = current_len + #word + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return wrapped
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end, { desc = "Toggle inline diagnostics" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>cd", function()
|
||||||
|
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
|
||||||
|
local diagnostics = vim.diagnostic.get(0, { lnum = line })
|
||||||
|
|
||||||
|
if #diagnostics == 0 then
|
||||||
|
vim.notify("No diagnostics on current line", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local messages = {}
|
||||||
|
for _, diag in ipairs(diagnostics) do
|
||||||
|
table.insert(messages, diag.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.fn.setreg("+", table.concat(messages, "\n"))
|
||||||
|
vim.notify("Copied diagnostic(s) to clipboard", vim.log.levels.INFO)
|
||||||
|
end, { desc = "Copy diagnostic to clipboard" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
return {
|
|
||||||
{ -- file finder
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
branch = "0.1.x",
|
|
||||||
event = "VimEnter",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
|
||||||
-- Only load if `make` is available. Make sure you have the system
|
|
||||||
-- requirements installed.
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope-fzf-native.nvim",
|
|
||||||
build = "make",
|
|
||||||
cond = function()
|
|
||||||
return vim.fn.executable("make") == 1
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
"nvim-telescope/telescope-ui-select.nvim",
|
|
||||||
|
|
||||||
-- Useful for getting pretty icons, but requires a Nerd Font.
|
|
||||||
"nvim-tree/nvim-web-devicons",
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local actions = require("telescope.actions")
|
|
||||||
local builtin = require("telescope.builtin")
|
|
||||||
|
|
||||||
require("telescope").setup({
|
|
||||||
defaults = {
|
|
||||||
mappings = {
|
|
||||||
i = {
|
|
||||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
|
||||||
["<C-j>"] = actions.move_selection_next, -- move to next result
|
|
||||||
["<C-l>"] = actions.select_default, -- open file
|
|
||||||
},
|
|
||||||
n = {
|
|
||||||
["q"] = actions.close,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
pickers = {
|
|
||||||
find_files = {
|
|
||||||
file_ignore_patterns = {
|
|
||||||
"node_modules",
|
|
||||||
"target",
|
|
||||||
".terraform",
|
|
||||||
".venv",
|
|
||||||
".git",
|
|
||||||
-- Ignore git submodules
|
|
||||||
"^./.git/",
|
|
||||||
"^./*/.git/",
|
|
||||||
".gitmodules",
|
|
||||||
".gitignore",
|
|
||||||
".*/%.git/.*", -- Ignore any .git directories in subdirectories
|
|
||||||
},
|
|
||||||
hidden = true,
|
|
||||||
-- Ignore git submodules
|
|
||||||
follow = true,
|
|
||||||
},
|
|
||||||
git_files = {
|
|
||||||
recurse_submodules = false,
|
|
||||||
show_untracked = true,
|
|
||||||
},
|
|
||||||
buffers = {
|
|
||||||
initial_mode = "normal",
|
|
||||||
sort_lastused = true,
|
|
||||||
-- sort_mru = true,
|
|
||||||
mappings = {
|
|
||||||
n = {
|
|
||||||
["d"] = actions.delete_buffer,
|
|
||||||
["l"] = actions.select_default,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
live_grep = {
|
|
||||||
file_ignore_patterns = {
|
|
||||||
"node_modules",
|
|
||||||
"target",
|
|
||||||
".terraform",
|
|
||||||
".git",
|
|
||||||
".venv",
|
|
||||||
},
|
|
||||||
additional_args = function(_)
|
|
||||||
return { "--hidden" }
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
path_display = {
|
|
||||||
filename_first = {
|
|
||||||
reverse_directories = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extensions = {
|
|
||||||
["ui-select"] = {
|
|
||||||
require("telescope.themes").get_dropdown(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
git_files = {
|
|
||||||
previewer = false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
|
||||||
pcall(require("telescope").load_extension, "fzf")
|
|
||||||
pcall(require("telescope").load_extension, "ui-select")
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>pf", builtin.find_files, { desc = "Telescope find files" })
|
|
||||||
vim.keymap.set("n", "<C-p>", builtin.git_files, { desc = "Telescope find git files" })
|
|
||||||
vim.keymap.set("n", "<leader>ps", function()
|
|
||||||
builtin.grep_string({ search = vim.fn.input("Grep > ") })
|
|
||||||
end, { desc = "Telescope grep" })
|
|
||||||
vim.keymap.set("n", "<leader>gc", builtin.git_commits, { desc = "Search [G]it [C]ommits" })
|
|
||||||
vim.keymap.set(
|
|
||||||
"n",
|
|
||||||
"<leader>gcf",
|
|
||||||
builtin.git_bcommits,
|
|
||||||
{ desc = "Search [G]it [C]ommits for current [F]ile" }
|
|
||||||
)
|
|
||||||
vim.keymap.set("n", "<leader>gb", builtin.git_branches, { desc = "Search [G]it [B]ranches" })
|
|
||||||
vim.keymap.set("n", "<leader>gs", builtin.git_status, { desc = "Search [G]it [S]tatus (diff view)" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>?", builtin.oldfiles, { desc = "[?] Find recently opened files" })
|
|
||||||
vim.keymap.set("n", "<leader>sb", builtin.buffers, { desc = "[S]earch existing [B]uffers" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
|
|
||||||
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
|
|
||||||
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
|
|
||||||
vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]resume" })
|
|
||||||
vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
|
||||||
vim.keymap.set("n", "<leader>sds", function()
|
|
||||||
builtin.lsp_document_symbols({
|
|
||||||
symbols = { "Class", "Function", "Method", "Constructor", "Interface", "Module", "Property" },
|
|
||||||
})
|
|
||||||
end, { desc = "[S]each LSP document [S]ymbols" })
|
|
||||||
vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
|
|
||||||
vim.keymap.set("n", "<leader>s/", function()
|
|
||||||
builtin.live_grep({
|
|
||||||
grep_open_files = true,
|
|
||||||
prompt_title = "Live Grep in Open Files",
|
|
||||||
})
|
|
||||||
end, { desc = "[S]earch [/] in Open Files" })
|
|
||||||
vim.keymap.set("n", "<leader>/", function()
|
|
||||||
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
|
||||||
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
|
|
||||||
previewer = false,
|
|
||||||
}))
|
|
||||||
end, { desc = "[/] Fuzzily search in current buffer" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
return {
|
|
||||||
{ -- integration with tmux config
|
|
||||||
"alexghergh/nvim-tmux-navigation",
|
|
||||||
config = function()
|
|
||||||
local nvim_tmux_nav = require("nvim-tmux-navigation")
|
|
||||||
|
|
||||||
nvim_tmux_nav.setup({
|
|
||||||
disable_when_zoomed = true, -- defaults to false
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.keymap.set(
|
|
||||||
"n",
|
|
||||||
"<S-left>",
|
|
||||||
nvim_tmux_nav.NvimTmuxNavigateLeft,
|
|
||||||
{ desc = "Move to the split to the left" }
|
|
||||||
)
|
|
||||||
vim.keymap.set("n", "<S-down>", nvim_tmux_nav.NvimTmuxNavigateDown, { desc = "Move to the split below" })
|
|
||||||
vim.keymap.set("n", "<S-up>", nvim_tmux_nav.NvimTmuxNavigateUp, { desc = "Move to the split above" })
|
|
||||||
vim.keymap.set(
|
|
||||||
"n",
|
|
||||||
"<S-right>",
|
|
||||||
nvim_tmux_nav.NvimTmuxNavigateRight,
|
|
||||||
{ desc = "Move to the split to the right" }
|
|
||||||
)
|
|
||||||
vim.keymap.set(
|
|
||||||
"n",
|
|
||||||
"<C-\\>",
|
|
||||||
nvim_tmux_nav.NvimTmuxNavigateLastActive,
|
|
||||||
{ desc = "Move to the last active split" }
|
|
||||||
)
|
|
||||||
vim.keymap.set("n", "<C-Space>", nvim_tmux_nav.NvimTmuxNavigateNext, { desc = "Move to the next split" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
16
nvim/.config/nvim/lua/plugins/tmux/init.lua
Normal file
16
nvim/.config/nvim/lua/plugins/tmux/init.lua
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/alexghergh/nvim-tmux-navigation" },
|
||||||
|
})
|
||||||
|
|
||||||
|
local nvim_tmux_nav = require("nvim-tmux-navigation")
|
||||||
|
|
||||||
|
nvim_tmux_nav.setup({
|
||||||
|
disable_when_zoomed = true, -- defaults to false
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<S-left>", nvim_tmux_nav.NvimTmuxNavigateLeft, { desc = "Move to the split to the left" })
|
||||||
|
vim.keymap.set("n", "<S-down>", nvim_tmux_nav.NvimTmuxNavigateDown, { desc = "Move to the split below" })
|
||||||
|
vim.keymap.set("n", "<S-up>", nvim_tmux_nav.NvimTmuxNavigateUp, { desc = "Move to the split above" })
|
||||||
|
vim.keymap.set("n", "<S-right>", nvim_tmux_nav.NvimTmuxNavigateRight, { desc = "Move to the split to the right" })
|
||||||
|
vim.keymap.set("n", "<C-\\>", nvim_tmux_nav.NvimTmuxNavigateLastActive, { desc = "Move to the last active split" })
|
||||||
|
vim.keymap.set("n", "<C-Space>", nvim_tmux_nav.NvimTmuxNavigateNext, { desc = "Move to the next split" })
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
return {
|
|
||||||
{
|
|
||||||
"zaldih/themery.nvim",
|
|
||||||
lazy = false,
|
|
||||||
config = function()
|
|
||||||
require("themery").setup({
|
|
||||||
-- add the config here
|
|
||||||
themes = { "rose-pine-dawn", "rose-pine-main" }, -- Your list of installed colorschemes.
|
|
||||||
livePreview = true, -- Apply theme while picking. Default to true.
|
|
||||||
})
|
|
||||||
vim.keymap.set("n", "<leader>tt", function()
|
|
||||||
local themery = require("themery")
|
|
||||||
local currentTheme = themery.getCurrentTheme()
|
|
||||||
if currentTheme and currentTheme.name == "rose-pine-dawn" then
|
|
||||||
themery.setThemeByName("rose-pine-main", true)
|
|
||||||
else
|
|
||||||
themery.setThemeByName("rose-pine-dawn", true)
|
|
||||||
end
|
|
||||||
end, { noremap = true, desc = "Alternate between light and dark mode" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"rose-pine/neovim",
|
|
||||||
name = "rose-pine",
|
|
||||||
config = function()
|
|
||||||
-- vim.cmd("colorscheme rose-pine")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
-- highlight color hex codes
|
|
||||||
{
|
|
||||||
"brenoprata10/nvim-highlight-colors",
|
|
||||||
opts = {},
|
|
||||||
config = function()
|
|
||||||
local highlight = require("nvim-highlight-colors")
|
|
||||||
highlight.setup()
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ --statusline
|
|
||||||
"nvim-lualine/lualine.nvim",
|
|
||||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
|
||||||
lazy = false,
|
|
||||||
opts = {
|
|
||||||
options = {
|
|
||||||
section_separators = "",
|
|
||||||
component_separators = "",
|
|
||||||
theme = "rose-pine",
|
|
||||||
},
|
|
||||||
-- extensions = { "neo-tree", "lazy", "fzf" },
|
|
||||||
extensions = { "fugitive", "lazy" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ -- git symbols on sidebar
|
|
||||||
"lewis6991/gitsigns.nvim",
|
|
||||||
opts = {
|
|
||||||
signs = {
|
|
||||||
add = { text = "+" },
|
|
||||||
change = { text = "~" },
|
|
||||||
delete = { text = "_" },
|
|
||||||
topdelete = { text = "‾" },
|
|
||||||
changedelete = { text = "~" },
|
|
||||||
},
|
|
||||||
signs_staged = {
|
|
||||||
add = { text = "+" },
|
|
||||||
change = { text = "~" },
|
|
||||||
delete = { text = "_" },
|
|
||||||
topdelete = { text = "‾" },
|
|
||||||
changedelete = { text = "~" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"f-person/git-blame.nvim",
|
|
||||||
-- load the plugin at startup
|
|
||||||
event = "VeryLazy",
|
|
||||||
keys = {
|
|
||||||
{ "<leader>gk", "<cmd>GitBlameToggle<cr>", desc = "Toggle git-blame" },
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
vim.g.gitblame_display_virtual_text = false
|
|
||||||
-- schedule_event = "CursorHold"
|
|
||||||
-- clear_event = "CursorHoldI"
|
|
||||||
vim.g.gitblame_delay = 50 -- miliseconds
|
|
||||||
local git_blame = require("gitblame")
|
|
||||||
require("lualine").setup({
|
|
||||||
sections = {
|
|
||||||
lualine_c = {
|
|
||||||
{ "filename" },
|
|
||||||
{ git_blame.get_current_blame_text, cond = git_blame.is_blame_text_available },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ -- cosmetic indent lines
|
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
|
||||||
main = "ibl",
|
|
||||||
opts = {
|
|
||||||
indent = {
|
|
||||||
char = "▏",
|
|
||||||
},
|
|
||||||
scope = {
|
|
||||||
show_start = false,
|
|
||||||
show_end = false,
|
|
||||||
show_exact_scope = false,
|
|
||||||
},
|
|
||||||
exclude = {
|
|
||||||
filetypes = {
|
|
||||||
"help",
|
|
||||||
"startify",
|
|
||||||
"dashboard",
|
|
||||||
"packer",
|
|
||||||
"neogitstatus",
|
|
||||||
"NvimTree",
|
|
||||||
"Trouble",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ -- colorful mode indicators
|
|
||||||
"mvllow/modes.nvim",
|
|
||||||
tag = "v0.2.1",
|
|
||||||
config = function()
|
|
||||||
require("modes").setup()
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ -- dashboard snack
|
|
||||||
"folke/snacks.nvim",
|
|
||||||
priority = 1000,
|
|
||||||
lazy = false,
|
|
||||||
---@type snacks.Config
|
|
||||||
opts = {
|
|
||||||
-- your configuration comes here
|
|
||||||
-- or leave it empty to use the default settings
|
|
||||||
-- refer to the configuration section below
|
|
||||||
dashboard = {
|
|
||||||
preset = {
|
|
||||||
header = [[
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗
|
|
||||||
████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║
|
|
||||||
██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║
|
|
||||||
██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║
|
|
||||||
██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║
|
|
||||||
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
]],
|
|
||||||
},
|
|
||||||
sections = {
|
|
||||||
{ section = "header" },
|
|
||||||
{
|
|
||||||
pane = 2,
|
|
||||||
section = "terminal",
|
|
||||||
cmd = "pokemon-colorscripts -n snorlax --no-title; sleep .1",
|
|
||||||
height = 20,
|
|
||||||
padding = 0,
|
|
||||||
},
|
|
||||||
{ section = "keys", gap = 1, padding = 1 },
|
|
||||||
{
|
|
||||||
pane = 2,
|
|
||||||
icon = " ",
|
|
||||||
title = "Recent Files",
|
|
||||||
section = "recent_files",
|
|
||||||
indent = 2,
|
|
||||||
padding = 1,
|
|
||||||
},
|
|
||||||
{ pane = 2, icon = " ", title = "Projects", section = "projects", indent = 2, padding = 1 },
|
|
||||||
{
|
|
||||||
pane = 2,
|
|
||||||
icon = " ",
|
|
||||||
title = "Git Status",
|
|
||||||
section = "terminal",
|
|
||||||
enabled = function()
|
|
||||||
return Snacks.git.get_root() ~= nil
|
|
||||||
end,
|
|
||||||
cmd = "git status --short --branch --renames",
|
|
||||||
height = 5,
|
|
||||||
padding = 1,
|
|
||||||
ttl = 5 * 60,
|
|
||||||
indent = 3,
|
|
||||||
},
|
|
||||||
{ section = "startup" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"MeanderingProgrammer/render-markdown.nvim",
|
|
||||||
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
|
|
||||||
---@module 'render-markdown'
|
|
||||||
---@type render.md.UserConfig
|
|
||||||
opts = {},
|
|
||||||
config = function()
|
|
||||||
require("render-markdown").setup({
|
|
||||||
completions = { lsp = { enabled = true } },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
82
nvim/.config/nvim/lua/plugins/ui/init.lua
Normal file
82
nvim/.config/nvim/lua/plugins/ui/init.lua
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
require("vim._core.ui2").enable({
|
||||||
|
enable = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying messages
|
||||||
|
|
||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/rose-pine/neovim" },
|
||||||
|
{ src = "https://github.com/zaldih/themery.nvim" },
|
||||||
|
{ src = "https://github.com/brenoprata10/nvim-highlight-colors" },
|
||||||
|
})
|
||||||
|
|
||||||
|
require("themery").setup({
|
||||||
|
-- add the config here
|
||||||
|
themes = { "rose-pine-dawn", "rose-pine-main" }, -- Your list of installed colorschemes.
|
||||||
|
livePreview = true, -- Apply theme while picking. Default to true.
|
||||||
|
})
|
||||||
|
vim.keymap.set("n", "<leader>tt", function()
|
||||||
|
local themery = require("themery")
|
||||||
|
local currentTheme = themery.getCurrentTheme()
|
||||||
|
if currentTheme and currentTheme.name == "rose-pine-dawn" then
|
||||||
|
themery.setThemeByName("rose-pine-main", true)
|
||||||
|
else
|
||||||
|
themery.setThemeByName("rose-pine-dawn", true)
|
||||||
|
end
|
||||||
|
end, { noremap = true, desc = "Alternate between light and dark mode" })
|
||||||
|
|
||||||
|
require("nvim-highlight-colors").setup()
|
||||||
|
|
||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
|
||||||
|
{ src = "https://github.com/nvim-lualine/lualine.nvim" },
|
||||||
|
{ src = "https://github.com/lukas-reineke/indent-blankline.nvim" },
|
||||||
|
})
|
||||||
|
|
||||||
|
require("lualine").setup({
|
||||||
|
options = {
|
||||||
|
section_separators = "",
|
||||||
|
component_separators = "",
|
||||||
|
theme = "rose-pine",
|
||||||
|
},
|
||||||
|
extensions = { "fugitive", "lazy" },
|
||||||
|
})
|
||||||
|
|
||||||
|
require("ibl").setup()
|
||||||
|
|
||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/lewis6991/gitsigns.nvim" },
|
||||||
|
{ src = "https://github.com/f-person/git-blame.nvim" },
|
||||||
|
})
|
||||||
|
|
||||||
|
require("gitsigns").setup({
|
||||||
|
signs = {
|
||||||
|
add = { text = "+" },
|
||||||
|
change = { text = "~" },
|
||||||
|
delete = { text = "_" },
|
||||||
|
topdelete = { text = "‾" },
|
||||||
|
changedelete = { text = "~" },
|
||||||
|
},
|
||||||
|
signs_staged = {
|
||||||
|
add = { text = "+" },
|
||||||
|
change = { text = "~" },
|
||||||
|
delete = { text = "_" },
|
||||||
|
topdelete = { text = "‾" },
|
||||||
|
changedelete = { text = "~" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>gk", "<cmd>GitBlameToggle<cr>", { desc = "Toggle git-blame" })
|
||||||
|
vim.g.gitblame_display_virtual_text = false
|
||||||
|
-- schedule_event = "CursorHold"
|
||||||
|
-- clear_event = "CursorHoldI"
|
||||||
|
vim.g.gitblame_delay = 50 -- miliseconds
|
||||||
|
local git_blame = require("gitblame")
|
||||||
|
require("lualine").setup({
|
||||||
|
sections = {
|
||||||
|
lualine_c = {
|
||||||
|
{ "filename" },
|
||||||
|
{ git_blame.get_current_blame_text, cond = git_blame.is_blame_text_available },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
103
nvim/.config/nvim/nvim-pack-lock.json
Normal file
103
nvim/.config/nvim/nvim-pack-lock.json
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"blink.cmp": {
|
||||||
|
"rev": "78336bc89ee5365633bcf754d93df01678b5c08f",
|
||||||
|
"src": "https://github.com/saghen/blink.cmp",
|
||||||
|
"version": "1.0.0 - 2.0.0"
|
||||||
|
},
|
||||||
|
"codecompanion.nvim": {
|
||||||
|
"rev": "7d7957c26d33a97085d3a0c82eeb0147a0f51314",
|
||||||
|
"src": "https://github.com/olimorris/codecompanion.nvim"
|
||||||
|
},
|
||||||
|
"conform.nvim": {
|
||||||
|
"rev": "086a40dc7ed8242c03be9f47fbcee68699cc2395",
|
||||||
|
"src": "https://github.com/stevearc/conform.nvim"
|
||||||
|
},
|
||||||
|
"fidget.nvim": {
|
||||||
|
"rev": "889e2e96edef4e144965571d46f7a77bcc4d0ddf",
|
||||||
|
"src": "https://github.com/j-hui/fidget.nvim"
|
||||||
|
},
|
||||||
|
"fzf-lua": {
|
||||||
|
"rev": "9f0432fdd7825ab163520045831a40b6df82ea28",
|
||||||
|
"src": "https://github.com/ibhagwan/fzf-lua"
|
||||||
|
},
|
||||||
|
"git-blame.nvim": {
|
||||||
|
"rev": "5c536e2d4134d064aa3f41575280bc8a2a0e03d7",
|
||||||
|
"src": "https://github.com/f-person/git-blame.nvim"
|
||||||
|
},
|
||||||
|
"gitsigns.nvim": {
|
||||||
|
"rev": "0d797daee85366bc242580e352a4f62d67557b84",
|
||||||
|
"src": "https://github.com/lewis6991/gitsigns.nvim"
|
||||||
|
},
|
||||||
|
"indent-blankline.nvim": {
|
||||||
|
"rev": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03",
|
||||||
|
"src": "https://github.com/lukas-reineke/indent-blankline.nvim"
|
||||||
|
},
|
||||||
|
"lualine.nvim": {
|
||||||
|
"rev": "8811f3f3f4dc09d740c67e9ce399e7a541e2e5b2",
|
||||||
|
"src": "https://github.com/nvim-lualine/lualine.nvim"
|
||||||
|
},
|
||||||
|
"mini.icons": {
|
||||||
|
"rev": "7fdae2443a0e2910015ca39ad74b50524ee682d3",
|
||||||
|
"src": "https://github.com/echasnovski/mini.icons"
|
||||||
|
},
|
||||||
|
"modes.nvim": {
|
||||||
|
"rev": "fc7bc0141500d9cf7c14f46fca846f728545a781",
|
||||||
|
"src": "https://github.com/mvllow/modes.nvim",
|
||||||
|
"version": "'v0.3.0'"
|
||||||
|
},
|
||||||
|
"neovim": {
|
||||||
|
"rev": "cf2a288696b03d0934da713d66c6d71557b5c997",
|
||||||
|
"src": "https://github.com/rose-pine/neovim"
|
||||||
|
},
|
||||||
|
"nvim-highlight-colors": {
|
||||||
|
"rev": "e2cb22089cc2358b2b995c09578224f142de6039",
|
||||||
|
"src": "https://github.com/brenoprata10/nvim-highlight-colors"
|
||||||
|
},
|
||||||
|
"nvim-jump": {
|
||||||
|
"rev": "41261ddebbb595decd0302cb9e5eec7ce230e382",
|
||||||
|
"src": "https://github.com/yorickpeterse/nvim-jump"
|
||||||
|
},
|
||||||
|
"nvim-lint": {
|
||||||
|
"rev": "4b03656c09c1561f89b6aa0665c15d292ba9499d",
|
||||||
|
"src": "https://github.com/mfussenegger/nvim-lint"
|
||||||
|
},
|
||||||
|
"nvim-tmux-navigation": {
|
||||||
|
"rev": "4898c98702954439233fdaf764c39636681e2861",
|
||||||
|
"src": "https://github.com/alexghergh/nvim-tmux-navigation"
|
||||||
|
},
|
||||||
|
"nvim-treesitter": {
|
||||||
|
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
|
||||||
|
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
|
||||||
|
"version": "'main'"
|
||||||
|
},
|
||||||
|
"nvim-web-devicons": {
|
||||||
|
"rev": "95b7a002d5dba1a42eb58f5fac5c565a485eefd0",
|
||||||
|
"src": "https://github.com/nvim-tree/nvim-web-devicons"
|
||||||
|
},
|
||||||
|
"oil.nvim": {
|
||||||
|
"rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e",
|
||||||
|
"src": "https://github.com/stevearc/oil.nvim"
|
||||||
|
},
|
||||||
|
"plenary.nvim": {
|
||||||
|
"rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
|
||||||
|
"src": "https://github.com/nvim-lua/plenary.nvim"
|
||||||
|
},
|
||||||
|
"snacks.nvim": {
|
||||||
|
"rev": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e",
|
||||||
|
"src": "https://github.com/folke/snacks.nvim"
|
||||||
|
},
|
||||||
|
"themery.nvim": {
|
||||||
|
"rev": "bfa58f4b279d21cb515b28023e1b68ec908584b2",
|
||||||
|
"src": "https://github.com/zaldih/themery.nvim"
|
||||||
|
},
|
||||||
|
"vim-fugitive": {
|
||||||
|
"rev": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0",
|
||||||
|
"src": "https://github.com/tpope/vim-fugitive"
|
||||||
|
},
|
||||||
|
"which-key.nvim": {
|
||||||
|
"rev": "3aab2147e74890957785941f0c1ad87d0a44c15a",
|
||||||
|
"src": "https://github.com/folke/which-key.nvim"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,353 +0,0 @@
|
|||||||
-- Lua snippets
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local c = ls.choice_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
-- Return a table of snippets for Bash
|
|
||||||
-- stylua: ignore start
|
|
||||||
return {
|
|
||||||
-- Shebang
|
|
||||||
s("shebang", {
|
|
||||||
t("#!/usr/bin/env bash"),
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- Bash strict mode
|
|
||||||
s("strict", fmt([[
|
|
||||||
set -euo pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
]], {})),
|
|
||||||
|
|
||||||
-- Function definition
|
|
||||||
s("func", fmt([[
|
|
||||||
{}() {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "function_name"),
|
|
||||||
i(2, "# function body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- If statement
|
|
||||||
s("if", fmt([[
|
|
||||||
if [ {} ]; then
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "condition"),
|
|
||||||
i(2, "# code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- If-else statement
|
|
||||||
s("ifelse", fmt([[
|
|
||||||
if [ {} ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "condition"),
|
|
||||||
i(2, "# if code"),
|
|
||||||
i(3, "# else code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- If-elif-else statement
|
|
||||||
s("ifelif", fmt([[
|
|
||||||
if [ {} ]; then
|
|
||||||
{}
|
|
||||||
elif [ {} ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "condition1"),
|
|
||||||
i(2, "# if code"),
|
|
||||||
i(3, "condition2"),
|
|
||||||
i(4, "# elif code"),
|
|
||||||
i(5, "# else code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For loop
|
|
||||||
s("for", fmt([[
|
|
||||||
for {} in {}; do
|
|
||||||
{}
|
|
||||||
done
|
|
||||||
]], {
|
|
||||||
i(1, "item"),
|
|
||||||
i(2, "items"),
|
|
||||||
i(3, "# loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For loop with range
|
|
||||||
s("fori", fmt([[
|
|
||||||
for ((i={}; i<{}; i++)); do
|
|
||||||
{}
|
|
||||||
done
|
|
||||||
]], {
|
|
||||||
i(1, "0"),
|
|
||||||
i(2, "10"),
|
|
||||||
i(3, "# loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- While loop
|
|
||||||
s("while", fmt([[
|
|
||||||
while [ {} ]; do
|
|
||||||
{}
|
|
||||||
done
|
|
||||||
]], {
|
|
||||||
i(1, "condition"),
|
|
||||||
i(2, "# loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Until loop
|
|
||||||
s("until", fmt([[
|
|
||||||
until [ {} ]; do
|
|
||||||
{}
|
|
||||||
done
|
|
||||||
]], {
|
|
||||||
i(1, "condition"),
|
|
||||||
i(2, "# loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Case statement
|
|
||||||
s("case", fmt([[
|
|
||||||
case {} in
|
|
||||||
{})
|
|
||||||
{}
|
|
||||||
;;
|
|
||||||
{})
|
|
||||||
{}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
{}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
]], {
|
|
||||||
i(1, "variable"),
|
|
||||||
i(2, "pattern1"),
|
|
||||||
i(3, "# code for pattern1"),
|
|
||||||
i(4, "pattern2"),
|
|
||||||
i(5, "# code for pattern2"),
|
|
||||||
i(6, "# default code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Read input
|
|
||||||
s("read", fmt([[
|
|
||||||
read -p "{}" {}
|
|
||||||
]], {
|
|
||||||
i(1, "Enter value: "),
|
|
||||||
i(2, "variable"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Command substitution
|
|
||||||
s("cmd", fmt([[
|
|
||||||
{}=$({}$)
|
|
||||||
]], {
|
|
||||||
i(1, "result"),
|
|
||||||
i(2, "command"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Variable declaration
|
|
||||||
s("var", fmt([[
|
|
||||||
{}="{}"
|
|
||||||
]], {
|
|
||||||
i(1, "variable"),
|
|
||||||
i(2, "value"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Array declaration
|
|
||||||
s("array", fmt([[
|
|
||||||
{}=({})
|
|
||||||
]], {
|
|
||||||
i(1, "array"),
|
|
||||||
i(2, "item1 item2 item3"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Check if command exists
|
|
||||||
s("cmdexists", fmt([[
|
|
||||||
if command -v {} &> /dev/null; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "command"),
|
|
||||||
i(2, "# command exists"),
|
|
||||||
i(3, "# command does not exist"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Check if file exists
|
|
||||||
s("fileexists", fmt([[
|
|
||||||
if [ -f {} ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "file"),
|
|
||||||
i(2, "# file exists"),
|
|
||||||
i(3, "# file does not exist"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Check if directory exists
|
|
||||||
s("direxists", fmt([[
|
|
||||||
if [ -d {} ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "directory"),
|
|
||||||
i(2, "# directory exists"),
|
|
||||||
i(3, "# directory does not exist"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Check if variable is empty
|
|
||||||
s("isempty", fmt([[
|
|
||||||
if [ -z "${{{}}}" ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "variable"),
|
|
||||||
i(2, "# variable is empty"),
|
|
||||||
i(3, "# variable is not empty"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Check if variable is not empty
|
|
||||||
s("isnotempty", fmt([[
|
|
||||||
if [ -n "${{{}}}" ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "variable"),
|
|
||||||
i(2, "# variable is not empty"),
|
|
||||||
i(3, "# variable is empty"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Error handling
|
|
||||||
s("error", fmt([[
|
|
||||||
error() {{
|
|
||||||
echo "[ERROR] $1" >&2
|
|
||||||
exit 1
|
|
||||||
}}
|
|
||||||
]], {})),
|
|
||||||
|
|
||||||
-- Parse command line arguments
|
|
||||||
s("getopts", fmt([[
|
|
||||||
while getopts ":{}:" opt; do
|
|
||||||
case $opt in
|
|
||||||
{})
|
|
||||||
{}
|
|
||||||
;;
|
|
||||||
{})
|
|
||||||
{}
|
|
||||||
;;
|
|
||||||
\?)
|
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
:)
|
|
||||||
echo "Option -$OPTARG requires an argument." >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
]], {
|
|
||||||
i(1, "ab:c:"),
|
|
||||||
i(2, "a"),
|
|
||||||
i(3, "# handle option a"),
|
|
||||||
i(4, "b"),
|
|
||||||
i(5, "# handle option b with value in $OPTARG"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Trap signals
|
|
||||||
s("trap", fmt([[
|
|
||||||
trap '{}' {}
|
|
||||||
]], {
|
|
||||||
i(1, "echo 'Caught signal, cleaning up...; exit 1'"),
|
|
||||||
i(2, "SIGINT SIGTERM"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Cleanup function with trap
|
|
||||||
s("cleanup", fmt([[
|
|
||||||
cleanup() {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
|
|
||||||
trap cleanup EXIT
|
|
||||||
]], {
|
|
||||||
i(1, "# cleanup code here"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Redirect stdout and stderr to file
|
|
||||||
s("redirect", fmt([[
|
|
||||||
{} > {} 2>&1
|
|
||||||
]], {
|
|
||||||
i(1, "command"),
|
|
||||||
i(2, "logfile.log"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Check exit status
|
|
||||||
s("checkstatus", fmt([[
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
{}
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
fi
|
|
||||||
]], {
|
|
||||||
i(1, "# success"),
|
|
||||||
i(2, "# failure"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Here document
|
|
||||||
s("heredoc", fmt([[
|
|
||||||
cat << EOF > {}
|
|
||||||
{}
|
|
||||||
EOF
|
|
||||||
]], {
|
|
||||||
i(1, "output.txt"),
|
|
||||||
i(2, "content goes here"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Here string
|
|
||||||
s("herestring", fmt([[
|
|
||||||
{} <<< "{}"
|
|
||||||
]], {
|
|
||||||
i(1, "command"),
|
|
||||||
i(2, "string"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Script usage/help
|
|
||||||
s("usage", fmt([[
|
|
||||||
usage() {{
|
|
||||||
cat << EOF
|
|
||||||
Usage: $(basename $0) [options] <arguments>
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-h, --help Show this help message and exit
|
|
||||||
-v, --verbose Enable verbose output
|
|
||||||
{}
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$(basename $0) {}
|
|
||||||
EOF
|
|
||||||
exit ${1:-0}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "-o, --option Description of option"),
|
|
||||||
i(2, "example_argument"),
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
-- stylua: ignore end
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
-- Lua snippets
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local c = ls.choice_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
-- Return a table of snippets for Lua
|
|
||||||
-- stylua: ignore start
|
|
||||||
return {
|
|
||||||
-- Basic print statement
|
|
||||||
s("pr", {
|
|
||||||
t('print("'),
|
|
||||||
i(1, "text"),
|
|
||||||
t('")'),
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- Function definition
|
|
||||||
s("fn", fmt([[
|
|
||||||
local function {}({})
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
]], {
|
|
||||||
i(1, "name"),
|
|
||||||
i(2, ""),
|
|
||||||
i(3, "-- TODO: implement"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Module pattern
|
|
||||||
s("mod", fmt([[
|
|
||||||
local {} = {{}}
|
|
||||||
|
|
||||||
function {}:new(o)
|
|
||||||
o = o or {{}}
|
|
||||||
setmetatable(o, self)
|
|
||||||
self.__index = self
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
{}
|
|
||||||
|
|
||||||
return {}
|
|
||||||
]], {
|
|
||||||
i(1, "ModuleName"),
|
|
||||||
rep(1),
|
|
||||||
i(2, "-- TODO: add methods"),
|
|
||||||
rep(1),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For loop
|
|
||||||
s("for", fmt([[
|
|
||||||
for {} = {}, {} do
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
]], {
|
|
||||||
i(1, "i"),
|
|
||||||
i(2, "1"),
|
|
||||||
i(3, "10"),
|
|
||||||
i(4, "-- TODO: loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For pairs loop
|
|
||||||
s("forp", fmt([[
|
|
||||||
for {}, {} in pairs({}) do
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
]], {
|
|
||||||
i(1, "k"),
|
|
||||||
i(2, "v"),
|
|
||||||
i(3, "table"),
|
|
||||||
i(4, "-- TODO: loop body"),
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
-- stylua: ignore end
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
-- Python snippets
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local c = ls.choice_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
-- Return a table of snippets for Python
|
|
||||||
-- stylua: ignore start
|
|
||||||
return {
|
|
||||||
-- Print statement
|
|
||||||
s("pr", {
|
|
||||||
t("print("),
|
|
||||||
i(1, "text"),
|
|
||||||
t(")"),
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- Function definition
|
|
||||||
s("def", fmt([[
|
|
||||||
def {}({}):
|
|
||||||
{}
|
|
||||||
]], {
|
|
||||||
i(1, "function_name"),
|
|
||||||
i(2, ""),
|
|
||||||
i(3, "pass"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Class definition
|
|
||||||
s("class", fmt([[
|
|
||||||
class {}:
|
|
||||||
def __init__(self, {}):
|
|
||||||
{}
|
|
||||||
]], {
|
|
||||||
i(1, "ClassName"),
|
|
||||||
i(2, ""),
|
|
||||||
i(3, "pass"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For loop
|
|
||||||
s("for", fmt([[
|
|
||||||
for {} in {}:
|
|
||||||
{}
|
|
||||||
]], {
|
|
||||||
i(1, "item"),
|
|
||||||
i(2, "iterable"),
|
|
||||||
i(3, "pass"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- If statement
|
|
||||||
s("if", fmt([[
|
|
||||||
if {}:
|
|
||||||
{}
|
|
||||||
]], {
|
|
||||||
i(1, "condition"),
|
|
||||||
i(2, "pass"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Try/except
|
|
||||||
s("try", fmt([[
|
|
||||||
try:
|
|
||||||
{}
|
|
||||||
except {}:
|
|
||||||
{}
|
|
||||||
]], {
|
|
||||||
i(1, "# code"),
|
|
||||||
i(2, "Exception"),
|
|
||||||
i(3, "pass"),
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
-- stylua: ignore end
|
|
||||||
@@ -1,340 +0,0 @@
|
|||||||
-- Lua snippets
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local c = ls.choice_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
-- Return a table of snippets for Rust
|
|
||||||
-- stylua: ignore start
|
|
||||||
return {
|
|
||||||
-- Basic main function
|
|
||||||
s("main", fmt([[
|
|
||||||
fn main() {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "// Your code here"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Function definition
|
|
||||||
s("fn", fmt([[
|
|
||||||
fn {}({}) {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "function_name"),
|
|
||||||
i(2, ""),
|
|
||||||
c(3, {
|
|
||||||
t(""),
|
|
||||||
t("-> ()"),
|
|
||||||
sn(nil, {t("-> "), i(1, "ReturnType")}),
|
|
||||||
}),
|
|
||||||
i(4, "// Function body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Public function
|
|
||||||
s("pfn", fmt([[
|
|
||||||
pub fn {}({}) {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "function_name"),
|
|
||||||
i(2, ""),
|
|
||||||
c(3, {
|
|
||||||
t(""),
|
|
||||||
t("-> ()"),
|
|
||||||
sn(nil, {t("-> "), i(1, "ReturnType")}),
|
|
||||||
}),
|
|
||||||
i(4, "// Function body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Struct definition
|
|
||||||
s("struct", fmt([[
|
|
||||||
struct {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "StructName"),
|
|
||||||
i(2, "// fields"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Public struct
|
|
||||||
s("pstruct", fmt([[
|
|
||||||
pub struct {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "StructName"),
|
|
||||||
i(2, "// fields"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Struct implementation
|
|
||||||
s("impl", fmt([[
|
|
||||||
impl {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "StructName"),
|
|
||||||
i(2, "// methods"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Trait implementation
|
|
||||||
s("implfor", fmt([[
|
|
||||||
impl {} for {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "Trait"),
|
|
||||||
i(2, "Type"),
|
|
||||||
i(3, "// trait implementation"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Trait definition
|
|
||||||
s("trait", fmt([[
|
|
||||||
trait {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "TraitName"),
|
|
||||||
i(2, "// trait methods"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Public trait
|
|
||||||
s("ptrait", fmt([[
|
|
||||||
pub trait {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "TraitName"),
|
|
||||||
i(2, "// trait methods"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Enum definition
|
|
||||||
s("enum", fmt([[
|
|
||||||
enum {} {{
|
|
||||||
{},
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "EnumName"),
|
|
||||||
i(2, "// variants"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Public enum
|
|
||||||
s("penum", fmt([[
|
|
||||||
pub enum {} {{
|
|
||||||
{},
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "EnumName"),
|
|
||||||
i(2, "// variants"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Match expression
|
|
||||||
s("match", fmt([[
|
|
||||||
match {} {{
|
|
||||||
{} => {},
|
|
||||||
_ => {},
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "expression"),
|
|
||||||
i(2, "pattern"),
|
|
||||||
i(3, "result"),
|
|
||||||
i(4, "default_result"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- If let expression
|
|
||||||
s("iflet", fmt([[
|
|
||||||
if let {} = {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "pattern"),
|
|
||||||
i(2, "expression"),
|
|
||||||
i(3, "// code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- While let loop
|
|
||||||
s("whilelet", fmt([[
|
|
||||||
while let {} = {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "pattern"),
|
|
||||||
i(2, "expression"),
|
|
||||||
i(3, "// loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For loop
|
|
||||||
s("for", fmt([[
|
|
||||||
for {} in {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "item"),
|
|
||||||
i(2, "iterator"),
|
|
||||||
i(3, "// loop body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Loop
|
|
||||||
s("loop", fmt([[
|
|
||||||
loop {{
|
|
||||||
{}
|
|
||||||
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "// loop body"),
|
|
||||||
i(2, "break;"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Closure
|
|
||||||
s("closure", fmt([[
|
|
||||||
|{}| {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "args"),
|
|
||||||
c(2, {
|
|
||||||
t(""),
|
|
||||||
sn(nil, {t("-> "), i(1, "ReturnType")}),
|
|
||||||
}),
|
|
||||||
i(3, "// closure body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Derive attribute
|
|
||||||
s("derive", fmt([[
|
|
||||||
#[derive({})]
|
|
||||||
]], {
|
|
||||||
i(1, "Debug, Clone"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Module
|
|
||||||
s("mod", fmt([[
|
|
||||||
mod {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "module_name"),
|
|
||||||
i(2, "// module contents"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Public module
|
|
||||||
s("pmod", fmt([[
|
|
||||||
pub mod {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "module_name"),
|
|
||||||
i(2, "// module contents"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Use statement
|
|
||||||
s("use", fmt([[
|
|
||||||
use {};
|
|
||||||
]], {
|
|
||||||
i(1, "path::to::module"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Test module
|
|
||||||
s("testmod", fmt([[
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {{
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn {}() {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "test_name"),
|
|
||||||
i(2, "// test code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Test function
|
|
||||||
s("test", fmt([[
|
|
||||||
#[test]
|
|
||||||
fn {}() {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "test_name"),
|
|
||||||
i(2, "// test code"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Async function
|
|
||||||
s("async", fmt([[
|
|
||||||
async fn {}({}) {} {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "function_name"),
|
|
||||||
i(2, ""),
|
|
||||||
c(3, {
|
|
||||||
t(""),
|
|
||||||
t("-> ()"),
|
|
||||||
sn(nil, {t("-> "), i(1, "ReturnType")}),
|
|
||||||
}),
|
|
||||||
i(4, "// async function body"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Result type
|
|
||||||
s("result", fmt([[
|
|
||||||
Result<{}, {}>
|
|
||||||
]], {
|
|
||||||
i(1, "T"),
|
|
||||||
i(2, "Error"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Option type
|
|
||||||
s("option", fmt([[
|
|
||||||
Option<{}>
|
|
||||||
]], {
|
|
||||||
i(1, "T"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Unwrap with error message
|
|
||||||
s("expect", fmt([[
|
|
||||||
.expect("{}")
|
|
||||||
]], {
|
|
||||||
i(1, "Failed to unwrap value"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Print debug
|
|
||||||
s("dbg", fmt([[
|
|
||||||
dbg!({});
|
|
||||||
]], {
|
|
||||||
i(1, "expression"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Print
|
|
||||||
s("print", fmt([[
|
|
||||||
println!("{}", {});
|
|
||||||
]], {
|
|
||||||
i(1, "{}"),
|
|
||||||
i(2, "expression"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Let statement
|
|
||||||
s("let", fmt([[
|
|
||||||
let {} = {};
|
|
||||||
]], {
|
|
||||||
i(1, "variable"),
|
|
||||||
i(2, "value"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Let mut statement
|
|
||||||
s("letmut", fmt([[
|
|
||||||
let mut {} = {};
|
|
||||||
]], {
|
|
||||||
i(1, "variable"),
|
|
||||||
i(2, "value"),
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
-- stylua: ignore end
|
|
||||||
@@ -1,297 +0,0 @@
|
|||||||
-- Terraform snippets
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local c = ls.choice_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
-- Return a table of snippets for Terraform
|
|
||||||
-- stylua: ignore start
|
|
||||||
return {
|
|
||||||
-- Terraform block
|
|
||||||
s("terraform", fmt([[
|
|
||||||
terraform {{
|
|
||||||
required_version = ">= {}"
|
|
||||||
|
|
||||||
required_providers {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "1.0.0"),
|
|
||||||
i(2, 'aws = {\n source = "hashicorp/aws"\n version = "~> 4.0"\n }'),
|
|
||||||
i(3, ""),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Provider block
|
|
||||||
s("provider", fmt([[
|
|
||||||
provider "{}" {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "aws"),
|
|
||||||
i(2, 'region = "us-west-2"'),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- AWS Provider with profile
|
|
||||||
s("aws", fmt([[
|
|
||||||
provider "aws" {{
|
|
||||||
region = "{}"
|
|
||||||
profile = "{}"
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "us-west-2"),
|
|
||||||
i(2, "default"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Resource block
|
|
||||||
s("resource", fmt([[
|
|
||||||
resource "{}" "{}" {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "aws_s3_bucket"),
|
|
||||||
i(2, "example"),
|
|
||||||
i(3, ""),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Data source block
|
|
||||||
s("data", fmt([[
|
|
||||||
data "{}" "{}" {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "aws_ami"),
|
|
||||||
i(2, "example"),
|
|
||||||
i(3, 'owners = ["amazon"]'),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Variable block
|
|
||||||
s("variable", fmt([[
|
|
||||||
variable "{}" {{
|
|
||||||
description = "{}"
|
|
||||||
type = {}
|
|
||||||
default = {}
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "example"),
|
|
||||||
i(2, "Example variable"),
|
|
||||||
c(3, {
|
|
||||||
t("string"),
|
|
||||||
t("number"),
|
|
||||||
t("bool"),
|
|
||||||
t("list(string)"),
|
|
||||||
t("map(string)"),
|
|
||||||
t("object({})"),
|
|
||||||
sn(nil, {t("list(object({"), i(1, "name = string, value = string"), t("}))")}),
|
|
||||||
}),
|
|
||||||
c(4, {
|
|
||||||
t('null'),
|
|
||||||
sn(nil, {t('"'), i(1, "default_value"), t('"')}),
|
|
||||||
sn(nil, {t('true')}),
|
|
||||||
sn(nil, {t('false')}),
|
|
||||||
sn(nil, {t('123')}),
|
|
||||||
sn(nil, {t('['), i(1, '"item1", "item2"'), t(']')}),
|
|
||||||
sn(nil, {t('{'), i(1, 'key = "value"'), t('}')}),
|
|
||||||
}),
|
|
||||||
i(5, ""),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Output block
|
|
||||||
s("output", fmt([[
|
|
||||||
output "{}" {{
|
|
||||||
description = "{}"
|
|
||||||
value = {}
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "example"),
|
|
||||||
i(2, "Example output"),
|
|
||||||
i(3, "aws_instance.example.id"),
|
|
||||||
c(4, {
|
|
||||||
t(""),
|
|
||||||
t("sensitive = true"),
|
|
||||||
}),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Local block
|
|
||||||
s("locals", fmt([[
|
|
||||||
locals {{
|
|
||||||
{} = {}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "example"),
|
|
||||||
i(2, '"value"'),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Module block
|
|
||||||
s("module", fmt([[
|
|
||||||
module "{}" {{
|
|
||||||
source = "{}"
|
|
||||||
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "example"),
|
|
||||||
i(2, "./modules/example"),
|
|
||||||
i(3, "# Module inputs"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Backend block
|
|
||||||
s("backend", fmt([[
|
|
||||||
backend "{}" {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "s3"),
|
|
||||||
i(2, 'bucket = "terraform-state"\nkey = "path/to/state.tfstate"\nregion = "us-west-2"'),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Conditional expression
|
|
||||||
s("condition", fmt([[
|
|
||||||
{} ? {} : {}
|
|
||||||
]], {
|
|
||||||
i(1, "var.environment == \"prod\""),
|
|
||||||
i(2, "\"production\""),
|
|
||||||
i(3, "\"development\""),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For expression
|
|
||||||
s("for", fmt([[
|
|
||||||
[for {} in {} : {}]
|
|
||||||
]], {
|
|
||||||
i(1, "item"),
|
|
||||||
i(2, "var.list"),
|
|
||||||
i(3, "item.name"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For expression with index
|
|
||||||
s("fori", fmt([[
|
|
||||||
[for {}, {} in {} : {}]
|
|
||||||
]], {
|
|
||||||
i(1, "index"),
|
|
||||||
i(2, "item"),
|
|
||||||
i(3, "var.list"),
|
|
||||||
i(4, "\"${index}-${item.name}\""),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For expression with map
|
|
||||||
s("formap", fmt([[
|
|
||||||
{{for {} in {} : {} => {}}}
|
|
||||||
]], {
|
|
||||||
i(1, "item"),
|
|
||||||
i(2, "var.list"),
|
|
||||||
i(3, "item.key"),
|
|
||||||
i(4, "item.value"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Count parameter
|
|
||||||
s("count", fmt([[
|
|
||||||
count = {}
|
|
||||||
|
|
||||||
{}[count.index]
|
|
||||||
]], {
|
|
||||||
i(1, "var.create_resource ? 1 : 0"),
|
|
||||||
i(2, "# Reference this resource elsewhere using aws_instance.example"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- For each parameter
|
|
||||||
s("foreach", fmt([[
|
|
||||||
for_each = {}
|
|
||||||
|
|
||||||
{}
|
|
||||||
]], {
|
|
||||||
c(1, {
|
|
||||||
sn(nil, {t("toset(["), i(1, "\"item1\", \"item2\""), t("])")}),
|
|
||||||
sn(nil, {t("{"), i(1, "key1 = \"value1\", key2 = \"value2\""), t("}")}),
|
|
||||||
sn(nil, {t("var."), i(1, "map_variable")}),
|
|
||||||
}),
|
|
||||||
i(2, "# Reference this resource elsewhere using aws_instance.example[each.key]"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Dynamic block
|
|
||||||
s("dynamic", fmt([[
|
|
||||||
dynamic "{}" {{
|
|
||||||
for_each = {}
|
|
||||||
content {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "ingress"),
|
|
||||||
i(2, "var.ingress_rules"),
|
|
||||||
i(3, "from_port = ingress.value.from_port\n to_port = ingress.value.to_port\n protocol = ingress.value.protocol\n cidr_blocks = ingress.value.cidr_blocks"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Lifecycle block
|
|
||||||
s("lifecycle", fmt([[
|
|
||||||
lifecycle {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
c(1, {
|
|
||||||
t("create_before_destroy = true"),
|
|
||||||
t("prevent_destroy = true"),
|
|
||||||
t("ignore_changes = [tags]"),
|
|
||||||
sn(nil, {t("ignore_changes = ["), i(1, "attribute"), t("]")}),
|
|
||||||
t("create_before_destroy = true\n prevent_destroy = true\n ignore_changes = [tags]"),
|
|
||||||
}),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Terraform workspace
|
|
||||||
s("workspace", fmt([[
|
|
||||||
terraform.workspace
|
|
||||||
]], {})),
|
|
||||||
|
|
||||||
-- Depends on
|
|
||||||
s("depends", fmt([[
|
|
||||||
depends_on = [
|
|
||||||
{},
|
|
||||||
]
|
|
||||||
]], {
|
|
||||||
i(1, "aws_iam_role_policy.example"),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Provisioner
|
|
||||||
s("provisioner", fmt([[
|
|
||||||
provisioner "{}" {{
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
c(1, {
|
|
||||||
t("local-exec"),
|
|
||||||
t("remote-exec"),
|
|
||||||
t("file"),
|
|
||||||
}),
|
|
||||||
c(2, {
|
|
||||||
sn(nil, {t('command = "'), i(1, "echo hello"), t('"')}),
|
|
||||||
sn(nil, {t('inline = [\n "'), i(1, "echo hello"), t('",\n ]')}),
|
|
||||||
sn(nil, {t('source = "'), i(1, "scripts/setup.sh"), t('"\n destination = "'), i(2, "/tmp/setup.sh"), t('"')}),
|
|
||||||
}),
|
|
||||||
})),
|
|
||||||
|
|
||||||
-- Null resource
|
|
||||||
s("null", fmt([[
|
|
||||||
resource "null_resource" "{}" {{
|
|
||||||
triggers = {{
|
|
||||||
{} = {}
|
|
||||||
}}
|
|
||||||
|
|
||||||
{}
|
|
||||||
}}
|
|
||||||
]], {
|
|
||||||
i(1, "example"),
|
|
||||||
i(2, "trigger"),
|
|
||||||
i(3, "uuid()"),
|
|
||||||
i(4, "# Provisioners or depends_on go here"),
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
-- stylua: ignore end
|
|
||||||
Reference in New Issue
Block a user