├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── after └── ftplugin │ ├── cs.vim │ ├── lua.lua │ ├── markdown.vim │ ├── python.vim │ ├── tex.lua │ ├── tex.vim │ └── vim.vim ├── init.lua ├── lazy-lock.json ├── lua └── user │ ├── autocmds.lua │ ├── mappings.lua │ ├── options.lua │ ├── plugins │ ├── config │ │ ├── alpha.lua │ │ ├── cmp │ │ │ ├── init.lua │ │ │ └── mappings.lua │ │ ├── cokeline.lua │ │ ├── devicons.lua │ │ ├── heirline │ │ │ ├── components.lua │ │ │ ├── init.lua │ │ │ ├── theme.lua │ │ │ └── utils.lua │ │ ├── indentline.lua │ │ ├── jaq.lua │ │ ├── lspconfig │ │ │ ├── init.lua │ │ │ ├── servers.lua │ │ │ └── utils.lua │ │ ├── neoformat.lua │ │ ├── neotree.lua │ │ ├── null_ls │ │ │ ├── init.lua │ │ │ └── sources.lua │ │ ├── others.lua │ │ ├── pretty_fold.lua │ │ ├── telescope │ │ │ ├── init.lua │ │ │ ├── sources.lua │ │ │ └── utils.lua │ │ ├── themer │ │ │ ├── defaults.lua │ │ │ ├── init.lua │ │ │ └── utils.lua │ │ ├── treesitter.lua │ │ └── vimtex.lua │ └── init.lua │ └── utils.lua ├── ultisnips ├── all.snippets ├── snippets.snippets └── tex │ ├── beamer.snippets │ ├── chem.snippets │ ├── cite.snippets │ ├── figures.snippets │ ├── font.snippets │ ├── general.snippets │ ├── lists.snippets │ ├── math.snippets │ ├── preamble.snippets │ ├── section.snippets │ ├── siunitx.snippets │ ├── tables.snippets │ └── tikz.snippets └── viml ├── autocommands.vim └── utils.vim /.gitattributes: -------------------------------------------------------------------------------- 1 | *.lua filter=modeline 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | ginit.vim 3 | plugin 4 | spell 5 | 6 | ultisnips/vim.snippets 7 | ultisnips/lua.snippets 8 | ultisnips/tex/temp.snippets 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Neelfrost 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

nvim-config

2 |

3 | Just another opinionated, visually appealing Neovim IDE. 4 |
5 | Configured for Windows, supports LaTeX, Python, Lua, C#, HTML, CSS, and Javascript. 6 |
7 |
8 | 9 | 12 | 13 | license 18 | stars 23 | forks 28 |

29 | 30 | ## Table of Contents 31 | 32 | - [Screenshots 📷](#screenshots-) 33 | - [Installation ⚡](#installation-) 34 | - [LaTeX](#latex) 35 | - [Language Servers](#language-servers) 36 | - [Update 🚀](#update-) 37 | - [Features 📃](#features-) 38 | - [General](#general) 39 | - [LaTeX](#latex-1) 40 | - [Folder Structure](#folder-structure) 41 | - [Plugins Used](#plugins-used) 42 | - [Mappings](#mappings) 43 | - [Todo ✔](#todo-) 44 | 45 | ## Screenshots 📷 46 | 47 | ![start](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/start.png) 48 | ![time](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/time.png) 49 | ![file explorer](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/explorer.png) 50 | ![file navigation](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/finder.png) 51 | ![latex](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/tex.png) 52 | ![latex](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/snippets.png) 53 | ![python](https://raw.githubusercontent.com/Neelfrost/github-assets/main/dotfiles/python.png) 54 | 55 | ## Installation ⚡ 56 | 57 | The following instructions are for Windows (powershell). **An admin prompt is required.** 58 | 59 | 1. Install chocolatey. 60 | 61 | ```powershell 62 | Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) 63 | ``` 64 | 65 | 2. Install main dependencies. 66 | 67 | ``` 68 | choco install -y git.install --params "/GitAndUnixToolsOnPath /NoGitLfs /SChannel /NoShellIntegration"; 69 | choco install -y neovim python SumatraPDF.install miktex.install; 70 | # Needed for various plugins 71 | choco install -y universal-ctags strawberryperl make SQLite ripgrep fd golang; refreshenv; exit 72 | ``` 73 | 74 | 3. Install python dependencies. 75 | 76 | ``` 77 | pip install pynvim neovim-remote 78 | ``` 79 | 80 | 4. Clone the repository and open nvim-qt or nvim. 81 | 82 | For fresh installation: 83 | 84 | ``` 85 | git clone https://github.com/Neelfrost/nvim-config.git "$HOME\Appdata\Local\nvim"; nvim-qt.exe 86 | ``` 87 | 88 | For existing config: 89 | 90 | ``` 91 | ren "$HOME\Appdata\Local\nvim" 'nvim-old'; git clone https://github.com/Neelfrost/nvim-config.git "$HOME\Appdata\Local\nvim"; nvim-qt.exe 92 | ``` 93 | 94 | ### LaTeX 95 | 96 | #### Formatting ([latexindent](https://github.com/cmhughes/latexindent.pl)) 97 | 98 | latexindent is now included with miktex, so downloading it separately is no longer necessary. Moreover, null-ls is pre-configured to run latexindent on save for tex files. Global formatting rules can be changed by: 99 | 100 | 1. Creating `$HOME/indentconfig.yaml`: 101 | 102 | ```yaml 103 | paths: 104 | - C:\Users\\defaultSettings.yaml 105 | ``` 106 | 107 | 2. Creating `$HOME/defaultSettings.yaml`, followed by copying and overriding [defaultSettings](https://github.com/cmhughes/latexindent.pl/blob/main/defaultSettings.yaml). 108 | 109 | For further reading refer: [docs](https://latexindentpl.readthedocs.io/en/latest/sec-indent-config-and-settings.html). 110 | 111 | #### Viewing PDF 112 | 113 | To launch SumatraPDF using VimTeX (\lv), ensure `SumatraPDF.exe` is added to environment path. 114 | 115 | ```powershell 116 | Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path + ";" + "$HOME\AppData\Local\SumatraPDF" + ";"); refreshenv; exit 117 | ``` 118 | 119 | #### Inverse Search 120 | 121 | For inverse search, open SumatraPDF then go to Settings -> Options and set inverse search command-line to: 122 | 123 | ```cmd 124 | cmd /c start /min nvim --headless -c "PackerLoad vimtex" -c "VimtexInverseSearch %l '%f'" 125 | ``` 126 | 127 | Use `:checkhealth` to check for errors if any. 128 | 129 | ### Language Servers 130 | 131 | #### Python ([pyright](https://github.com/microsoft/pyright)) 132 | 133 | 1. Install npm. 134 | 135 | ``` 136 | choco install -y nodejs.install; refreshenv; exit 137 | ``` 138 | 139 | 2. Install pyright. 140 | 141 | ``` 142 | npm install -g pyright 143 | ``` 144 | 145 | 3. Install black, isort, and flake for formatting and linting. 146 | 147 | ``` 148 | pip install flake8 black isort 149 | ``` 150 | 151 | 4. Use `:checkhealth` to check for errors if any. 152 | 153 | #### Lua ([LuaLs](https://github.com/LuaLS/lua-language-server)) 154 | 155 | 1. Install dependencies. 156 | 157 | ``` 158 | choco install -y 7zip.install; refreshenv; exit 159 | ``` 160 | 161 | 2. cd into install directory. _For example:_ 162 | 163 | ``` 164 | cd C:\tools 165 | ``` 166 | 167 | 3. Install LuaLs. 168 | 169 | ```powershell 170 | curl.exe -L $(curl.exe -s https://api.github.com/repos/LuaLS/lua-language-server/releases/latest | findstr.exe "win32-x64" | %{"$($_.Split('"')[3])"} | findstr.exe "github") -o luals.zip; 7z.exe x .\luals.zip -olua-language-server; rm luals.zip 171 | ``` 172 | 173 | 4. Add LuaLs to environment path. 174 | 175 | ```powershell 176 | Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path + ";" + "C:\tools\lua-language-server\bin" + ";"); refreshenv; exit 177 | ``` 178 | 179 | 5. Install stylua for formatting. 180 | 181 | ```powershell 182 | curl.exe -L $(curl.exe -s https://api.github.com/repos/JohnnyMorganz/StyLua/releases/latest | findstr.exe "win64.zip" | %{"$($_.Split('"')[3])"} | findstr.exe "github") -o stylua-win64.zip; 7z.exe x -oC:\tools\stylua .\stylua-win64.zip; rm .\stylua-win64.zip; 183 | # Add stylua to environment path: 184 | Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path + ";" + "C:\tools\stylua" + ";"); refreshenv; exit 185 | ``` 186 | 187 | 6. Use `:checkhealth` to check for errors if any. 188 | 189 | #### C# ([omnisharp](https://github.com/omnisharp/omnisharp-roslyn)) 190 | 191 | 1. Install dotnet-sdk. 192 | 193 | ``` 194 | choco install dotnet-sdk -y 195 | ``` 196 | 197 | 2. Install omnisharp-roslyn. 198 | 199 | ``` 200 | curl.exe -L $(curl.exe -s https://api.github.com/repos/OmniSharp/omnisharp-roslyn/releases/latest | findstr.exe "omnisharp-win-x64-net6.0.zip" | %{"$($_.Split('"')[3])"} | findstr.exe "github") -o omnisharp-win-x64-net6.0.zip; 7z.exe x -oC:\tools\omnisharp .\omnisharp-win-x64-net6.0.zip; rm .\omnisharp-win-x64-net6.0.zip; 201 | ``` 202 | 203 | 3. Use `:checkhealth` to check for errors if any. 204 | 205 | #### HTML, CSS, Javascript ([vscode-langservers-extracted](https://github.com/hrsh7th/vscode-langservers-extracted)) 206 | 207 | 1. Install dependencies. 208 | 209 | ``` 210 | npm i -g vscode-langservers-extracted 211 | ``` 212 | 213 | 2. Install prettierd for formatting. 214 | 215 | ``` 216 | npm i -g @fsouza/prettierd 217 | ``` 218 | 219 | 3. Use `:checkhealth` to check for errors if any. 220 | 221 | ## Update 🚀 222 | 223 | 1. Pull changes. 224 | 225 | ``` 226 | cd "$HOME\Appdata\Local\nvim"; git pull 227 | ``` 228 | 229 | 2. Open nvim-qt or nvim and update plugins: 230 | 231 | ``` 232 | :PackerSync 233 | ``` 234 | 235 | ## Features 📃 236 | 237 | ### General 238 | 239 | - Smart display line movement. 240 | - Resume cursor position when re-opening a file. 241 | - Auto update file if changed outside of neovim. 242 | - Fix mixed indents (tabs are converted to spaces). 243 | - Persistent cursor positions when switching buffers. 244 | - Ability to search custom directories in telescope.nvim. 245 | - Ability to reload specific modules using telescope.nvim. 246 | - Automatically trim trailing whitespaces and newlines on save. 247 | - Search and replace selection (automatically escape special chars). 248 | - Open windows terminal, vscode, explorer at current directory using \\\\t, \\\\c, \\\\e respectively. 249 | 250 | ### LaTeX 251 | 252 |
253 | Compile status on statusline 254 |
255 | Compile not started 256 | Compile not started 260 | Compile running 261 | Compile running 265 | Compile success 266 | Compile success 270 | Compile failed 271 | Compile failed 275 |
276 |
277 | 278 | - Extensive snippets for LaTeX. 279 | - Better auxiliary file cleaner. 280 | - Null-ls: latexindent, chktex support. 281 | - Automatically substitute `\` in imports (include, input) with `/` on save. 282 | - Keybinds for bold, underline, math, chemical formula environments. 283 | - Start newline with \item (or \task) if inside a list environment when pressing Enter, o or O. 284 | 285 | ### Folder Structure 286 | 287 | ```bash 288 | nvim 289 | ├── after 290 | │   └── ftplugin # filetype specific options, settings, mappings 291 | ├── lua # .lua config files 292 | │   └── user 293 | │   └── mappings.lua # keybinds 294 | │   └── options.lua # vim options 295 | │   └── utils.lua # utility functions 296 | │   └── plugins 297 | │   ├── config # plugin config 298 | │   └── init.lua # plugin definition file 299 | ├── ultisnips # snippets 300 | │   └── tex # latex snippets 301 | └── viml # .vim config files 302 | ``` 303 | 304 | ### Plugins 305 | 306 | - Plugin manager: [lazy.nvim](https://github.com/folke/lazy.nvim) 307 | 308 | #### LSP 309 | 310 | - LSP: [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) 311 | - Diagnostics, formatting LSP: [null-ls.nvim](https://github.com/jose-elias-alvarez/null-ls.nvim) 312 | - Python language server: [pyright](https://github.com/microsoft/pyright) 313 | - C# language server: [omnisharp](https://github.com/omnisharp/omnisharp-roslyn) 314 | - Lua language server: [LuaLs](https://github.com/LuaLS/lua-language-server) 315 | - HTML, CSS, Javascript language server: ([vscode-langservers-extracted](https://github.com/hrsh7th/vscode-langservers-extracted)) 316 | - Function signature when typing: [lsp_signature.nvim](https://github.com/ray-x/lsp_signature.nvim) 317 | - Refactor functionality: [refactoring.nvim](https://github.com/ThePrimeagen/refactoring.nvim) 318 | - Backup code formatting: [neoformat](https://github.com/sbdchd/neoformat) 319 | 320 | #### File navigation 321 | 322 | - File explorer: [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) 323 | - Fuzzy finder: [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) 324 | - Telescope frecency picker: [telescope-frecency.nvim](https://github.com/nvim-telescope/telescope-frecency.nvim) 325 | - Telescope fzf sorter: [telescope-fzf-native.nvim](https://github.com/nvim-telescope/telescope-fzf-native.nvim) 326 | - Telescope ultisnips viewer: [telescope-ultisnips.nvim](https://github.com/fhill2/telescope-ultisnips.nvim) 327 | 328 | #### Code completion 329 | 330 | - Code completion: [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) 331 | - Ultisnips source: [cmp-nvim-ultisnips](https://github.com/quangnguyen30192/cmp-nvim-ultisnips) 332 | - LSP source: [cmp-nvim-lsp](https://github.com/hrsh7th/cmp-nvim-lsp) 333 | - Buffer source: [cmp-buffer](https://github.com/hrsh7th/cmp-buffer) 334 | - Path source: [cmp-path](https://github.com/hrsh7th/cmp-path) 335 | - Cmdline source: [cmp-cmdline](https://github.com/hrsh7th/cmp-cmdline) 336 | - Omni source (for vimtex): [cmp-omni](https://github.com/hrsh7th/cmp-omni) 337 | 338 | #### LaTeX 339 | 340 | - LaTeX support: [vimtex](https://github.com/lervag/vimtex) 341 | - Snippet engine: [ultisnips](https://github.com/SirVer/ultisnips) 342 | - Tag management: [vim-gutentags](https://github.com/ludovicchabant/vim-gutentags) 343 | 344 | #### Looks 345 | 346 | - Theme support: [themer.lua](https://github.com/ThemerCorp/themer.lua) 347 | - Indent lines: [indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) 348 | - Thin virtual column: [virt-column.nvim](https://github.com/lukas-reineke/virt-column.nvim) 349 | - Icons support: [nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) 350 | - Syntax highlighting: [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) 351 | - Colored matching brackets: [nvim-ts-rainbow2](https://github.com/HiPhish/nvim-ts-rainbow2) 352 | - Color preview: [vim-hexokinase](https://github.com/RRethy/vim-hexokinase) 353 | - Prettier folds: [pretty-fold.nvim](https://github.com/anuvyklack/pretty-fold.nvim) 354 | 355 | #### Buffer, Status 356 | 357 | - Bufferline: [cokeline.nvim](https://github.com/noib3/cokeline.nvim) 358 | - Statusline: [heirline.nvim](https://github.com/rebelot/heirline.nvim) 359 | 360 | #### QOL 361 | 362 | - Repeat actions: [vim-repeat](https://github.com/tpope/vim-repeat) 363 | - Faster navigation: [hop.nvim](https://github.com/phaazon/hop.nvim) 364 | - Better quickfix: [nvim-pqf](https://gitlab.com/yorickpeterse/nvim-pqf) 365 | - Aligning: [vim-easy-align](https://github.com/junegunn/vim-easy-align) 366 | - Commenting: [nvim-comment](https://github.com/terrortylor/nvim-comment) 367 | - Toggle booleans & more: [alternate-toggler](https://github.com/rmagatti/alternate-toggler) 368 | - Multiple cursors: [vim-visual-multi](https://github.com/mg979/vim-visual-multi) 369 | - Title Case: [vim-titlecase](https://github.com/christoomey/vim-titlecase) 370 | - Start screen: [alpha-nvim](goolord/alpha-nvim) 371 | - Auto pair brackets: [auto-pairs](https://github.com/jiangmiao/auto-pairs) 372 | - Bracket operations: [nvim-surround](https://github.com/kylechui/nvim-surround) 373 | - Startup time: [vim-startuptime](https://github.com/dstein64/vim-startuptime) 374 | - Fix cursorhold autocmd: [FixCursorHold.nvim](https://github.com/antoinemadec/FixCursorHold.nvim) 375 | - Fast expr folds: [FastFold](https://github.com/antoinemadec/Konfekt/FastFold) 376 | - Markdown preview: [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim) 377 | - Run commands asynchronously: [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim) 378 | - Session manager: [neovim-session-manager](https://github.com/Shatur/neovim-session-manager) 379 | - Annotation generator: [neogen](https://github.com/danymat/neogen) 380 | 381 | ### Mappings 382 | 383 | | Shortcut | Mode | Description | 384 | | ------------------------- | -------------------- | -------------------------------------------------- | 385 | | F2 | Normal | Replace word under cursor | 386 | | F2 | Visual | Rename selection | 387 | | F5 | Normal | Open telescope.nvim module reloader | 388 | | F10 | Normal | Toggle spellcheck | 389 | | F11 | Normal | Toggle warp | 390 | | F12 | Normal | Toggle paste mode | 391 | | \\\\t | Normal | Open windows terminal at cwd | 392 | | \\\\e | Normal | Open explorer at cwd | 393 | | \\\\c | Normal | Open current file in VSCode | 394 | | \\\\n | Normal | Open current file in notepad | 395 | | tf | Normal | Open telescope.nvim find files | 396 | | tr | Normal | Open telescope.nvim recent files | 397 | | ts | Normal | Open telescope.nvim session browser | 398 | | \q | Normal | Toggle quickfix | 399 | | \h | Normal | Disable search highlight | 400 | | \v | Normal/Insert | Paste from system clipboard in **paste** mode | 401 | | \w | Normal | Close buffer _(will discard changes if not saved)_ | 402 | | \u | Normal | Open URL under cursor in browser | 403 | | \s | Normal | Search word under cursor in browser | 404 | | \n | Normal | Open dashboard | 405 | | f | Normal | Search buffer using 1 chars | 406 | | S | Normal | Search buffer using 2 chars | 407 | | Tab | Normal | Move to next buffer | 408 | | Shift Tab | Normal | Move to previous buffer | 409 | | Tab | Insert | Expand trigger or jump to next tab stop | 410 | | Shift Tab | Insert | Jump to previous tab stop | 411 | | Ctrl j(k) | Command | Move between completion items | 412 | | Ctrl j(k) | Insert | Move between completion items | 413 | | Alt d | Normal | Duplicate current line below | 414 | | Alt j(k) | Normal/Visual | Move line (block) up or down | 415 | | Alt ] | Normal | Increase indent | 416 | | Alt [ | Normal | Decrease indent | 417 | | Ctrl / | Normal/Visual/Insert | Comment current (selected) line(s) | 418 | | Enter | Insert | Select completion item | 419 | | Ctrl Space | Insert | Force completion menu to open | 420 | | Ctrl c | Insert | Force completion menu to close | 421 | | Ctrl e | Insert | Select first completion item | 422 | | Ctrl t | Insert | Open omni-func completion | 423 | | Ctrl Backspace | Insert | Delete previous word | 424 | | Ctrl Delete | Insert | Delete next word | 425 | | Ctrl b | Normal | Toggle nvim-tree | 426 | | Ctrl f | Normal | Format document | 427 | | Ctrl h(jkl) | Normal | Move to window to the left (down, up, right) | 428 | | Ctrl s | Normal | Save current file | 429 | | Ctrl Shift s | Normal | Save and reload module (current file) | 430 | | Ctrl v | Insert | Paste from system clipboard | 431 | | Ctrl z | Insert | Correct preceding misspelt word | 432 | | Ctrl z | Normal | Correct misspelt word under cursor | 433 | | gD | Normal | LSP: Goto function declaration | 434 | | gi | Normal | LSP: Goto function implementation | 435 | | gh | Normal | LSP: Preview documentation | 436 | | gd | Normal | LSP: Preview function definition | 437 | | gs | Normal | LSP: Preview signature help | 438 | | gr | Normal | LSP: Rename instance | 439 | | gl | Normal | LSP: Show line diagnostic | 440 | | gR | Normal | LSP: Show references | 441 | | ga | Normal | LSP: Trigger code action | 442 | | \li | Normal | VimTeX: Info | 443 | | \lT | Normal | VimTeX: TOC toggle | 444 | | \lq | Normal | VimTeX: Log | 445 | | \lv | Normal | VimTeX: View pdf | 446 | | \lr | Normal | VimTeX: Reverse search | 447 | | \ll | Normal | VimTeX: Compile | 448 | | \lk | Normal | VimTeX: Stop | 449 | | \le | Normal | VimTeX: Errors | 450 | | \lC | Normal | VimTeX: Clean full | 451 | | \lx | Normal | VimTeX: Reload | 452 | | \lX | Normal | VimTeX: Reload state | 453 | | \t | Normal | Python, Lua, C#: Run code in external terminal | 454 | | \r | Normal | Python, Lua: Run code without terminal output | 455 | | \lt | Normal | Lua (LÖVE2D): Run game in external terminal | 456 | | \lr | Normal | Lua (LÖVE2D): Run game without terminal output | 457 | 458 | ## Todo ✔ 459 | 460 | - [ ] Improve mappings table 461 | - [ ] Document snippets 462 | - [ ] Automatic install script 463 | - [ ] Create video to showcase snippets 464 | -------------------------------------------------------------------------------- /after/ftplugin/cs.vim: -------------------------------------------------------------------------------- 1 | " Run C# console app 2 | nnoremap t :AsyncRun -save=1 -mode=term -pos=external dotnet run 3 | -------------------------------------------------------------------------------- /after/ftplugin/lua.lua: -------------------------------------------------------------------------------- 1 | vim.opt_local.textwidth = 120 2 | 3 | local n_opts = { noremap = true } 4 | -- Run lua script 5 | -- With terminal 6 | vim.api.nvim_buf_set_keymap(0, "n", "t", "w!AsyncRun -mode=term -pos=external lua %", n_opts) 7 | -- Without terminal 8 | vim.api.nvim_buf_set_keymap(0, "n", "r", "w!AsyncRun lua %", n_opts) 9 | 10 | -- Run love2d 11 | -- With terminal 12 | vim.api.nvim_buf_set_keymap( 13 | 0, 14 | "n", 15 | "lt", 16 | "w!AsyncRun -mode=term -pos=external lovec .", 17 | n_opts 18 | ) 19 | -- Without terminal 20 | vim.api.nvim_buf_set_keymap(0, "n", "lr", "w!AsyncRun love .", n_opts) 21 | -------------------------------------------------------------------------------- /after/ftplugin/markdown.vim: -------------------------------------------------------------------------------- 1 | setlocal spell 2 | setlocal linebreak 3 | setlocal wrap 4 | setlocal conceallevel=2 5 | setlocal foldexpr= 6 | 7 | " Bold word under cursor or selected 8 | nmap Ysurroundiw*YsurroundW* 9 | xmap VSurround*gvVSurround* 10 | " Italics word under cursor or selected 11 | nmap Ysurroundiw_ 12 | xmap VSurround_ 13 | -------------------------------------------------------------------------------- /after/ftplugin/python.vim: -------------------------------------------------------------------------------- 1 | setlocal textwidth=120 2 | setlocal foldmethod=indent 3 | setlocal foldnestmax=1 4 | setlocal colorcolumn=120 5 | 6 | " Run script with terminal 7 | nnoremap t :AsyncRun -save=1 -mode=term -pos=external python "$(VIM_FILEPATH)" 8 | " Run script without terminal 9 | nnoremap r :AsyncRun -save=1 python "$(VIM_FILEPATH)" 10 | -------------------------------------------------------------------------------- /after/ftplugin/tex.lua: -------------------------------------------------------------------------------- 1 | local cmp = require("cmp") 2 | cmp.setup.filetype("tex", { 3 | sources = cmp.config.sources({ 4 | { name = "omni" }, 5 | { name = "ultisnips" }, 6 | { 7 | name = "buffer", 8 | option = { 9 | get_bufnrs = function() 10 | local bufs = {} 11 | for _, win in ipairs(vim.api.nvim_list_wins()) do 12 | bufs[vim.api.nvim_win_get_buf(win)] = true 13 | end 14 | return vim.tbl_keys(bufs) 15 | end, 16 | }, 17 | }, 18 | { name = "path" }, 19 | }), 20 | }) 21 | -------------------------------------------------------------------------------- /after/ftplugin/tex.vim: -------------------------------------------------------------------------------- 1 | " ---------------------------------- Options --------------------------------- " 2 | 3 | setlocal spell 4 | setlocal linebreak 5 | setlocal wrap 6 | setlocal shiftwidth=2 7 | setlocal softtabstop=2 8 | setlocal tabstop=2 9 | setlocal noexpandtab 10 | setlocal foldmethod=manual 11 | setlocal foldexpr=vimtex#fold#level(v:lnum) 12 | setlocal foldtext=v:lua.require('pretty-fold').foldtext.global() 13 | 14 | " --------------------------------- Functions -------------------------------- " 15 | 16 | " Auto insert \item, \task on 17 | " https://stackoverflow.com/questions/2547739/auto-insert-text-at-a-newline-in-vim 18 | function! AutoItem() 19 | let [end_lnum, end_col] = searchpairpos('\\begin{', '', '\\end{', 'nW') 20 | if match(getline(end_lnum), '\(itemize\|enumerate\|description\)') != -1 21 | return '\item ' 22 | elseif match(getline(end_lnum), '\(tasks\)') != -1 23 | return '\task ' 24 | else 25 | return '' 26 | endif 27 | endfunction 28 | 29 | function! GetLine() 30 | let list = ['\\task $', '\\item $'] 31 | return getline('.') =~ list[0] || getline('.') =~ list[1] 32 | endfunction 33 | 34 | function! MiscFixes() 35 | let l:save = winsaveview() 36 | " Replace \ with / in LaTeX input fields 37 | keeppatterns %s/\(input\|include\)\({.\+\)\\\(.\+}\)/\1\2\/\3/ge 38 | " do not remove trailing space after LaTeX \item 39 | keeppatterns %s/\\item$/\\item /e 40 | " do not remove trailing space after LaTeX \task 41 | keeppatterns %s/\\task$/\\task /e 42 | " remove duplicate '\items' on sameline 43 | keeppatterns %s/^\s*\\item\s*\\item/\\item/e 44 | " '\item\something' -> '\item \something' 45 | keeppatterns %s/\\item\\/\\item \\/e 46 | " '%\label{fig:main_label}%' -> '' 47 | keeppatterns %s/^\s\+%\\label{fig:main_label}%\n//e 48 | call winrestview(l:save) 49 | endfunction 50 | 51 | " Clean up auxiliary files 52 | function! CleanAuxFiles(...) abort 53 | let l:cur_tex_path = fnamemodify(b:vimtex.tex, ':p:h') 54 | python3 << EOF 55 | import vim 56 | import os 57 | cur_tex_path = vim.eval("l:cur_tex_path") 58 | 59 | for folder, _, files in os.walk(cur_tex_path): 60 | for file in files: 61 | if file.endswith( 62 | ( 63 | ".toc", 64 | ".out", 65 | ".aux", 66 | ".log", 67 | ".nav", 68 | ".snm", 69 | ".vrb", 70 | ".fls", 71 | ".bak", 72 | "indent", 73 | "output", 74 | "indent.log", 75 | ".fdb_latexmk", 76 | "synctex(busy)", 77 | ) 78 | ): 79 | os.remove(os.path.join(folder, file)) 80 | EOF 81 | echo 'Auxiliary files cleaned!' 82 | endfunction 83 | 84 | " ------------------------------- Autocommands ------------------------------- " 85 | 86 | augroup TEX_AUTOCOMMANDS 87 | autocmd! 88 | " Fix inputs 89 | autocmd BufWritePre *.tex :call MiscFixes() 90 | " Clean up auxiliary files on quit 91 | autocmd User VimtexEventQuit :silent! VimtexStopAll 92 | autocmd User VimtexEventQuit :silent! call CleanAuxFiles() 93 | augroup END 94 | 95 | " --------------------------------- Mappings --------------------------------- " 96 | 97 | " Override VimtexClean 98 | nnoremap lc :call CleanAuxFiles() 99 | 100 | " Auto \item, \task 101 | inoremap GetLine() 102 | \ ? '' 103 | \ : (col('.') < col('$') ? '' : '' . AutoItem()) 104 | nnoremap o 'o' . AutoItem() 105 | nnoremap O 'O' . AutoItem() 106 | 107 | " Insert \item, \task on Numpad Enter 108 | imap o 109 | 110 | " Push to next item of the list 111 | nnoremap i\item 112 | " Adjoin next item 113 | nnoremap gJidWdW 114 | 115 | " Bold - italics word under cursor or selected 116 | nmap Ysurroundiw}i\textbi 117 | xmap VSurround}i\textbi 118 | 119 | " Bold word under cursor or selected 120 | nmap Ysurroundiw}i\textbf 121 | xmap VSurround}i\textbf 122 | 123 | " Underline word under cursor or selected 124 | nmap Ysurroundiw}i\ul 125 | xmap VSurround}i\ul 126 | nmap Ysurroundiw}i\underline 127 | xmap VSurround}i\underline 128 | 129 | " Put the word inside chem environment 130 | nmap Ysurroundiw}i\ch 131 | xmap VSurround}i\ch 132 | 133 | " Put the word inside math environment 134 | nmap Ysurroundiw$ 135 | xmap VSurround$ 136 | 137 | " Append period or comma to selected lines 138 | vnoremap np :norm A. 139 | vnoremap nc :norm A, 140 | 141 | nmap gui}gzi} 142 | -------------------------------------------------------------------------------- /after/ftplugin/vim.vim: -------------------------------------------------------------------------------- 1 | setlocal textwidth=80 2 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | -- Author: Neel Basak 2 | -- Github: https:/github.com/Neelfrost 3 | -- File: init.lua 4 | 5 | -- Colorscheme 6 | SCHEME = "jellybeans" 7 | 8 | -- Language servers 9 | SERVERS = { "pyright", "lua_ls", "omnisharp", "html", "cssls", "eslint", "emmet_ls", "ruff" } 10 | 11 | -- Treesitter parsers 12 | PARSERS = { "comment", "python", "lua", "c_sharp", "html", "css", "javascript", "yaml", "json", "markdown", "vim" } 13 | 14 | -- Plugin filetypes 15 | PLUGINS = { "alpha", "neo-tree" } 16 | 17 | -- Paths 18 | HOME_PATH = vim.fn.expand("$HOME") 19 | CONFIG_PATH = vim.fn.stdpath("config") 20 | LAZY_PATH = vim.fn.stdpath("data") .. "/lazy" 21 | 22 | -- Linting icons 23 | ICON_ERROR = "E" 24 | ICON_WARN = "W" 25 | ICON_INFO = "I" 26 | ICON_HINT = "H" 27 | 28 | -- Configuration files 29 | vim.cmd("source ~/AppData/Local/nvim/viml/utils.vim") 30 | vim.cmd("source ~/AppData/Local/nvim/viml/autocommands.vim") 31 | require("user.autocmds") 32 | require("user.options") 33 | require("user.utils") 34 | require("user.mappings") 35 | require("user.plugins") 36 | -------------------------------------------------------------------------------- /lazy-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "FastFold": { "branch": "master", "commit": "ab3d199d288a51708c3181a25aba1f9de2050b89" }, 3 | "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, 4 | "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, 5 | "alternate-toggler": { "branch": "main", "commit": "819800304d3e8e575fd6aa461a8bcf2217e1cfb6" }, 6 | "auto-pairs": { "branch": "master", "commit": "39f06b873a8449af8ff6a3eee716d3da14d63a76" }, 7 | "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, 8 | "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, 9 | "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, 10 | "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, 11 | "cmp-nvim-ultisnips": { "branch": "main", "commit": "404401792ec62d51ca2e8c279a81996082c2f937" }, 12 | "cmp-omni": { "branch": "main", "commit": "4ef610bbd85a5ee4e97e09450c0daecbdc60de86" }, 13 | "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, 14 | "gitsigns.nvim": { "branch": "main", "commit": "e9c4187c3774a46df2d086a66cf3a7e6bea4c432" }, 15 | "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, 16 | "hop.nvim": { "branch": "master", "commit": "90db1b2c61b820e230599a04fedcd2679e64bd07" }, 17 | "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, 18 | "jaq-nvim": { "branch": "master", "commit": "236296aae555657487d1bb4d066cbde9d79d8cd4" }, 19 | "lazy.nvim": { "branch": "main", "commit": "b02c9eae6a250f98908c146d1dc1a891f5019f0a" }, 20 | "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, 21 | "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, 22 | "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, 23 | "neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" }, 24 | "neovim-session-manager": { "branch": "master", "commit": "dd0f5ebb06431505a6de75fd1bc50cd62226adef" }, 25 | "none-ls.nvim": { "branch": "main", "commit": "0d1b3fa2ad0b371b94cb4b9a27ba6e5a1a915c91" }, 26 | "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, 27 | "nvim-cmp": { "branch": "main", "commit": "7e348da6e5085ac447144a2ef4b637220ba27209" }, 28 | "nvim-cokeline": { "branch": "main", "commit": "adfd1eb87e0804b6b86126e03611db6f62bb2909" }, 29 | "nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" }, 30 | "nvim-highlight-colors": { "branch": "main", "commit": "a8f6952cb1ff7bde864a34c502f1a42c360a6662" }, 31 | "nvim-lspconfig": { "branch": "master", "commit": "216deb2d1b5fbf24398919228208649bbf5cbadf" }, 32 | "nvim-pqf": { "branch": "main", "commit": "d15582d3d0c09280f371fa5f21537cf4530ed330" }, 33 | "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, 34 | "nvim-treesitter": { "branch": "master", "commit": "7f4ac678770175cdf0d42c015f4a5b6e18b6cb33" }, 35 | "nvim-ts-autotag": { "branch": "main", "commit": "323a3e16ed603e2e17b26b1c836d1e86c279f726" }, 36 | "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, 37 | "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, 38 | "pretty-fold.nvim": { "branch": "master", "commit": "ce302faec7da79ea8afb5a6eec5096b68ba28cb5" }, 39 | "rainbow-delimiters.nvim": { "branch": "master", "commit": "b29da4a6061a88270e875b38367d82c04c856128" }, 40 | "refactoring.nvim": { "branch": "master", "commit": "d07218748c48e756c27aa6859bfa6e62a3d271af" }, 41 | "telescope-frecency.nvim": { "branch": "master", "commit": "1154548e611ffe9227f8d7a3f74c64c396afd0f2" }, 42 | "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, 43 | "telescope-ultisnips.nvim": { "branch": "main", "commit": "d1cca4b5aa809a90b7a8caddeb860329d5a8c2ff" }, 44 | "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, 45 | "themer.lua": { "branch": "main", "commit": "625510cfec70b55fe42d04b1256c5f93c92a4202" }, 46 | "ultisnips": { "branch": "master", "commit": "49dc8cb2086db19d385791c8e1635723b0fd95c7" }, 47 | "vim-easy-align": { "branch": "master", "commit": "9815a55dbcd817784458df7a18acacc6f82b1241" }, 48 | "vim-gutentags": { "branch": "master", "commit": "aa47c5e29c37c52176c44e61c780032dfacef3dd" }, 49 | "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, 50 | "vim-startuptime": { "branch": "master", "commit": "ac2cccb5be617672add1f4f3c0a55ce99ba34e01" }, 51 | "vim-titlecase": { "branch": "master", "commit": "69a697c54a08ca5603cb757b4d4f78cd4b567549" }, 52 | "vim-visual-multi": { "branch": "master", "commit": "38b0e8d94a5499ccc17d6159763d32c79f53417b" }, 53 | "vimtex": { "branch": "master", "commit": "80c9bc179784c30192d482741a43f176c859daa1" }, 54 | "virt-column.nvim": { "branch": "master", "commit": "b62b4ef0774d19452d4ed18e473e824c7a756f2f" } 55 | } -------------------------------------------------------------------------------- /lua/user/autocmds.lua: -------------------------------------------------------------------------------- 1 | local augroup = vim.api.nvim_create_augroup 2 | local autocmd = vim.api.nvim_create_autocmd 3 | 4 | local group = augroup("on_bufenter", { clear = true }) 5 | autocmd("BufEnter", { 6 | callback = function() 7 | set_title() 8 | end, 9 | desc = "Set application window title.", 10 | group = group, 11 | pattern = "*", 12 | }) 13 | autocmd("BufEnter", { 14 | callback = function() 15 | vim.opt_local.formatoptions:remove({ "r", "o" }) 16 | end, 17 | desc = "After pressing in insert mode, and on 'o' or 'O', disable inserting comment leader.", 18 | group = group, 19 | pattern = "*", 20 | }) 21 | 22 | group = augroup("update_statuline", { clear = true }) 23 | autocmd("User", { 24 | command = [[redrawstatus]], 25 | desc = "Update lualine on lsp progress.", 26 | group = group, 27 | pattern = "LspProgressUpdate", 28 | }) 29 | 30 | group = augroup("clean_onsave", { clear = true }) 31 | autocmd("BufWritePre", { 32 | callback = function() 33 | perform_cleanup() 34 | end, 35 | desc = "Remove trailing whitespace and newlines on save.", 36 | group = group, 37 | pattern = "*", 38 | }) 39 | 40 | group = augroup("highlight_onyank", { clear = true }) 41 | autocmd("TextYankPost", { 42 | callback = function() 43 | vim.highlight.on_yank({ higroup = "Visual", timeout = 500, on_visual = true, on_macro = true }) 44 | end, 45 | desc = "Highlight selection on yank.", 46 | group = group, 47 | pattern = "*", 48 | }) 49 | 50 | group = augroup("update_file", { clear = true }) 51 | autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, { 52 | callback = function() 53 | local regex = vim.regex([[\(c\|r.?\|!\|t\)]]) 54 | local mode = vim.api.nvim_get_mode()["mode"] 55 | if (not regex:match_str(mode)) and vim.fn.getcmdwintype() == "" then 56 | vim.cmd("checktime") 57 | end 58 | end, 59 | desc = "If the file is changed outside of neovim, reload it automatically.", 60 | group = group, 61 | pattern = "*", 62 | }) 63 | autocmd("FileChangedShellPost", { 64 | callback = function() 65 | vim_notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN) 66 | end, 67 | desc = "If the file is changed outside of neovim, reload it automatically.", 68 | group = group, 69 | pattern = "*", 70 | }) 71 | 72 | group = augroup("restore_cur_pos", { clear = true }) 73 | autocmd("BufReadPost", { 74 | command = [[if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"zz" | endif]], 75 | desc = "Restore cursor position to last known position on read.", 76 | group = group, 77 | pattern = "*", 78 | }) 79 | 80 | -- Poor man's vim-rooter: https://www.reddit.com/r/neovim/comments/zy5s0l/you_dont_need_vimrooter_usually_or_how_to_set_up/ 81 | -- Array of file names indicating root directory. Modify to your liking. 82 | local root_names = { ".git", "Makefile" } 83 | 84 | -- Cache to use for speed up (at cost of possibly outdated results) 85 | local root_cache = {} 86 | 87 | local set_root = function() 88 | -- Get directory path to start search from 89 | local path = vim.api.nvim_buf_get_name(0) 90 | if path == "" then 91 | return 92 | end 93 | path = vim.fs.dirname(path) 94 | 95 | -- Try cache and resort to searching upward for root directory 96 | local root = root_cache[path] 97 | if root == nil then 98 | local root_file = vim.fs.find(root_names, { path = path, upward = true })[1] 99 | -- If any in root_names is not found, set cwd to current directory 100 | if root_file == nil then 101 | vim.fn.chdir(path) 102 | return 103 | end 104 | root = vim.fs.dirname(root_file) 105 | root_cache[path] = root 106 | end 107 | 108 | -- Set current directory 109 | vim.fn.chdir(root) 110 | end 111 | 112 | group = augroup("MyAutoRoot", { clear = true }) 113 | autocmd("BufEnter", { group = group, callback = set_root }) 114 | -------------------------------------------------------------------------------- /lua/user/mappings.lua: -------------------------------------------------------------------------------- 1 | local map = vim.keymap.set 2 | local e_opts = { expr = true } 3 | local s_opts = { silent = true } 4 | local se_opts = { silent = true, expr = true } 5 | 6 | -- Open windows terminal terminal at cwd or git root 7 | map("n", "t", function() 8 | local gitsigns_status = vim.b.gitsigns_status_dict 9 | if gitsigns_status then 10 | launch_ext_prog("wt", "-d", vim.fn.shellescape(gitsigns_status.root)) 11 | else 12 | launch_ext_prog("wt", "-d", vim.fn.shellescape(vim.fn.expand("%:p:h"))) 13 | end 14 | end, s_opts) 15 | 16 | -- Open explorer at cwd 17 | map("n", "e", function() 18 | launch_ext_prog("explorer", vim.fn.shellescape(vim.fn.expand("%:p:h"))) 19 | end, s_opts) 20 | 21 | -- Open current file in vscode with current cursor position 22 | map("n", "c", function() 23 | launch_ext_prog( 24 | "code", 25 | "-g", 26 | vim.fn.shellescape(vim.api.nvim_buf_get_name(0) .. ":" .. table.concat(vim.api.nvim_win_get_cursor(0), ":")) 27 | ) 28 | end, s_opts) 29 | 30 | -- Open current file in notepad 31 | map("n", "n", function() 32 | launch_ext_prog("notepad", vim.fn.shellescape(vim.fn.expand("%:p"))) 33 | end, s_opts) 34 | 35 | -- Open url at cursor in browser 36 | map("n", "ou", function() 37 | local pos = vim.api.nvim_win_get_cursor(0) 38 | local col, _ = vim.api.nvim_get_current_line():find("https?") 39 | if not col then 40 | return 41 | end 42 | vim.api.nvim_win_set_cursor(0, { pos[1], col - 1 }) 43 | open_url(vim.fn.expand("")) 44 | vim.api.nvim_win_set_cursor(0, pos) 45 | end, s_opts) 46 | 47 | -- Open plugin repository at cursor in browser 48 | map("n", "or", function() 49 | open_url(vim.fn.expand(""), [[https://github.com/]]) 50 | end, s_opts) 51 | 52 | -- Replace word under cursor 53 | map("n", "", [[:%s/\<\>/]]) 54 | map("v", "", [[:%s/=EscapeString(GetVisualSelection())/]]) 55 | 56 | -- Save file 57 | map("n", "", "update!", s_opts) 58 | map("i", "", "update!", s_opts) 59 | 60 | -- Save and reload module 61 | map("n", "", "lua save_reload_module()", s_opts) 62 | 63 | -- Toggle quickfix 64 | map("n", "q", "QFix", s_opts) 65 | 66 | -- Format entire document 67 | map("n", "", "gg=G''zz", s_opts) 68 | 69 | -- Toggle spell 70 | map("n", "", "setlocal spell!", s_opts) 71 | map("n", "", "setlocal paste!", s_opts) 72 | 73 | -- Remove highlight 74 | map("n", "h", "nohl", s_opts) 75 | 76 | -- Map $ to g_ 77 | map("n", "$", "g_", s_opts) 78 | map("v", "$", "g_", s_opts) 79 | 80 | -- Yank till line end 81 | map("n", "Y", '"+yg_', s_opts) 82 | 83 | -- Always yank to clipboard 84 | map("n", "y", '"+y', s_opts) 85 | map("v", "y", '"+y', s_opts) 86 | 87 | -- Paste from system clipboard in insert/select mode without breaking indentation 88 | map("i", "", "+", s_opts) 89 | map("n", "", "i+", s_opts) 90 | map("s", "", "i+", s_opts) 91 | 92 | -- Move to line end 93 | map("i", "", "g_a", s_opts) 94 | 95 | -- Display line movements 96 | map("n", "j", "v:count == 0 ? 'gj' : 'j'", e_opts) 97 | map("n", "k", "v:count == 0 ? 'gk' : 'k'", e_opts) 98 | 99 | -- Fix accidental line joining during visual block selection 100 | map("v", "J", "j", s_opts) 101 | map("v", "K", "k", s_opts) 102 | 103 | -- Correct previous bad word in insert mode 104 | map("i", "", "u[s1z=`]au", s_opts) 105 | -- Correct word under cursor 106 | map("n", "", "1z=", s_opts) 107 | 108 | -- Delete previous word 109 | map("i", "", "", s_opts) 110 | -- Delete next word 111 | map("i", "", "dW", s_opts) 112 | 113 | -- Indenting 114 | map("n", "", ">>", s_opts) 115 | map("n", "", "<<", s_opts) 116 | 117 | -- Continuous visual shifting https://superuser.com/q/310417/736190 118 | map("x", "", ">gv", s_opts) 119 | map("x", "", "", "h", s_opts) 123 | map("n", "", "l", s_opts) 124 | map("n", "", "k", s_opts) 125 | map("n", "", "j", s_opts) 126 | 127 | -- Disable word search on shift mouse 128 | map("", "", "") 129 | map("", "", "") 130 | 131 | -- Command mode movement 132 | map("c", "", "", s_opts) 133 | map("c", "", "", s_opts) 134 | 135 | -- Duplicate line 136 | map("n", "", "t.", s_opts) 137 | map("i", "", "t.gi", s_opts) 138 | 139 | -- Move line / block 140 | map("n", "", ":m .+1==", s_opts) 141 | map("n", "", ":m .-2==", s_opts) 142 | map("v", "", ":m '>+1gv-gv", s_opts) 143 | map("v", "", ":m '<-2gv-gv", s_opts) 144 | 145 | -- Toggle wrap 146 | map("n", "", "setlocal linebreak! wrap!", s_opts) 147 | 148 | -- Close buffer 149 | map("n", "w", function() 150 | if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then 151 | return "cclose" 152 | else 153 | return "bd!" 154 | end 155 | end, se_opts) 156 | -- Close window without changing layout 157 | map("n", "c", "bp | sp | bn | bd", s_opts) 158 | 159 | -- Enter normal mode in terminal 160 | map("t", "", "", s_opts) 161 | 162 | -- Center cursor after traversing search 163 | map("n", "n", "nzz", s_opts) 164 | map("n", "N", "Nzz", s_opts) 165 | 166 | -- Toggle fold (single level) 167 | map("n", "", "foldlevel('.') ? 'za' : ''", se_opts) 168 | 169 | -- Handle save & close, force close when multiple buffers are active 170 | map("n", "ZZ", "len(getbufinfo({'buflisted':1})) > 1 ? 'wqall' : 'wq'", se_opts) 171 | map("n", "ZQ", "len(getbufinfo({'buflisted':1})) > 1 ? 'qall!' : 'q!'", se_opts) 172 | 173 | -- Undo break points 174 | local break_points = { ".", ",", "!", "?", "=", "-", "_" } 175 | for _, v in pairs(break_points) do 176 | map("i", tostring(v), v .. "u", s_opts) 177 | end 178 | -------------------------------------------------------------------------------- /lua/user/options.lua: -------------------------------------------------------------------------------- 1 | -- File encoding 2 | vim.opt.fileencoding = "utf-8" 3 | 4 | -- DOS fileformat 5 | vim.opt.fileformat = "dos" 6 | vim.opt.fileformats = "dos" 7 | 8 | -- Enable dark background colorschemes 9 | vim.opt.background = "dark" 10 | -- Enable 24bit colors in terminal 11 | vim.opt.termguicolors = true 12 | 13 | -- Auto-indent new lines 14 | vim.opt.autoindent = true 15 | -- Enable smart-indent 16 | vim.opt.smartindent = true 17 | 18 | -- Use spaces instead of tabs 19 | vim.opt.expandtab = true 20 | -- Number of auto-indent spaces 21 | vim.opt.shiftwidth = 4 22 | -- Number of spaces per Tab 23 | vim.opt.softtabstop = 4 24 | -- Number of columns per tab 25 | vim.opt.tabstop = 4 26 | 27 | -- No wrap 28 | vim.opt.wrap = false 29 | 30 | -- Always case-insensitive 31 | vim.opt.ignorecase = true 32 | -- Enable smart-case search 33 | vim.opt.smartcase = true 34 | -- Searches for strings incrementally 35 | vim.opt.incsearch = true 36 | 37 | -- Show line numbers 38 | vim.opt.number = true 39 | -- Enable relative line numbers 40 | vim.opt.relativenumber = true 41 | 42 | -- Enable completion for vim-compe 43 | vim.opt.completeopt = { "menu", "menuone", "noselect" } 44 | -- Show max. 10 completions 45 | vim.opt.pumheight = 10 46 | 47 | -- Splits 48 | vim.opt.splitright = true 49 | vim.opt.splitbelow = true 50 | 51 | -- Folding configuration 52 | vim.opt.viewoptions:remove("options") 53 | vim.opt.foldmethod = "marker" 54 | 55 | -- Display eol characters 56 | vim.opt.list = true 57 | 58 | -- Display chars 59 | vim.opt.fillchars = { 60 | eob = "–", 61 | fold = " ", 62 | foldsep = " ", 63 | foldclose = "", 64 | foldopen = "", 65 | horiz = "━", 66 | horizup = "┻", 67 | horizdown = "┳", 68 | vert = "┃", 69 | vertleft = "┫", 70 | vertright = "┣", 71 | verthoriz = "╋", 72 | stl = "─", 73 | stlnc = "─", 74 | } 75 | vim.opt.listchars:append({ tab = " ", lead = "·", trail = "·", eol = "﬋" }) 76 | 77 | -- Use en_us to spellcheck 78 | vim.opt.spelllang = "en_us" 79 | 80 | -- Global statusline 81 | vim.opt.laststatus = 3 82 | 83 | -- Fold column 84 | vim.opt.foldcolumn = "auto:9" 85 | vim.opt.signcolumn = "yes" 86 | 87 | -- No redraw during macro, regex execution 88 | vim.opt.lazyredraw = true 89 | 90 | -- Enable mouse for normal and visual modes 91 | vim.opt.mouse = "nv" 92 | 93 | -- Lead scroll by 8 lines 94 | vim.opt.scrolloff = 8 95 | 96 | -- No completion messages in secondary mode bar 97 | vim.opt.shortmess = "ilmxoOsTIcF" 98 | 99 | -- Disable secondary mode bar 100 | vim.opt.showmode = false 101 | 102 | -- No swap file 103 | vim.opt.swapfile = false 104 | 105 | -- Real-time substitute 106 | vim.opt.inccommand = "split" 107 | 108 | -- Enable title 109 | vim.opt.title = true 110 | 111 | vim.opt.startofline = false 112 | 113 | -- Cmdline height 114 | -- vim.opt.ch = 0 115 | 116 | -- Ignore LaTeX aux files 117 | vim.opt.wildignore = { 118 | "*.aux", 119 | "*.lof", 120 | "*.lot", 121 | "*.fls", 122 | "*.out", 123 | "*.toc", 124 | "*.fmt", 125 | "*.fot", 126 | "*.cb", 127 | "*.cb2", 128 | ".*.lb", 129 | "__latex*", 130 | "*.fdb_latexmk", 131 | "*.synctex", 132 | "*.synctex(busy)", 133 | "*.synctex.gz", 134 | "*.synctex.gz(busy)", 135 | "*.pdfsync", 136 | "*.bbl", 137 | "*.bcf", 138 | "*.blg", 139 | "*.run.xml", 140 | "indent.log", 141 | "*.pdf", 142 | } 143 | 144 | -- Undo dir (persistent undo's) 145 | local undo_dir = HOME_PATH .. [[\.cache\vim\undo]] 146 | if not vim.fn.isdirectory(undo_dir) then 147 | vim.fn.mkdir(undo_dir) 148 | end 149 | vim.opt.undodir = undo_dir 150 | vim.opt.undofile = true 151 | 152 | -- Python3 path 153 | vim.g.python3_host_prog = vim.fn.split(vim.fn.trim(vim.fn.system("where python")), "\n")[1] 154 | 155 | -- Disable builtin vim plugins 156 | local disabled_built_ins = { 157 | "netrw", 158 | "netrwPlugin", 159 | "netrwSettings", 160 | "netrwFileHandlers", 161 | "gzip", 162 | "zip", 163 | "zipPlugin", 164 | "tar", 165 | "tarPlugin", 166 | "getscript", 167 | "getscriptPlugin", 168 | "vimball", 169 | "vimballPlugin", 170 | "2html_plugin", 171 | "logipat", 172 | "rrhelper", 173 | "matchit", 174 | } 175 | 176 | for _, plugin in pairs(disabled_built_ins) do 177 | vim.g["loaded_" .. plugin] = 1 178 | end 179 | 180 | -- Disable perl provider 181 | vim.g.loaded_perl_provider = 0 182 | 183 | -- Disable ruby provider 184 | vim.g.loaded_ruby_provider = 0 185 | 186 | -- Disable node provider 187 | vim.g.loaded_node_provider = 0 188 | -------------------------------------------------------------------------------- /lua/user/plugins/config/alpha.lua: -------------------------------------------------------------------------------- 1 | local group = vim.api.nvim_create_augroup("alpha_options", { clear = true }) 2 | vim.api.nvim_create_autocmd("FileType", { 3 | command = [[setlocal buflisted fillchars=eob:\ ]], 4 | desc = "Fix buffer movement, remove eob in alpha.", 5 | group = group, 6 | pattern = "alpha", 7 | }) 8 | 9 | -- Alpha theme 10 | local dashboard = require("alpha.themes.dashboard") 11 | 12 | -- Plugin count 13 | local lazy_stats = require("lazy").stats() 14 | local vim_version = table.concat({ vim.version().major, vim.version().minor, vim.version().patch }, ".") 15 | 16 | -- Common highlight 17 | local highlight = "Alpha" 18 | 19 | local function set_button(sc, txt, keybind, keybind_opts) 20 | local button = dashboard.button(sc, txt, keybind, keybind_opts) 21 | button.opts.hl = highlight 22 | button.opts.hl_shortcut = highlight 23 | return button 24 | end 25 | 26 | local header = { 27 | type = "text", 28 | val = { 29 | " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", 30 | " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", 31 | " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ", 32 | " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ", 33 | " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", 34 | " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", 35 | }, 36 | opts = { position = "center", hl = highlight }, 37 | } 38 | 39 | local tip_text = vim.fn.system("curl.exe -s -m 3 https://vtip.43z.one") 40 | local tip = { 41 | type = "text", 42 | val = { tip_text }, 43 | opts = { position = "center", hl = highlight }, 44 | } 45 | 46 | local footer = { 47 | type = "text", 48 | val = { 49 | " " .. lazy_stats.count .. " plugins (" .. lazy_stats.loaded .. " loaded) |  v" .. vim_version, 50 | }, 51 | opts = { position = "center", hl = highlight }, 52 | } 53 | 54 | local buttons = { 55 | type = "group", 56 | val = { 57 | set_button("1", " Load Last Session", "SessionManager load_last_session"), 58 | set_button("2", " Browse Sessions", "SessionManager load_session"), 59 | set_button( 60 | "3", 61 | " Recent Files", 62 | "lua require('user.plugins.config.telescope.sources').frecency()" 63 | ), 64 | set_button("4", " Find Files", "Telescope find_files"), 65 | set_button("5", " New File", "enew"), 66 | set_button("u", " Update", "Lazy sync"), 67 | set_button("q", " Quit", "qa"), 68 | }, 69 | opts = { 70 | spacing = 1, 71 | }, 72 | } 73 | 74 | local top_margin_per = 0.2 75 | local header_padding = vim.fn.max({ 2, vim.fn.floor(vim.fn.winheight(0) * top_margin_per) }) 76 | 77 | local opts = { 78 | layout = { 79 | { type = "padding", val = header_padding }, 80 | header, 81 | { type = "padding", val = 4 }, 82 | buttons, 83 | { type = "padding", val = 1 }, 84 | footer, 85 | tip, 86 | { type = "padding", val = 1 }, 87 | }, 88 | opts = { 89 | margin = 5, 90 | }, 91 | } 92 | 93 | require("alpha").setup(opts) 94 | -------------------------------------------------------------------------------- /lua/user/plugins/config/cmp/init.lua: -------------------------------------------------------------------------------- 1 | local icons = { 2 | Text = "", 3 | Method = "", 4 | Function = "", 5 | Constructor = "⌘", 6 | Field = "ﰠ", 7 | Variable = "", 8 | Class = "ﴯ", 9 | Interface = "", 10 | Module = "", 11 | Property = "ﰠ", 12 | Unit = "塞", 13 | Value = "", 14 | Enum = "", 15 | Keyword = "廓", 16 | Snippet = "", 17 | Color = "", 18 | File = "", 19 | Reference = "", 20 | Folder = "", 21 | EnumMember = "", 22 | Constant = "", 23 | Struct = "פּ", 24 | Event = "", 25 | Operator = "", 26 | TypeParameter = "", 27 | } 28 | 29 | local feedkey = function(key, mode) 30 | mode = mode or "n" 31 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) 32 | end 33 | 34 | local cmp = require("cmp") 35 | local cmp_mappings = require("user.plugins.config.cmp.mappings") 36 | 37 | cmp.setup({ 38 | snippet = { 39 | expand = function(args) 40 | vim.fn["UltiSnips#Anon"](args.body) 41 | end, 42 | }, 43 | formatting = { 44 | fields = { "kind", "abbr", "menu" }, 45 | format = function(entry, vim_item) 46 | vim_item.menu = vim_item.kind 47 | .. " " 48 | .. ({ 49 | omni = "[Omni]", 50 | buffer = "[Buf]", 51 | nvim_lsp = "[Lsp]", 52 | nvim_lua = "[Lua]", 53 | ultisnips = "[Snip]", 54 | path = "[Path]", 55 | })[entry.source.name] 56 | vim_item.kind = icons[vim_item.kind] 57 | return vim_item 58 | end, 59 | }, 60 | mapping = cmp.mapping.preset.insert({ 61 | [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), 62 | [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), 63 | [""] = cmp.mapping.scroll_docs(4), 64 | [""] = cmp.mapping.scroll_docs(-4), 65 | [""] = cmp.mapping.complete(), 66 | [""] = cmp.mapping.close(), 67 | [""] = cmp.mapping(function(fallback) 68 | cmp_mappings.compose({ "expand", "jump_forwards", "confirm" })(fallback) 69 | end, { 70 | "i", 71 | "s", 72 | }), 73 | [""] = cmp.mapping(function(fallback) 74 | cmp_mappings.compose({ "confirm" })(fallback) 75 | end, { 76 | "i", 77 | "s", 78 | }), 79 | }), 80 | sources = cmp.config.sources({ 81 | { name = "ultisnips" }, 82 | { name = "nvim_lsp" }, 83 | { 84 | name = "buffer", 85 | option = { 86 | get_bufnrs = function() 87 | local bufs = {} 88 | for _, win in ipairs(vim.api.nvim_list_wins()) do 89 | bufs[vim.api.nvim_win_get_buf(win)] = true 90 | end 91 | return vim.tbl_keys(bufs) 92 | end, 93 | }, 94 | }, 95 | { name = "nvim_lua" }, 96 | { name = "path" }, 97 | }), 98 | window = { 99 | documentation = { 100 | winhighlight = "NormalFloat:CmpDocumentation,FloatBorder:CmpDocumentationBorder", 101 | }, 102 | }, 103 | experimental = { 104 | ghost_text = true, 105 | }, 106 | }) 107 | 108 | local cmdline_formatting = { 109 | format = function(_, vim_item) 110 | vim_item.kind = "" 111 | vim_item.menu = "" 112 | return vim_item 113 | end, 114 | } 115 | 116 | local cmdline_mapping = cmp.mapping.preset.insert({ 117 | [""] = cmp.mapping({ 118 | c = function() 119 | if cmp.visible() then 120 | cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert }) 121 | else 122 | feedkey("") 123 | end 124 | end, 125 | }), 126 | [""] = cmp.mapping({ 127 | c = function() 128 | if cmp.visible() then 129 | cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert }) 130 | else 131 | feedkey("") 132 | end 133 | end, 134 | }), 135 | [""] = cmp.mapping({ 136 | c = function(fallback) 137 | if cmp.visible() then 138 | cmp.confirm({ select = true }) 139 | else 140 | fallback() 141 | end 142 | end, 143 | }), 144 | }) 145 | 146 | cmp.setup.cmdline("/", { 147 | formatting = cmdline_formatting, 148 | mapping = cmdline_mapping, 149 | sources = cmp.config.sources({ 150 | { name = "buffer" }, 151 | }), 152 | }) 153 | 154 | cmp.setup.cmdline(":", { 155 | formatting = cmdline_formatting, 156 | mapping = cmdline_mapping, 157 | sources = cmp.config.sources({ 158 | { name = "cmdline" }, 159 | { name = "buffer" }, 160 | { name = "path" }, 161 | }), 162 | }) 163 | -------------------------------------------------------------------------------- /lua/user/plugins/config/cmp/mappings.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/quangnguyen30192/cmp-nvim-ultisnips/blob/main/lua/cmp_nvim_ultisnips/mappings.lua 2 | local cmp = require("cmp") 3 | 4 | local has_words_before = function() 5 | if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then 6 | return false 7 | end 8 | local line, col = unpack(vim.api.nvim_win_get_cursor(0)) 9 | return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil 10 | end 11 | 12 | local feedkey = function(key, mode) 13 | mode = mode or "m" 14 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) 15 | end 16 | 17 | local can_execute = function(arg) 18 | return vim.fn[arg]() == 1 19 | end 20 | 21 | local valid_actions = { 22 | expand = { 23 | condition = { can_execute, "UltiSnips#CanExpandSnippet" }, 24 | command = { feedkey, "(cmpu-expand)" }, 25 | }, 26 | jump_forwards = { 27 | condition = { can_execute, "UltiSnips#CanJumpForwards" }, 28 | command = { feedkey, "(cmpu-jump-forwards)" }, 29 | }, 30 | jump_backwards = { 31 | condition = { can_execute, "UltiSnips#CanJumpBackwards" }, 32 | command = { feedkey, "(cmpu-jump-backwards)" }, 33 | }, 34 | confirm = { 35 | condition = { has_words_before }, 36 | command = { cmp.confirm, { select = true } }, 37 | }, 38 | } 39 | 40 | local M = {} 41 | 42 | ---Executes a command when condition match 43 | ---@param actions table list of actions to execute 44 | M.compose = function(actions) 45 | return function(fallback) 46 | for _, v in ipairs(actions) do 47 | local action = valid_actions[v] 48 | if not action then 49 | vim_notify( 50 | ('[cmp_mappings] Invalid action ("%s"). Please check your mappings.\nAllowed values: { %s }'):format( 51 | v, 52 | table.concat(vim.tbl_keys(valid_actions), ", ") 53 | ), 54 | vim.log.levels.ERROR 55 | ) 56 | return 57 | end 58 | if action.condition[1](action.condition[2]) == true then 59 | action.command[1](action.command[2]) 60 | return 61 | end 62 | end 63 | fallback() 64 | end 65 | end 66 | 67 | return M 68 | -------------------------------------------------------------------------------- /lua/user/plugins/config/cokeline.lua: -------------------------------------------------------------------------------- 1 | local present, _ = pcall(require, "themer.modules.core.api") 2 | if not present then 3 | return 4 | end 5 | 6 | -- Themer colors 7 | local themer = require("user.plugins.config.themer") 8 | local colors = themer.colors 9 | local utils = themer.utils 10 | 11 | local active_fg = colors.blue 12 | local active_bg = colors.bg.base 13 | local inactive_fg = utils.adjust_color(colors.fg, -100) 14 | local inactive_bg = utils.adjust_color(colors.bg.base, 5) 15 | local modified_fg = colors.red 16 | local switch_fg = colors.green 17 | 18 | --- Variable padding component 19 | --- @param n number Amount of padding (default: 1) 20 | --- @return table Padding component 21 | local padding_component = setmetatable({ 22 | text = " ", 23 | truncation = { priority = 1 }, 24 | }, { 25 | __call = function(_, n) 26 | return { 27 | text = string.rep(" ", n), 28 | truncation = { priority = 1 }, 29 | } 30 | end, 31 | }) 32 | 33 | --- Poor man's superscript converter 34 | --- @param n number Number to be converted into superscript 35 | --- @return string Converted superscript number 36 | local function superscript(n) 37 | local superscripts = { "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹" } 38 | 39 | local str = tostring(n) 40 | local digits = {} 41 | for i = 1, #str do 42 | digits[i] = superscripts[1 + (str:sub(i, i) % 10)] 43 | end 44 | 45 | return table.concat(digits, "") 46 | end 47 | 48 | local is_picking_focus = require("cokeline.mappings").is_picking_focus 49 | local is_picking_close = require("cokeline.mappings").is_picking_close 50 | local buffer_ignore_types = { "terminal", "quickfix" } 51 | 52 | local function is_picking_focus_or_close() 53 | return is_picking_focus() or is_picking_close() 54 | end 55 | 56 | require("cokeline").setup({ 57 | show_if_buffers_are_at_least = 1, 58 | 59 | buffers = { 60 | filter_valid = function(buffer) 61 | return not vim.tbl_contains(buffer_ignore_types, buffer.type) 62 | end, 63 | new_buffers_position = "next", 64 | }, 65 | 66 | mappings = { 67 | cycle_prev_next = true, 68 | }, 69 | 70 | rendering = { 71 | max_buffer_width = 24, 72 | }, 73 | 74 | sidebar = { 75 | filetype = "neo-tree", 76 | components = { 77 | { 78 | text = "  Neo-Tree", 79 | hl = { 80 | fg = active_fg, 81 | bg = active_bg, 82 | style = "bold", 83 | }, 84 | }, 85 | }, 86 | }, 87 | 88 | default_hl = { 89 | fg = function(buffer) 90 | return (buffer.is_focused and not (is_picking_focus_or_close())) and active_fg or inactive_fg 91 | end, 92 | bg = function(buffer) 93 | return (buffer.is_focused and not (is_picking_focus_or_close())) and active_bg or inactive_bg 94 | end, 95 | style = function(buffer) 96 | return (buffer.is_focused and not (is_picking_focus_or_close())) and "bold" or nil 97 | end, 98 | }, 99 | 100 | components = { 101 | { 102 | text = "|", 103 | fg = inactive_fg, 104 | bg = inactive_bg, 105 | truncation = { priority = 1 }, 106 | }, 107 | padding_component(2), 108 | { 109 | text = function(buffer) 110 | return is_picking_focus_or_close() and buffer.pick_letter .. " " or buffer.devicon.icon 111 | end, 112 | fg = function(buffer) 113 | if is_picking_focus() then 114 | return switch_fg 115 | elseif is_picking_close() then 116 | return modified_fg 117 | elseif buffer.is_focused then 118 | return buffer.devicon.color 119 | else 120 | return inactive_fg 121 | end 122 | end, 123 | truncation = { priority = 1 }, 124 | }, 125 | { 126 | text = function(buffer) 127 | return buffer.unique_prefix 128 | end, 129 | truncation = { 130 | priority = 3, 131 | direcion = "right", 132 | }, 133 | }, 134 | { 135 | text = function(buffer) 136 | return buffer.unique_prefix ~= "" and "/" or "" 137 | end, 138 | truncation = { priority = 1 }, 139 | }, 140 | { 141 | text = function(buffer) 142 | return buffer.filename 143 | end, 144 | truncation = { 145 | priority = 2, 146 | direcion = "left", 147 | }, 148 | }, 149 | padding_component, 150 | { 151 | text = function(buffer) 152 | return superscript(buffer.index) 153 | end, 154 | truncation = { priority = 1 }, 155 | }, 156 | padding_component, 157 | { 158 | text = function(buffer) 159 | return buffer.is_modified and "" or "" 160 | end, 161 | delete_buffer_on_left_click = true, 162 | fg = function(buffer) 163 | return buffer.is_modified and modified_fg or nil 164 | end, 165 | truncation = { priority = 1 }, 166 | }, 167 | padding_component(2), 168 | { 169 | text = function(buffer) 170 | return buffer.is_last and "|" or "" 171 | end, 172 | fg = inactive_fg, 173 | bg = inactive_bg, 174 | truncation = { priority = 1 }, 175 | }, 176 | }, 177 | }) 178 | 179 | local map = vim.keymap.set 180 | local opts = { silent = true } 181 | 182 | map("n", "", "(cokeline-focus-next)", opts) 183 | map("n", "", "(cokeline-focus-prev)", opts) 184 | map("n", "", "(cokeline-switch-prev)", opts) 185 | map("n", "", "(cokeline-switch-next)", opts) 186 | map("n", "bf", function() 187 | require("cokeline.mappings").pick("focus") 188 | end, opts) 189 | map("n", "bc", function() 190 | require("cokeline.mappings").pick("close") 191 | end, opts) 192 | -------------------------------------------------------------------------------- /lua/user/plugins/config/devicons.lua: -------------------------------------------------------------------------------- 1 | require("nvim-web-devicons").setup({ 2 | override = { 3 | tex = { 4 | icon = "", 5 | color = "#008080", 6 | name = "tex", 7 | }, 8 | cls = { 9 | icon = "", 10 | color = "#008080", 11 | name = "cls", 12 | }, 13 | sty = { 14 | icon = "", 15 | color = "#008080", 16 | name = "sty", 17 | }, 18 | snippets = { 19 | icon = "", 20 | color = "#a9b665", 21 | name = "snippets", 22 | }, 23 | tags = { 24 | icon = "", 25 | color = "#6d8086", 26 | name = "tags", 27 | }, 28 | prettierrc = { 29 | icon = "", 30 | color = "#6d8086", 31 | name = "prettierrc", 32 | }, 33 | ps1 = { 34 | icon = "ﲵ", 35 | color = "#4478d2", 36 | name = "ps1", 37 | }, 38 | css = { 39 | icon = "", 40 | color = "#28a9e0", 41 | name = "css", 42 | }, 43 | html = { 44 | icon = "", 45 | color = "#f1662b", 46 | name = "html", 47 | }, 48 | js = { 49 | icon = "", 50 | color = "#e5c61d", 51 | name = "js", 52 | }, 53 | xml = { 54 | icon = "", 55 | color = "#f1662b", 56 | name = "xml", 57 | }, 58 | }, 59 | default = true, 60 | }) 61 | -------------------------------------------------------------------------------- /lua/user/plugins/config/heirline/components.lua: -------------------------------------------------------------------------------- 1 | local present, _ = pcall(require, "themer.modules.core.api") 2 | if not present then 3 | return 4 | end 5 | 6 | -- Themer colors 7 | local themer = require("user.plugins.config.themer") 8 | local colors = themer.colors 9 | 10 | -- Helpers 11 | local helper = require("user.plugins.config.heirline.utils") 12 | local theme = require("user.plugins.config.heirline.theme") 13 | local conditions = require("heirline.conditions") 14 | local utils = require("heirline.utils") 15 | 16 | local M = {} 17 | 18 | local function mode() 19 | return M.visual_multi.condition() and "V-M" or vim.api.nvim_get_mode().mode 20 | end 21 | 22 | M.align = { 23 | provider = "%=", 24 | hl = function() 25 | return { fg = helper.mode_colors[vim.api.nvim_get_mode().mode:sub(1, 1)], bold = true } 26 | end, 27 | } 28 | M.null = { provider = "" } 29 | M.space = setmetatable({ 30 | provider = " ", 31 | }, { 32 | __call = function(_, condition) 33 | return { 34 | provider = " ", 35 | condition = condition, 36 | } 37 | end, 38 | }) 39 | 40 | M.delim_left = function(icon, hl) 41 | return { 42 | { 43 | provider = helper.icons.powerline[icon], 44 | hl = hl, 45 | }, 46 | M.space, 47 | } 48 | end 49 | M.delim_right = function(icon, hl) 50 | return { 51 | M.space, 52 | { 53 | provider = helper.icons.powerline[icon], 54 | hl = hl, 55 | }, 56 | } 57 | end 58 | 59 | M.vim_icon = { 60 | provider = helper.icons.vim, 61 | hl = { fg = theme.vim }, 62 | } 63 | 64 | M.vim_mode = {} 65 | 66 | M.vim_mode = utils.insert(M.vim_mode, M.space, M.vim_icon, M.space, { 67 | init = function(self) 68 | self.mode = mode() 69 | end, 70 | 71 | { 72 | flexible = 8, 73 | { 74 | provider = function(self) 75 | return helper.mode_names[self.mode] 76 | end, 77 | }, 78 | { 79 | provider = function(self) 80 | return helper.mode_names[self.mode]:sub(1, 1) 81 | end, 82 | }, 83 | }, 84 | 85 | hl = function(self) 86 | return { bg = theme.bg1, fg = helper.mode_colors[self.mode:sub(1, 1)], bold = true } 87 | end, 88 | }, M.space) 89 | 90 | M.vim_mode = utils.surround({ "", helper.icons.powerline.slant_right }, function() 91 | return theme.bg1 92 | end, M.vim_mode) 93 | 94 | M.git_info = { 95 | condition = conditions.is_git_repo, 96 | 97 | init = function(self) 98 | self.status_dict = vim.b.gitsigns_status_dict 99 | self.added = self.status_dict.added and self.status_dict.added ~= 0 100 | self.removed = self.status_dict.removed and self.status_dict.removed ~= 0 101 | self.changed = self.status_dict.changed and self.status_dict.changed ~= 0 102 | self.has_changes = self.added or self.removed or self.changed 103 | end, 104 | 105 | M.delim_left("slant_left_2", theme.surround), 106 | { 107 | provider = function() 108 | return helper.icons.git_branch .. " " 109 | end, 110 | hl = { fg = colors.magenta }, 111 | }, 112 | { 113 | provider = function(self) 114 | return self.status_dict.head 115 | end, 116 | }, 117 | { 118 | flexible = 6, 119 | { 120 | { 121 | condition = function(self) 122 | return self.has_changes 123 | end, 124 | provider = " (", 125 | }, 126 | { 127 | provider = function(self) 128 | local count = self.status_dict.added or 0 129 | return count > 0 and ("+" .. count) 130 | end, 131 | hl = { fg = colors.green }, 132 | }, 133 | M.space(function(self) 134 | return self.added and (self.removed or self.changed) 135 | end), 136 | { 137 | provider = function(self) 138 | local count = self.status_dict.removed or 0 139 | return count > 0 and ("-" .. count) 140 | end, 141 | hl = { fg = colors.red }, 142 | }, 143 | M.space(function(self) 144 | return self.removed and self.changed 145 | end), 146 | { 147 | provider = function(self) 148 | local count = self.status_dict.changed or 0 149 | return count > 0 and ("~" .. count) 150 | end, 151 | hl = { fg = colors.yellow }, 152 | }, 153 | { 154 | condition = function(self) 155 | return self.has_changes 156 | end, 157 | provider = ")", 158 | }, 159 | }, 160 | M.null, 161 | }, 162 | M.delim_right("slant_right", theme.surround), 163 | 164 | hl = theme.component, 165 | } 166 | 167 | M.file_block = { 168 | init = function(self) 169 | self.filename = vim.api.nvim_buf_get_name(0) 170 | end, 171 | 172 | hl = theme.component, 173 | } 174 | 175 | M.readonly = { 176 | condition = function() 177 | return vim.bo.readonly or not vim.bo.modifiable 178 | end, 179 | 180 | provider = helper.icons.padlock .. " ", 181 | 182 | hl = { fg = colors.red, bold = true }, 183 | } 184 | 185 | M.file_icon = { 186 | init = function(self) 187 | self.filetype = vim.fn.fnamemodify(self.filename, ":e") 188 | self.icon, self.icon_color = 189 | require("nvim-web-devicons").get_icon_color(self.filename, self.filetype, { default = true }) 190 | end, 191 | 192 | provider = function(self) 193 | return self.filetype ~= "" and (self.icon .. " ") 194 | end, 195 | 196 | hl = function(self) 197 | return { fg = self.icon_color } 198 | end, 199 | } 200 | 201 | M.file_name = { 202 | provider = function(self) 203 | local _filename = vim.fn.fnamemodify(self.filename, ":t") 204 | 205 | -- Truncate file_name if too big 206 | -- Set file name to [No Name] on empty buffers 207 | if _filename == "" then 208 | _filename = "[No Name]" 209 | end 210 | 211 | if not conditions.width_percent_below(#_filename, 0.25) then 212 | _filename = string.sub(_filename, 1, 12) .. "…" .. self.filetype 213 | end 214 | 215 | -- Empty file_name for plugin releated buffers 216 | for _, v in pairs(PLUGINS) do 217 | if v == vim.bo.filetype then 218 | _filename = "…" 219 | end 220 | end 221 | 222 | return _filename 223 | end, 224 | 225 | hl = theme.component, 226 | } 227 | 228 | M.vimtex_compile_status = { 229 | condition = function() 230 | return vim.bo.filetype == "tex" 231 | end, 232 | 233 | init = function(self) 234 | if vim.b.vimtex then 235 | self.status = vim.b.vimtex["compiler"]["status"] 236 | end 237 | end, 238 | 239 | provider = function(self) 240 | -- Status: running 241 | if self.status == 1 then 242 | return " (⋯)" 243 | -- Status: compile success 244 | elseif self.status == 2 then 245 | return " ()" 246 | -- Status: compile failed 247 | elseif self.status == 3 then 248 | return " ()" 249 | end 250 | end, 251 | 252 | hl = function(self) 253 | if self.status == 1 then 254 | return { fg = colors.blue } 255 | elseif self.status == 2 then 256 | return { fg = colors.green } 257 | elseif self.status == 3 then 258 | return { fg = colors.red } 259 | end 260 | end, 261 | } 262 | 263 | M.file_block = utils.insert( 264 | M.file_block, 265 | M.space, 266 | M.readonly, 267 | utils.insert(M.file_icon, M.file_name, M.vimtex_compile_status), 268 | M.space 269 | ) 270 | 271 | M.file_block = 272 | utils.surround({ helper.icons.powerline.slant_left_2, helper.icons.powerline.slant_right }, theme.bg1, M.file_block) 273 | 274 | M.search_results = { 275 | condition = function(self) 276 | if vim.api.nvim_buf_line_count(0) > 50000 or M.visual_multi.condition() then 277 | return 278 | end 279 | 280 | local query = vim.fn.getreg("/") 281 | if query == "" or query:find("@") then 282 | return 283 | end 284 | 285 | local active = false 286 | local search_count = vim.fn.searchcount({ recompute = 1, maxcount = -1 }) 287 | 288 | if vim.v.hlsearch and vim.v.hlsearch == 1 and search_count.total > 0 then 289 | active = true 290 | end 291 | 292 | if not active then 293 | return 294 | end 295 | 296 | self.count = search_count 297 | 298 | return true 299 | end, 300 | 301 | M.delim_left("slant_left_2", theme.surround), 302 | { 303 | provider = helper.icons.search .. " ", 304 | hl = { fg = colors.yellow }, 305 | }, 306 | { 307 | provider = function(self) 308 | return table.concat({ self.count.current, "/", self.count.total }) 309 | end, 310 | }, 311 | M.delim_right("slant_right", theme.surround), 312 | 313 | hl = theme.component, 314 | } 315 | 316 | M.visual_multi = { 317 | condition = function() 318 | return exists_and_not_nil(vim.b.VM_Selection) 319 | end, 320 | 321 | init = function(self) 322 | local info = vim.fn.VMInfos() 323 | self.patterns = exists_and_not_nil(info.patterns) 324 | and string.format("(%s)", table.concat(info.patterns, ", "):gsub("[\\<>]", "")) 325 | or "" 326 | self.ratio = info.ratio and info.ratio:gsub(" ", "") or "" 327 | self.status = info.status or "" 328 | end, 329 | 330 | M.delim_left("slant_left_2", theme.surround), 331 | { 332 | provider = helper.icons.search, 333 | hl = { fg = colors.yellow }, 334 | }, 335 | M.space, 336 | { 337 | provider = function(self) 338 | return self.patterns 339 | end, 340 | }, 341 | M.space(function(self) 342 | return self.patterns ~= "" and self.ratio ~= "" 343 | end), 344 | { 345 | provider = function(self) 346 | return self.ratio 347 | end, 348 | }, 349 | M.space(function(self) 350 | return self.ratio ~= "" and self.status ~= "" 351 | end), 352 | { 353 | provider = function(self) 354 | return self.status 355 | end, 356 | }, 357 | M.delim_right("slant_right", theme.surround), 358 | 359 | hl = theme.component, 360 | } 361 | 362 | M.spellcheck = { 363 | condition = function() 364 | return vim.wo.spell 365 | end, 366 | 367 | M.delim_left("slant_left_2", theme.surround), 368 | { provider = vim.bo.spelllang }, 369 | M.delim_right("slant_right", theme.surround), 370 | 371 | hl = theme.component, 372 | } 373 | 374 | M.file_format = { 375 | init = function(self) 376 | self.fileformat = vim.bo.fileformat 377 | if self.fileformat == "dos" then 378 | self.text = "CRLF" 379 | elseif self.fileformat == "unix" then 380 | self.text = "LF" 381 | else 382 | self.text = "CR" 383 | end 384 | end, 385 | 386 | condition = function(self) 387 | return self.fileformat ~= "dos" 388 | end, 389 | 390 | M.delim_left("slant_left_2", theme.surround), 391 | { 392 | provider = function(self) 393 | return self.text 394 | end, 395 | }, 396 | M.delim_right("slant_right", theme.surround), 397 | 398 | hl = theme.component, 399 | } 400 | 401 | M.file_encoding = { 402 | condition = function() 403 | return vim.bo.fileencoding ~= "utf-8" 404 | end, 405 | 406 | M.delim_left("slant_left_2", theme.surround), 407 | { provider = vim.bo.fileencoding:upper() }, 408 | M.delim_right("slant_right", theme.surround), 409 | 410 | hl = theme.component, 411 | } 412 | 413 | M.paste = { 414 | condition = function() 415 | return vim.o.paste 416 | end, 417 | 418 | M.delim_left("slant_left", theme.surround), 419 | { provider = helper.icons.paste }, 420 | M.delim_right("slant_right_2", theme.surround), 421 | 422 | hl = theme.component, 423 | } 424 | 425 | M.wrap = { 426 | condition = function() 427 | return vim.o.wrap 428 | end, 429 | 430 | M.delim_left("slant_left", theme.surround), 431 | { provider = helper.icons.wrap }, 432 | M.delim_right("slant_right_2", theme.surround), 433 | 434 | hl = theme.component, 435 | } 436 | 437 | M.mixed_indents = { 438 | condition = function() 439 | local space_indent = vim.fn.search([[\v^ +]], "nw") > 0 440 | local tab_indent = vim.fn.search([[\v^\t+]], "nw") > 0 441 | return (space_indent and tab_indent) or vim.fn.search([[\v^(\t+ | +\t)]], "nw") > 0 442 | end, 443 | 444 | M.delim_left("slant_left", theme.surround), 445 | { provider = helper.icons.mixed_indents }, 446 | M.delim_right("slant_right_2", theme.surround), 447 | 448 | hl = theme.component, 449 | } 450 | 451 | M.lsp_info = { 452 | condition = conditions.lsp_attached, 453 | 454 | init = function(self) 455 | self.clients = table.concat(helper.lsp_client_names(), ", ") 456 | self.short_clients = table.concat(helper.lsp_client_names(true), ", ") 457 | -- self.status = helper.lsp_status() 458 | end, 459 | 460 | { 461 | flexible = 3, 462 | { 463 | M.delim_left("slant_left", theme.surround), 464 | { 465 | provider = function(self) 466 | return self.status ~= "" and self.status or self.clients 467 | end, 468 | }, 469 | M.delim_right("slant_right_2", theme.surround), 470 | }, 471 | { 472 | M.delim_left("slant_left", theme.surround), 473 | { 474 | provider = function(self) 475 | return self.short_clients 476 | end, 477 | }, 478 | M.delim_right("slant_right_2", theme.surround), 479 | }, 480 | M.null, 481 | }, 482 | 483 | hl = theme.component, 484 | } 485 | 486 | M.line_info = { 487 | init = function(self) 488 | self.line = vim.fn.line(".") 489 | self.column = vim.fn.col(".") 490 | end, 491 | 492 | M.delim_left("slant_left", theme.surround), 493 | { 494 | flexible = 4, 495 | { 496 | provider = function(self) 497 | return string.format("Ln %d, Col %d", self.line, self.column) 498 | end, 499 | }, 500 | { 501 | provider = function(self) 502 | return string.format("%d : %d", self.line, self.column) 503 | end, 504 | }, 505 | }, 506 | M.delim_right("slant_right_2", theme.surround), 507 | 508 | hl = theme.component, 509 | } 510 | 511 | M.total_lines = { 512 | init = function(self) 513 | self.lines = vim.fn.line("$") 514 | end, 515 | 516 | provider = function(self) 517 | return string.format(" %d %s ", self.lines, helper.icons.total_lines) 518 | end, 519 | 520 | hl = function() 521 | return { 522 | fg = helper.mode_colors[mode():sub(1, 1)], 523 | bg = theme.bg1, 524 | bold = true, 525 | } 526 | end, 527 | } 528 | 529 | M.total_lines = utils.surround({ helper.icons.powerline.slant_left, "" }, function() 530 | return theme.bg1 531 | end, M.total_lines) 532 | 533 | M.terminal_name = {} 534 | 535 | M.terminal_name = utils.insert( 536 | M.terminal_name, 537 | M.space, 538 | { provider = helper.icons.terminal, hl = { fg = colors.blue, bold = true } }, 539 | M.space, 540 | { 541 | provider = function() 542 | local tname, _ = vim.api.nvim_buf_get_name(0):gsub(".*:", "") 543 | return tname 544 | end, 545 | 546 | hl = function() 547 | return { bg = theme.bg1, fg = helper.mode_colors[vim.api.nvim_get_mode().mode:sub(1, 1)], bold = true } 548 | end, 549 | }, 550 | M.space 551 | ) 552 | 553 | M.terminal_name = utils.surround({ helper.icons.powerline.slant_left, "" }, function() 554 | return theme.bg1 555 | end, M.terminal_name) 556 | 557 | M.winbar = { 558 | fallthrough = false, 559 | { 560 | condition = function() 561 | return conditions.buffer_matches({ 562 | buftype = { "terminal", "nofile", "prompt", "help", "quickfix" }, 563 | filetype = { "^git.*", "fugitive" }, 564 | }) 565 | end, 566 | init = function() 567 | vim.opt_local.winbar = nil 568 | end, 569 | }, 570 | { 571 | init = function(self) 572 | self.file_path = vim.api.nvim_buf_get_name(0):gsub("^%l", string.upper) 573 | self.is_git_repo = conditions.is_git_repo() 574 | end, 575 | 576 | provider = function(self) 577 | return self.is_git_repo 578 | and string.rep(" ", 4) .. helper.replace_pathsep( 579 | helper.icons.git_branch 580 | .. "\\" 581 | .. self.file_path:gsub(vim.b.gitsigns_status_dict.root:gsub("/", "\\") .. "\\", "") 582 | ) 583 | or string.rep(" ", 4) .. helper.replace_pathsep(self.file_path) 584 | end, 585 | }, 586 | hl = theme.winbar, 587 | } 588 | 589 | return M 590 | -------------------------------------------------------------------------------- /lua/user/plugins/config/heirline/init.lua: -------------------------------------------------------------------------------- 1 | local c = require("user.plugins.config.heirline.components") 2 | local conditions = require("heirline.conditions") 3 | 4 | local normal_statusline = { 5 | c.vim_mode, 6 | c.git_info, 7 | c.file_block, 8 | c.search_results, 9 | c.visual_multi, 10 | c.spellcheck, 11 | c.file_format, 12 | c.file_encoding, 13 | c.align, 14 | c.mixed_indents, 15 | c.wrap, 16 | c.paste, 17 | c.lsp_info, 18 | c.line_info, 19 | c.total_lines, 20 | } 21 | 22 | local terminal_statusline = { 23 | condition = function() 24 | return conditions.buffer_matches({ buftype = { "terminal" } }) 25 | end, 26 | 27 | { 28 | c.vim_mode, 29 | c.align, 30 | c.terminal_name, 31 | }, 32 | } 33 | 34 | local statusline = { 35 | fallthrough = false, 36 | terminal_statusline, 37 | normal_statusline, 38 | } 39 | 40 | local winbar = { 41 | c.winbar, 42 | } 43 | 44 | require("heirline").setup({ statusline = statusline, winbar = winbar }) 45 | -------------------------------------------------------------------------------- /lua/user/plugins/config/heirline/theme.lua: -------------------------------------------------------------------------------- 1 | local present, themer_api = pcall(require, "themer.modules.core.api") 2 | if not present then 3 | return 4 | end 5 | 6 | -- Themer colors 7 | local themer = require("user.plugins.config.themer") 8 | local colors = themer.colors 9 | local utils = themer.utils 10 | 11 | local M = {} 12 | 13 | M.vim = utils.adjust_color(colors.green, -30) 14 | M.fg1 = colors.fg_darker 15 | M.bg1 = colors.bg.lighter 16 | 17 | -- Component color 18 | M.component = { fg = M.fg1, bg = M.bg1, bold = true } 19 | 20 | -- Surround color 21 | M.surround = { fg = M.bg1, bg = colors.bg.base, bold = true } 22 | 23 | -- Winbar Color 24 | M.winbar = { fg = M.fg1, bg = M.bg1 } 25 | 26 | return M 27 | -------------------------------------------------------------------------------- /lua/user/plugins/config/heirline/utils.lua: -------------------------------------------------------------------------------- 1 | local present, themer_api = pcall(require, "themer.modules.core.api") 2 | if not present then 3 | return 4 | end 5 | 6 | local colors = themer_api.get_cp(SCHEME) 7 | 8 | local M = {} 9 | 10 | M.icons = { 11 | powerline = { 12 | --  13 | vertical_bar_thin = "│", 14 | vertical_bar = "┃", 15 | block = "█", 16 | ---------------------------------------------- 17 | left = "", 18 | left_filled = "", 19 | right = "", 20 | right_filled = "", 21 | ---------------------------------------------- 22 | slant_left = "", 23 | slant_left_thin = "", 24 | slant_right = "", 25 | slant_right_thin = "", 26 | ---------------------------------------------- 27 | slant_left_2 = "", 28 | slant_left_2_thin = "", 29 | slant_right_2 = "", 30 | slant_right_2_thin = "", 31 | ---------------------------------------------- 32 | left_rounded = "", 33 | left_rounded_thin = "", 34 | right_rounded = "", 35 | right_rounded_thin = "", 36 | ---------------------------------------------- 37 | trapezoid_left = "", 38 | trapezoid_right = "", 39 | ---------------------------------------------- 40 | line_number = "", 41 | column_number = "", 42 | }, 43 | vim = "", 44 | padlock = "", 45 | git_branch = "", 46 | paste = "", 47 | wrap = "﬋", 48 | mixed_indents = "", 49 | terminal = "", 50 | circle = "", 51 | circle_plus = "", 52 | dot_circle_o = "", 53 | circle_o = "⭘", 54 | search = "", 55 | total_lines = "", 56 | path_sep = "", 57 | } 58 | 59 | M.mode_names = { 60 | ["n"] = "NORMAL", 61 | ["no"] = "O-PENDING", 62 | ["nov"] = "O-PENDING", 63 | ["noV"] = "O-PENDING", 64 | ["no\22"] = "O-PENDING", 65 | ["niI"] = "NORMAL", 66 | ["niR"] = "NORMAL", 67 | ["niV"] = "NORMAL", 68 | ["nt"] = "NORMAL", 69 | ["v"] = "VISUAL", 70 | ["vs"] = "VISUAL", 71 | ["V"] = "V-LINE", 72 | ["Vs"] = "V-LINE", 73 | ["\22"] = "V-BLOCK", 74 | ["\22s"] = "V-BLOCK", 75 | ["s"] = "SELECT", 76 | ["S"] = "S-LINE", 77 | ["\19"] = "S-BLOCK", 78 | ["i"] = "INSERT", 79 | ["ic"] = "INSERT", 80 | ["ix"] = "INSERT", 81 | ["R"] = "REPLACE", 82 | ["Rc"] = "REPLACE", 83 | ["Rx"] = "REPLACE", 84 | ["Rv"] = "V-REPLACE", 85 | ["Rvc"] = "V-REPLACE", 86 | ["Rvx"] = "V-REPLACE", 87 | ["c"] = "COMMAND", 88 | ["cv"] = "EX", 89 | ["ce"] = "EX", 90 | ["r"] = "REPLACE", 91 | ["rm"] = "MORE", 92 | ["r?"] = "CONFIRM", 93 | ["!"] = "SHELL", 94 | ["t"] = "TERMINAL", 95 | ["V-M"] = "V-MULTI", 96 | } 97 | 98 | M.mode_colors = { 99 | n = colors.blue, 100 | i = colors.green, 101 | v = colors.orange, 102 | V = colors.orange, 103 | ["\22"] = colors.orange, 104 | c = colors.yellow, 105 | s = colors.purple, 106 | S = colors.purple, 107 | ["\19"] = colors.purple, 108 | R = colors.red, 109 | r = colors.red, 110 | ["!"] = colors.cyan, 111 | t = colors.cyan, 112 | } 113 | 114 | M.buffer_is_plugin = function() 115 | local file_name = vim.fn.expand("%:t") 116 | for _, v in pairs(PLUGINS) do 117 | if file_name == v or vim.bo.filetype == v then 118 | return true 119 | end 120 | end 121 | end 122 | 123 | M.lsp_client_names = function(shorten) 124 | local get_sources = function() 125 | local _, null_ls = pcall(require, "null-ls.sources") 126 | local sources = null_ls.get_available(vim.bo.filetype) 127 | local names = {} 128 | 129 | for _, source in pairs(sources) do 130 | table.insert(names, source.name) 131 | end 132 | 133 | return names 134 | end 135 | 136 | -- Get all active clients in the buffer 137 | local clients = vim.lsp.get_clients() 138 | local client_names = {} 139 | 140 | if not shorten then 141 | for _, client in pairs(clients) do 142 | if client.name ~= "null-ls" then 143 | table.insert(client_names, client.name) 144 | else 145 | vim.list_extend(client_names, get_sources()) 146 | end 147 | end 148 | else 149 | for _, client in pairs(clients) do 150 | table.insert(client_names, client.name) 151 | end 152 | end 153 | 154 | return client_names 155 | end 156 | 157 | M.lsp_status = function() 158 | local get_lsp_status = function(client_names) 159 | local progress = vim.lsp.status() 160 | -- Get lsp status for current buffer 161 | for _, v in ipairs(progress) do 162 | if vim.tbl_contains(client_names, v.name) or v.name == "null-ls" then 163 | return v 164 | end 165 | end 166 | end 167 | 168 | local client_names = M.lsp_client_names() 169 | local lsp_status = get_lsp_status(client_names) 170 | 171 | -- Show client status 172 | if lsp_status and lsp_status.message then 173 | return lsp_status.title:gsub("^%l", string.upper) 174 | .. " [" 175 | .. (lsp_status.percentage and (lsp_status.percentage .. "%%") or lsp_status.message:gsub( 176 | "^%l", 177 | string.upper 178 | )) 179 | .. "]" 180 | end 181 | end 182 | 183 | M.replace_pathsep = function(path) 184 | return path:gsub("/", "\\"):gsub("\\", (" %s "):format(M.icons.path_sep)) 185 | end 186 | 187 | return M 188 | -------------------------------------------------------------------------------- /lua/user/plugins/config/indentline.lua: -------------------------------------------------------------------------------- 1 | local filetypes = { 2 | "", 3 | "checkhealth", 4 | "help", 5 | "lspinfo", 6 | "packer", 7 | "TelescopePrompt", 8 | "TelescopeResults", 9 | "yaml", 10 | } 11 | filetypes = vim.list_extend(filetypes, PLUGINS) 12 | 13 | require("ibl").setup({ 14 | indent = { 15 | char = "│", 16 | }, 17 | scope = { 18 | show_start = false, 19 | show_end = false, 20 | show_exact_scope = true, 21 | }, 22 | exclude = { 23 | filetypes = filetypes, 24 | buftypes = { "terminal", "quickfix" }, 25 | }, 26 | }) 27 | -------------------------------------------------------------------------------- /lua/user/plugins/config/jaq.lua: -------------------------------------------------------------------------------- 1 | require("jaq-nvim").setup({ 2 | cmds = { 3 | -- Uses vim commands 4 | internal = { 5 | lua = 'luafile "$filePath"', 6 | vim = 'source "$filePath"', 7 | }, 8 | 9 | -- Uses shell commands 10 | external = { 11 | python = 'py -u "$filePath"', 12 | cs = "dotnet run", 13 | }, 14 | }, 15 | behavior = { 16 | -- Default type 17 | default = "float", 18 | -- Start in insert mode 19 | startinsert = false, 20 | -- Use `wincmd p` on startup 21 | wincmd = false, 22 | -- Auto-save files 23 | autosave = false, 24 | }, 25 | ui = { 26 | float = { 27 | -- See ':h nvim_open_win' 28 | border = "single", 29 | -- See ':h winhl' 30 | winhl = "Normal", 31 | borderhl = "FloatBorder", 32 | -- See ':h winblend' 33 | winblend = 0, 34 | 35 | -- Num from `0-1` for measurements 36 | height = 0.8, 37 | width = 0.8, 38 | x = 0.5, 39 | y = 0.5, 40 | }, 41 | 42 | terminal = { 43 | -- Window position 44 | position = "bot", 45 | -- Window size 46 | size = 15, 47 | -- Disable line numbers 48 | line_no = true, 49 | }, 50 | 51 | quickfix = { 52 | -- Window position 53 | position = "bot", 54 | -- Window size 55 | size = 10, 56 | }, 57 | }, 58 | }) 59 | -------------------------------------------------------------------------------- /lua/user/plugins/config/lspconfig/init.lua: -------------------------------------------------------------------------------- 1 | -- Default diagnostic settings 2 | vim.diagnostic.config({ 3 | virtual_text = { 4 | source = "if_many", 5 | prefix = " ", 6 | }, 7 | signs = true, 8 | underline = true, 9 | update_in_insert = false, 10 | severity_sort = false, 11 | }) 12 | 13 | -- Set completion icons 14 | vim.fn.sign_define("DiagnosticsSignError", { text = ICON_ERROR }) 15 | vim.fn.sign_define("DiagnosticsSignWarning", { text = ICON_WARN }) 16 | vim.fn.sign_define("DiagnosticsSignInformation", { text = ICON_INFO }) 17 | vim.fn.sign_define("DiagnosticsSignHint", { text = ICON_HINT }) 18 | 19 | -- Set square borders 20 | vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }) 21 | vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }) 22 | 23 | local present, lspconfig = pcall(require, "lspconfig") 24 | if not present then 25 | return 26 | end 27 | 28 | -- Server configs 29 | local servers = require("user.plugins.config.lspconfig.servers") 30 | 31 | -- Setup language servers 32 | for _, lsp in ipairs(SERVERS) do 33 | local config = servers.specific_configs[lsp] or {} 34 | config = vim.tbl_extend("keep", config, servers.default_config) 35 | lspconfig[lsp].setup(config) 36 | end 37 | -------------------------------------------------------------------------------- /lua/user/plugins/config/lspconfig/servers.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local _, lspconfig_util = pcall(require, "lspconfig.util") 4 | local utils = require("user.plugins.config.lspconfig.utils") 5 | 6 | -- Setup language servers 7 | -- https://www.reddit.com/r/neovim/comments/r6gouy/migrating_from_nvim_051_to_nvim_060/hmvzsps/?context=3 8 | 9 | -- Omnisharp vars 10 | local omnisharp_dll = [[C:\tools\omnisharp\OmniSharp.dll]] 11 | 12 | -- Specific server config 13 | M.specific_configs = { 14 | lua_ls = { 15 | settings = { 16 | Lua = { 17 | runtime = { 18 | version = "LuaJIT", 19 | }, 20 | diagnostics = { 21 | globals = { "vim" }, 22 | }, 23 | workspace = { 24 | library = vim.api.nvim_get_runtime_file("", true), 25 | maxPreload = 10000, 26 | preloadFileSize = 10000, 27 | checkThirdParty = false, 28 | }, 29 | telemetry = { 30 | enable = false, 31 | }, 32 | }, 33 | }, 34 | root_pattern = lspconfig_util.root_pattern(".git", ".luarc.json", ".luacheckrc", ".stylua.toml", "selene.toml"), 35 | root_dir = function(fname) 36 | return lspconfig_util.root_pattern(".git", ".luarc.json", ".luacheckrc", ".stylua.toml", "selene.toml")( 37 | fname 38 | ) or lspconfig_util.path.dirname(fname) 39 | end, 40 | }, 41 | omnisharp = { 42 | cmd = { "dotnet", omnisharp_dll }, 43 | }, 44 | html = { 45 | cmd = { "vscode-html-language-server.cmd", "--stdio" }, 46 | -- Disable builtin formatter 47 | init_options = { 48 | provideFormatter = false, 49 | }, 50 | }, 51 | cssls = { 52 | cmd = { "vscode-css-language-server.cmd", "--stdio" }, 53 | }, 54 | eslint = { 55 | cmd = { "vscode-eslint-language-server.cmd", "--stdio" }, 56 | root_dir = lspconfig_util.root_pattern( 57 | ".eslintrc", 58 | ".eslintrc.js", 59 | ".eslintrc.cjs", 60 | ".eslintrc.yaml", 61 | ".eslintrc.yml", 62 | ".eslintrc.json", 63 | "package.json", 64 | ".git" 65 | ), 66 | settings = { format = false }, 67 | }, 68 | emmet_ls = { 69 | filetypes = { "html" }, 70 | }, 71 | } 72 | 73 | -- Common config for all servers 74 | M.default_config = { 75 | on_attach = utils.on_attach, 76 | capabilities = utils.capabilities, 77 | flags = { 78 | debounce_text_changes = 500, 79 | }, 80 | } 81 | 82 | return M 83 | -------------------------------------------------------------------------------- /lua/user/plugins/config/lspconfig/utils.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | -- Snippet, autocompletion support 4 | M.capabilities = vim.lsp.protocol.make_client_capabilities() 5 | M.capabilities.textDocument.completion.completionItem = { 6 | documentationFormat = { "markdown", "plaintext" }, 7 | snippetSupport = true, 8 | resolveSupport = { 9 | properties = { 10 | "documentation", 11 | "detail", 12 | "additionalTextEdits", 13 | }, 14 | }, 15 | } 16 | M.capabilities = require("cmp_nvim_lsp").default_capabilities(M.capabilities) 17 | 18 | -- Use the following when ls attches to a buffer 19 | M.on_attach = function(client, bufnr) 20 | -- Mappings 21 | local opts = { buffer = bufnr, silent = true } 22 | vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) 23 | vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) 24 | vim.keymap.set("n", "gl", function() 25 | local float_opts = { 26 | focusable = false, 27 | close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, 28 | border = "single", 29 | source = "if_many", 30 | prefix = "", 31 | } 32 | vim.diagnostic.open_float(nil, float_opts) 33 | end, opts) 34 | vim.keymap.set("n", "ga", vim.lsp.buf.code_action, opts) 35 | vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 36 | vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) 37 | vim.keymap.set("n", "gh", vim.lsp.buf.hover, opts) 38 | vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) 39 | vim.keymap.set("n", "gr", vim.lsp.buf.rename, opts) 40 | vim.keymap.set("n", "gR", vim.lsp.buf.references, opts) 41 | vim.keymap.set("n", "gs", vim.lsp.buf.signature_help, opts) 42 | 43 | -- Format on save if formatting is available 44 | if 45 | client.server_capabilities.documentFormattingProvider 46 | or client.server_capabilities.documentRangeFormattingProvider 47 | then 48 | local group = vim.api.nvim_create_augroup("lsp_format_onsave", { clear = false }) 49 | vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group }) 50 | vim.api.nvim_create_autocmd("BufWritePre", { 51 | buffer = bufnr, 52 | callback = function() 53 | vim.lsp.buf.format({ timeout_ms = 2000 }) 54 | end, 55 | desc = "Format using lsp/null-ls on save.", 56 | group = group, 57 | }) 58 | end 59 | end 60 | 61 | return M 62 | -------------------------------------------------------------------------------- /lua/user/plugins/config/neoformat.lua: -------------------------------------------------------------------------------- 1 | vim.g.neoformat_lua_stylua = { 2 | exe = "stylua", 3 | args = { "--stdin-filepath", '"%:p"', "--config-path", '"C:\\Users\\Neel\\.stylua.toml"', "--", "-" }, 4 | stdin = 1, 5 | } 6 | vim.g.neoformat_tex_latexindent = { 7 | exe = "latexindent", 8 | args = { "-g /dev/stderr", "2>/dev/null", "-d" }, 9 | stdin = 1, 10 | } 11 | 12 | vim.g.neoformat_run_all_formatters = 1 13 | vim.g.neoformat_enabled_python = { "isort", "black" } 14 | vim.g.neoformat_enabled_lua = { "stylua" } 15 | vim.g.neoformat_enabled_tex = { "latexindent" } 16 | -------------------------------------------------------------------------------- /lua/user/plugins/config/neotree.lua: -------------------------------------------------------------------------------- 1 | require("neo-tree").setup({ 2 | popup_border_style = "single", 3 | enable_git_status = true, 4 | enable_diagnostics = false, 5 | event_handlers = { 6 | { 7 | event = "vim_buffer_enter", 8 | handler = function() 9 | if vim.bo.filetype == "neo-tree" then 10 | vim.cmd([[setlocal signcolumn=no]]) 11 | end 12 | end, 13 | }, 14 | { 15 | event = "file_opened", 16 | handler = function() 17 | require("neo-tree").close_all() 18 | end, 19 | }, 20 | { 21 | event = "file_opened", 22 | handler = function(args) 23 | if args.state then 24 | require("neo-tree.sources.filesystem").reset_search() 25 | end 26 | end, 27 | }, 28 | { 29 | event = "file_renamed", 30 | handler = function(args) 31 | vim_notify(("'%s' renamed to '%s'"):format(args.source, args.destination), vim.log.levels.INFO) 32 | end, 33 | }, 34 | { 35 | event = "file_moved", 36 | handler = function(args) 37 | vim_notify(("'%s' moved to '%s'"):format(args.source, args.destination), vim.log.levels.INFO) 38 | end, 39 | }, 40 | { 41 | event = "file_deleted", 42 | handler = function(args) 43 | vim_notify(("'%s' deleted"):format(args), vim.log.levels.WARN) 44 | end, 45 | }, 46 | { 47 | event = "file_added", 48 | handler = function(args) 49 | vim_notify(("'%s' created"):format(args), vim.log.levels.INFO) 50 | end, 51 | }, 52 | }, 53 | sort_function = function(a, b) 54 | a.ft = a.path:gsub(".+%.", "") 55 | b.ft = b.path:gsub(".+%.", "") 56 | 57 | -- Show subdirectories before files 58 | if a.type ~= b.type then 59 | return a.type ~= "file" 60 | end 61 | 62 | -- Sort by filetype, then name 63 | if a.ft ~= b.ft then 64 | return a.ft < b.ft 65 | elseif a.type == b.type then 66 | return a.path < b.path 67 | else 68 | return a.type < b.type 69 | end 70 | end, 71 | default_component_configs = { 72 | indent = { 73 | indent_size = 2, 74 | padding = 1, 75 | with_markers = true, 76 | indent_marker = "│", 77 | last_indent_marker = "└", 78 | highlight = "IblIndent", 79 | }, 80 | icon = { 81 | folder_closed = "", 82 | folder_open = "", 83 | folder_empty = "ﰊ", 84 | default_icon = "*", 85 | }, 86 | name = { 87 | trailing_slash = false, 88 | use_git_status_colors = false, 89 | }, 90 | git_status = { 91 | symbols = { 92 | -- Change type 93 | added = "", 94 | deleted = "", 95 | modified = "", 96 | renamed = "", 97 | -- Status type 98 | untracked = "", 99 | ignored = " ", 100 | unstaged = " ", 101 | staged = " ", 102 | conflict = " ", 103 | }, 104 | }, 105 | }, 106 | filesystem = { 107 | filtered_items = { 108 | visible = false, 109 | hide_dotfiles = true, 110 | hide_gitignored = true, 111 | hide_by_name = {}, 112 | never_show = {}, 113 | }, 114 | follow_current_file = { 115 | enabled = true, 116 | leave_dirs_open = true, 117 | }, 118 | use_libuv_file_watcher = false, 119 | bind_to_cwd = true, 120 | window = { 121 | position = "left", 122 | width = 30, 123 | mappings = { 124 | ["<2-LeftMouse>"] = "open", 125 | [""] = "open", 126 | ["S"] = "open_split", 127 | ["s"] = "open_vsplit", 128 | ["C"] = "close_node", 129 | [""] = "navigate_up", 130 | ["."] = "set_root", 131 | ["H"] = "toggle_hidden", 132 | ["I"] = "toggle_gitignore", 133 | ["R"] = "refresh", 134 | ["/"] = "filter_as_you_type", 135 | ["f"] = "filter_on_submit", 136 | [""] = "clear_filter", 137 | ["a"] = "add", 138 | ["A"] = "add_directory", 139 | ["d"] = "delete", 140 | ["r"] = "rename", 141 | ["c"] = "copy_to_clipboard", 142 | ["x"] = "cut_to_clipboard", 143 | ["p"] = "paste_from_clipboard", 144 | ["q"] = "close_window", 145 | [""] = "close_window", 146 | ["y"] = function(state) 147 | local node = state.tree:get_node() 148 | vim_notify(("Name '%s' copied to clipboard"):format(node.name), vim.log.levels.INFO) 149 | vim.cmd(("let @+ = '%s'"):format(node.name)) 150 | end, 151 | ["Y"] = function(state) 152 | local node = state.tree:get_node() 153 | vim_notify(("Path '%s' copied to clipboard"):format(node.path), vim.log.levels.INFO) 154 | vim.cmd(("let @+ = '%s'"):format(node.path)) 155 | end, 156 | }, 157 | }, 158 | }, 159 | }) 160 | -------------------------------------------------------------------------------- /lua/user/plugins/config/null_ls/init.lua: -------------------------------------------------------------------------------- 1 | local null_present, null_ls = pcall(require, "null-ls") 2 | if not null_present then 3 | return 4 | end 5 | 6 | local utils = require("user.plugins.config.lspconfig.utils") 7 | local null_ls_sources = require("user.plugins.config.null_ls.sources") 8 | 9 | local sources = { 10 | -- Formatters 11 | null_ls.builtins.formatting.prettierd, 12 | null_ls.builtins.formatting.stylua.with({ 13 | extra_args = { 14 | "--config-path", 15 | vim.fn.expand("~/.stylua.toml"), 16 | }, 17 | }), 18 | null_ls_sources.latexindent, 19 | -- Diagnostics 20 | null_ls_sources.chktex, 21 | } 22 | 23 | null_ls.setup({ 24 | debounce = 500, 25 | default_timeout = 10000, 26 | diagnostics_format = "#{m} (#{s})", 27 | sources = sources, 28 | on_attach = utils.on_attach, 29 | }) 30 | -------------------------------------------------------------------------------- /lua/user/plugins/config/null_ls/sources.lua: -------------------------------------------------------------------------------- 1 | local helper = require("null-ls.helpers") 2 | local methods = require("null-ls.methods") 3 | 4 | local FORMATTING = methods.internal.FORMATTING 5 | local RANGE_FORMATTING = methods.internal.RANGE_FORMATTING 6 | local DIAGNOSTICS = methods.internal.DIAGNOSTICS 7 | 8 | local M = {} 9 | 10 | M.latexindent = helper.make_builtin({ 11 | name = "latexindent", 12 | method = FORMATTING, 13 | filetypes = { "tex" }, 14 | generator_opts = { 15 | command = "latexindent.exe", 16 | to_stdin = true, 17 | args = { "-r" }, 18 | }, 19 | factory = helper.formatter_factory, 20 | }) 21 | 22 | M.black = helper.make_builtin({ 23 | name = "black", 24 | method = FORMATTING, 25 | filetypes = { "python" }, 26 | generator_opts = { 27 | command = "black", 28 | args = { 29 | "--quiet", 30 | "-", 31 | }, 32 | to_stdin = true, 33 | }, 34 | factory = helper.formatter_factory, 35 | }) 36 | 37 | M.chktex = helper.make_builtin({ 38 | name = "chktex", 39 | method = DIAGNOSTICS, 40 | filetypes = { "tex" }, 41 | generator_opts = { 42 | command = "chktex", 43 | to_stdin = true, 44 | from_stderr = true, 45 | args = { 46 | -- Only current file 47 | "-I", 48 | -- Disable printing version information to stderr 49 | "-q", 50 | -- Format output 51 | "-f%l:%c:%d:%k:%n:%m\n", 52 | }, 53 | format = "line", 54 | check_exit_code = function(code) 55 | return code <= 1 56 | end, 57 | on_output = helper.diagnostics.from_pattern( 58 | [[(%d+):(%d+):(%d+):(%w+):(%d+):(.+)]], 59 | { "row", "col", "_length", "severity", "code", "message" }, 60 | { 61 | adapters = { 62 | helper.diagnostics.adapters.end_col.from_length, 63 | }, 64 | severities = { 65 | Error = helper.diagnostics.severities["error"], 66 | Warning = helper.diagnostics.severities["warning"], 67 | }, 68 | } 69 | ), 70 | }, 71 | factory = helper.generator_factory, 72 | }) 73 | 74 | return M 75 | -------------------------------------------------------------------------------- /lua/user/plugins/config/others.lua: -------------------------------------------------------------------------------- 1 | local augroup = vim.api.nvim_create_augroup 2 | local autocmd = vim.api.nvim_create_autocmd 3 | local map = vim.keymap.set 4 | local e_opts = { expr = true } 5 | local s_opts = { silent = true } 6 | local se_opts = { silent = true, expr = true } 7 | 8 | -- Contains configs for plugins 9 | local M = {} 10 | 11 | M.autopairs = function() 12 | vim.g.AutoPairsShortcutToggle = "" 13 | map("i", "", "call AutoPairsJump()a", s_opts) 14 | local group = augroup("custom_autopairs", { clear = true }) 15 | autocmd("Filetype", { 16 | command = [[let b:AutoPairs = AutoPairsDefine({'<' : '>'})]], 17 | desc = "Add angle brackets as an autopair.", 18 | group = group, 19 | pattern = { "lua", "vim", "md", "html", "xml" }, 20 | }) 21 | autocmd("Filetype", { 22 | command = [[let b:AutoPairs = {'(':')', '[':']', '{':'}', "'":"'", '"':'"', "`":"'", '``':"''"}]], 23 | desc = "Add latex quotes as autopairs.", 24 | group = group, 25 | pattern = "tex", 26 | }) 27 | end 28 | 29 | M.gutentags = function() 30 | vim.g.gutentags_generate_on_new = 1 31 | vim.g.gutentags_generate_on_write = 1 32 | vim.g.gutentags_generate_on_missing = 1 33 | vim.g.gutentags_generate_on_empty_buffer = 0 34 | end 35 | 36 | M.ultisnips = function() 37 | -- Disable snipmate plugins to avoid duplicate snippets 38 | vim.g.UltiSnipsEnableSnipMate = 0 39 | vim.g.UltiSnipsRemoveSelectModeMappings = 0 40 | vim.g.UltiSnipsExpandTrigger = "" 41 | vim.g.UltiSnipsJumpForwardTrigger = "" 42 | vim.g.UltiSnipsJumpBackwardTrigger = "" 43 | end 44 | 45 | M.nvim_comment = function() 46 | require("nvim_comment").setup({ comment_empty = false }) 47 | map("i", "", "CommentToggleA", s_opts) 48 | map("n", "", "CommentToggle", s_opts) 49 | map("v", "", ":call CommentOperator(visualmode())", s_opts) 50 | end 51 | 52 | M.fastfold = function() 53 | vim.g.fastfold_savehook = 0 54 | vim.g.fastfold_fold_command_suffixes = { "x", "X" } 55 | vim.g.fastfold_fold_movement_commands = { "]z", "[z", "zj", "zk" } 56 | end 57 | 58 | M.lsp_signature = function() 59 | require("lsp_signature").setup({ 60 | bind = true, 61 | hint_enable = false, 62 | handler_opts = { 63 | border = "single", 64 | }, 65 | close_timeout = 1000, 66 | zindex = 10, 67 | extra_trigger_chars = { "(", "," }, 68 | }) 69 | end 70 | 71 | M.hop = function() 72 | require("hop").setup({ jump_on_sole_occurrence = true }) 73 | map("n", "S", "HopChar2", s_opts) 74 | map("n", "f", "HopChar1", s_opts) 75 | map("o", "f", function() 76 | require("hop").hint_char1({ 77 | direction = require("hop.hint").HintDirection.AFTER_CURSOR, 78 | current_line_only = true, 79 | }) 80 | end) 81 | end 82 | 83 | M.session = function() 84 | local path = require("plenary.path") 85 | require("session_manager").setup({ 86 | sessions_dir = path:new(vim.fn.stdpath("data"), "sessions"), 87 | path_replacer = "__", 88 | colon_replacer = "++", 89 | autoload_mode = require("session_manager.config").AutoloadMode.Disabled, 90 | autosave_last_session = false, 91 | autosave_ignore_not_normal = true, 92 | autosave_only_in_session = true, 93 | }) 94 | map("n", "ss", "SessionManager save_current_session", s_opts) 95 | map("n", "ls", "SessionManager load_session", s_opts) 96 | end 97 | 98 | M.markdown_preview = function() 99 | -- https://github.com/wbthomason/packer.nvim/issues/620 100 | vim.cmd("doautocmd mkdp_init BufEnter") 101 | vim.g.mkdp_auto_close = 0 102 | vim.g.mkdp_page_title = "${name}" 103 | end 104 | 105 | M.neogen = function() 106 | require("neogen").setup({ enabled = true }) 107 | end 108 | 109 | M.refactoring = function() 110 | vim.api.nvim_create_user_command("ExtractFunction", function() 111 | require("refactoring").refactor("Extract Function") 112 | end, { 113 | force = true, 114 | range = true, 115 | }) 116 | vim.api.nvim_create_user_command("ExtractVariable", function() 117 | require("refactoring").refactor("Extract Variable") 118 | end, { 119 | force = true, 120 | range = true, 121 | }) 122 | vim.api.nvim_create_user_command("ExtractFunctionToFile", function() 123 | require("refactoring").refactor("Extract Function To File") 124 | end, { 125 | force = true, 126 | range = true, 127 | }) 128 | end 129 | 130 | return M 131 | -------------------------------------------------------------------------------- /lua/user/plugins/config/pretty_fold.lua: -------------------------------------------------------------------------------- 1 | require("pretty-fold").setup({ 2 | fill_char = " ", 3 | sections = { 4 | left = { 5 | "content", 6 | }, 7 | right = { 8 | " ", 9 | "number_of_folded_lines", 10 | " ", 11 | function(config) 12 | return config.fill_char:rep(3) 13 | end, 14 | }, 15 | }, 16 | 17 | remove_fold_markers = true, 18 | 19 | -- Keep the indentation of the content of the fold string. 20 | keep_indentation = true, 21 | 22 | -- Possible values: 23 | -- "delete" : Delete all comment signs from the fold string. 24 | -- "spaces" : Replace all comment signs with equal number of spaces. 25 | -- false : Do nothing with comment signs. 26 | process_comment_signs = "spaces", 27 | 28 | -- List of patterns that will be removed from content foldtext section. 29 | stop_words = { 30 | "@brief%s*", -- (for cpp) Remove '@brief' and all spaces after. 31 | }, 32 | 33 | add_close_pattern = true, 34 | 35 | matchup_patterns = { 36 | { "{", "}" }, 37 | { "%(", ")" }, -- % to escape lua pattern char 38 | { "%[", "]" }, -- % to escape lua pattern char 39 | { "if%s", "end" }, 40 | { "do%s", "end" }, 41 | { "for%s", "end" }, 42 | }, 43 | }) 44 | -------------------------------------------------------------------------------- /lua/user/plugins/config/telescope/init.lua: -------------------------------------------------------------------------------- 1 | local telescope = require("telescope") 2 | local actions = require("telescope.actions") 3 | local utils = require("user.plugins.config.telescope.utils") 4 | 5 | telescope.setup({ 6 | defaults = { 7 | vimgrep_arguments = { 8 | "rg", 9 | "--color=never", 10 | "--no-heading", 11 | "--with-filename", 12 | "--line-number", 13 | "--column", 14 | "--smart-case", 15 | }, 16 | layout_config = { 17 | horizontal = { 18 | prompt_position = "top", 19 | preview_width = 0.55, 20 | results_width = 0.8, 21 | }, 22 | vertical = { 23 | mirror = false, 24 | }, 25 | width = 0.87, 26 | height = 0.80, 27 | preview_cutoff = 120, 28 | }, 29 | borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, 30 | border = true, 31 | use_less = true, 32 | color_devicons = true, 33 | winblend = 0, 34 | entry_prefix = " ", 35 | prompt_prefix = "  ", 36 | selection_caret = "  ", 37 | initial_mode = "insert", 38 | scroll_strategy = "cycle", 39 | path_display = function(_, path) 40 | local smart_path = require("telescope.utils").path_smart(path) 41 | return (smart_path:find("%.\\") or 0) + (smart_path:find("%./") or 0) == 1 and string.sub(smart_path, 3) 42 | or smart_path 43 | end, 44 | selection_strategy = "reset", 45 | layout_strategy = "horizontal", 46 | sorting_strategy = "ascending", 47 | set_env = { COLORTERM = "truecolor" }, 48 | file_ignore_patterns = utils.ignore_patterns, 49 | file_sorter = require("telescope.sorters").get_fuzzy_file, 50 | file_previewer = require("telescope.previewers").vim_buffer_cat.new, 51 | generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, 52 | grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, 53 | qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, 54 | mappings = { 55 | i = { 56 | [""] = false, 57 | [""] = false, 58 | [""] = actions.move_selection_next, 59 | [""] = actions.move_selection_previous, 60 | [""] = actions.close, 61 | }, 62 | n = { 63 | [""] = false, 64 | [""] = false, 65 | [""] = actions.move_selection_next, 66 | [""] = actions.move_selection_previous, 67 | }, 68 | }, 69 | }, 70 | pickers = { 71 | find_files = utils.dropdown(), 72 | oldfiles = utils.dropdown({ prompt_title = "Recent Files" }), 73 | git_files = utils.dropdown(), 74 | }, 75 | extensions = { 76 | frecency = { 77 | show_scores = false, 78 | show_unindexed = false, 79 | ignore_patterns = { "*.git/*" }, 80 | }, 81 | fzf = { 82 | fuzzy = true, 83 | override_generic_sorter = true, 84 | override_file_sorter = true, 85 | case_mode = "ignore_case", 86 | }, 87 | }, 88 | }) 89 | 90 | -- Load extensions 91 | local extensions = { "ultisnips", "fzf", "frecency", "themes" } 92 | pcall(function() 93 | for _, ext in ipairs(extensions) do 94 | telescope.load_extension(ext) 95 | end 96 | end) 97 | local map = vim.keymap.set 98 | local opts = { silent = true } 99 | 100 | map("n", "tr", function() 101 | require("user.plugins.config.telescope.sources").frecency() 102 | end, opts) 103 | map("n", "tf", function() 104 | require("user.plugins.config.telescope.sources").git_or_find() 105 | end, opts) 106 | map("n", "tn", function() 107 | require("user.plugins.config.telescope.sources").dir_nvim() 108 | end, opts) 109 | map("n", "ts", function() 110 | require("user.plugins.config.telescope.sources").sessions() 111 | end, opts) 112 | map("n", "", function() 113 | require("user.plugins.config.telescope.sources").reload_modules() 114 | end, opts) 115 | map("n", "", function() 116 | require("user.plugins.config.telescope.sources").dir_plugins() 117 | end, opts) 118 | -------------------------------------------------------------------------------- /lua/user/plugins/config/telescope/sources.lua: -------------------------------------------------------------------------------- 1 | local utils = require("user.plugins.config.telescope.utils") 2 | local file_sorter = utils.file_sorter 3 | local dropdown = utils.dropdown 4 | 5 | -- Custom telescope pickers 6 | local M = {} 7 | 8 | -- List files in specified directories with pre-filtering 9 | M.dir_nvim = function() 10 | local opts = { 11 | cwd = CONFIG_PATH, 12 | prompt_title = "Neovim", 13 | no_ignore = true, 14 | } 15 | require("telescope.builtin").find_files(opts) 16 | end 17 | 18 | M.dir_plugins = function() 19 | local opts = { 20 | cwd = LAZY_PATH, 21 | file_ignore_patterns = vim.list_extend({ "test\\" }, utils.ignore_patterns), 22 | prompt_title = "Plugin Files", 23 | } 24 | require("telescope.builtin").find_files(opts) 25 | end 26 | 27 | -- Reload lua modules using Telescope 28 | -- taken and modified from: 29 | -- https://ustrajunior.com/posts/reloading-neovim-config-with-telescope/ 30 | M.reload_modules = function() 31 | local actions_state = require("telescope.actions.state") 32 | local cwd = CONFIG_PATH .. "\\lua\\" 33 | 34 | local opts = { 35 | cwd = cwd, 36 | prompt_title = "Reload Neovim Modules", 37 | -- Only show lua files 38 | sorter = file_sorter({ "%.lua$" }), 39 | attach_mappings = function(prompt_bufnr, map) 40 | -- Reload module 41 | local reload_module_map = function(should_close) 42 | local entry = actions_state.get_selected_entry() 43 | -- Append cwd to entry value (due to smart display mode) 44 | -- Remove leading ".\" 45 | local name = get_module_name(cwd .. entry.value:gsub("^%.\\", "")) 46 | 47 | if should_close then 48 | require("telescope.actions").close(prompt_bufnr) 49 | end 50 | 51 | -- Reload filename 52 | plenary_reload(name) 53 | -- Print filename 54 | vim_notify(("%s Reloaded."):format(name), vim.log.levels.INFO) 55 | end 56 | 57 | -- Map to reload module 58 | require("telescope.actions.set").select:replace(function() 59 | reload_module_map(true) 60 | end) 61 | -- Map to reload module 62 | map("i", "", function() 63 | reload_module_map() 64 | end) 65 | 66 | return true 67 | end, 68 | } 69 | 70 | require("telescope.builtin").find_files(opts) 71 | end 72 | 73 | -- Use dropdown theme with Frecency 74 | M.frecency = function() 75 | local frecency_opts = dropdown({ prompt_title = "Recent Files", path_display = { "absolute" } }) 76 | require("telescope").extensions.frecency.frecency(frecency_opts) 77 | end 78 | 79 | -- Fall back to find_files if not a git directory 80 | M.git_or_find = function() 81 | local opts = dropdown({ prompt_title = "Find Files" }) 82 | local ok = pcall(require("telescope.builtin").git_files, opts) 83 | if not ok then 84 | require("telescope.builtin").find_files(opts) 85 | end 86 | end 87 | 88 | return M 89 | -------------------------------------------------------------------------------- /lua/user/plugins/config/telescope/utils.lua: -------------------------------------------------------------------------------- 1 | -- Telescope utilities 2 | local M = {} 3 | 4 | M.ignore_patterns = { 5 | -- git 6 | ".git\\", 7 | -- tags 8 | "TAGS", 9 | "%.TAGS", 10 | "tags", 11 | "%.tags", 12 | "gtags%.files", 13 | "GTAGS", 14 | "GRTAGS", 15 | "GPATH", 16 | "GSYMS", 17 | "cscope%.files", 18 | "cscope%.out", 19 | "cscope%.in%.out", 20 | "cscope%.po%.out", 21 | -- python 22 | "__pycache__\\", 23 | ".*%.py[cod]", 24 | ".*$py%.class", 25 | "%.Python", 26 | "build\\", 27 | "develop-eggs\\", 28 | "dist\\", 29 | "downloads\\", 30 | "eggs\\", 31 | "%.eggs\\", 32 | "lib\\", 33 | "lib64\\", 34 | "parts\\", 35 | "sdist\\", 36 | "var\\", 37 | "wheels\\", 38 | "share\\python-wheels\\", 39 | ".*%.egg-info\\", 40 | "%.installed%.cfg", 41 | ".*%.egg", 42 | "MANIFEST", 43 | "%.env", 44 | "%.venv", 45 | "env\\", 46 | "venv\\", 47 | "ENV\\", 48 | "env%.bak\\", 49 | "venv%.bak\\", 50 | -- images 51 | "%.jpg", 52 | "%.jpeg", 53 | "%.jpe", 54 | "%.jif", 55 | "%.jfif", 56 | "%.jfi", 57 | "%.jp2", 58 | "%.j2k", 59 | "%.jpf", 60 | "%.jpx", 61 | "%.jpm", 62 | "%.mj2", 63 | "%.jxr", 64 | "%.hdp", 65 | "%.wdp", 66 | "%.gif", 67 | "%.raw", 68 | "%.webp", 69 | "%.png", 70 | "%.apng", 71 | "%.mng", 72 | "%.tiff", 73 | "%.tif", 74 | "%.svg", 75 | "%.svgz", 76 | "%.pdf", 77 | "%.xbm", 78 | "%.bmp", 79 | "%.dib", 80 | "%.ico", 81 | "%.3dm", 82 | "%.max", 83 | -- fonts 84 | "%.fnt", 85 | "%.fon", 86 | "%.otf", 87 | "%.ttf", 88 | "%.woff", 89 | "%.woff2", 90 | -- latex 91 | "%.fdb_latexmk", 92 | "%.synctex", 93 | "%.synctex%(busy%)", 94 | "%.synctex%.gz", 95 | "%.synctex%.gz%(busy%)", 96 | "%.pdfsync", 97 | } 98 | 99 | -- Custom dropdown theme 100 | M.dropdown = function(opts) 101 | opts = opts or {} 102 | 103 | local theme_opts = { 104 | theme = "dropdown", 105 | 106 | previewer = false, 107 | results_title = false, 108 | 109 | sorting_strategy = "ascending", 110 | layout_strategy = "center", 111 | 112 | layout_config = { 113 | width = function(_, max_columns, _) 114 | return math.min(max_columns - 10, 100) 115 | end, 116 | 117 | height = function(_, _, max_lines) 118 | return math.min(max_lines, 20) 119 | end, 120 | }, 121 | 122 | border = true, 123 | borderchars = { 124 | { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, 125 | prompt = { "─", "│", " ", "│", "┌", "┐", "│", "│" }, 126 | results = { "─", "│", "─", "│", "├", "┤", "┘", "└" }, 127 | preview = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, 128 | }, 129 | } 130 | 131 | return vim.tbl_deep_extend("force", theme_opts, opts) 132 | end 133 | 134 | -- Only list files with extensions in the whitelist 135 | M.file_sorter = function(whitelist) 136 | local sorter = require("telescope.sorters").get_fuzzy_file() 137 | 138 | sorter._was_discarded = function() 139 | return false 140 | end 141 | 142 | -- Filter based on whitelist 143 | sorter.filter_function = function(_, prompt, entry) 144 | for _, v in ipairs(whitelist) do 145 | if entry.value:find(v) then 146 | -- 0 is highest filtering score 147 | return 0, prompt 148 | end 149 | end 150 | -- -1 is considered filtered 151 | return -1, prompt 152 | end 153 | 154 | return sorter 155 | end 156 | 157 | return M 158 | -------------------------------------------------------------------------------- /lua/user/plugins/config/themer/defaults.lua: -------------------------------------------------------------------------------- 1 | return { 2 | ["syntax"] = { 3 | ["punctuation"] = "#668799", 4 | ["function"] = "#fad07a", 5 | ["operator"] = "#8fbfdc", 6 | ["constant"] = "#cf6a4c", 7 | ["todo"] = { ["bg"] = "#0", ["fg"] = "#c7c7c7" }, 8 | ["conditional"] = "#8197bf", 9 | ["statement"] = "#8197bf", 10 | ["field"] = "#c6b6ee", 11 | ["preproc"] = "#8fbfdc", 12 | ["type"] = "#ffb964", 13 | ["constructor"] = "#799d6a", 14 | ["variable"] = "#0", 15 | ["string"] = "#99ad6a", 16 | ["number"] = "#cf6a4c", 17 | ["tag"] = "#8197bf", 18 | ["keyword"] = "#8197bf", 19 | ["struct"] = "#8fbfdc", 20 | ["parameter"] = "#c6b6ee", 21 | ["include"] = "#8fbfdc", 22 | ["property"] = "#c6b6ee", 23 | ["comment"] = "#888888", 24 | }, 25 | ["match"] = "#0", 26 | ["uri"] = "#80a0ff", 27 | ["accent"] = "#799d6a", 28 | ["search_result"] = { ["telescope"] = "#0", ["bg"] = "#302028", ["fg"] = "#f0a0c0" }, 29 | ["dimmed"] = { ["inactive"] = "#606060", ["subtle"] = "#ffffff" }, 30 | ["heading"] = { ["h2"] = "#0", ["h1"] = "#0" }, 31 | ["green"] = "#9ece6a", 32 | ["border"] = "#777777", 33 | ["yellow"] = "#e0af68", 34 | ["built_in"] = { 35 | ["keyword"] = "#8197bf", 36 | ["constant"] = "#799d6a", 37 | ["function"] = "#799d6a", 38 | ["variable"] = "#799d6a", 39 | ["type"] = "#ffb964", 40 | }, 41 | ["inc_search"] = { ["bg"] = "#0", ["fg"] = "#0" }, 42 | ["pum"] = { 43 | ["thumb"] = "#ffffff", 44 | ["bg"] = "#606060", 45 | ["sel"] = { ["bg"] = "#eeeeee", ["fg"] = "#101010" }, 46 | ["fg"] = "#ffffff", 47 | ["sbar"] = "#808080", 48 | }, 49 | ["bg"] = { ["alt"] = "#606060", ["selected"] = "#1c1c1c", ["base"] = "#151515" }, 50 | ["magenta"] = "#9d7cd8", 51 | ["diagnostic"] = { ["hint"] = "#d3d3d3", ["info"] = "#add8e6", ["error"] = "#ff0000", ["warn"] = "#ffa500" }, 52 | ["cursorlinenr"] = "#ccc5c4", 53 | ["orange"] = "#e0af68", 54 | ["cyan"] = "#0db9d7", 55 | ["fg"] = "#e8e8d3", 56 | ["blue"] = "#7aa2f7", 57 | ["diff"] = { ["add"] = "#437019", ["text"] = "#0", ["change"] = "#2b5b77", ["remove"] = "#700009" }, 58 | ["remaps"] = { 59 | ["base"] = { 60 | ["ColorColumn"] = { bg = "#000000" }, 61 | ["LineNr"] = { fg = "#606060" }, 62 | ["Visual"] = { bg = "#404040" }, 63 | }, 64 | }, 65 | ["red"] = "#cf6a4c", 66 | } 67 | -------------------------------------------------------------------------------- /lua/user/plugins/config/themer/init.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local colors = vim.tbl_extend( 4 | "keep", 5 | require("themer.modules.core.api").get_cp(SCHEME), 6 | require("user.plugins.config.themer.defaults") 7 | ) 8 | local utils = require("user.plugins.config.themer.utils") 9 | local darken = require("themer.utils.colors").darken 10 | 11 | colors.bg.lighter = utils.adjust_color(colors.bg.base, 5) 12 | colors.bg.darker = darken(colors.bg.base, 0.9, "#000000") 13 | colors.fg_darker = utils.adjust_color(colors.fg, -80) 14 | colors.alpha = utils.adjust_color(colors.blue, -50) 15 | 16 | M.colors = colors 17 | M.utils = utils 18 | M.darken = darken 19 | 20 | require("themer").setup({ 21 | colorscheme = SCHEME, 22 | styles = { 23 | comment = { style = "italic" }, 24 | ["function"] = { style = "bold" }, 25 | }, 26 | remaps = { 27 | highlights = { 28 | globals = { 29 | themer = { 30 | ThemerBorder = { fg = colors.bg.darker, bg = colors.bg.darker }, 31 | ThemerNormalFloat = { bg = colors.bg.darker }, 32 | ThemerSelected = { bg = darken(colors.bg.base, 0.8, colors.magenta) }, 33 | }, 34 | base = { 35 | Alpha = { fg = colors.alpha, bg = colors.bg.base }, 36 | 37 | Folded = { fg = colors.fg_darker, bg = colors.bg.lighter }, 38 | FoldColumn = { fg = colors.blue, bg = colors.bg.base }, 39 | LineNr = { fg = colors.blue, bg = colors.bg.base }, 40 | LineNrAbove = { fg = utils.adjust_color(colors.bg.base, 50) }, 41 | LineNrBelow = { fg = utils.adjust_color(colors.bg.base, 50) }, 42 | MatchParen = { fg = colors.diagnostic.warn, bg = "None", style = "underline" }, 43 | TabLineFill = { fg = colors.bg.lighter, bg = colors.bg.lighter }, 44 | 45 | SpellBad = { fg = "#ee6d85", bg = "black", style = "bold" }, 46 | SpellCap = { fg = colors.green, bg = "black", style = "bold" }, 47 | SpellLocal = { fg = colors.blue, bg = "black", style = "bold" }, 48 | SpellRare = { fg = colors.magenta, bg = "black", style = "bold" }, 49 | 50 | WinSeparator = { fg = colors.bg.lighter, bg = "None", style = "none" }, 51 | StatusLine = { fg = colors.bg.lighter, bg = "None", style = "None" }, 52 | StatusLineNC = { fg = colors.bg.lighter, bg = "None", style = "None" }, 53 | WinBar = { fg = colors.bg.lighter, bg = "None", style = "None" }, 54 | WinBarNC = { fg = colors.bg.lighter, bg = "None", style = "None" }, 55 | ColorColumn = { fg = utils.adjust_color(colors.red, -50), bg = "None" }, 56 | 57 | NormalFloat = { bg = colors.bg.darker }, 58 | FloatBorder = { link = "ThemerBorder" }, 59 | PmenuSel = { bg = colors.syntax.comment or colors.dimmed.subtle }, 60 | Comment = { fg = utils.adjust_color(colors.bg.base, 60) }, 61 | }, 62 | plugins = { 63 | virtcolumn = { 64 | VirtColumn = { fg = utils.adjust_color(colors.red, -50), bg = "None" }, 65 | }, 66 | indentline = { 67 | IblIndent = { fg = utils.adjust_color(colors.bg.base, 10), bg = "None" }, 68 | IblSpace = { fg = utils.adjust_color(colors.bg.base, 10), bg = "None" }, 69 | IblWhiteSpace = { fg = utils.adjust_color(colors.bg.base, 10), bg = "None" }, 70 | }, 71 | cmp = { 72 | CmpItemMenu = { fg = colors.syntax.comment or colors.dimmed.subtle, bg = colors.pum.bg }, 73 | CmpDocumentation = { fg = colors.pum.fg, bg = colors.pum.bg }, 74 | CmpDocumentationBorder = { bg = colors.pum.bg }, 75 | CmpItemAbbr = { fg = colors.fg, style = "NONE" }, 76 | CmpItemAbbrDeprecated = { fg = colors.fg }, 77 | CmpItemAbbrMatch = { fg = colors.green, style = "bold" }, 78 | CmpItemAbbrMatchFuzzy = { fg = colors.blue }, 79 | CmpItemKindText = { fg = colors.orange }, 80 | CmpItemKindMethod = { fg = colors.blue }, 81 | CmpItemKindFunction = { fg = colors.blue }, 82 | CmpItemKindConstructor = { fg = colors.yellow }, 83 | CmpItemKindField = { fg = colors.blue }, 84 | CmpItemKindClass = { fg = colors.yellow }, 85 | CmpItemKindInterface = { fg = colors.yellow }, 86 | CmpItemKindModule = { fg = colors.blue }, 87 | CmpItemKindProperty = { fg = colors.blue }, 88 | CmpItemKindValue = { fg = colors.orange }, 89 | CmpItemKindEnum = { fg = colors.yellow }, 90 | CmpItemKindKeyword = { fg = colors.purple }, 91 | CmpItemKindSnippet = { fg = colors.green }, 92 | CmpItemKindFile = { fg = colors.blue }, 93 | CmpItemKindEnumMember = { fg = colors.cyan }, 94 | CmpItemKindConstant = { fg = colors.orange }, 95 | CmpItemKindStruct = { fg = colors.yellow }, 96 | CmpItemKindTypeParameter = { fg = colors.yellow }, 97 | }, 98 | telescope = { 99 | TelescopeTitle = { bg = colors.blue, style = "bold" }, 100 | TelescopePromptPrefix = { fg = colors.red }, 101 | TelescopeNormal = { link = "ThemerNormalFloat" }, 102 | }, 103 | vimtex = { 104 | texStatement = { link = "ThemerField" }, 105 | texOnlyMath = { link = "ThemerPunctuation" }, 106 | texDefName = { link = "ThemerType" }, 107 | texNewCmd = { link = "ThemerOperator" }, 108 | texCmdName = { link = "ThemerPunctuation" }, 109 | texBeginEnd = { link = "ThemerInclude" }, 110 | texBeginEndName = { link = "ThemerPunctuation" }, 111 | texDocType = { link = "ThemerStruct" }, 112 | texDocTypeArgs = { link = "ThemerOperator" }, 113 | texCmd = { link = "ThemerField" }, 114 | texCmdClass = { link = "ThemerStruct" }, 115 | texCmdTitle = { link = "ThemerStruct" }, 116 | texCmdAuthor = { link = "ThemerStruct" }, 117 | texCmdPart = { link = "ThemerStruct" }, 118 | texCmdBib = { link = "ThemerStruct" }, 119 | texCmdPackage = { link = "ThemerType" }, 120 | texCmdNew = { link = "ThemerType" }, 121 | texArgNew = { link = "ThemerOperator" }, 122 | texPartArgTitle = { link = "ThemerConstantBuiltIn" }, 123 | texFileArg = { link = "ThemerConstantBuiltIn" }, 124 | texEnvArgName = { link = "ThemerConstantBuiltIn" }, 125 | texMathEnvArgName = { link = "ThemerConstantBuiltIn" }, 126 | texTitleArg = { link = "ThemerConstantBuiltIn" }, 127 | texAuthorArg = { link = "ThemerConstantBuiltIn" }, 128 | }, 129 | lsp = { 130 | DiagnosticUnderlineHint = { style = "underline" }, 131 | DiagnosticUnderlineInfo = { style = "underline" }, 132 | DiagnosticUnderlineWarn = { style = "underline" }, 133 | DiagnosticUnderlineError = { style = "underline" }, 134 | DiagnosticVirtualTextHint = { 135 | fg = colors.diagnostic.hint, 136 | bg = darken(colors.diagnostic.hint, 0.05, colors.bg.base), 137 | style = "NONE", 138 | }, 139 | DiagnosticVirtualTextInfo = { 140 | fg = colors.diagnostic.info, 141 | bg = darken(colors.diagnostic.info, 0.05, colors.bg.base), 142 | style = "NONE", 143 | }, 144 | DiagnosticVirtualTextWarn = { 145 | fg = colors.diagnostic.warn, 146 | bg = darken(colors.diagnostic.warn, 0.05, colors.bg.base), 147 | style = "NONE", 148 | }, 149 | DiagnosticVirtualTextError = { 150 | fg = colors.diagnostic.error, 151 | bg = darken(colors.diagnostic.error, 0.05, colors.bg.base), 152 | style = "NONE", 153 | }, 154 | }, 155 | neotree = { 156 | NeoTreeRootName = { link = "ThemerMatch" }, 157 | NeoTreeDirectoryName = { link = "ThemerMatch" }, 158 | NeoTreeNormal = { bg = colors.bg.darker }, 159 | NeoTreeNormalNC = { bg = colors.bg.darker }, 160 | }, 161 | }, 162 | }, 163 | }, 164 | }, 165 | }) 166 | 167 | return M 168 | -------------------------------------------------------------------------------- /lua/user/plugins/config/themer/utils.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | M.adjust_color = function(col, amt) 4 | local function clamp(component) 5 | return math.min(math.max(component, 0), 255) 6 | end 7 | 8 | local num = tonumber(col:gsub("#", ""), 16) 9 | local r = math.floor(num / 0x10000) + amt 10 | local g = (math.floor(num / 0x100) % 0x100) + amt 11 | local b = (num % 0x100) + amt 12 | return string.format("#%06X", clamp(r) * 0x10000 + clamp(g) * 0x100 + clamp(b)) 13 | end 14 | 15 | return M 16 | -------------------------------------------------------------------------------- /lua/user/plugins/config/treesitter.lua: -------------------------------------------------------------------------------- 1 | require("nvim-treesitter.configs").setup({ 2 | ensure_installed = PARSERS, 3 | sync_install = true, 4 | highlight = { 5 | enable = true, 6 | additional_vim_regex_highlighting = false, 7 | }, 8 | textobjects = { 9 | select = { 10 | enable = true, 11 | -- Automatically jump forward to textobj, similar to targets.vim 12 | lookahead = true, 13 | keymaps = { 14 | ["af"] = "@function.outer", 15 | ["if"] = "@function.inner", 16 | ["ac"] = "@class.outer", 17 | ["ic"] = "@class.inner", 18 | }, 19 | }, 20 | }, 21 | }) 22 | require("nvim-ts-autotag").setup() 23 | -------------------------------------------------------------------------------- /lua/user/plugins/config/vimtex.lua: -------------------------------------------------------------------------------- 1 | vim.g.vimtex_compiler_method = "latexmk" 2 | vim.g.vimtex_compiler_latexmk = { 3 | callback = 1, 4 | continuous = 1, 5 | executable = "latexmk", 6 | options = { 7 | "-shell-escape", 8 | "-verbose", 9 | "-file-line-error", 10 | "-synctex=1", 11 | "-interaction=nonstopmode", 12 | }, 13 | } 14 | -- Disable imaps (using Ultisnips) 15 | vim.g.vimtex_imaps_enabled = 0 16 | -- Do not open pdfviwer on compile 17 | vim.g.vimtex_view_automatic = 0 18 | -- Disable conceal 19 | vim.g.vimtex_syntax_conceal = { 20 | accents = 0, 21 | cites = 0, 22 | fancy = 0, 23 | greek = 0, 24 | math_bounds = 0, 25 | math_delimiters = 0, 26 | math_fracs = 0, 27 | math_super_sub = 0, 28 | math_symbols = 0, 29 | sections = 0, 30 | styles = 0, 31 | } 32 | -- Disable quickfix auto open 33 | vim.g.vimtex_quickfix_ignore_mode = 0 34 | vim.g.vimtex_compiler_progname = "nvr" 35 | -- PDF viewer settings 36 | vim.g.vimtex_view_general_viewer = "SumatraPDF" 37 | vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf" 38 | -- Do not auto open quickfix on compile erros 39 | vim.g.vimtex_quickfix_mode = 0 40 | -- Latex warnings to ignore 41 | vim.g.vimtex_quickfix_ignore_filters = { 42 | "Command terminated with space", 43 | "LaTeX Font Warning: Font shape", 44 | "Package caption Warning: The option", 45 | [[Underfull \\hbox (badness [0-9]*) in]], 46 | "Package enumitem Warning: Negative labelwidth", 47 | [[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in]], 48 | [[Package caption Warning: Unused \\captionsetup]], 49 | "Package typearea Warning: Bad type area settings!", 50 | [[Package fancyhdr Warning: \\headheight is too small]], 51 | [[Underfull \\hbox (badness [0-9]*) in paragraph at lines]], 52 | "Package hyperref Warning: Token not allowed in a PDF string", 53 | [[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in paragraph at lines]], 54 | } 55 | vim.g.vimtex_fold_enabled = 1 56 | vim.g.vimtex_fold_manual = 1 57 | vim.g.vimtex_fold_types = { 58 | cmd_addplot = { 59 | cmds = { "addplot[+3]?" }, 60 | }, 61 | cmd_multi = { 62 | cmds = { 63 | "%(re)?new%(command|environment)", 64 | "providecommand", 65 | "presetkeys", 66 | "Declare%(Multi|Auto)?CiteCommand", 67 | "Declare%(Index)?%(Field|List|Name)%(Format|Alias)", 68 | }, 69 | }, 70 | cmd_single = { 71 | cmds = { "hypersetup", "tikzset", "pgfplotstableread", "lstset" }, 72 | }, 73 | cmd_single_opt = { 74 | cmds = { "usepackage", "includepdf" }, 75 | }, 76 | comments = { 77 | enabled = 0, 78 | }, 79 | env_options = vim.empty_dict(), 80 | envs = { 81 | blacklist = {}, 82 | whitelist = { 83 | "figure", 84 | "frame", 85 | "table", 86 | "example", 87 | "answer", 88 | "titlepage", 89 | "cvskills", 90 | "cventries", 91 | "cvhonors", 92 | }, 93 | }, 94 | items = { 95 | enabled = 0, 96 | }, 97 | markers = vim.empty_dict(), 98 | preamble = { 99 | enabled = 0, 100 | }, 101 | sections = { 102 | parse_levels = 0, 103 | parts = { "appendix", "frontmatter", "mainmatter", "backmatter" }, 104 | sections = { 105 | "%(add)?part", 106 | "%(chapter|addchap)", 107 | "%(section|section\\*)", 108 | "%(subsection|subsection\\*)", 109 | "%(subsubsection|subsubsection\\*)", 110 | "paragraph", 111 | }, 112 | }, 113 | } 114 | -------------------------------------------------------------------------------- /lua/user/plugins/init.lua: -------------------------------------------------------------------------------- 1 | local lazypath = LAZY_PATH .. "/lazy.nvim" 2 | if not (vim.uv or vim.loop).fs_stat(lazypath) then 3 | local lazyrepo = "https://github.com/folke/lazy.nvim.git" 4 | local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) 5 | if vim.v.shell_error ~= 0 then 6 | vim.api.nvim_echo({ 7 | { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, 8 | { out, "WarningMsg" }, 9 | { "\nPress any key to exit..." }, 10 | }, true, {}) 11 | vim.fn.getchar() 12 | os.exit(1) 13 | end 14 | end 15 | vim.opt.rtp:prepend(lazypath) 16 | 17 | require("lazy").setup({ 18 | -- ------------------------------- Themes ------------------------------- -- 19 | { 20 | "ThemerCorp/themer.lua", 21 | config = function() 22 | require("user.plugins.config.themer") 23 | end, 24 | }, 25 | 26 | -- -------------------------------- Looks ------------------------------- -- 27 | { 28 | "nvim-treesitter/nvim-treesitter", 29 | dependencies = { 30 | "HiPhish/rainbow-delimiters.nvim", 31 | "windwp/nvim-ts-autotag", 32 | -- "nvim-treesitter/nvim-treesitter-textobjects", 33 | }, 34 | config = function() 35 | require("user.plugins.config.treesitter") 36 | end, 37 | build = ":TSUpdate", 38 | }, 39 | { 40 | "nvim-treesitter/playground", 41 | dependencies = "nvim-treesitter/nvim-treesitter", 42 | enabled = false, 43 | }, 44 | { 45 | "kyazdani42/nvim-web-devicons", 46 | config = function() 47 | require("user.plugins.config.devicons") 48 | end, 49 | }, 50 | { 51 | "lukas-reineke/indent-blankline.nvim", 52 | main = "ibl", 53 | config = function() 54 | require("user.plugins.config.indentline") 55 | end, 56 | }, 57 | -- Load default 58 | { 59 | "lukas-reineke/virt-column.nvim", 60 | opts = {}, 61 | }, 62 | { 63 | "brenoprata10/nvim-highlight-colors", 64 | config = function() 65 | require("nvim-highlight-colors").setup({ 66 | render = "virtual", 67 | }) 68 | end, 69 | cmd = "HighlightColors", 70 | }, 71 | 72 | -- --------------------------------- LSP -------------------------------- -- 73 | { 74 | "neovim/nvim-lspconfig", 75 | config = function() 76 | require("user.plugins.config.lspconfig") 77 | end, 78 | }, 79 | { 80 | "nvimtools/none-ls.nvim", 81 | dependencies = "nvim-lua/plenary.nvim", 82 | config = function() 83 | require("user.plugins.config.null_ls") 84 | end, 85 | }, 86 | { 87 | "ray-x/lsp_signature.nvim", 88 | dependencies = "nvim-lspconfig", 89 | config = function() 90 | require("user.plugins.config.others").lsp_signature() 91 | end, 92 | }, 93 | { 94 | "ThePrimeagen/refactoring.nvim", 95 | dependencies = { 96 | "nvim-lua/plenary.nvim", 97 | "nvim-treesitter/nvim-treesitter", 98 | }, 99 | init = function() 100 | require("user.plugins.config.others").refactoring() 101 | end, 102 | }, 103 | 104 | -- ----------------------------- Completion ----------------------------- -- 105 | { 106 | "hrsh7th/nvim-cmp", 107 | dependencies = { 108 | "hrsh7th/cmp-nvim-lsp", 109 | "hrsh7th/cmp-buffer", 110 | "hrsh7th/cmp-path", 111 | "hrsh7th/cmp-cmdline", 112 | "hrsh7th/cmp-nvim-lua", 113 | "quangnguyen30192/cmp-nvim-ultisnips", 114 | { "hrsh7th/cmp-omni", ft = "tex" }, 115 | }, 116 | config = function() 117 | require("user.plugins.config.cmp") 118 | end, 119 | event = "InsertEnter", 120 | }, 121 | 122 | -- ------------------------------ Features ------------------------------ -- 123 | { 124 | "dstein64/vim-startuptime", 125 | config = function() 126 | vim.g.startuptime_tries = 5 127 | vim.g.startuptime_event_width = 50 128 | end, 129 | cmd = "StartupTime", 130 | }, 131 | { 132 | "is0n/jaq-nvim", 133 | config = function() 134 | require("user.plugins.config.jaq") 135 | end, 136 | }, 137 | { 138 | "terrortylor/nvim-comment", 139 | config = function() 140 | require("user.plugins.config.others").nvim_comment() 141 | end, 142 | cmd = "CommentToggle", 143 | keys = { 144 | { mode = "n", "" }, 145 | { mode = "v", "" }, 146 | { mode = "i", "" }, 147 | { mode = "n", "gc" }, 148 | { mode = "v", "gc" }, 149 | }, 150 | }, 151 | { 152 | "jiangmiao/auto-pairs", 153 | config = function() 154 | require("user.plugins.config.others").autopairs() 155 | end, 156 | event = "InsertEnter", 157 | }, 158 | { 159 | "goolord/alpha-nvim", 160 | config = function() 161 | require("user.plugins.config.alpha") 162 | end, 163 | }, 164 | { 165 | "iamcco/markdown-preview.nvim", 166 | config = function() 167 | require("user.plugins.config.others").markdown_preview() 168 | end, 169 | cmd = "MarkdownPreview", 170 | ft = "markdown", 171 | build = "cd app && yarn install", 172 | }, 173 | { 174 | "danymat/neogen", 175 | dependencies = "nvim-treesitter/nvim-treesitter", 176 | config = function() 177 | require("user.plugins.config.others").neogen() 178 | end, 179 | cmd = "Neogen", 180 | }, 181 | { 182 | "nvim-neo-tree/neo-tree.nvim", 183 | branch = "v3.x", 184 | dependencies = { 185 | "nvim-lua/plenary.nvim", 186 | "MunifTanjim/nui.nvim", 187 | }, 188 | config = function() 189 | require("user.plugins.config.neotree") 190 | end, 191 | keys = { { "", "Neotree source=filesystem toggle dir=./", mode = "n" } }, 192 | }, 193 | { 194 | "Shatur/neovim-session-manager", 195 | dependencies = "nvim-lua/plenary.nvim", 196 | config = function() 197 | require("user.plugins.config.others").session() 198 | end, 199 | cmd = "SessionManager", 200 | keys = { 201 | { mode = "n", "ss" }, 202 | { mode = "n", "ls" }, 203 | }, 204 | }, 205 | { 206 | "phaazon/hop.nvim", 207 | version = "2.x", 208 | config = function() 209 | require("user.plugins.config.others").hop() 210 | end, 211 | keys = { 212 | { mode = "n", "f" }, 213 | { mode = "n", "S" }, 214 | { mode = "o", "f" }, 215 | }, 216 | }, 217 | { 218 | "kylechui/nvim-surround", 219 | opts = { 220 | highlight = { duration = 500 }, 221 | move_cursor = false, 222 | }, 223 | }, 224 | { 225 | "mg979/vim-visual-multi", 226 | config = function() 227 | vim.g.VM_set_statusline = 0 228 | end, 229 | keys = { 230 | { mode = "n", "" }, 231 | { mode = "n", "" }, 232 | { mode = "n", "" }, 233 | }, 234 | }, 235 | 236 | -- -------------------------------- LaTeX ------------------------------- -- 237 | { 238 | "lervag/vimtex", 239 | config = function() 240 | require("user.plugins.config.vimtex") 241 | end, 242 | ft = { 243 | "tex", 244 | "bib", 245 | }, 246 | }, 247 | { 248 | "ludovicchabant/vim-gutentags", 249 | config = function() 250 | require("user.plugins.config.others").gutentags() 251 | end, 252 | ft = { 253 | "tex", 254 | "bib", 255 | }, 256 | }, 257 | { 258 | "SirVer/ultisnips", 259 | config = function() 260 | require("user.plugins.config.others").ultisnips() 261 | end, 262 | event = "InsertEnter", 263 | }, 264 | 265 | -- ------------------------------ Telescope ----------------------------- -- 266 | { 267 | "nvim-telescope/telescope.nvim", 268 | branch = "0.1.x", 269 | dependencies = { 270 | "nvim-lua/plenary.nvim", 271 | { 272 | "nvim-telescope/telescope-fzf-native.nvim", 273 | build = "make", 274 | }, 275 | { 276 | "nvim-telescope/telescope-frecency.nvim", 277 | }, 278 | "fhill2/telescope-ultisnips.nvim", 279 | }, 280 | config = function() 281 | require("user.plugins.config.telescope") 282 | end, 283 | cmd = "Telescope", 284 | keys = { "tr", "tf", "tp", "tn", "tl", "ts", "", "" }, 285 | }, 286 | 287 | -- ------------------------- Buffer, Statusline ------------------------- -- 288 | { 289 | "willothy/nvim-cokeline", 290 | config = function() 291 | require("user.plugins.config.cokeline") 292 | end, 293 | dependencies = "ThemerCorp/themer.lua", 294 | }, 295 | { 296 | "rebelot/heirline.nvim", 297 | dependencies = { 298 | "ThemerCorp/themer.lua", 299 | -- Load default 300 | { 301 | "lewis6991/gitsigns.nvim", 302 | opts = {}, 303 | lazy = true, 304 | }, 305 | }, 306 | config = function() 307 | require("user.plugins.config.heirline") 308 | end, 309 | }, 310 | 311 | -- --------------------------------- QOL -------------------------------- -- 312 | { 313 | "tpope/vim-repeat", 314 | }, 315 | { 316 | "https://gitlab.com/yorickpeterse/nvim-pqf", 317 | config = function() 318 | require("pqf").setup() 319 | end, 320 | name = "nvim-pqf", 321 | event = "VeryLazy", 322 | }, 323 | { 324 | "christoomey/vim-titlecase", 325 | keys = "gz", 326 | }, 327 | { 328 | "junegunn/vim-easy-align", 329 | cmd = "EasyAlign", 330 | }, 331 | { 332 | "antoinemadec/FixCursorHold.nvim", 333 | config = function() 334 | vim.g.curshold_updatime = 500 335 | end, 336 | }, 337 | { 338 | "Konfekt/FastFold", 339 | config = function() 340 | require("user.plugins.config.others").fastfold() 341 | end, 342 | }, 343 | { 344 | "bbjornstad/pretty-fold.nvim", 345 | config = function() 346 | require("user.plugins.config.pretty_fold") 347 | end, 348 | }, 349 | { 350 | "rmagatti/alternate-toggler", 351 | config = function() 352 | vim.keymap.set("n", "ta", ":ToggleAlternate") 353 | end, 354 | cmd = "ToggleAlternate", 355 | keys = "ta", 356 | }, 357 | }) 358 | -------------------------------------------------------------------------------- /lua/user/utils.lua: -------------------------------------------------------------------------------- 1 | --- Trim newline at eof, trailing whitespace. 2 | function _G.perform_cleanup() 3 | local patterns = { 4 | -- Remove leading empty lines 5 | [[%s/\%^\n//e]], 6 | -- Remove trailing empty lines 7 | [[%s/$\n\+\%$//e]], 8 | -- Remove trailing spaces 9 | [[%s/\s\+$//e]], 10 | -- Remove trailing "\r" 11 | [[%s/\r\+//e]], 12 | } 13 | 14 | local view = vim.fn.winsaveview() 15 | 16 | for _, v in pairs(patterns) do 17 | vim.cmd(string.format("keepjumps keeppatterns silent! %s", v)) 18 | end 19 | 20 | vim.fn.winrestview(view) 21 | end 22 | 23 | --- Launch external program 24 | --- @param prog string program to run 25 | --- @vararg string args for program 26 | function _G.launch_ext_prog(prog, ...) 27 | vim.fn.system(prog .. " " .. table.concat({ ... }, " ")) 28 | end 29 | 30 | function _G.open_url(url, prefix) 31 | launch_ext_prog("start", (prefix or "") .. url) 32 | end 33 | 34 | --- Reloading lua modules using Telescope 35 | --- taken and modified from: 36 | --- https://ustrajunior.com/posts/reloading-neovim-config-with-telescope/ 37 | --- 38 | --- Reload module using plenary 39 | --- @param name string module 40 | function _G.plenary_reload(name) 41 | -- Check for plenary 42 | local present, plenary = pcall(require, "plenary.reload") 43 | 44 | if not present then 45 | vim_notify("Plenary not found.", vim.levels.WARN) 46 | return 47 | end 48 | 49 | -- Reload module if found 50 | plenary.reload_module(name) 51 | end 52 | 53 | --- Get module from file path 54 | --- @param file_path string path to file e.g., "C:\Users\Neel\AppData\Local\nvim\user\lua\user\plugins\custom\telescope.lua" 55 | --- @return string module_name module representation of file "user.plugins.custom.telescope" 56 | function _G.get_module_name(file_path) 57 | -- Path to the lua folder 58 | local path_to_lua = CONFIG_PATH .. "\\lua\\" 59 | local module_name = file_path:gsub(path_to_lua, "") 60 | 61 | -- In the case that current file is not within "lua" folder 62 | if module_name == file_path then 63 | vim_notify(("Not a valid module (%s)"):format(module_name), vim.log.levels.WARN) 64 | return 65 | end 66 | 67 | module_name = module_name:gsub("%.lua", "") 68 | module_name = module_name:gsub("\\", ".") 69 | module_name = module_name:gsub("%.init", "") 70 | return module_name 71 | end 72 | 73 | --- Save and reload a module 74 | function _G.save_reload_module() 75 | local file_path = vim.fn.fnameescape(vim.fn.expand("%:p")) 76 | 77 | -- Handle lowercase drive names 78 | file_path = file_path:gsub("^%l", string.upper) 79 | 80 | -- Handle weird behavior (multiple separators) 81 | if string.match(file_path, "\\\\") then 82 | file_path = file_path:gsub("\\\\", "\\") 83 | end 84 | 85 | -- Save changes if any 86 | vim.cmd("update!") 87 | 88 | if file_path:find("%.vim$") then 89 | -- Source 90 | vim.cmd(("source %s"):format(file_path)) 91 | -- Print 92 | vim_notify(("%s Reloaded."):format(vim.fn.expand("%")), vim.log.levels.INFO) 93 | else 94 | -- Get module 95 | local module = get_module_name(file_path) 96 | -- Reload if current file is a valid module or is a ".vim" file 97 | if module then 98 | -- Reload 99 | plenary_reload(module) 100 | -- Source 101 | vim.cmd(("source %s"):format(file_path)) 102 | -- Print 103 | vim_notify(("%s Reloaded."):format(module), vim.log.levels.INFO) 104 | end 105 | end 106 | end 107 | 108 | --- Set window title 109 | function _G.set_title() 110 | local file = vim.fn.expand("%:p:t") 111 | local cwd = vim.fn.split(vim.fn.expand("%:p:h"):gsub("/", "\\"), "\\") 112 | 113 | local present, utils = pcall(require, "user.plugins.config.heirline.utils") 114 | if not present then 115 | return 116 | end 117 | 118 | if file ~= "" and not utils.buffer_is_plugin() then 119 | vim.opt.titlestring = cwd[#cwd] .. "/" .. file 120 | else 121 | vim.opt.titlestring = "Neovim" 122 | end 123 | end 124 | 125 | --- Quickfix toggle 126 | --- https://vim.fandom.com/wiki/Toggle_to_open_or_close_the_quickfix_window 127 | vim.api.nvim_create_user_command("QFix", function(bang) 128 | if vim.fn.getqflist({ winid = 0 }).winid ~= 0 and bang then 129 | vim.cmd("cclose") 130 | else 131 | vim.cmd("copen 10") 132 | end 133 | end, { 134 | nargs = "?", 135 | bang = true, 136 | force = true, 137 | }) 138 | 139 | --- Redraw before notifying 140 | ---@param msg string Content of the notification to show to the user. 141 | ---@param level number|nil One of the values from vim.log.levels. 142 | function _G.vim_notify(msg, level) 143 | vim.cmd("redraw") 144 | vim.notify(msg, level) 145 | end 146 | 147 | function _G.exists_and_not_nil(t) 148 | if t then 149 | return next(t) ~= nil 150 | end 151 | return false 152 | end 153 | -------------------------------------------------------------------------------- /ultisnips/all.snippets: -------------------------------------------------------------------------------- 1 | # Author: Neel Basak 2 | # Github: https://github.com/Neelfrost 3 | # File: all.snippets 4 | 5 | global !p 6 | 7 | from lorem import get_sentence 8 | 9 | # Copied from: https://github.com/honza/vim-snippets/blob/master/pythonx/vimsnippets.py 10 | def _parse_comments(s): 11 | """Parses vim's comments option to extract comment format""" 12 | import string 13 | 14 | i = iter(s.split(",")) 15 | 16 | rv = [] 17 | try: 18 | while True: 19 | # get the flags and text of a comment part 20 | flags, text = next(i).split(":", 1) 21 | 22 | if len(flags) == 0: 23 | rv.append(("OTHER", text, text, text, "")) 24 | # parse 3-part comment, but ignore those with O flag 25 | elif "s" in flags and "O" not in flags: 26 | ctriple = ["TRIPLE"] 27 | indent = "" 28 | 29 | if flags[-1] in string.digits: 30 | indent = " " * int(flags[-1]) 31 | ctriple.append(text) 32 | 33 | flags, text = next(i).split(":", 1) 34 | assert flags[0] == "m" 35 | ctriple.append(text) 36 | 37 | flags, text = next(i).split(":", 1) 38 | assert flags[0] == "e" 39 | ctriple.append(text) 40 | ctriple.append(indent) 41 | 42 | rv.append(ctriple) 43 | elif "b" in flags: 44 | if len(text) == 1: 45 | rv.insert(0, ("SINGLE_CHAR", text, text, text, "")) 46 | except StopIteration: 47 | return rv 48 | 49 | 50 | def get_comment_format(): 51 | """Returns a 4-element tuple (first_line, middle_lines, end_line, indent) 52 | representing the comment format for the current file. 53 | 54 | It first looks at the 'commentstring', if that ends with %s, it uses that. 55 | Otherwise it parses '&comments' and prefers single character comment 56 | markers if there are any. 57 | """ 58 | import vim 59 | 60 | commentstring = vim.eval("&commentstring") 61 | if commentstring.endswith("%s"): 62 | c = commentstring[:-2] 63 | return (c.rstrip(), c.rstrip(), c.rstrip(), "") 64 | comments = _parse_comments(vim.eval("&comments")) 65 | for c in comments: 66 | if c[0] == "SINGLE_CHAR": 67 | return c[1:] 68 | return comments[0][1:] 69 | 70 | def comment_divider(comment: str): 71 | max_length = 80 72 | padding = 1 73 | comment_len_is_odd = 2 if len(comment) % 2 != 0 else 0 74 | 75 | f, m, e, i = get_comment_format() 76 | comment_str_padding = len(f) * 2 77 | 78 | divider = ( 79 | " " * (len(comment) - len(comment.strip())) 80 | + f 81 | + " " 82 | + "-" * int((comment_len_is_odd + max_length - len(comment) - comment_str_padding - padding * 4) / 2) 83 | + " " 84 | + comment.strip() 85 | + " " 86 | + "-" * int((max_length - len(comment) - comment_str_padding - padding * 4) / 2) 87 | + " " 88 | + e 89 | ) 90 | return divider 91 | endglobal 92 | 93 | snippet box "Box" b 94 | `!p snip.rv = '┌' + '─' * (len(t[1]) + 2) + '┐'` 95 | │ $1 │ 96 | `!p snip.rv = '└' + '─' * (len(t[1]) + 2) + '┘'` 97 | $0 98 | endsnippet 99 | 100 | snippet '(.+)div' "Comment divider" r 101 | `!p snip.rv = comment_divider(match.group(1))` 102 | endsnippet 103 | 104 | snippet auth "Author" b 105 | `!p snip.rv = get_comment_format()[0] + " Author: Neel Basak"` 106 | `!p snip.rv = get_comment_format()[0] + " Github: https://github.com/Neelfrost"` 107 | `!p snip.rv = get_comment_format()[0] + " File: " + snip.fn` 108 | endsnippet 109 | 110 | # Generate lorem ipsum sentences 111 | snippet 'lorem(\d*)' "Lorem ipsum" r 112 | `!p if not snip.c: snip.rv = get_sentence(count=int(match.group(1)) if match.group(1) else 1)` 113 | endsnippet 114 | 115 | # vim:ts=4 sw=4 noexpandtab 116 | -------------------------------------------------------------------------------- /ultisnips/snippets.snippets: -------------------------------------------------------------------------------- 1 | # We use a little hack so that the snippet is expanded 2 | # and parsed correctly 3 | snippet snip "Ultisnips snippet definition" b 4 | `!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b} 5 | ${0:${VISUAL}} 6 | `!p snip.rv = "endsnippet"` 7 | endsnippet 8 | 9 | snippet global "Global snippet" b 10 | `!p snip.rv = "global"` !p 11 | ${0:${VISUAL}} 12 | `!p snip.rv = "endglobal"` 13 | endsnippet 14 | 15 | snippet vis "${VISUAL}" i 16 | :\$\{VISUAL${1:${2:default}${3:/transform/}}\} 17 | endsnippet 18 | 19 | # vim:ts=4 sw=4 noexpandtab 20 | -------------------------------------------------------------------------------- /ultisnips/tex/beamer.snippets: -------------------------------------------------------------------------------- 1 | # Author: Neel Basak 2 | # Github: https://github.com/Neelfrost 3 | # File: beamer.snippets 4 | 5 | # --------------------------------- Contexts --------------------------------- # 6 | 7 | global !p 8 | def beamer(): 9 | return vim.eval('b:vimtex["documentclass"]') == 'beamer' 10 | endglobal 11 | 12 | # ---------------------------------- Beamer ---------------------------------- # 13 | 14 | context "beamer()" 15 | snippet frame "BEAMER: frame" b 16 | \begin{frame}[allowframebreaks]{$1} 17 | $0 18 | \end{frame} 19 | endsnippet 20 | 21 | context "beamer()" 22 | snippet split "BEAMER: 50-50 split frame" b 23 | \begin{columns} 24 | \begin{column}{0.5\textwidth} 25 | ${1:${VISUAL}} 26 | \end{column} 27 | \begin{column}{0.5\textwidth} 28 | $2 29 | \end{column} 30 | \end{columns}$0 31 | endsnippet 32 | 33 | context "beamer()" 34 | snippet imgsplit "BEAMER: 50-50 split frame of images" b 35 | \begin{columns} 36 | \begin{column}{0.5\textwidth} 37 | \begin{figure}[htb!] 38 | \centering 39 | \includegraphics[width=\linewidth]{${1:File}} 40 | \caption{${2:Caption}}% 41 | \end{figure} 42 | \end{column} 43 | \begin{column}{0.5\textwidth} 44 | \begin{figure}[htb!] 45 | \centering 46 | \includegraphics[width=\linewidth]{${3:File}} 47 | \caption{${4:Caption}}% 48 | \end{figure} 49 | \end{column} 50 | \end{columns}$0 51 | endsnippet 52 | 53 | context "beamer()" 54 | snippet setlenitem "BEAMER: 1ex itemsep" w 55 | \setlength\itemsep{1ex}$0 56 | endsnippet 57 | 58 | context "beamer()" 59 | snippet setcouitem "BEAMER: Start list count from" w 60 | \setcounter{enumi}{$1}$0 61 | endsnippet 62 | 63 | context "beamer()" 64 | snippet fb "BEAMER: framebreak" b 65 | \framebreak% 66 | endsnippet 67 | 68 | context "beamer()" 69 | snippet titleframe "BEAMER: centered titleframe" b 70 | \begin{frame} 71 | \begin{center} 72 | \LARGE{\textbf{$1}} 73 | \end{center}$0 74 | \end{frame} 75 | endsnippet 76 | 77 | # vim:ts=2 sw=2 noexpandtab 78 | -------------------------------------------------------------------------------- /ultisnips/tex/chem.snippets: -------------------------------------------------------------------------------- 1 | # Author: Neel Basak 2 | # Github: https://github.com/Neelfrost 3 | # File: chem.snippets 4 | # Requires: chemmacros, chemformula packages 5 | 6 | # --------------------------------- Contexts --------------------------------- # 7 | 8 | global !p 9 | def math(): 10 | return vim.eval('vimtex#syntax#in_mathzone()') == '1' and not vim.eval('vimtex#syntax#in("texRefArg")') == '1' 11 | 12 | def chem(): 13 | return vim.eval('vimtex#syntax#in("texCHArg")') == '1' 14 | 15 | def env(name): 16 | [x,y] = vim.eval("vimtex#env#is_inside('" + name + "')") 17 | return x != '0' and x != '0' 18 | 19 | def delta_less(match): 20 | return ", pre=" if match in ["e", "s"] else "" 21 | endglobal 22 | 23 | # ----------------------------------- Main ----------------------------------- # 24 | 25 | # Chemformula env 26 | snippet ilc "Chemformula env" wA 27 | \ch{${1:${VISUAL}}}$0 28 | endsnippet 29 | 30 | snippet \} "Chemformula escaped {}" iA 31 | \\{${1:${VISUAL}}\\} 32 | endsnippet 33 | 34 | context "chem()" 35 | snippet !us "Chemical reaction with underset" iA 36 | !( ${1:Bottom} )( ${2:${VISUAL:Top}} )$0 37 | endsnippet 38 | 39 | # ----------------------------- Electrochemistry ----------------------------- # 40 | 41 | context "chem()" 42 | snippet e- "electron" A 43 | e^{-} 44 | endsnippet 45 | 46 | context "chem()" 47 | snippet ++ "1+ valency charge" iA 48 | ^{+}$0 49 | endsnippet 50 | 51 | context "chem()" 52 | snippet -- "1- valency charge" iA 53 | ^{-}$0 54 | endsnippet 55 | 56 | context "chem()" 57 | snippet '(\d)([-+])' "n+(-) valency charge" irA 58 | ^{`!p snip.rv = match.group(1) + match.group(2)`}$0 59 | endsnippet 60 | 61 | # ------------------------------ Reaction Arrows ----------------------------- # 62 | 63 | # Arrow 64 | context "env('gather') or chem() and not env('align')" 65 | snippet ;a "Arrow ->" wA 66 | -> $0 67 | endsnippet 68 | 69 | context "env('align')" 70 | snippet ;a "Arrow aligned &->" wA 71 | &-> $0 72 | endsnippet 73 | 74 | # Equilibrium arrow 75 | context "env('gather') or chem() and not env('align')" 76 | snippet ;e "Equilibrium <=>" wA 77 | <=> $0 78 | endsnippet 79 | 80 | context "env('align')" 81 | snippet ;e "Equilibrium aligned &<=>" wA 82 | &<=> $0 83 | endsnippet 84 | 85 | # ---------------------------------- States ---------------------------------- # 86 | 87 | snippet '!state(\w)' "Thermodynamic state" rA 88 | \state[superscript-right=`!p snip.rv = delta_less(match.group(1))`]{`!p snip.rv = match.group(1).upper()`} 89 | endsnippet 90 | 91 | snippet '!std(\w)' "Thermodynamic state at stp" rA 92 | \state[superscript-right=$\circ$`!p snip.rv = delta_less(match.group(1))`]{`!p snip.rv = match.group(1).upper()`} 93 | endsnippet 94 | 95 | # ---------------------------------- Phases ---------------------------------- # 96 | 97 | context "chem()" 98 | snippet '(? "long <>" iA 80 | \langle ${1:${VISUAL}} \rangle 81 | endsnippet 82 | 83 | # Trig, log functions 84 | context "math()" 85 | snippet '(? "Superscript" i 115 | ^{$1}$0 116 | endsnippet 117 | 118 | context "math()" 119 | snippet '(\w)<([^\s]+) ' "Auto subscript" rA 120 | `!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`} 121 | endsnippet 122 | 123 | context "math()" 124 | snippet '(\w)>([^\s]+) ' "Auto superscript" rA 125 | `!p snip.rv = match.group(1)`^{`!p snip.rv = match.group(2)`} 126 | endsnippet 127 | 128 | # ------------------------------ Math env texts ------------------------------ # 129 | 130 | context "math()" 131 | snippet ;t "\text" iA 132 | \text{${1:${VISUAL:Text}}}$0 133 | endsnippet 134 | 135 | context "math()" 136 | snippet ;q "\text between quads" iA 137 | \quad\text{${1:${VISUAL:Text}}}\quad$0 138 | endsnippet 139 | 140 | context "math()" 141 | snippet ;bt "\beforetext" iA 142 | \beforetext{${1:${VISUAL:Text}}}$0 143 | endsnippet 144 | 145 | context "math()" 146 | snippet ;it "\intertext" iA 147 | \intertext{${1:${VISUAL:Text}}}$0 148 | endsnippet 149 | 150 | # ------------------------------- Math symbols ------------------------------- # 151 | 152 | # Aligned = 153 | context "env('align')" 154 | snippet == "&=" wA 155 | &= $0 156 | endsnippet 157 | 158 | context "math()" 159 | snippet =e "equivalent" wA 160 | \equiv $0 161 | endsnippet 162 | 163 | context "math()" 164 | snippet =a "approx" wA 165 | \approx $0 166 | endsnippet 167 | 168 | context "math()" 169 | snippet =p "proportional" wA 170 | \propto $0 171 | endsnippet 172 | 173 | context "math()" 174 | snippet '(?angle -> \ang{} 10 | snippet '(\d+\.\d+|\d+)ang' "Angle" rA 11 | \ang{`!p snip.rv = match.group(1)`}$0 12 | endsnippet 13 | 14 | # Automatic number 15 | # Usage: num -> \num{}, works with scientific notation eg., e5num -> \num{e5} 16 | snippet '(\d+\.\d+|\d+|e\d+)num' "Number" rA 17 | \num{`!p snip.rv = match.group(1)`}$0 18 | endsnippet 19 | 20 | # Automatic number range 21 | # Usage: -num -> \numrange{} 22 | priority 10 23 | snippet '(\d+\.\d+|\d+|e\d+)-(\d+\.\d+|\d+|e\d+)num' "Number range" rA 24 | \numrange{`!p snip.rv = match.group(1)`}{`!p snip.rv = match.group(2)`}$0 25 | endsnippet 26 | 27 | # SI unit 28 | snippet si "SI-Unit" w 29 | \SI{${1:${VISUAL}}}{\\${2:Unit}}$0 30 | endsnippet 31 | 32 | priority 10 33 | snippet '(\d+\.\d+|\d+|e\d+)si' "SI-Unit" rA 34 | \SI{`!p snip.rv = match.group(1)`}{\\${1:Unit}}$0 35 | endsnippet 36 | 37 | # SI range 38 | snippet sr "SI-Range" w 39 | \SIrange{$1}{$2}{\\${3:Unit}}$0 40 | endsnippet 41 | 42 | priority 10 43 | snippet '(\d+\.\d+|\d+|e\d+)-(\d+\.\d+|\d+|e\d+)sr' "SI-Range" rA 44 | \SIrange{`!p snip.rv = match.group(1)`}{`!p snip.rv = match.group(2)`}{\\${1:Unit}}$0 45 | endsnippet 46 | 47 | # Automatic si unit 48 | # Usage: visual select a number, press tab, type asi 49 | snippet asi "Auto SI-Unit" wA 50 | \SI{`!p snip.rv = re.search("(\d+\.\d+|\d+)", snip.v.text).group()`}{\\${1:Unit}}$0 51 | endsnippet 52 | 53 | # Automatic si range 54 | # Usage: visual select a number range (eg., 10-12 or 10 to 3), press tab, type asr 55 | snippet asr "Auto SI-Range" wA 56 | \SIrange{`!p snip.rv = re.search("(\d+\.\d+|\d+).+?(\d+\.\d+|\d+)", snip.v.text).group(1)`}{`!p snip.rv = re.search("(\d+\.\d+|\d+).+?(\d+\.\d+|\d+)", snip.v.text).group(2)`}{\\${1:Unit}}$0 57 | endsnippet 58 | 59 | # Degree celsius 60 | # Usage: dc -> \SI{}{\celsius} 61 | snippet '(\d+\.\d+|\d+|e\d+)dc' "Degree celsius" rwA 62 | \SI{`!p snip.rv = match.group(1)`}{\celsius}$0 63 | endsnippet 64 | 65 | priority 100 66 | snippet '(\d+\.\d+|\d+|e\d+)-(\d+\.\d+|\d+|e\d+)dc' "Degree celsius" rA 67 | \SIrange{`!p snip.rv = match.group(1)`}{`!p snip.rv = match.group(2)`}{\celsius}$0 68 | endsnippet 69 | 70 | # Usage: visual select number, press tab, type ;dc 71 | priority 10 72 | snippet adc "Degree celsius" wA 73 | \SI{`!p snip.rv = re.search("(\d+\.\d+|\d+)", snip.v.text).group()`}{\celsius}$0 74 | endsnippet 75 | 76 | # vim:ts=2 sw=2 noexpandtab 77 | -------------------------------------------------------------------------------- /ultisnips/tex/tables.snippets: -------------------------------------------------------------------------------- 1 | # Author: Neel Basak 2 | # Github: https://github.com/Neelfrost 3 | # File: tables.snippets 4 | # Requires: tabularx, tabulary, array packages 5 | 6 | global !p 7 | def create_row_placeholders(snip): 8 | # retrieving single line from current string and treat it like tabstops 9 | # count 10 | placeholders_amount = int(snip.buffer[snip.line].strip()) 11 | 12 | # erase current line 13 | snip.buffer[snip.line] = '' 14 | 15 | # create anonymous snippet with expected content and number of tabstops 16 | anon_snippet_body = ' & '.join(['$' + str(i+1) for i in range(placeholders_amount)]) 17 | 18 | # expand anonymous snippet 19 | snip.expand_anon(anon_snippet_body + r"\\\\") 20 | endglobal 21 | 22 | # ---------------------------- Table environments ---------------------------- # 23 | 24 | snippet tab "Table env" b 25 | \begin{table}[htb!] 26 | \centering 27 | \caption{${1:Caption}} 28 | \begin{tabular}{$2} 29 | $3 30 | \end{tabular} 31 | \end{table}$0 32 | endsnippet 33 | 34 | snippet tabl "Table env with label" b 35 | \begin{table}[htb!] 36 | \centering 37 | \caption{${1:Caption}}% 38 | \label{table:${4:Label}} 39 | \begin{tabular}{$2} 40 | $3 41 | \end{tabular} 42 | \end{table}$0 43 | endsnippet 44 | 45 | snippet tabx "Tabularx env" b 46 | \begin{table}[htb!] 47 | \centering 48 | \caption{${1:Caption}} 49 | \begin{tabularx}{\linewidth}{$2} 50 | $3 51 | \end{tabularx} 52 | \end{table}$0 53 | endsnippet 54 | 55 | snippet tabxl "Tabularx env with label" b 56 | \begin{table}[htb!] 57 | \centering 58 | \caption{${1:Caption}}% 59 | \label{table:${4:Label}} 60 | \begin{tabularx}{\linewidth}{$2} 61 | $3 62 | \end{tabularx} 63 | \end{table}$0 64 | endsnippet 65 | 66 | snippet taby "Tabulary env" b 67 | \begin{table}[htb!] 68 | \centering 69 | \caption{${1:Caption}} 70 | \begin{tabulary}{\linewidth}{$2} 71 | $3 72 | \end{tabulary} 73 | \end{table}$0 74 | endsnippet 75 | 76 | snippet tabyl "Tabulary env with label" b 77 | \begin{table}[htb!] 78 | \centering 79 | \caption{${1:Caption}}% 80 | \label{table:${4:Label}} 81 | \begin{tabulary}{\linewidth}{$2} 82 | $3 83 | \end{tabulary} 84 | \end{table}$0 85 | endsnippet 86 | 87 | # Creates: x x x x x x 88 | # Usage: x*6, where x can be: l, c, r, p{}, m{}, X (tabularx), CLRJ (tabulary) 89 | snippet '(\w+)\*(\d+)' "Non-centered tabular columns" r 90 | `!p 91 | col_str = str(match.group(1)) 92 | col_count = int(match.group(2)) 93 | snip.rv = col_str*col_count 94 | ` 95 | endsnippet 96 | 97 | # Creates: |x|x|x|x|x|x| 98 | # Usage: x*6, where x can be: l, c, r, p{}, m{}, X (tabularx), CLRJ (tabulary) 99 | snippet '\|(\w+)\*(\d+)' "Non-centered tabular columns" r 100 | `!p 101 | col_str = "|" + str(match.group(1)) 102 | col_count = int(match.group(2)) 103 | snip.rv = col_str*col_count + "|" 104 | ` 105 | endsnippet 106 | 107 | # Needs array package 108 | # Creates: |>{\centering\arraybackslash}x|>{\centering\arraybackslash}x| 109 | # Usage: c-x*2, where x can be: l, c, r, p{}, m{}, X (tabularx), CLRJ (tabulary) 110 | priority 10 111 | snippet '\|c-(\S+)\*(\d+)' "Centered tabular columns" r 112 | `!p 113 | col_str = r"|>{\centering\arraybackslash}" + str(match.group(1)) 114 | col_count = int(match.group(2)) 115 | snip.rv = col_str*col_count + "|" 116 | ` 117 | endsnippet 118 | 119 | post_jump "create_row_placeholders(snip)" 120 | snippet "tr(\d+)" "latex table row variable" br 121 | `!p snip.rv = match.group(1)` 122 | endsnippet 123 | 124 | # vim:ts=2 sw=2 noexpandtab 125 | -------------------------------------------------------------------------------- /ultisnips/tex/tikz.snippets: -------------------------------------------------------------------------------- 1 | # Author: Neel Basak 2 | # Github: https://github.com/Neelfrost 3 | # File: tikz.snippets 4 | 5 | # ----------------------------------- Tikz ----------------------------------- # 6 | 7 | snippet node "Tikz node" b 8 | \node[ 9 | ${1:Params} 10 | ] (${2/(\w)/\l$1/g}) {${2:Text}};$0 11 | endsnippet 12 | 13 | snippet draw "Draw tikz node" b 14 | \draw[arrow] (${1:From}) ${2:Line} (${3:To}); 15 | endsnippet 16 | 17 | # vim:ts=2 sw=2 noexpandtab 18 | -------------------------------------------------------------------------------- /viml/autocommands.vim: -------------------------------------------------------------------------------- 1 | " Save current view settings on a per-window, per-buffer basis. 2 | function! AutoSaveWinView() 3 | if !exists("w:SavedBufView") 4 | let w:SavedBufView = {} 5 | endif 6 | let w:SavedBufView[bufnr("%")] = winsaveview() 7 | endfunction 8 | 9 | " Restore current view settings. 10 | function! AutoRestoreWinView() 11 | let buf = bufnr("%") 12 | if exists("w:SavedBufView") && has_key(w:SavedBufView, buf) 13 | let v = winsaveview() 14 | let atStartOfFile = v.lnum == 1 && v.col == 0 15 | if atStartOfFile && !&diff 16 | call winrestview(w:SavedBufView[buf]) 17 | endif 18 | unlet w:SavedBufView[buf] 19 | endif 20 | endfunction 21 | 22 | augroup RESTORE_WIN_VIEW 23 | autocmd! 24 | autocmd BufLeave * call AutoSaveWinView() 25 | autocmd BufEnter * call AutoRestoreWinView() 26 | augroup END 27 | -------------------------------------------------------------------------------- /viml/utils.vim: -------------------------------------------------------------------------------- 1 | " Sort lines based on length 2 | function! SortLines() range 3 | execute a:firstline . ',' . a:lastline 4 | \ . 's/^\(.*\)$/\=strdisplaywidth( submatch(0) ) . " " . submatch(0)/' 5 | execute a:firstline . ',' . a:lastline . 'sort n' 6 | execute a:firstline . ',' . a:lastline . 's/^\d\+\s//' 7 | redraw! 8 | endfunction 9 | command! -range Sort ,call SortLines() 10 | 11 | " Redirect the output of a Vim or external command into a scratch buffer 12 | function! Redir(cmd) 13 | if a:cmd =~ '^!' 14 | execute "let output = system('" . substitute(a:cmd, '^!', '', '') . "')" 15 | else 16 | redir => output 17 | execute a:cmd 18 | redir END 19 | endif 20 | vnew 21 | setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile 22 | call setline(1, split(output, "\n")) 23 | put! = a:cmd 24 | endfunction 25 | command! -nargs=1 Redir silent call Redir() 26 | 27 | " https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript 28 | function! GetVisualSelection() 29 | let [line_start, column_start] = getpos("'<")[1:2] 30 | let [line_end, column_end] = getpos("'>")[1:2] 31 | let lines = getline(line_start, line_end) 32 | if len(lines) == 0 33 | return '' 34 | endif 35 | let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)] 36 | let lines[0] = lines[0][column_start - 1:] 37 | return join(lines, "\n") 38 | endfunction 39 | 40 | " https://stackoverflow.com/questions/676600/vim-search-and-replace-selected-text/6171215#6171215 41 | function! EscapeString (string) 42 | let string=a:string 43 | " Escape regex characters 44 | let string = escape(string, '^$.*\/~[]') 45 | " Escape the line endings 46 | let string = substitute(string, '\n', '\\n', 'g') 47 | return string 48 | endfunction 49 | --------------------------------------------------------------------------------