├── .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 |
18 |
23 |
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 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 
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 |
260 | Compile running
261 |
265 | Compile success
266 |
270 | Compile failed
271 |
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 .. "