Compare commits
12 Commits
0763449f80
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7eac65fadc | |||
| 7cc34cbda4 | |||
| 298e81add0 | |||
| b141b21d0f | |||
| 414602c66a | |||
| eb8c484c45 | |||
| 6808f8a148 | |||
| 2bbfd4ab95 | |||
| 214efb0e8a | |||
| 2afffb0488 | |||
| ed1cc8eedf | |||
| 372f3a7720 |
18
README.md
18
README.md
@@ -52,10 +52,7 @@ dotfiles/
|
||||
- python3-libtmux
|
||||
- Installed via `apt` in Debian. Remember to run `brew unlink python3` to
|
||||
prevent conflicting Python environments.
|
||||
- [Cursor](https://www.cursor.com/) CLI (`agent` binary at `~/.local/bin/agent`)
|
||||
- Required by [avante.nvim](https://github.com/yetone/avante.nvim) for
|
||||
AI-assisted coding via ACP (Agent Communication Protocol)
|
||||
- Run `agent login` once to authenticate
|
||||
- gdb
|
||||
- reattach-to-user-namespace (macOS only)
|
||||
|
||||
### Language Servers & Linters
|
||||
@@ -70,6 +67,13 @@ dotfiles/
|
||||
|
||||
### Extras
|
||||
|
||||
- pipx
|
||||
- awsume
|
||||
- podman
|
||||
- wl-clipboard (Debian only)
|
||||
- secret-tool (Debian only)
|
||||
- fzf
|
||||
- tree-sitter-cli
|
||||
- lesspipe
|
||||
- cbonsai
|
||||
|
||||
@@ -122,10 +126,10 @@ sudo apt update && sudo apt install terraform
|
||||
|
||||
```bash
|
||||
# System packages
|
||||
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 libsecret-tools wl-clipboard podman qemu-system-x86 qemu-utils virtiofsd gvproxy gdb
|
||||
|
||||
# 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
|
||||
npm install --save-dev prettier prettier-plugin-go-template
|
||||
@@ -141,7 +145,7 @@ brew unlink python3
|
||||
brew install curl git alacritty zsh tmux stow zsh-syntax-highlighting lesspipe cbonsai reattach-to-user-namespace
|
||||
|
||||
# Development tools
|
||||
brew install neovim stylua lua-language-server bash-language-server prettier terraform-ls tflint ruff
|
||||
brew install neovim stylua lua-language-server bash-language-server prettier terraform-ls tflint ruff fzf tree-sitter-cli podman gdb
|
||||
|
||||
# Node packages
|
||||
npm install --save-dev prettier prettier-plugin-go-template
|
||||
|
||||
@@ -1,141 +1,126 @@
|
||||
# Neovim Configuration
|
||||
|
||||
Keybinds reference for autocompletion, LSP, linting, diagnostics, and AI
|
||||
features. Leader key is `<Space>`.
|
||||
Keybinds reference for window management, file navigation, autocompletion, LSP,
|
||||
linting, formatting, and AI features. Leader key is `<Space>`. Local leader is `\`.
|
||||
|
||||
## General & Window Management
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<leader>sn` | Normal | Save without formatting |
|
||||
| `<leader>w` | Normal | Toggle line wrapping |
|
||||
| `<leader>tt` | Normal | Alternate light/dark theme (Themery) |
|
||||
| `x` | Nor/Vis| Remove char under cursor without yank |
|
||||
| `p` | Visual | Paste without yanking underlying text |
|
||||
| `<` / `>` | Visual | Indent left / right |
|
||||
| `gl` | Normal | Jump to last change |
|
||||
| `<C-up/down>`| Nor/Vis| Move screen up / down one line |
|
||||
|
||||
## Buffer Management
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<Tab>` | Normal | Switch to next buffer |
|
||||
| `<S-Tab>` | Normal | Switch to previous buffer |
|
||||
| `<leader>x` | Normal | Close buffer |
|
||||
| `<leader>b` | Normal | Open new buffer |
|
||||
|
||||
## Splits & Navigation (Tmux Integrated)
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<leader>v` | Normal | Split vertical |
|
||||
| `<leader>h` | Normal | Split horizontal |
|
||||
| `<leader>xs` | Normal | Close split |
|
||||
| `<leader>se` | Normal | Reset split sizes |
|
||||
| `<S-up>` | Normal | Move to split above |
|
||||
| `<S-down>` | Normal | Move to split below |
|
||||
| `<S-left>` | Normal | Move to split left |
|
||||
| `<S-right>` | Normal | Move to split right |
|
||||
| `<C-\>` | Normal | Move to last active split |
|
||||
| `<C-Space>` | Normal | Move to next split |
|
||||
|
||||
## File Explorer & Fuzzy Finding (Fzf-Lua / Oil)
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ---------------- | ------ | ------------------------------------ |
|
||||
| `<leader>pv` | Normal | Open file explorer (Oil) |
|
||||
| `<leader>pf` | Normal | Fuzzy find project files |
|
||||
| `<leader>ps` | Normal | Live grep project text |
|
||||
| `<leader><space>`| Normal | Fuzzy find open buffers |
|
||||
| `<leader>gf` | Normal | Fuzzy find tracked Git files |
|
||||
| `<leader>f` | N/X/O | Jump to label |
|
||||
|
||||
## Git Integration
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<leader>gs` | Normal | Open Git status (Fugitive) |
|
||||
| `<leader>gk` | Normal | Toggle inline Git blame |
|
||||
|
||||
## Autocompletion (blink.cmp)
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| --------- | ------- | --------------------------------- |
|
||||
| `C-y` | Insert | Accept completion |
|
||||
| `C-space` | Insert | Open menu or toggle docs |
|
||||
| `C-n` | Insert | Select next item |
|
||||
| `C-p` | Insert | Select previous item |
|
||||
| `C-e` | Insert | Dismiss completion menu |
|
||||
| `C-k` | Insert | Toggle signature help |
|
||||
| --------- | ------- | ------------------------------------------ |
|
||||
| `Tab` | Command | Show and accept cmdline completion |
|
||||
|
||||
Completion is disabled in Avante's input buffer.
|
||||
Completion is handled natively via Blink and Neovim 0.11+ built-in
|
||||
`vim.snippet`. CodeCompanion and LSP provide the completion sources.
|
||||
|
||||
### Snippets (LuaSnip)
|
||||
|
||||
Snippets are available for Lua, Rust, Bash, Python, and Terraform. Type a
|
||||
snippet prefix and accept it from the completion menu (`C-y`).
|
||||
|
||||
## LSP
|
||||
|
||||
### Code Actions & Refactoring
|
||||
## LSP & Navigation
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<leader>ca` | Normal | Code action menu |
|
||||
| `<leader>ca` | Visual | Code action (quickfix for selection) |
|
||||
| `<leader>cf` | Normal | Apply quickfix at cursor |
|
||||
| `<leader>ci` | Normal | Organize imports |
|
||||
|
||||
### Navigation (Neovim 0.11+ built-ins)
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------- | ------ | -------------------- |
|
||||
| `K` | Normal | Hover documentation |
|
||||
| `gd` | Normal | Go to definition |
|
||||
| `gd` | Normal | Go to definition (Fzf-Lua) |
|
||||
| `gD` | Normal | Go to declaration |
|
||||
| `grr` | Normal | Go to references |
|
||||
| `gri` | Normal | Go to implementation |
|
||||
| `grn` | Normal | Rename symbol |
|
||||
| `gr` | Normal | Go to references (Fzf-Lua) |
|
||||
| `gI` | Normal | Go to implementation (Fzf-Lua) |
|
||||
| `<leader>th` | Normal | Toggle Inlay Hints |
|
||||
|
||||
### Inlay Hints
|
||||
|
||||
Inlay hints are enabled automatically for any LSP that supports them.
|
||||
|
||||
## Linting & Diagnostics
|
||||
## Linting, Diagnostics & Code Actions
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------------- | ---------------------------------- |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<leader>cf` | Normal | Apply quickfix at cursor |
|
||||
| `<leader>l` | Normal | Trigger linting for current file |
|
||||
| `<leader>d` | Normal | Toggle inline diagnostics |
|
||||
| `<leader>sd` | Normal | Search all diagnostics (Telescope) |
|
||||
| `<leader>cd` | Normal | Copy diagnostic to clipboard |
|
||||
|
||||
Linting runs automatically on `BufEnter`, `BufWritePost`, and `InsertLeave`.
|
||||
|
||||
### Configured Linters
|
||||
|
||||
| Language | Linter |
|
||||
| ---------- | ---------------- |
|
||||
| Lua | luacheck |
|
||||
| Bash / sh | shellcheck |
|
||||
| Terraform | tflint |
|
||||
| Markdown | markdownlint-cli2|
|
||||
| Go | golangci-lint |
|
||||
|
||||
## Formatting
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------------- | --------------------------------- |
|
||||
| `<leader>mp` | Normal/Visual | Format file or range |
|
||||
| `<leader>sn` | Normal | Save without formatting |
|
||||
|
||||
Format on save is enabled by default.
|
||||
## Debugging (nvim-dap)
|
||||
|
||||
### Configured Formatters
|
||||
|
||||
| Language | Formatter |
|
||||
| --------------- | --------------- |
|
||||
| Lua | stylua |
|
||||
| Rust | rustfmt |
|
||||
| Go | gofumpt |
|
||||
| Python | ruff |
|
||||
| Bash / sh / zsh | shfmt |
|
||||
| JSON | prettier |
|
||||
| YAML | yamlfmt |
|
||||
| Markdown | markdownlint-cli2|
|
||||
| Terraform | terraform_fmt |
|
||||
|
||||
## AI (Avante)
|
||||
|
||||
Provider is selected automatically: **Cursor ACP** when `~/.local/bin/agent`
|
||||
exists, otherwise **Gemini API** (requires `GEMINI_API_KEY`).
|
||||
|
||||
All tool calls require explicit approval (`auto_approve_tool_permissions = false`).
|
||||
|
||||
### Global Keybinds
|
||||
Supports C, C++, Rust (via gdb/rust-gdb) and Go (via delve).
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ---------------- | --------------------- |
|
||||
| `<C-\>` | Normal/Visual/Insert | Toggle Avante sidebar |
|
||||
| `<leader>aa` | Normal | Avante Ask |
|
||||
| `<leader>ae` | Normal | Avante Edit |
|
||||
| `<leader>ar` | Normal | Avante Refresh |
|
||||
| ------------- | ------------- | --------------------------------- |
|
||||
| `<leader>gdc` | Normal | Continue / Launch |
|
||||
| `<leader>gdb` | Normal | Toggle breakpoint |
|
||||
| `<leader>gdB` | Normal | Set conditional breakpoint |
|
||||
| `<leader>gds` | Normal | Step over |
|
||||
| `<leader>gdi` | Normal | Step into |
|
||||
| `<leader>gdo` | Normal | Step out |
|
||||
| `<leader>gdh` | Normal/Visual | Hover variable under cursor |
|
||||
| `<leader>gdS` | Normal | Show scopes (all variables) |
|
||||
| `<leader>gdF` | Normal | Show call stack frames |
|
||||
| `<leader>gdr` | Normal | Open REPL |
|
||||
| `<leader>gdl` | Normal | Re-run last debug session |
|
||||
| `<leader>gdt` | Normal | Terminate session |
|
||||
|
||||
### Sidebar (defaults)
|
||||
## AI (CodeCompanion)
|
||||
|
||||
| Keybind | Description |
|
||||
| --------- | ------------------------------- |
|
||||
| `A` | Apply all suggestions |
|
||||
| `a` | Apply suggestion at cursor |
|
||||
| `r` | Retry user request |
|
||||
| `e` | Edit user request |
|
||||
| `<Tab>` | Switch windows in sidebar |
|
||||
| `<S-Tab>` | Reverse switch windows |
|
||||
| `@` | Add file to context |
|
||||
| `d` | Remove file from context |
|
||||
| `q` | Close sidebar |
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------------- | --------------------------------- |
|
||||
| `<leader>a` | Normal/Visual | Toggle CodeCompanion Chat |
|
||||
| `<leader>ca` | Visual | Add visual selection to Chat |
|
||||
| `<leader>ci` | Normal/Visual | Open inline prompt |
|
||||
| `<leader>cp` | Normal/Visual | Open Action Palette |
|
||||
|
||||
### Diff Review
|
||||
|
||||
When changes are proposed and applied, a conflict-style diff appears in the
|
||||
buffer. Use these keybinds to accept or reject hunks:
|
||||
|
||||
| Keybind | Description |
|
||||
| ----------- | ------------------------ |
|
||||
| `co` | Choose ours (original) |
|
||||
| `ct` | Choose theirs (suggested)|
|
||||
| `ca` | Accept all theirs |
|
||||
| `cb` | Choose both |
|
||||
| `cc` | Choose at cursor |
|
||||
| `]x` / `[x` | Next / previous diff hunk |
|
||||
|
||||
### Input Buffer
|
||||
|
||||
The Avante input prompt auto-resizes to fit your text (up to 20 lines) and
|
||||
shrinks back after sending.
|
||||
Active provider is automatically selected: **Gemini** (if `GEMINI_API_KEY` is set) or **Kiro** (local model).
|
||||
|
||||
@@ -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("config.lazy")
|
||||
require("plugins")
|
||||
|
||||
@@ -9,10 +9,11 @@ return {
|
||||
loadOutDirsFromCheck = true,
|
||||
runBuildScripts = true,
|
||||
},
|
||||
checkOnSave = true,
|
||||
check = {
|
||||
command = "clippy",
|
||||
},
|
||||
completion = {
|
||||
autoself = { enable = true },
|
||||
snippets = { enable = true },
|
||||
},
|
||||
diagnostics = {
|
||||
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.lsp")
|
||||
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.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||
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.backup = false -- creates a backup file
|
||||
|
||||
vim.wo.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.wo.signcolumn = "yes" -- Keep signcolumn on by default
|
||||
|
||||
vim.opt.swapfile = false -- creates a swapfile
|
||||
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
|
||||
-- allowed to be edited
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.autoread = true -- reload files changed outside of neovim
|
||||
vim.o.completeopt = "menuone,noinsert,popup,fuzzy"
|
||||
vim.opt.termguicolors = true -- set termguicolors to enable highlight groups
|
||||
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.opt.mouse = "a"
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
|
||||
vim.o.linebreak = true -- 2. Break lines at word boundaries (improves readability)
|
||||
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
|
||||
@@ -32,18 +27,25 @@ vim.opt.shiftwidth = 4 -- Number of spaces inserted when indenting
|
||||
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.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.opt.cursorline = true
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||
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.backspace = "indent,eol,start" -- allow backspace on
|
||||
|
||||
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.iskeyword:append("-") -- hyphenated words recognized by searches
|
||||
@@ -55,13 +57,9 @@ vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins fr
|
||||
-- Nice and simple folding:
|
||||
vim.opt.foldenable = true
|
||||
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.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)
|
||||
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold" }, {
|
||||
@@ -86,7 +84,7 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
--
|
||||
-- Set a keymap to toggle the 'wrap' option
|
||||
vim.keymap.set("n", "<leader>w", function()
|
||||
vim.opt.wrap:toggle()
|
||||
vim.opt.wrap = not vim.opt.wrap:get()
|
||||
end, { desc = "Toggle line wrapping" })
|
||||
|
||||
local uv = vim.uv
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
--- [[ LSP setup]]
|
||||
---
|
||||
|
||||
vim.lsp.enable("luals")
|
||||
vim.lsp.enable("rust")
|
||||
vim.lsp.enable("gopls")
|
||||
vim.lsp.enable("bashls")
|
||||
vim.lsp.enable("terraform")
|
||||
-- [[ LSP setup ]]
|
||||
-- You can consolidate your enable calls into a single table
|
||||
vim.lsp.enable({
|
||||
"luals",
|
||||
"rust",
|
||||
"gopls",
|
||||
"bashls",
|
||||
"terraform",
|
||||
})
|
||||
|
||||
-- Global capabilities override remains exactly the same
|
||||
vim.lsp.config("*", {
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
@@ -17,54 +19,86 @@ vim.lsp.config("*", {
|
||||
},
|
||||
})
|
||||
|
||||
-- [[FOLDING SETUP
|
||||
-- Prefer LSP folding if client supports it
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
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,
|
||||
-- Add rounded borders to diagnostic floating windows
|
||||
vim.diagnostic.config({
|
||||
float = { border = "rounded" },
|
||||
})
|
||||
-- ]]
|
||||
|
||||
-- [[INLAY HINTS
|
||||
-- Consolidate all LSP actions into a single LspAttach autocmd
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }),
|
||||
callback = function(args)
|
||||
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
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local bufnr = args.data.bufnr
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { buffer = bufnr, desc = "Code action (menu)" })
|
||||
vim.keymap.set("v", "<leader>ca", function()
|
||||
vim.lsp.buf.code_action({ context = { only = { "quickfix" } } })
|
||||
end, { buffer = bufnr, desc = "Code action (selection)" })
|
||||
-- Quickfix at cursor: apply single fix without menu when only one available
|
||||
-- args.buf is the modern 0.12 standard. It guarantees you are acting
|
||||
-- exactly on the buffer that triggered the attach.
|
||||
local bufnr = args.buf
|
||||
|
||||
-- [[ INLAY HINTS ]]
|
||||
if client:supports_method("textDocument/inlayHint") then
|
||||
-- Enable them by default when opening the file
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
|
||||
-- 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.lsp.buf.code_action({
|
||||
context = { only = { "quickfix" } },
|
||||
apply = true,
|
||||
})
|
||||
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.lsp.buf.code_action({
|
||||
context = {
|
||||
only = { "source.organizeImports.rust", "source.organizeImports" },
|
||||
},
|
||||
apply = true,
|
||||
})
|
||||
end, { buffer = bufnr, desc = "Organize imports" })
|
||||
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.maplocalleader = "\\"
|
||||
-- (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 options = { noremap = true, silent = true }
|
||||
@@ -27,7 +22,7 @@ map("n", "N", "Nzzzv", { desc = "Find previous occurence of search" })
|
||||
|
||||
map("n", "<Tab>", ":bnext<CR>", { desc = "Switch to next buffer" })
|
||||
map("n", "<S-Tab>", ":bprev<CR>", { desc = "Switch to previous buffer" })
|
||||
map("n", "<leader>x", ":bdelete!<CR>", { desc = "Close buffer" })
|
||||
map("n", "<leader>xb", ":bdelete!<CR>", { desc = "Close buffer" })
|
||||
map("n", "<leader>b", "<cmd> enew <CR>", { desc = "Open new buffer" })
|
||||
|
||||
map("n", "<leader>v", "<C-w>v", { desc = "Split vertical" })
|
||||
@@ -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", "C-d", "<C-d>zz")
|
||||
map("n", "C-u", "<C-u>zz")
|
||||
map("n", "C-f", "<C-f>zz")
|
||||
map("n", "C-b", "<C-b>zz")
|
||||
map("n", "<C-d>", "<C-d>zz")
|
||||
map("n", "<C-u>", "<C-u>zz")
|
||||
map("n", "<C-f>", "<C-f>zz")
|
||||
map("n", "<C-b>", "<C-b>zz")
|
||||
|
||||
-- map('n', '<C-f>', 'za', { desc = 'Toggle cursor fold' })
|
||||
-- map('n', '<C-down>', 'zm', { desc = 'Toggle all folds at cursor' })
|
||||
|
||||
@@ -1,27 +1,132 @@
|
||||
--- @return string
|
||||
local function tab_info()
|
||||
local fname = vim.fn.expand("%:p")
|
||||
if fname == "" then
|
||||
return ""
|
||||
local git_root_cache = {}
|
||||
|
||||
local function get_git_root(path)
|
||||
local dir = vim.fn.fnamemodify(path, ":h")
|
||||
if git_root_cache[dir] then
|
||||
return git_root_cache[dir]
|
||||
end
|
||||
return "%#WildMenu# " .. fname .. " %*"
|
||||
local root = vim.fn.systemlist("git -C " .. vim.fn.shellescape(dir) .. " rev-parse --show-toplevel 2>/dev/null")[1]
|
||||
if vim.v.shell_error ~= 0 or not root or root == "" then
|
||||
root = false
|
||||
end
|
||||
git_root_cache[dir] = root
|
||||
return root
|
||||
end
|
||||
|
||||
--- @return string
|
||||
local function filestatus()
|
||||
if vim.bo.modified == true then
|
||||
return "%#Error# ● %*"
|
||||
local function git_relative_path(abs_path)
|
||||
if abs_path == "" then
|
||||
return "[No Name]"
|
||||
end
|
||||
if vim.bo.readonly == true then
|
||||
return "%#Error# %*"
|
||||
local root = get_git_root(abs_path)
|
||||
if root then
|
||||
local rel = abs_path:sub(#root + 2) -- strip root + trailing /
|
||||
return rel ~= "" and rel or abs_path
|
||||
end
|
||||
return ""
|
||||
return abs_path
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("DirChanged", {
|
||||
callback = function()
|
||||
git_root_cache = {}
|
||||
end,
|
||||
})
|
||||
|
||||
local mru_bufs = {}
|
||||
|
||||
-- Initialize with currently listed buffers
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.bo[bufnr].buflisted then
|
||||
table.insert(mru_bufs, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("MRU_Buffers", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
group = augroup,
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
if vim.bo[bufnr].buflisted then
|
||||
for i, b in ipairs(mru_bufs) do
|
||||
if b == bufnr then
|
||||
table.remove(mru_bufs, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
table.insert(mru_bufs, 1, bufnr)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufDelete", {
|
||||
group = augroup,
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
for i, b in ipairs(mru_bufs) do
|
||||
if b == bufnr then
|
||||
table.remove(mru_bufs, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
function _G.TabLine()
|
||||
return table.concat({
|
||||
tab_info(),
|
||||
filestatus(),
|
||||
})
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local available_width = vim.o.columns
|
||||
local used_width = 0
|
||||
local tabline = ""
|
||||
local ellipsis = "%#TabLineFill# ..."
|
||||
|
||||
local valid_bufs = {}
|
||||
|
||||
-- 1. Always place the current buffer first
|
||||
if vim.bo[current_buf].buflisted then
|
||||
table.insert(valid_bufs, current_buf)
|
||||
end
|
||||
|
||||
-- 2. Add the rest of the buffers in native ID order (matches :bnext)
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if bufnr ~= current_buf and vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].buflisted then
|
||||
table.insert(valid_bufs, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
for _, bufnr in ipairs(valid_bufs) do
|
||||
local is_current = (bufnr == current_buf)
|
||||
local name = git_relative_path(vim.api.nvim_buf_get_name(bufnr))
|
||||
|
||||
local hl = is_current and "%#WildMenu#" or "%#TabLine#"
|
||||
|
||||
local status_raw = ""
|
||||
local status_hl = ""
|
||||
if vim.bo[bufnr].modified then
|
||||
status_raw = status_raw .. "● "
|
||||
status_hl = status_hl .. "%#Error#● " .. hl
|
||||
end
|
||||
if vim.bo[bufnr].readonly then
|
||||
status_raw = status_raw .. " "
|
||||
status_hl = status_hl .. "%#Error# " .. hl
|
||||
end
|
||||
|
||||
local text_to_measure = string.format(" %s %s", name, status_raw)
|
||||
local display_width = vim.api.nvim_strwidth(text_to_measure)
|
||||
|
||||
if used_width + display_width > available_width - 4 then
|
||||
tabline = tabline .. ellipsis
|
||||
break
|
||||
end
|
||||
|
||||
local segment = string.format("%s %s %s", hl, name, status_hl)
|
||||
tabline = tabline .. segment
|
||||
used_width = used_width + display_width
|
||||
end
|
||||
|
||||
return tabline .. "%#TabLineFill#"
|
||||
end
|
||||
|
||||
vim.opt.tabline = "%!v:lua.TabLine()"
|
||||
vim.opt.showtabline = 2 -- always show tabs
|
||||
|
||||
-- Adds the buffer name to the top of each window
|
||||
vim.opt.winbar = " %t %m"
|
||||
|
||||
133
nvim/.config/nvim/lua/plugins/ai/init.lua
Normal file
133
nvim/.config/nvim/lua/plugins/ai/init.lua
Normal file
@@ -0,0 +1,133 @@
|
||||
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")
|
||||
local has_gemini = os.getenv("GEMINI_API_KEY")
|
||||
|
||||
codecompanion.setup({
|
||||
interactions = {
|
||||
chat = {
|
||||
adapter = has_gemini and "gemini" or "kiro",
|
||||
tools = {
|
||||
["web_search"] = {
|
||||
opts = { require_approval_before = false },
|
||||
},
|
||||
["fetch_webpage"] = {
|
||||
opts = { require_approval_before = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
inline = { adapter = has_gemini and "gemini" or nil },
|
||||
},
|
||||
adapters = {
|
||||
http = {
|
||||
gemini = function()
|
||||
return require("codecompanion.adapters").extend("gemini", {
|
||||
env = {
|
||||
api_key = os.getenv("GEMINI_API_KEY") or "cmd:cat ~/.gemini_api_key",
|
||||
},
|
||||
schema = {
|
||||
model = {
|
||||
default = "gemini-3.1-pro-preview",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
acp = {
|
||||
kiro = function()
|
||||
return require("codecompanion.adapters").extend("kiro", {
|
||||
defaults = {
|
||||
model = "kiro_default",
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Optional: Keymaps for CodeCompanion
|
||||
vim.keymap.set({ "n", "v" }, "<leader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true })
|
||||
-- Inline prompt for buffer modifications (Generates diffs)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ci", "<cmd>CodeCompanion <cr>", { noremap = true, silent = true })
|
||||
-- Add visual selection to chat
|
||||
vim.keymap.set("v", "<leader>ca", "<cmd>CodeCompanionChat Add<cr>", { noremap = true, silent = true })
|
||||
-- Action palette (Use this to Accept/Reject inline diffs)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>cp", "<cmd>CodeCompanionActions<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" } },
|
||||
ghost_text = { enabled = true }, -- Enables ghost text in insert mode
|
||||
},
|
||||
|
||||
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,
|
||||
score_offset = 100, -- Boosts priority so AI suggestions appear first in ghost text
|
||||
async = true, -- Ensures AI fetching doesn't block the UI
|
||||
},
|
||||
},
|
||||
},
|
||||
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",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
143
nvim/.config/nvim/lua/plugins/basic/init.lua
Normal file
143
nvim/.config/nvim/lua/plugins/basic/init.lua
Normal file
@@ -0,0 +1,143 @@
|
||||
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,
|
||||
},
|
||||
preview = {
|
||||
max_width = 0.9,
|
||||
min_width = { 40, 0.4 },
|
||||
max_height = 0.9,
|
||||
min_height = { 5, 0.1 },
|
||||
},
|
||||
float = {
|
||||
max_width = math.floor(vim.o.columns * 0.66),
|
||||
max_height = math.floor(vim.o.lines * 0.66),
|
||||
},
|
||||
keymaps = {
|
||||
["<Esc><Esc>"] = { "actions.close", mode = "n" },
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "OilEnter",
|
||||
callback = vim.schedule_wrap(function(args)
|
||||
local oil = require("oil")
|
||||
if vim.api.nvim_get_current_buf() == args.data.buf and oil.get_current_dir() then
|
||||
require("oil.actions").preview.callback()
|
||||
end
|
||||
end),
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>pv", function()
|
||||
if vim.o.lines >= 40 and vim.o.columns >= 120 then
|
||||
require("oil").open_float()
|
||||
else
|
||||
require("oil").open()
|
||||
end
|
||||
end, { desc = "Open file explorer" })
|
||||
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
|
||||
|
||||
local function get_submodule_excludes()
|
||||
local git_root = vim.fs.root(0, ".git")
|
||||
if not git_root then
|
||||
return {}
|
||||
end
|
||||
local handle =
|
||||
io.popen("git -C " .. vim.fn.shellescape(git_root) .. " submodule --quiet foreach 'echo $sm_path' 2>/dev/null")
|
||||
if not handle then
|
||||
return {}
|
||||
end
|
||||
local excludes = {}
|
||||
for line in handle:lines() do
|
||||
table.insert(excludes, line)
|
||||
end
|
||||
handle:close()
|
||||
return excludes
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>pf", function()
|
||||
local fzf = require("fzf-lua")
|
||||
local defaults = fzf.defaults.files
|
||||
local fd_opts = defaults.fd_opts
|
||||
local rg_opts = defaults.rg_opts
|
||||
for _, sub in ipairs(get_submodule_excludes()) do
|
||||
fd_opts = fd_opts .. " --exclude " .. vim.fn.shellescape(sub)
|
||||
rg_opts = "-g '!" .. sub .. "' " .. rg_opts
|
||||
end
|
||||
rg_opts = "--hidden " .. rg_opts
|
||||
fzf.files({ cwd = get_project_root(), fd_opts = fd_opts, rg_opts = rg_opts })
|
||||
end, { desc = "Fuzzy find project files" })
|
||||
|
||||
vim.keymap.set("n", "<leader>ps", function()
|
||||
local fzf = require("fzf-lua")
|
||||
local defaults = fzf.defaults.grep
|
||||
local rg_opts = defaults.rg_opts
|
||||
for _, sub in ipairs(get_submodule_excludes()) do
|
||||
rg_opts = "-g '!" .. sub .. "' " .. rg_opts
|
||||
end
|
||||
rg_opts = "--hidden " .. rg_opts
|
||||
fzf.live_grep({ cwd = get_project_root(), rg_opts = rg_opts })
|
||||
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()
|
||||
local excludes = get_submodule_excludes()
|
||||
local pathspecs = {}
|
||||
for _, sub in ipairs(excludes) do
|
||||
table.insert(pathspecs, ":(exclude)" .. sub)
|
||||
end
|
||||
require("fzf-lua").git_files({ cmd = "git ls-files --exclude-standard -- . " .. table.concat(pathspecs, " ") })
|
||||
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" },
|
||||
},
|
||||
}
|
||||
158
nvim/.config/nvim/lua/plugins/debugging/init.lua
Normal file
158
nvim/.config/nvim/lua/plugins/debugging/init.lua
Normal file
@@ -0,0 +1,158 @@
|
||||
vim.pack.add({
|
||||
{ src = "https://codeberg.org/mfussenegger/nvim-dap" },
|
||||
})
|
||||
|
||||
local dap = require("dap")
|
||||
|
||||
-- GDB adapter for C/C++ (requires gdb 14.0+)
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
|
||||
}
|
||||
|
||||
-- Rust-specific adapter using rust-gdb for pretty-printing Rust types
|
||||
dap.adapters["rust-gdb"] = {
|
||||
type = "executable",
|
||||
command = "rust-gdb",
|
||||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
|
||||
}
|
||||
|
||||
-- Delve adapter for Go (uses delve's built-in DAP mode)
|
||||
dap.adapters.delve = function(callback, config)
|
||||
if config.mode == "remote" and config.request == "attach" then
|
||||
callback({
|
||||
type = "server",
|
||||
host = config.host or "127.0.0.1",
|
||||
port = config.port or "38697",
|
||||
})
|
||||
else
|
||||
callback({
|
||||
type = "server",
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = "dlv",
|
||||
args = { "dap", "-l", "127.0.0.1:${port}", "--log", "--log-output=dap" },
|
||||
detached = vim.fn.has("win32") == 0,
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- C configurations
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
args = function()
|
||||
local input = vim.fn.input("Arguments: ")
|
||||
return vim.split(input, " ", { trimempty = true })
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
},
|
||||
{
|
||||
name = "Attach to process",
|
||||
type = "gdb",
|
||||
request = "attach",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
pid = function()
|
||||
local name = vim.fn.input("Executable name (filter): ")
|
||||
return require("dap.utils").pick_process({ filter = name })
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.cpp = dap.configurations.c
|
||||
|
||||
-- Rust configurations (using rust-gdb for pretty-printed types)
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "rust-gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
|
||||
end,
|
||||
args = function()
|
||||
local input = vim.fn.input("Arguments: ")
|
||||
return vim.split(input, " ", { trimempty = true })
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
},
|
||||
{
|
||||
name = "Attach to process",
|
||||
type = "rust-gdb",
|
||||
request = "attach",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
|
||||
end,
|
||||
pid = function()
|
||||
local name = vim.fn.input("Executable name (filter): ")
|
||||
return require("dap.utils").pick_process({ filter = name })
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
}
|
||||
|
||||
-- Go configurations (using delve)
|
||||
dap.configurations.go = {
|
||||
{
|
||||
type = "delve",
|
||||
name = "Debug",
|
||||
request = "launch",
|
||||
program = "${file}",
|
||||
},
|
||||
{
|
||||
type = "delve",
|
||||
name = "Debug test",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "${file}",
|
||||
},
|
||||
{
|
||||
type = "delve",
|
||||
name = "Debug test (go.mod)",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "./${relativeFileDirname}",
|
||||
},
|
||||
}
|
||||
|
||||
-- Breakpoint signs
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" })
|
||||
vim.fn.sign_define("DapBreakpointCondition", { text = "◆", texthl = "DapBreakpoint", linehl = "", numhl = "" })
|
||||
vim.fn.sign_define("DapStopped", { text = "▶", texthl = "DapStopped", linehl = "DapStopped", numhl = "" })
|
||||
|
||||
-- Keybindings
|
||||
vim.keymap.set("n", "<leader>gdb", dap.toggle_breakpoint, { desc = "Toggle breakpoint" })
|
||||
vim.keymap.set("n", "<leader>gdB", function()
|
||||
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end, { desc = "Conditional breakpoint" })
|
||||
vim.keymap.set("n", "<leader>gdc", dap.continue, { desc = "Continue / Launch" })
|
||||
vim.keymap.set("n", "<leader>gds", dap.step_over, { desc = "Step over" })
|
||||
vim.keymap.set("n", "<leader>gdi", dap.step_into, { desc = "Step into" })
|
||||
vim.keymap.set("n", "<leader>gdo", dap.step_out, { desc = "Step out" })
|
||||
vim.keymap.set("n", "<leader>gdr", dap.repl.open, { desc = "Open REPL" })
|
||||
vim.keymap.set("n", "<leader>gdl", dap.run_last, { desc = "Run last" })
|
||||
vim.keymap.set("n", "<leader>gdt", dap.terminate, { desc = "Terminate" })
|
||||
vim.keymap.set("n", "<leader>gdh", function()
|
||||
require("dap.ui.widgets").hover()
|
||||
end, { desc = "Hover variable" })
|
||||
vim.keymap.set("v", "<leader>gdh", function()
|
||||
require("dap.ui.widgets").hover()
|
||||
end, { desc = "Hover selection" })
|
||||
vim.keymap.set("n", "<leader>gdF", function()
|
||||
require("dap.ui.widgets").centered_float(require("dap.ui.widgets").frames)
|
||||
end, { desc = "Show frames" })
|
||||
vim.keymap.set("n", "<leader>gdS", function()
|
||||
require("dap.ui.widgets").centered_float(require("dap.ui.widgets").scopes)
|
||||
end, { desc = "Show scopes" })
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
88
nvim/.config/nvim/lua/plugins/formatting/init.lua
Normal file
88
nvim/.config/nvim/lua/plugins/formatting/init.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
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",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
callback = function()
|
||||
pcall(vim.treesitter.start)
|
||||
end,
|
||||
})
|
||||
|
||||
-- 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" },
|
||||
},
|
||||
yamlfmt = {
|
||||
prepend_args = { "-formatter", "max_line_length=0,retain_document_start=true" },
|
||||
},
|
||||
},
|
||||
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,
|
||||
})
|
||||
7
nvim/.config/nvim/lua/plugins/init.lua
Normal file
7
nvim/.config/nvim/lua/plugins/init.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
require("plugins.basic")
|
||||
require("plugins.tmux")
|
||||
require("plugins.ui")
|
||||
require("plugins.formatting")
|
||||
require("plugins.linting")
|
||||
require("plugins.debugging")
|
||||
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,
|
||||
},
|
||||
}
|
||||
114
nvim/.config/nvim/lua/plugins/ui/init.lua
Normal file
114
nvim/.config/nvim/lua/plugins/ui/init.lua
Normal file
@@ -0,0 +1,114 @@
|
||||
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/brenoprata10/nvim-highlight-colors" },
|
||||
})
|
||||
|
||||
-- Sync background with tmux rose-pine variant
|
||||
if vim.env.TMUX then
|
||||
local variant = vim.fn.system("tmux show-option -gqv @rose_pine_variant"):gsub("%s+", "")
|
||||
vim.o.background = variant == "dawn" and "light" or "dark"
|
||||
else
|
||||
vim.o.background = "dark"
|
||||
end
|
||||
|
||||
vim.cmd.colorscheme("rose-pine")
|
||||
|
||||
vim.keymap.set("n", "<leader>tt", function()
|
||||
vim.o.background = vim.o.background == "dark" and "light" or "dark"
|
||||
end, { desc = "Alternate between light and dark mode" })
|
||||
|
||||
-- Insert-mode cursor: extmark overlay for full fg+bg control (terminal ignores fg on cursor hl groups)
|
||||
local function set_icursor_hl()
|
||||
local palette = require("rose-pine.palette")
|
||||
vim.api.nvim_set_hl(0, "iCursorChar", { fg = palette.surface, bg = palette.love })
|
||||
end
|
||||
|
||||
set_icursor_hl()
|
||||
vim.api.nvim_create_autocmd({ "ColorScheme", "OptionSet" }, {
|
||||
pattern = { "*", "background" },
|
||||
callback = set_icursor_hl,
|
||||
})
|
||||
|
||||
local icursor_ns = vim.api.nvim_create_namespace("icursor")
|
||||
|
||||
local function update_icursor()
|
||||
vim.api.nvim_buf_clear_namespace(0, icursor_ns, 0, -1)
|
||||
local r, c = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local char = c < #line and line:sub(c + 1, c + 1) or " "
|
||||
vim.api.nvim_buf_set_extmark(0, icursor_ns, r - 1, c, {
|
||||
virt_text = { { char, "iCursorChar" } },
|
||||
virt_text_pos = "overlay",
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("ModeChanged", { pattern = "*:i*", callback = update_icursor })
|
||||
vim.api.nvim_create_autocmd("CursorMovedI", { callback = update_icursor })
|
||||
vim.api.nvim_create_autocmd("ModeChanged", {
|
||||
pattern = "i*:*",
|
||||
callback = function()
|
||||
vim.api.nvim_buf_clear_namespace(0, icursor_ns, 0, -1)
|
||||
end,
|
||||
})
|
||||
|
||||
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 },
|
||||
},
|
||||
},
|
||||
})
|
||||
107
nvim/.config/nvim/nvim-pack-lock.json
Normal file
107
nvim/.config/nvim/nvim-pack-lock.json
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"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-dap": {
|
||||
"rev": "45a69eba683a2c448dd9ecfc4de89511f0646b5f",
|
||||
"src": "https://codeberg.org/mfussenegger/nvim-dap"
|
||||
},
|
||||
"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
|
||||
103
scripts/hcf/podman_setup
Executable file
103
scripts/hcf/podman_setup
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to configure podman for the local environment
|
||||
#
|
||||
# ./podman_setup
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if ! command -v podman &>/dev/null; then
|
||||
echo "Error: podman is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(uname -s)" == Linux* ]]; then
|
||||
if ! command -v gvproxy &>/dev/null; then
|
||||
echo "Error: gvproxy is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v qemu-img &>/dev/null; then
|
||||
echo "Error: qemu-img is not installed (usually provided by the qemu-utils package)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v qemu-system-x86 &>/dev/null && ! command -v qemu-system-x86_64 &>/dev/null; then
|
||||
echo "Error: qemu-system-x86 is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f /usr/libexec/virtiofsd ]]; then
|
||||
echo "Error: virtiofsd is not installed in /usr/libexec/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -e /usr/local/bin/virtiofsd ]]; then
|
||||
echo "Linking virtiofsd to /usr/local/bin (requires sudo)..."
|
||||
sudo ln -s /usr/libexec/virtiofsd /usr/local/bin/virtiofsd
|
||||
fi
|
||||
|
||||
if [[ ! -e /usr/local/libexec/podman/gvproxy ]]; then
|
||||
echo "Setting up gvproxy in /usr/local/libexec/podman (requires sudo)..."
|
||||
sudo mkdir -p /usr/local/libexec/podman
|
||||
sudo ln -s "$(command -v gvproxy)" /usr/local/libexec/podman/gvproxy
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$(uname -s)" in
|
||||
Darwin*) memory=12288 ;;
|
||||
Linux*) memory=8192 ;;
|
||||
*)
|
||||
echo "Unsupported platform"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$(uname -s)" == Darwin* ]]; then
|
||||
helper_plist="/Library/LaunchDaemons/com.github.containers.podman.helper-$(whoami).plist"
|
||||
if [[ ! -f "$helper_plist" ]]; then
|
||||
echo "Installing podman-mac-helper (requires sudo)..."
|
||||
sudo podman-mac-helper install
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! podman machine inspect &>/dev/null; then
|
||||
echo "Initializing podman machine with 4 CPUs and $((memory / 1024))GB RAM..."
|
||||
podman machine init --rootful --cpus 4 --memory "$memory"
|
||||
fi
|
||||
|
||||
if [[ "$(uname -s)" == Darwin* ]]; then
|
||||
rosetta=$(podman machine inspect --format '{{.Rosetta}}')
|
||||
if [[ "$rosetta" != "true" ]]; then
|
||||
echo "Warning: Rosetta translation is not enabled on this podman machine."
|
||||
fi
|
||||
fi
|
||||
|
||||
state=$(podman machine inspect --format '{{.State}}')
|
||||
case "$state" in
|
||||
running)
|
||||
echo "Podman machine is already running."
|
||||
;;
|
||||
stopped)
|
||||
echo "Starting podman machine..."
|
||||
podman machine start
|
||||
;;
|
||||
*)
|
||||
echo "Error: podman machine is in unexpected state: $state"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$(uname -s)" in
|
||||
Darwin*) resolved_ip=$(dscacheutil -q host -a name host.docker.internal 2>/dev/null | awk '/^ip_address:/{print $2; exit}') ;;
|
||||
*) resolved_ip=$(getent hosts host.docker.internal 2>/dev/null | awk '{print $1}' || true) ;;
|
||||
esac
|
||||
if [[ -z "$resolved_ip" ]] || ! echo "$resolved_ip" | grep -qE '^(127\.|::1$)'; then
|
||||
echo "Adding host.docker.internal to /etc/hosts (requires sudo)..."
|
||||
echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts >/dev/null
|
||||
fi
|
||||
|
||||
if [[ ! -e /usr/local/bin/docker ]]; then
|
||||
echo "Creating docker symlink to avoid issues with projects that do not inherit aliases (requires sudo)..."
|
||||
sudo ln -s "$(command -v podman)" /usr/local/bin/docker
|
||||
fi
|
||||
@@ -25,7 +25,14 @@ bind '"' split-window -v -c "#{pane_current_path}"
|
||||
bind % split-window -h -c "#{pane_current_path}"
|
||||
|
||||
### set-environment -g PATH "$HOMEBREW_PREFIX/bin:$PATH"
|
||||
bind C-o popup -E -E -d "#{pane_current_path}" -w 90% -h 90% "opencode"
|
||||
bind o run-shell '\
|
||||
SID="scratch-#{window_id}"; \
|
||||
if ! tmux has-session -t "$SID" 2>/dev/null; then \
|
||||
tmux new-session -d -s "$SID" -c "#{pane_current_path}"; \
|
||||
fi; \
|
||||
tmux popup -d "#{pane_current_path}" -w 66% -h 66% -E "tmux attach-session -t \"$SID\""'
|
||||
|
||||
# set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
|
||||
|
||||
bind-key -n C-S-Down next-window
|
||||
bind-key -n C-S-Up previous-window
|
||||
@@ -34,7 +41,7 @@ bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
|
||||
|
||||
setw -g mode-keys vi
|
||||
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
||||
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
|
||||
bind-key -T copy-mode-vi y send-keys -X copy-selection
|
||||
|
||||
set -g set-clipboard on
|
||||
set -g focus-events on
|
||||
@@ -51,7 +58,12 @@ set-option -g allow-rename off
|
||||
set-option -sa terminal-features ',alacritty:RGB'
|
||||
set-option -ga terminal-features ",alacritty:usstyle"
|
||||
set-option -ga terminal-overrides ',alacritty:Tc'
|
||||
set -g default-terminal "alacritty"
|
||||
|
||||
if-shell 'infocmp tmux-256color >/dev/null 2>&1' {
|
||||
set -g default-terminal "tmux-256color"
|
||||
} {
|
||||
set -g default-terminal "tmux"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
@@ -107,39 +119,6 @@ set-option -g @ssh-split-r-key "R"
|
||||
|
||||
set -g @plugin 'Morantron/tmux-fingers'
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
### tmux-continuum ###
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
||||
|
||||
set -g @resurrect-capture-pane-contents 'on'
|
||||
set -g @resurrect-dir '~/.tmux/resurrect/'
|
||||
|
||||
set -g @continuum-save-interval '15'
|
||||
set -g @continuum-restore 'on'
|
||||
set -g @continuum-boot 'on'
|
||||
|
||||
### tmux-resurrect
|
||||
set -g @resurrect-save 'S' # prefix + Shift-s - save
|
||||
set -g @resurrect-restore 'R' # prefix + Shift-r - restore
|
||||
# for neovim
|
||||
set -g @resurrect-strategy-nvim 'session'
|
||||
|
||||
# Platform-specific settings
|
||||
if-shell "uname | grep -q Darwin" {
|
||||
# macOS specific settings
|
||||
set -g @continuum-boot-options 'alacritty,fullscreen'
|
||||
# Don't use -l (login shell): avoids slow .zprofile on every new window; env is set in .zshenv
|
||||
set -g default-command "reattach-to-user-namespace $SHELL"
|
||||
} {
|
||||
# Linux specific settings
|
||||
set -g @continuum-boot-options 'alacritty,fullscreen'
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
### Nvim-tmux-navigation setup ###
|
||||
|
||||
134
zsh/.zsh_aliases
134
zsh/.zsh_aliases
@@ -7,22 +7,111 @@ alias tmux_secondary_win='tmux new-session -t main -s secondary'
|
||||
# enable color support of ls and also add handy aliases
|
||||
alias ls='ls --color=auto'
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias fgrep='grep -F --color=auto'
|
||||
alias egrep='grep -E --color=auto'
|
||||
|
||||
alias docker=podman
|
||||
|
||||
alias d='dirs -v'
|
||||
# shfmt needs to ignore this because it is a zsh specific syntax
|
||||
# shfmt:ignore:start
|
||||
for index ({1..9}) alias "c$index"="cd +${index}"; unset index
|
||||
# shfmt:ignore:end
|
||||
for index in 1 2 3 4 5 6 7 8 9; do alias "c$index"="cd +${index}"; done; unset index
|
||||
|
||||
alias kpget="keepassxc-cli show -a Password ${KEEPASS_DB}"
|
||||
alias kptotp="keepassxc-cli show -t ${KEEPASS_DB}"
|
||||
|
||||
# --- KeePassXC cached session (password stored in OS keychain) ---
|
||||
# macOS: security (Keychain)
|
||||
# Linux: secret-tool (GNOME Keyring via libsecret-tools)
|
||||
_KP_KEYCHAIN_SVC="keepassxc-cli-cache"
|
||||
_KP_KEYCHAIN_ACCT="master-password"
|
||||
|
||||
_kp_pw_store() {
|
||||
case "$UNAME_STRING" in
|
||||
Darwin)
|
||||
security add-generic-password -U \
|
||||
-s "$_KP_KEYCHAIN_SVC" -a "$_KP_KEYCHAIN_ACCT" -w "$1"
|
||||
;;
|
||||
Linux)
|
||||
echo -n "$1" | secret-tool store --label="$_KP_KEYCHAIN_SVC" \
|
||||
service "$_KP_KEYCHAIN_SVC" account "$_KP_KEYCHAIN_ACCT"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_kp_pw_get() {
|
||||
case "$UNAME_STRING" in
|
||||
Darwin)
|
||||
security find-generic-password \
|
||||
-s "$_KP_KEYCHAIN_SVC" -a "$_KP_KEYCHAIN_ACCT" -w 2>/dev/null
|
||||
;;
|
||||
Linux)
|
||||
secret-tool lookup \
|
||||
service "$_KP_KEYCHAIN_SVC" account "$_KP_KEYCHAIN_ACCT" 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_kp_pw_clear() {
|
||||
case "$UNAME_STRING" in
|
||||
Darwin)
|
||||
security delete-generic-password \
|
||||
-s "$_KP_KEYCHAIN_SVC" -a "$_KP_KEYCHAIN_ACCT" &>/dev/null
|
||||
;;
|
||||
Linux)
|
||||
secret-tool clear \
|
||||
service "$_KP_KEYCHAIN_SVC" account "$_KP_KEYCHAIN_ACCT" 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_kp_run() {
|
||||
local pw stderr_redir="/dev/null"
|
||||
[[ -n "$KP_DEBUG" ]] && stderr_redir="/dev/stderr"
|
||||
pw=$(_kp_pw_get)
|
||||
if [[ -z "$pw" ]]; then
|
||||
read -rs "pw?KeePassXC master password: " </dev/tty && echo
|
||||
_kp_pw_store "$pw" || return 1
|
||||
fi
|
||||
echo "$pw" | keepassxc-cli "$@" 2>"$stderr_redir"
|
||||
}
|
||||
|
||||
kpclose() { _kp_pw_clear && echo "KeePassXC session cleared."; }
|
||||
|
||||
kpgets() { _kp_run show -sa Password "$KEEPASS_DB" "$1"; }
|
||||
kptotps() { _kp_run show -st "$KEEPASS_DB" "$1"; }
|
||||
|
||||
# run with KP_DEBUG=1 to troubleshoot if needed
|
||||
function load_gemini() {
|
||||
export GEMINI_API_KEY=$(kpget "Gemini API Key")
|
||||
export GEMINI_API_KEY=$(kpgets "Gemini API Key")
|
||||
echo "Gemini API Key loaded into environment!"
|
||||
}
|
||||
|
||||
function totp() {
|
||||
local clip=false
|
||||
[[ "$1" == "-c" ]] && clip=true && shift
|
||||
|
||||
local code
|
||||
case "$1" in
|
||||
hcf) code=$(kptotps "personal/Dev/AWS Console") ;;
|
||||
aws) code=$(kptotps "work/Own/AWS console") ;;
|
||||
pci) code=$(kptotps "work/Own/PCI/AWS Workspaces") ;;
|
||||
*) echo "Usage: totp [-c] {hcf|aws|pci}" >&2; return 1 ;;
|
||||
esac
|
||||
|
||||
echo "$code"
|
||||
if $clip; then
|
||||
case "$UNAME_STRING" in
|
||||
Darwin) echo -n "$code" | pbcopy ;;
|
||||
Linux) if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then
|
||||
echo -n "$code" | wl-copy
|
||||
else
|
||||
echo -n "$code" | xclip -selection clipboard
|
||||
fi ;;
|
||||
|
||||
esac
|
||||
echo "(copied to clipboard)"
|
||||
fi
|
||||
}
|
||||
|
||||
_get_aws_config_path() {
|
||||
local config_path="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
|
||||
echo "$config_path"
|
||||
@@ -75,16 +164,23 @@ _awsume_cmd() {
|
||||
|
||||
alias asm="_awsume_cmd"
|
||||
|
||||
alias tf="terraform"
|
||||
alias tfi="tf init"
|
||||
alias tfp="tf plan -lock=false"
|
||||
alias tfa="tf apply"
|
||||
alias tfu="tf get -update"
|
||||
alias tg="terragrunt"
|
||||
alias tgi="tg init"
|
||||
alias tgp="tg plan -lock=false"
|
||||
alias tga="tg apply"
|
||||
alias tgu="tg get -update"
|
||||
_ensure_awsume() {
|
||||
if [[ -z "$AWSUME_PROFILE" ]]; then
|
||||
echo "No awsume session found. Starting one..."
|
||||
_awsume_cmd || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
tf() { _ensure_awsume && terraform "$@"; }
|
||||
tfi() { _ensure_awsume && terraform init "$@"; }
|
||||
tfp() { _ensure_awsume && terraform plan -lock=false "$@"; }
|
||||
tfa() { _ensure_awsume && terraform apply "$@"; }
|
||||
tfu() { _ensure_awsume && terraform get -update "$@"; }
|
||||
tg() { _ensure_awsume && terragrunt "$@"; }
|
||||
tgi() { _ensure_awsume && terragrunt init "$@"; }
|
||||
tgp() { _ensure_awsume && terragrunt plan -lock=false "$@"; }
|
||||
tga() { _ensure_awsume && terragrunt apply "$@"; }
|
||||
tgu() { _ensure_awsume && terragrunt get -update "$@"; }
|
||||
|
||||
alias curltime="curl -w \"@$HOME/.curl-format.txt\" -o /dev/null -s "
|
||||
|
||||
@@ -124,7 +220,7 @@ git_push() {
|
||||
local branch
|
||||
branch=$(git branch --show-current)
|
||||
|
||||
git push origin "$branch" $@
|
||||
git push origin "$branch" "$@"
|
||||
}
|
||||
|
||||
alias gpush="git_push"
|
||||
@@ -132,7 +228,7 @@ alias gpush="git_push"
|
||||
passgen() {
|
||||
length=${1:-"12"}
|
||||
if [[ "$length" == <-> ]]; then
|
||||
echo $(cat /dev/urandom| base64 | head -c "$length")
|
||||
echo $(cat /dev/urandom| base64 -w0 | head -c "$length")
|
||||
else
|
||||
echo "passgen() takes a positive integer as first argument"
|
||||
echo "got $length"
|
||||
|
||||
@@ -22,6 +22,8 @@ export SSH_ENV="$HOME/.ssh/agent-environment"
|
||||
|
||||
export GOPRIVATE="gitlab.feedzai.com,git.hcf.zone"
|
||||
|
||||
export UNAME_STRING=$(uname -s)
|
||||
|
||||
. "$HOME/.cargo/env"
|
||||
|
||||
# Interactive shells (e.g. new tmux windows): set PATH so we don't need a login shell.
|
||||
@@ -30,7 +32,7 @@ if [[ -t 0 ]]; then
|
||||
export PATH=~/.local/bin:$PATH
|
||||
export PATH=~/.dotnet:$PATH
|
||||
export PATH=$DOTFILES/scripts/hcf/:$PATH
|
||||
case "$(uname -s)" in
|
||||
case "$UNAME_STRING" in
|
||||
Linux*) eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" ;;
|
||||
Darwin*)
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
@@ -47,4 +49,4 @@ if [[ -t 0 ]]; then
|
||||
[[ -n "$TMUX" ]] && printf '\e]7;file://%s\a' "$(pwd)"
|
||||
fi
|
||||
|
||||
export PATH
|
||||
typeset -U path
|
||||
|
||||
25
zsh/.zshrc
25
zsh/.zshrc
@@ -1,11 +1,8 @@
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format.
|
||||
setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history.
|
||||
setopt HIST_FIND_NO_DUPS # Do not display a previously found event.
|
||||
setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate.
|
||||
setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again.
|
||||
setopt HIST_IGNORE_SPACE # Do not record an event starting with a space.
|
||||
unsetopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file.
|
||||
setopt SHARE_HISTORY # Share history between all sessions.
|
||||
|
||||
bindkey -e
|
||||
@@ -25,15 +22,11 @@ setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd.
|
||||
DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# install zsh-syntax-highlighting
|
||||
case "$(uname -s)" in
|
||||
case "$UNAME_STRING" in
|
||||
Linux*) {
|
||||
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
local lesspipe_bin_location
|
||||
lesspipe_bin_location=$(which lesspipe)
|
||||
if [ $? -eq 0 ]; then
|
||||
[ -x $lesspipe_bin_location ] && eval "$(lesspipe)"
|
||||
fi
|
||||
(($+commands[lesspipe])) && eval "$(lesspipe)"
|
||||
} ;;
|
||||
Darwin*) {
|
||||
# Use HOMEBREW_PREFIX (set in .zshenv) to avoid slow brew --prefix subprocess on every new shell
|
||||
@@ -54,10 +47,6 @@ fpath=("$DOTFILES/zsh/zsh-completions/src" $fpath)
|
||||
source "$DOTFILES/zsh/completion.zsh"
|
||||
source "$DOTFILES/zsh/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||
|
||||
# export starship_precmd_user_func="set_win_title"
|
||||
#
|
||||
# eval "$(starship init zsh)"
|
||||
|
||||
autoload -Uz vcs_info
|
||||
setopt prompt_subst
|
||||
|
||||
@@ -125,9 +114,9 @@ function +vi-git-extra() {
|
||||
# Check if upstream exists before trying to get ahead/behind counts
|
||||
if git rev-parse --verify ${hook_com[branch]}@{upstream} >/dev/null 2>&1; then
|
||||
local ahead_behind=$(git rev-list --left-right --count HEAD...${hook_com[branch]}@{upstream} 2>/dev/null)
|
||||
local ahead=$(echo $ahead_behind | awk '{print $1}')
|
||||
local behind=$(echo $ahead_behind | awk '{print $2}')
|
||||
|
||||
local split=($=ahead_behind)
|
||||
local ahead=$split[1]
|
||||
local behind=$split[2]
|
||||
[[ $ahead -gt 0 ]] && hook_com[misc]+="+"${ahead}
|
||||
[[ $behind -gt 0 ]] && hook_com[misc]+=${hook_com[misc]:+"/"}"-"${behind}
|
||||
fi
|
||||
@@ -137,7 +126,3 @@ function +vi-git-extra() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
|
||||
export PATH="/Users/inaki.dominguez/.rd/bin:$PATH"
|
||||
### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)
|
||||
|
||||
Submodule zsh/zsh-completions updated: 922abfe707...8b97eaf521
Reference in New Issue
Block a user