Compare commits
17 Commits
6c9a94e600
...
87846dc87c
| Author | SHA1 | Date |
|---|---|---|
|
|
87846dc87c | |
|
|
a882fc5d24 | |
|
|
bd4d79f7f3 | |
|
|
044ebe7bff | |
|
|
1b6c7bdf45 | |
|
|
3fc7120f1b | |
|
|
5ed85f9cf9 | |
|
|
4ec5add8ce | |
|
|
8402b24466 | |
|
|
1418ed2435 | |
|
|
a57e14db1a | |
|
|
2b4f2987c2 | |
|
|
2adcea052c | |
|
|
48e9082bf8 | |
|
|
1fd3c1d354 | |
|
|
f976a7cba6 | |
|
|
0081252e35 |
45
README.md
45
README.md
|
|
@ -1,5 +1,9 @@
|
||||||
# kickstart.nvim
|
# kickstart.nvim
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone ssh://git@forgejo.galard.uk:222/franchioping/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
|
||||||
|
```
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
A starting point for Neovim that is:
|
A starting point for Neovim that is:
|
||||||
|
|
@ -22,24 +26,24 @@ If you are experiencing issues, please make sure you have the latest versions.
|
||||||
### Install External Dependencies
|
### Install External Dependencies
|
||||||
|
|
||||||
External Requirements:
|
External Requirements:
|
||||||
- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`)
|
* Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`)
|
||||||
- [ripgrep](https://github.com/BurntSushi/ripgrep#installation)
|
* [ripgrep](https://github.com/BurntSushi/ripgrep#installation)
|
||||||
- Clipboard tool (xclip/xsel/win32yank or other depending on the platform)
|
* Clipboard tool (xclip/xsel/win32yank or other depending on the platform)
|
||||||
- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons
|
* A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons
|
||||||
- if you have it set `vim.g.have_nerd_font` in `init.lua` to true
|
* if you have it set `vim.g.have_nerd_font` in `init.lua` to true
|
||||||
- Language Setup:
|
* Language Setup:
|
||||||
- If you want to write Typescript, you need `npm`
|
* If you want to write Typescript, you need `npm`
|
||||||
- If you want to write Golang, you will need `go`
|
* If you want to write Golang, you will need `go`
|
||||||
- etc.
|
* etc.
|
||||||
|
|
||||||
> **NOTE**
|
> **NOTE**
|
||||||
> See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes
|
> See [Install Recipes](#install-recipes) for additional Windows and Linux specific notes
|
||||||
> and quick install snippets
|
> and quick install snippets
|
||||||
|
|
||||||
### Install Kickstart
|
### Install Kickstart
|
||||||
|
|
||||||
> **NOTE**
|
> **NOTE**
|
||||||
> [Backup](#FAQ) your previous configuration (if any exists)
|
> [Backup](#faq) your previous configuration (if any exists)
|
||||||
|
|
||||||
Neovim's configurations are located under the following paths, depending on your OS:
|
Neovim's configurations are located under the following paths, depending on your OS:
|
||||||
|
|
||||||
|
|
@ -64,6 +68,7 @@ too - it's ignored in the kickstart repo to make maintenance easier, but it's
|
||||||
[recommended to track it in version control](https://lazy.folke.io/usage/lockfile).
|
[recommended to track it in version control](https://lazy.folke.io/usage/lockfile).
|
||||||
|
|
||||||
#### Clone kickstart.nvim
|
#### Clone kickstart.nvim
|
||||||
|
>
|
||||||
> **NOTE**
|
> **NOTE**
|
||||||
> If following the recommended step above (i.e., forking the repo), replace
|
> If following the recommended step above (i.e., forking the repo), replace
|
||||||
> `nvim-lua` with `<your_github_username>` in the commands below
|
> `nvim-lua` with `<your_github_username>` in the commands below
|
||||||
|
|
@ -112,7 +117,6 @@ examples of adding popularly requested plugins.
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> For more information about a particular plugin check its repository's documentation.
|
> For more information about a particular plugin check its repository's documentation.
|
||||||
|
|
||||||
|
|
||||||
### Getting Started
|
### Getting Started
|
||||||
|
|
||||||
[The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o)
|
[The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o)
|
||||||
|
|
@ -127,9 +131,11 @@ examples of adding popularly requested plugins.
|
||||||
* Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME`
|
* Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME`
|
||||||
to maintain multiple configurations. For example, you can install the kickstart
|
to maintain multiple configurations. For example, you can install the kickstart
|
||||||
configuration in `~/.config/nvim-kickstart` and create an alias:
|
configuration in `~/.config/nvim-kickstart` and create an alias:
|
||||||
|
|
||||||
```
|
```
|
||||||
alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim'
|
alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim'
|
||||||
```
|
```
|
||||||
|
|
||||||
When you run Neovim using `nvim-kickstart` alias it will use the alternative
|
When you run Neovim using `nvim-kickstart` alias it will use the alternative
|
||||||
config directory and the matching local directory
|
config directory and the matching local directory
|
||||||
`~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim
|
`~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim
|
||||||
|
|
@ -151,7 +157,7 @@ examples of adding popularly requested plugins.
|
||||||
|
|
||||||
Below you can find OS specific install instructions for Neovim and dependencies.
|
Below you can find OS specific install instructions for Neovim and dependencies.
|
||||||
|
|
||||||
After installing all the dependencies continue with the [Install Kickstart](#Install-Kickstart) step.
|
After installing all the dependencies continue with the [Install Kickstart](#install-kickstart) step.
|
||||||
|
|
||||||
#### Windows Installation
|
#### Windows Installation
|
||||||
|
|
||||||
|
|
@ -162,11 +168,12 @@ See `telescope-fzf-native` documentation for [more details](https://github.com/n
|
||||||
|
|
||||||
This requires:
|
This requires:
|
||||||
|
|
||||||
- Install CMake and the Microsoft C++ Build Tools on Windows
|
* Install CMake and the Microsoft C++ Build Tools on Windows
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
|
{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details><summary>Windows with gcc/make using chocolatey</summary>
|
<details><summary>Windows with gcc/make using chocolatey</summary>
|
||||||
Alternatively, one can install gcc and make which don't require changing the config,
|
Alternatively, one can install gcc and make which don't require changing the config,
|
||||||
|
|
@ -175,15 +182,18 @@ the easiest way is to use choco:
|
||||||
1. install [chocolatey](https://chocolatey.org/install)
|
1. install [chocolatey](https://chocolatey.org/install)
|
||||||
either follow the instructions on the page or use winget,
|
either follow the instructions on the page or use winget,
|
||||||
run in cmd as **admin**:
|
run in cmd as **admin**:
|
||||||
|
|
||||||
```
|
```
|
||||||
winget install --accept-source-agreements chocolatey.chocolatey
|
winget install --accept-source-agreements chocolatey.chocolatey
|
||||||
```
|
```
|
||||||
|
|
||||||
2. install all requirements using choco, exit the previous cmd and
|
2. install all requirements using choco, exit the previous cmd and
|
||||||
open a new one so that choco path is set, and run in cmd as **admin**:
|
open a new one so that choco path is set, and run in cmd as **admin**:
|
||||||
|
|
||||||
```
|
```
|
||||||
choco install -y neovim git ripgrep wget fd unzip gzip mingw make
|
choco install -y neovim git ripgrep wget fd unzip gzip mingw make
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details><summary>WSL (Windows Subsystem for Linux)</summary>
|
<details><summary>WSL (Windows Subsystem for Linux)</summary>
|
||||||
|
|
||||||
|
|
@ -194,9 +204,11 @@ sudo add-apt-repository ppa:neovim-ppa/unstable -y
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install make gcc ripgrep unzip git xclip neovim
|
sudo apt install make gcc ripgrep unzip git xclip neovim
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
#### Linux Install
|
#### Linux Install
|
||||||
|
|
||||||
<details><summary>Ubuntu Install Steps</summary>
|
<details><summary>Ubuntu Install Steps</summary>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
@ -204,6 +216,7 @@ sudo add-apt-repository ppa:neovim-ppa/unstable -y
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install make gcc ripgrep unzip git xclip neovim
|
sudo apt install make gcc ripgrep unzip git xclip neovim
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details><summary>Debian Install Steps</summary>
|
<details><summary>Debian Install Steps</summary>
|
||||||
|
|
||||||
|
|
@ -221,12 +234,14 @@ sudo tar -C /opt -xzf nvim-linux64.tar.gz
|
||||||
# make it available in /usr/local/bin, distro installs to /usr/bin
|
# make it available in /usr/local/bin, distro installs to /usr/bin
|
||||||
sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/
|
sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details><summary>Fedora Install Steps</summary>
|
<details><summary>Fedora Install Steps</summary>
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo dnf install -y gcc make git ripgrep fd-find unzip neovim
|
sudo dnf install -y gcc make git ripgrep fd-find unzip neovim
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details><summary>Arch Install Steps</summary>
|
<details><summary>Arch Install Steps</summary>
|
||||||
|
|
@ -234,5 +249,5 @@ sudo dnf install -y gcc make git ripgrep fd-find unzip neovim
|
||||||
```
|
```
|
||||||
sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim
|
sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
vim.opt_local.spell = true
|
||||||
|
vim.opt_local.spelllang = { 'en_us', 'pt_PT' }
|
||||||
311
init.lua
311
init.lua
|
|
@ -87,11 +87,17 @@ P.S. You can delete this when you're done too. It's your config now! :)
|
||||||
-- Set <space> as the leader key
|
-- Set <space> as the leader key
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
||||||
|
--
|
||||||
|
-- autocomplete
|
||||||
|
vim.o.pumheight = 20
|
||||||
|
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ','
|
||||||
|
|
||||||
|
vim.g.tex_flavor = 'latex'
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = true
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.opt`
|
-- See `:help vim.opt`
|
||||||
|
|
@ -102,7 +108,7 @@ vim.g.have_nerd_font = false
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- Experiment for yourself to see if you like it!
|
||||||
-- vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|
@ -156,6 +162,10 @@ vim.opt.cursorline = true
|
||||||
-- Minimal number of screen lines to keep above and below the cursor.
|
-- Minimal number of screen lines to keep above and below the cursor.
|
||||||
vim.opt.scrolloff = 10
|
vim.opt.scrolloff = 10
|
||||||
|
|
||||||
|
-- vim.cmd 'set expandtab'
|
||||||
|
|
||||||
|
vim.opt.smartindent = false
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
|
|
||||||
|
|
@ -164,7 +174,7 @@ vim.opt.scrolloff = 10
|
||||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
-- Diagnostic keymaps
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
vim.keymap.set('n', '<leader>h', vim.diagnostic.setloclist, { desc = 'Open Diagnostic Quickfix list' })
|
||||||
|
|
||||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
||||||
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
||||||
|
|
@ -315,13 +325,9 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- Document existing key chains
|
-- Document existing key chains
|
||||||
spec = {
|
spec = {
|
||||||
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
|
{ '<leader>f', group = 'Telescope Find' },
|
||||||
{ '<leader>d', group = '[D]ocument' },
|
{ '<leader>c', group = 'Config Toggle' },
|
||||||
{ '<leader>r', group = '[R]ename' },
|
{ '<leader>h', group = 'Help Errors', mode = { 'n', 'v' } },
|
||||||
{ '<leader>s', group = '[S]earch' },
|
|
||||||
{ '<leader>w', group = '[W]orkspace' },
|
|
||||||
{ '<leader>t', group = '[T]oggle' },
|
|
||||||
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -402,39 +408,39 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
-- See `:help telescope.builtin`
|
||||||
local builtin = require 'telescope.builtin'
|
local builtin = require 'telescope.builtin'
|
||||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope Help Tags' })
|
||||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
vim.keymap.set('n', '<leader>fk', builtin.keymaps, { desc = 'Telescope Keymaps' })
|
||||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope Find Files' })
|
||||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
-- vim.keymap.set('n', '<leader>fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' })
|
||||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
-- vim.keymap.set('n', '<leader>fw', builtin.grep_string, { desc = '[F]ind current [W]ord' })
|
||||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope Live Grep' })
|
||||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
-- vim.keymap.set('n', '<leader>fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' })
|
||||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
-- vim.keymap.set('n', '<leader>fr', builtin.resume, { desc = '[F]ind [R]esume' })
|
||||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
-- vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' })
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = 'Telescope Buffers' })
|
||||||
|
|
||||||
-- Slightly advanced example of overriding default behavior and theme
|
-- Slightly advanced example of overriding default behavior and theme
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
-- vim.keymap.set('n', '<leader>/', function()
|
||||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
-- builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||||
winblend = 10,
|
-- winblend = 10,
|
||||||
previewer = false,
|
-- previewer = false,
|
||||||
})
|
-- })
|
||||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
-- end, { desc = '[/] Fuzzily search in current buffer' })
|
||||||
|
|
||||||
-- It's also possible to pass additional configuration options.
|
-- It's also possible to pass additional configuration options.
|
||||||
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
||||||
vim.keymap.set('n', '<leader>s/', function()
|
vim.keymap.set('n', '<leader>f/', function()
|
||||||
builtin.live_grep {
|
builtin.live_grep {
|
||||||
grep_open_files = true,
|
grep_open_files = true,
|
||||||
prompt_title = 'Live Grep in Open Files',
|
prompt_title = 'Live Grep in Open Files',
|
||||||
}
|
}
|
||||||
end, { desc = '[S]earch [/] in Open Files' })
|
end, { desc = 'Telescope Live Grep in Open Files' })
|
||||||
|
|
||||||
-- Shortcut for searching your Neovim configuration files
|
-- Shortcut for searching your Neovim configuration files
|
||||||
vim.keymap.set('n', '<leader>sn', function()
|
vim.keymap.set('n', '<leader>fn', function()
|
||||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||||
end, { desc = '[S]earch [N]eovim files' })
|
end, { desc = 'Telescope Nvim Files' })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -460,7 +466,7 @@ require('lazy').setup({
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
|
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
|
||||||
{ 'williamboman/mason.nvim', opts = {} },
|
{ 'williamboman/mason.nvim', opts = {} },
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
-- 'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||||
|
|
||||||
-- Useful status updates for LSP.
|
-- Useful status updates for LSP.
|
||||||
{ 'j-hui/fidget.nvim', opts = {} },
|
{ 'j-hui/fidget.nvim', opts = {} },
|
||||||
|
|
@ -469,6 +475,37 @@ require('lazy').setup({
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
|
vim.lsp.config('clangd', {
|
||||||
|
cmd = { 'clangd' },
|
||||||
|
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
||||||
|
autostart = true,
|
||||||
|
})
|
||||||
|
vim.lsp.enable 'clangd'
|
||||||
|
if os.getenv 'NVIM_ESP32_ENV' then
|
||||||
|
local query_driver = os.getenv 'CLANGD_QUERY_DRIVER'
|
||||||
|
vim.lsp.config('clangd', {
|
||||||
|
cmd = {
|
||||||
|
'clangd',
|
||||||
|
'--compile-commands-dir=' .. 'build',
|
||||||
|
'--background-index',
|
||||||
|
'--clang-tidy',
|
||||||
|
'--header-insertion=iwyu',
|
||||||
|
'--completion-style=detailed',
|
||||||
|
'--function-arg-placeholders',
|
||||||
|
'--fallback-style=llvm',
|
||||||
|
'--query-driver=' .. query_driver,
|
||||||
|
},
|
||||||
|
root_markers = { 'sdkconfig', 'CMakeLists.txt', '.git' },
|
||||||
|
capabilities = {
|
||||||
|
offsetEncoding = { 'utf-16' },
|
||||||
|
},
|
||||||
|
init_options = {
|
||||||
|
usePlaceholders = true,
|
||||||
|
completeUnimported = true,
|
||||||
|
clangdFileStatus = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
-- Brief aside: **What is LSP?**
|
-- Brief aside: **What is LSP?**
|
||||||
--
|
--
|
||||||
-- LSP is an initialism you've probably heard, but might not understand what it is.
|
-- LSP is an initialism you've probably heard, but might not understand what it is.
|
||||||
|
|
@ -514,39 +551,39 @@ require('lazy').setup({
|
||||||
-- Jump to the definition of the word under your cursor.
|
-- Jump to the definition of the word under your cursor.
|
||||||
-- This is where a variable was first declared, or where a function is defined, etc.
|
-- This is where a variable was first declared, or where a function is defined, etc.
|
||||||
-- To jump back, press <C-t>.
|
-- To jump back, press <C-t>.
|
||||||
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
map('gd', require('telescope.builtin').lsp_definitions, 'Goto Definition')
|
||||||
|
|
||||||
-- Find references for the word under your cursor.
|
-- Find references for the word under your cursor.
|
||||||
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
map('grr', require('telescope.builtin').lsp_references, 'Goto References')
|
||||||
|
|
||||||
-- Jump to the implementation of the word under your cursor.
|
-- Jump to the implementation of the word under your cursor.
|
||||||
-- Useful when your language has ways of declaring types without an actual implementation.
|
-- Useful when your language has ways of declaring types without an actual implementation.
|
||||||
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
map('gI', require('telescope.builtin').lsp_implementations, 'Goto Implementation')
|
||||||
|
|
||||||
-- Jump to the type of the word under your cursor.
|
-- Jump to the type of the word under your cursor.
|
||||||
-- Useful when you're not sure what type a variable is and you want to see
|
-- Useful when you're not sure what type a variable is and you want to see
|
||||||
-- the definition of its *type*, not where it was *defined*.
|
-- the definition of its *type*, not where it was *defined*.
|
||||||
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
map('gDt', require('telescope.builtin').lsp_type_definitions, 'Goto Type Definition')
|
||||||
|
|
||||||
-- Fuzzy find all the symbols in your current document.
|
-- Fuzzy find all the symbols in your current document.
|
||||||
-- Symbols are things like variables, functions, types, etc.
|
-- Symbols are things like variables, functions, types, etc.
|
||||||
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
map('<leader>fd', require('telescope.builtin').lsp_document_symbols, 'Telescope Document Symbols')
|
||||||
|
|
||||||
-- Fuzzy find all the symbols in your current workspace.
|
-- Fuzzy find all the symbols in your current workspace.
|
||||||
-- Similar to document symbols, except searches over your entire project.
|
-- Similar to document symbols, except searches over your entire project.
|
||||||
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
map('<leader>fw', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Telescope Workspace Symbols')
|
||||||
|
|
||||||
-- Rename the variable under your cursor.
|
-- Rename the variable under your cursor.
|
||||||
-- Most Language Servers support renaming across files, etc.
|
-- Most Language Servers support renaming across files, etc.
|
||||||
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
map('grn', vim.lsp.buf.rename, 'Rename')
|
||||||
|
|
||||||
-- Execute a code action, usually your cursor needs to be on top of an error
|
-- Execute a code action, usually your cursor needs to be on top of an error
|
||||||
-- or a suggestion from your LSP for this to activate.
|
-- or a suggestion from your LSP for this to activate.
|
||||||
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
|
map('gra', vim.lsp.buf.code_action, 'Code Action', { 'n', 'x' })
|
||||||
|
|
||||||
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
||||||
-- For example, in C this would take you to the header.
|
-- For example, in C this would take you to the header.
|
||||||
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
map('gDd', vim.lsp.buf.declaration, 'Goto Declaration')
|
||||||
|
|
||||||
-- The following two autocommands are used to highlight references of the
|
-- The following two autocommands are used to highlight references of the
|
||||||
-- word under your cursor when your cursor rests there for a little while.
|
-- word under your cursor when your cursor rests there for a little while.
|
||||||
|
|
@ -582,9 +619,9 @@ require('lazy').setup({
|
||||||
--
|
--
|
||||||
-- This may be unwanted, since they displace some of your code
|
-- This may be unwanted, since they displace some of your code
|
||||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
|
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
|
||||||
map('<leader>th', function()
|
map('<leader>ch', function()
|
||||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
|
||||||
end, '[T]oggle Inlay [H]ints')
|
end, 'Toggle Inlay Hints')
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
@ -606,6 +643,13 @@ require('lazy').setup({
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
|
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
|
||||||
|
|
||||||
|
local read_exec_path = function(exec_name)
|
||||||
|
local handle = io.popen('which ' .. exec_name)
|
||||||
|
local result = handle:read('*a'):gsub('\n', '')
|
||||||
|
handle:close()
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
-- Enable the following language servers
|
-- Enable the following language servers
|
||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
--
|
--
|
||||||
|
|
@ -616,17 +660,15 @@ require('lazy').setup({
|
||||||
-- - settings (table): Override the default settings passed when initializing the server.
|
-- - settings (table): Override the default settings passed when initializing the server.
|
||||||
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
|
||||||
-- gopls = {},
|
-- gopls = {},
|
||||||
-- pyright = {},
|
rust_analyzer = {},
|
||||||
-- rust_analyzer = {},
|
|
||||||
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
||||||
--
|
--
|
||||||
-- Some languages (like typescript) have entire language plugins that can be useful:
|
-- Some languages (like typescript) have entire language plugins that can be useful:
|
||||||
-- https://github.com/pmizio/typescript-tools.nvim
|
-- https://github.com/pmizio/typescript-tools.nvim
|
||||||
--
|
--
|
||||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
||||||
-- ts_ls = {},
|
ts_ls = {},
|
||||||
--
|
--
|
||||||
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
|
|
@ -639,7 +681,7 @@ require('lazy').setup({
|
||||||
callSnippet = 'Replace',
|
callSnippet = 'Replace',
|
||||||
},
|
},
|
||||||
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
||||||
-- diagnostics = { disable = { 'missing-fields' } },
|
diagnostics = { disable = { 'missing-fields' } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -658,11 +700,11 @@ require('lazy').setup({
|
||||||
--
|
--
|
||||||
-- You can add other tools here that you want Mason to install
|
-- You can add other tools here that you want Mason to install
|
||||||
-- for you, so that they are available from within Neovim.
|
-- for you, so that they are available from within Neovim.
|
||||||
local ensure_installed = vim.tbl_keys(servers or {})
|
-- local ensure_installed = vim.tbl_keys(servers or {})
|
||||||
vim.list_extend(ensure_installed, {
|
-- vim.list_extend(ensure_installed, {
|
||||||
'stylua', -- Used to format Lua code
|
-- 'stylua', -- Used to format Lua code
|
||||||
})
|
-- })
|
||||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
-- require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||||
|
|
||||||
require('mason-lspconfig').setup {
|
require('mason-lspconfig').setup {
|
||||||
handlers = {
|
handlers = {
|
||||||
|
|
@ -675,6 +717,7 @@ require('lazy').setup({
|
||||||
require('lspconfig')[server_name].setup(server)
|
require('lspconfig')[server_name].setup(server)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
-- automatic_installation = true,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
@ -685,36 +728,28 @@ require('lazy').setup({
|
||||||
cmd = { 'ConformInfo' },
|
cmd = { 'ConformInfo' },
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
'<leader>f',
|
'<leader>p',
|
||||||
function()
|
function()
|
||||||
require('conform').format { async = true, lsp_format = 'fallback' }
|
require('conform').format { async = true, lsp_format = 'fallback' }
|
||||||
end,
|
end,
|
||||||
mode = '',
|
mode = '',
|
||||||
desc = '[F]ormat buffer',
|
desc = 'format',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
notify_on_error = false,
|
notify_on_error = false,
|
||||||
format_on_save = function(bufnr)
|
format_on_save = {
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
timeout_ms = 5000,
|
||||||
-- have a well standardized coding style. You can add additional
|
lsp_format = true,
|
||||||
-- languages here or re-enable it for the disabled ones.
|
},
|
||||||
local disable_filetypes = { c = true, cpp = true }
|
|
||||||
local lsp_format_opt
|
|
||||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
|
||||||
lsp_format_opt = 'never'
|
|
||||||
else
|
|
||||||
lsp_format_opt = 'fallback'
|
|
||||||
end
|
|
||||||
return {
|
|
||||||
timeout_ms = 500,
|
|
||||||
lsp_format = lsp_format_opt,
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { 'stylua' },
|
lua = { 'stylua' },
|
||||||
|
markdown = { 'markdownlint' },
|
||||||
|
json = { 'fixjson', 'jq' },
|
||||||
|
c = { 'clang-format' },
|
||||||
|
cpp = { 'clang-format' },
|
||||||
-- Conform can also run multiple formatters sequentially
|
-- Conform can also run multiple formatters sequentially
|
||||||
-- python = { "isort", "black" },
|
python = { 'isort', 'black' },
|
||||||
--
|
--
|
||||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||||
|
|
@ -738,6 +773,9 @@ require('lazy').setup({
|
||||||
end
|
end
|
||||||
return 'make install_jsregexp'
|
return 'make install_jsregexp'
|
||||||
end)(),
|
end)(),
|
||||||
|
config = function(_, _)
|
||||||
|
require('luasnip.loaders.from_lua').lazy_load { paths = './lua/luasnippets/' }
|
||||||
|
end,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
-- See the README about individual language/framework/plugin snippets:
|
-- See the README about individual language/framework/plugin snippets:
|
||||||
|
|
@ -750,8 +788,10 @@ require('lazy').setup({
|
||||||
-- },
|
-- },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
'saadparwaiz1/cmp_luasnip',
|
'saadparwaiz1/cmp_luasnip',
|
||||||
|
-- dev = true,
|
||||||
|
},
|
||||||
-- Adds other completion capabilities.
|
-- Adds other completion capabilities.
|
||||||
-- nvim-cmp does not ship with all sources by default. They are split
|
-- nvim-cmp does not ship with all sources by default. They are split
|
||||||
-- into multiple repos for maintenance purposes.
|
-- into multiple repos for maintenance purposes.
|
||||||
|
|
@ -762,9 +802,56 @@ require('lazy').setup({
|
||||||
-- See `:help cmp`
|
-- See `:help cmp`
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
luasnip.config.setup {}
|
luasnip.config.setup { enable_autosnippets = true }
|
||||||
|
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
|
formatting = {
|
||||||
|
fields = { 'abbr', 'menu', 'kind' },
|
||||||
|
format = function(entry, item)
|
||||||
|
-- Define menu shorthand for different completion sources.
|
||||||
|
local menu_icon = {
|
||||||
|
nvim_lsp = 'NLSP',
|
||||||
|
nvim_lua = 'NLUA',
|
||||||
|
luasnip = 'LSNP',
|
||||||
|
buffer = 'BUFF',
|
||||||
|
path = 'PATH',
|
||||||
|
}
|
||||||
|
-- Set the menu "icon" to the shorthand for each completion source.
|
||||||
|
item.menu = menu_icon[entry.source.name]
|
||||||
|
|
||||||
|
-- Set the fixed width of the completion menu to 60 characters.
|
||||||
|
fixed_width = 20
|
||||||
|
|
||||||
|
-- Set 'fixed_width' to false if not provided.
|
||||||
|
FixedWidth = FixedWidth or false
|
||||||
|
|
||||||
|
-- Get the completion entry text shown in the completion window.
|
||||||
|
local content = item.abbr
|
||||||
|
|
||||||
|
-- Set the fixed completion window width.
|
||||||
|
if FixedWidth then
|
||||||
|
vim.o.pumwidth = FixedWidth
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the width of the current window.
|
||||||
|
local win_width = vim.api.nvim_win_get_width(0)
|
||||||
|
|
||||||
|
-- Set the max content width based on either: 'fixed_width'
|
||||||
|
-- or a percentage of the window width, in this case 20%.
|
||||||
|
-- We subtract 10 from 'fixed_width' to leave room for 'kind' fields.
|
||||||
|
local max_content_width = FixedWidth and FixedWidth - 10 or math.floor(win_width * 0.2)
|
||||||
|
|
||||||
|
-- Truncate the completion entry text if it's longer than the
|
||||||
|
-- max content width. We subtract 3 from the max content width
|
||||||
|
-- to account for the "..." that will be appended to it.
|
||||||
|
if #content > max_content_width then
|
||||||
|
item.abbr = vim.fn.strcharpart(content, 0, max_content_width - 3) .. '...'
|
||||||
|
else
|
||||||
|
item.abbr = content .. (' '):rep(max_content_width - #content)
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end,
|
||||||
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
|
|
@ -789,7 +876,7 @@ require('lazy').setup({
|
||||||
-- Accept ([y]es) the completion.
|
-- Accept ([y]es) the completion.
|
||||||
-- This will auto-import if your LSP supports it.
|
-- This will auto-import if your LSP supports it.
|
||||||
-- This will expand snippets if the LSP sent a snippet.
|
-- This will expand snippets if the LSP sent a snippet.
|
||||||
['<C-y>'] = cmp.mapping.confirm { select = true },
|
['<C-Space>'] = cmp.mapping.confirm { select = true },
|
||||||
|
|
||||||
-- If you prefer more traditional completion keymaps,
|
-- If you prefer more traditional completion keymaps,
|
||||||
-- you can uncomment the following lines
|
-- you can uncomment the following lines
|
||||||
|
|
@ -800,7 +887,7 @@ require('lazy').setup({
|
||||||
-- Manually trigger a completion from nvim-cmp.
|
-- Manually trigger a completion from nvim-cmp.
|
||||||
-- Generally you don't need this, because nvim-cmp will display
|
-- Generally you don't need this, because nvim-cmp will display
|
||||||
-- completions whenever it has completion options available.
|
-- completions whenever it has completion options available.
|
||||||
['<C-Space>'] = cmp.mapping.complete {},
|
['<C-S-Space>'] = cmp.mapping.complete {},
|
||||||
|
|
||||||
-- Think of <c-l> as moving to the right of your snippet expansion.
|
-- Think of <c-l> as moving to the right of your snippet expansion.
|
||||||
-- So if you have a snippet that's like:
|
-- So if you have a snippet that's like:
|
||||||
|
|
@ -810,12 +897,12 @@ require('lazy').setup({
|
||||||
--
|
--
|
||||||
-- <c-l> will move you to the right of each of the expansion locations.
|
-- <c-l> will move you to the right of each of the expansion locations.
|
||||||
-- <c-h> is similar, except moving you backwards.
|
-- <c-h> is similar, except moving you backwards.
|
||||||
['<C-l>'] = cmp.mapping(function()
|
['<Tab>'] = cmp.mapping(function()
|
||||||
if luasnip.expand_or_locally_jumpable() then
|
if luasnip.locally_jumpable(1) then
|
||||||
luasnip.expand_or_jump()
|
luasnip.jump(1)
|
||||||
end
|
end
|
||||||
end, { 'i', 's' }),
|
end, { 'i', 's' }),
|
||||||
['<C-h>'] = cmp.mapping(function()
|
['<S-Tab>'] = cmp.mapping(function()
|
||||||
if luasnip.locally_jumpable(-1) then
|
if luasnip.locally_jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
end
|
end
|
||||||
|
|
@ -831,28 +918,46 @@ require('lazy').setup({
|
||||||
group_index = 0,
|
group_index = 0,
|
||||||
},
|
},
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'luasnip' },
|
{
|
||||||
|
name = 'luasnip',
|
||||||
|
option = {
|
||||||
|
show_autosnippets = true,
|
||||||
|
use_show_condition = false,
|
||||||
|
-- label_aliases = {
|
||||||
|
-- ['(?<!\\\\)(sec)'] = 'sec',
|
||||||
|
-- ['(?<!\\\\)(sec*)'] = 'sec*',
|
||||||
|
-- },
|
||||||
|
},
|
||||||
|
},
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- You can easily change to a different colorscheme.
|
-- { -- You can easily change to a different colorscheme.
|
||||||
-- Change the name of the colorscheme plugin below, and then
|
-- -- Change the name of the colorscheme plugin below, and then
|
||||||
-- change the command in the config to whatever the name of that colorscheme is.
|
-- -- change the command in the config to whatever the name of that colorscheme is.
|
||||||
|
-- --
|
||||||
|
-- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
||||||
|
-- 'folke/tokyonight.nvim',
|
||||||
|
-- priority = 1000, -- Make sure to load this before all the other start plugins.
|
||||||
|
-- init = function()
|
||||||
|
-- -- Load the colorscheme here.
|
||||||
|
-- -- Like many other themes, this one has different styles, and you could load
|
||||||
|
-- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||||
|
-- vim.cmd.colorscheme 'tokyonight-night'
|
||||||
--
|
--
|
||||||
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
-- -- You can configure highlights by doing something like:
|
||||||
'folke/tokyonight.nvim',
|
-- vim.cmd.hi 'Comment gui=none'
|
||||||
priority = 1000, -- Make sure to load this before all the other start plugins.
|
-- end,
|
||||||
|
-- },
|
||||||
|
{
|
||||||
|
'ellisonleao/gruvbox.nvim',
|
||||||
|
priority = 1000,
|
||||||
init = function()
|
init = function()
|
||||||
-- Load the colorscheme here.
|
vim.o.background = 'dark'
|
||||||
-- Like many other themes, this one has different styles, and you could load
|
vim.cmd.colorscheme 'gruvbox'
|
||||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
|
||||||
|
|
||||||
-- You can configure highlights by doing something like:
|
|
||||||
vim.cmd.hi 'Comment gui=none'
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -911,6 +1016,7 @@ require('lazy').setup({
|
||||||
-- If you are experiencing weird indenting issues, add the language to
|
-- If you are experiencing weird indenting issues, add the language to
|
||||||
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
|
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
|
||||||
additional_vim_regex_highlighting = { 'ruby' },
|
additional_vim_regex_highlighting = { 'ruby' },
|
||||||
|
disable = { 'latex' },
|
||||||
},
|
},
|
||||||
indent = { enable = true, disable = { 'ruby' } },
|
indent = { enable = true, disable = { 'ruby' } },
|
||||||
},
|
},
|
||||||
|
|
@ -933,8 +1039,8 @@ require('lazy').setup({
|
||||||
--
|
--
|
||||||
-- require 'kickstart.plugins.debug',
|
-- require 'kickstart.plugins.debug',
|
||||||
-- require 'kickstart.plugins.indent_line',
|
-- require 'kickstart.plugins.indent_line',
|
||||||
-- require 'kickstart.plugins.lint',
|
require 'kickstart.plugins.lint',
|
||||||
-- require 'kickstart.plugins.autopairs',
|
require 'kickstart.plugins.autopairs',
|
||||||
-- require 'kickstart.plugins.neo-tree',
|
-- require 'kickstart.plugins.neo-tree',
|
||||||
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
||||||
|
|
||||||
|
|
@ -942,7 +1048,7 @@ require('lazy').setup({
|
||||||
-- This is the easiest way to modularize your config.
|
-- This is the easiest way to modularize your config.
|
||||||
--
|
--
|
||||||
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
||||||
-- { import = 'custom.plugins' },
|
{ import = 'custom.plugins' },
|
||||||
--
|
--
|
||||||
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
|
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
|
||||||
-- Or use telescope!
|
-- Or use telescope!
|
||||||
|
|
@ -968,7 +1074,18 @@ require('lazy').setup({
|
||||||
lazy = '💤 ',
|
lazy = '💤 ',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
dev = {
|
||||||
|
-- Directory where you store your local plugin projects. If a function is used,
|
||||||
|
-- the plugin directory (e.g. `~/projects/plugin-name`) must be returned.
|
||||||
|
---@type string | fun(plugin: LazyPlugin): string
|
||||||
|
path = './devplugins',
|
||||||
|
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
|
||||||
|
patterns = {}, -- For example {"folke"}
|
||||||
|
fallback = true, -- Fallback to git when local plugin doesn't exist
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
require 'custom.custom-keybinds'
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" },
|
||||||
|
"ccc.nvim": { "branch": "main", "commit": "9d1a256e006decc574789dfc7d628ca11644d4c2" },
|
||||||
|
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
|
||||||
|
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||||
|
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||||
|
"conform.nvim": { "branch": "master", "commit": "ffe26e8df8115c9665d24231f8a49fadb2d611ce" },
|
||||||
|
"esp32.nvim": { "branch": "main", "commit": "7b929bd908ba7358b073d1923832cd8d2e682503" },
|
||||||
|
"fidget.nvim": { "branch": "main", "commit": "e32b672d8fd343f9d6a76944fedb8c61d7d8111a" },
|
||||||
|
"gitsigns.nvim": { "branch": "main", "commit": "5813e4878748805f1518cee7abb50fd7205a3a48" },
|
||||||
|
"gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
|
||||||
|
"lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" },
|
||||||
|
"leetcode.nvim": { "branch": "master", "commit": "fdd3f91800b3983e27bc9fcfb99cfa7293d7f11a" },
|
||||||
|
"luasnip-latex-snippets.nvim": { "branch": "main", "commit": "57e4330f967da6ac64bf9b05b06ecb3c4a120ec3" },
|
||||||
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "0b9bb925c000ae649ff7e7149c8cd00031f4b539" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" },
|
||||||
|
"mini.nvim": { "branch": "main", "commit": "e27fcecf6cbffd8ed391bdf0eb746fdb5b9bfa44" },
|
||||||
|
"neo-tree.nvim": { "branch": "v3.x", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" },
|
||||||
|
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||||
|
"nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" },
|
||||||
|
"nvim-cmp": { "branch": "main", "commit": "d97d85e01339f01b842e6ec1502f639b080cb0fc" },
|
||||||
|
"nvim-lint": { "branch": "master", "commit": "ebe535956106c60405b02220246e135910f6853d" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "9c923997123ff9071198ea3b594d4c1931fab169" },
|
||||||
|
"nvim-surround": { "branch": "main", "commit": "fcfa7e02323d57bfacc3a141f8a74498e1522064" },
|
||||||
|
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||||
|
"nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" },
|
||||||
|
"nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
|
"snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" },
|
||||||
|
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
||||||
|
"telescope-undo.nvim": { "branch": "main", "commit": "928d0c2dc9606e01e2cc547196f48d2eaecf58e5" },
|
||||||
|
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||||
|
"todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
|
||||||
|
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
|
||||||
|
"vimtex": { "branch": "master", "commit": "32bcb3922c20588e00de68f73c86312eda2141ad" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
-- local function map(mode, lhs, rhs, opts)
|
||||||
|
-- local options = { noremap = true, silent = true }
|
||||||
|
-- if opts then
|
||||||
|
-- if opts.desc then
|
||||||
|
-- opts.desc = 'keymaps.lua: ' .. opts.desc
|
||||||
|
-- end
|
||||||
|
-- options = vim.tbl_extend('force', options, opts)
|
||||||
|
-- end
|
||||||
|
-- vim.keymap.set(mode, lhs, rhs, options)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- vim.keymap.set('n', '<leader>/', 'gcc', { remap = true })
|
||||||
|
-- vim.keymap.set('v', '<leader>/', 'gc', { remap = true })
|
||||||
|
--
|
||||||
|
|
||||||
|
vim.keymap.set({ 'x', 'n' }, '<leader>d', '"_d', { remap = false, desc = 'Delete without copying' })
|
||||||
|
|
||||||
|
local operator_rhs = function()
|
||||||
|
return require('vim._comment').operator()
|
||||||
|
end
|
||||||
|
vim.keymap.set({ 'x' }, '<leader>/', operator_rhs, { expr = true, desc = 'Toggle comment' })
|
||||||
|
|
||||||
|
local line_rhs = function()
|
||||||
|
return require('vim._comment').operator() .. '_'
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', '<leader>/', line_rhs, { expr = true, desc = 'Toggle comment line' })
|
||||||
|
|
||||||
|
vim.g.tex_flavor = 'latex'
|
||||||
|
|
||||||
|
local list_snips = function()
|
||||||
|
local ft_list = require('luasnip').available()[vim.o.filetype]
|
||||||
|
local ft_snips = {}
|
||||||
|
for _, item in pairs(ft_list) do
|
||||||
|
ft_snips[item.trigger] = item.name
|
||||||
|
end
|
||||||
|
print(vim.inspect(ft_snips))
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command('SnipList', list_snips, {})
|
||||||
|
|
||||||
|
local list_all_snips = function()
|
||||||
|
local ft_lists = require('luasnip').available()
|
||||||
|
local ft_snips = {}
|
||||||
|
for _, ft_list in pairs(ft_lists) do
|
||||||
|
for _, item in pairs(ft_list) do
|
||||||
|
ft_snips[item.trigger] = item.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print(vim.inspect(ft_snips))
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command('SnipListAll', list_all_snips, {})
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
return {
|
||||||
|
-- {
|
||||||
|
-- 'akinsho/toggleterm.nvim',
|
||||||
|
-- version = '*',
|
||||||
|
-- opts = {--[[ things you want to change go here]]
|
||||||
|
-- },
|
||||||
|
-- keys = {
|
||||||
|
-- { '<leader>t', ':ToggleTerm direction=float<CR>', desc = 'Terminal', silent = true },
|
||||||
|
-- },
|
||||||
|
-- config = function()
|
||||||
|
-- local opts = { buffer = 0 }
|
||||||
|
-- vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
||||||
|
-- vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
|
||||||
|
-- vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||||||
|
-- vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||||||
|
-- vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||||||
|
-- vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||||||
|
-- vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
{
|
||||||
|
'windwp/nvim-ts-autotag',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'uga-rosa/ccc.nvim',
|
||||||
|
config = function()
|
||||||
|
local ccc = require 'ccc'
|
||||||
|
|
||||||
|
ccc.setup {
|
||||||
|
highlighter = {
|
||||||
|
auto_enable = true,
|
||||||
|
lsp = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'kylechui/nvim-surround',
|
||||||
|
version = '^3.0.0', -- Use for stability; omit to use `main` branch for the latest features
|
||||||
|
event = 'VeryLazy',
|
||||||
|
config = function()
|
||||||
|
require('nvim-surround').setup {
|
||||||
|
-- Configuration here, or leave empty to use defaults
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'Aietes/esp32.nvim',
|
||||||
|
opts = {
|
||||||
|
build_dir = 'build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'folke/todo-comments.nvim',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
-- You can add your own plugins here or in other files in this directory!
|
|
||||||
-- I promise not to create any merge conflicts in this directory :)
|
|
||||||
--
|
|
||||||
-- See the kickstart.nvim README for more information
|
|
||||||
return {}
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
return {
|
||||||
|
|
||||||
|
{
|
||||||
|
'lervag/vimtex',
|
||||||
|
lazy = false, -- we don't want to lazy load VimTeX
|
||||||
|
-- tag = "v2.15", -- uncomment to pin to a specific release
|
||||||
|
init = function()
|
||||||
|
-- VimTeX configuration goes here, e.g.
|
||||||
|
vim.g.vimtex_view_method = 'zathura'
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
vim.g.vimtex_compiler_latexmk = { ['out_dir'] = '/home/flima/Notes/build' }
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- {
|
||||||
|
-- 'franchioping/luasnip-latex-snippets.nvim',
|
||||||
|
-- dev = true,
|
||||||
|
-- },
|
||||||
|
{
|
||||||
|
'iurimateus/luasnip-latex-snippets.nvim',
|
||||||
|
-- vimtex isn't required if using treesitter
|
||||||
|
requires = { 'L3MON4D3/LuaSnip', 'lervag/vimtex' },
|
||||||
|
config = function()
|
||||||
|
require('luasnip-latex-snippets').setup()
|
||||||
|
-- or setup({ use_treesitter = true })
|
||||||
|
require('luasnip').config.setup { enable_autosnippets = true }
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- {
|
||||||
|
-- 'iurimateus/luasnip-latex-snippets.nvim',
|
||||||
|
-- -- vimtex isn't required if using treesitter
|
||||||
|
-- requires = { 'L3MON4D3/LuaSnip', 'lervag/vimtex' },
|
||||||
|
-- config = function()
|
||||||
|
-- require('luasnip-latex-snippets').setup()
|
||||||
|
-- -- or setup({ use_treesitter = true })
|
||||||
|
-- require('luasnip').config.setup { enable_autosnippets = true }
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'kawre/leetcode.nvim',
|
||||||
|
build = ':TSUpdate html', -- if you have `nvim-treesitter` installed
|
||||||
|
dependencies = {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
-- "ibhagwan/fzf-lua",
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
'MunifTanjim/nui.nvim',
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
-- configuration goes here
|
||||||
|
injector = {
|
||||||
|
['cpp'] = {
|
||||||
|
before = { '#include <bits/stdc++.h>', 'using namespace std;' },
|
||||||
|
after = 'int main() {}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
-- You can add your own plugins here or in other files in this directory!
|
||||||
|
-- I promise not to create any merge conflicts in this directory :)
|
||||||
|
--
|
||||||
|
-- See the kickstart.nvim README for more information
|
||||||
|
return {
|
||||||
|
|
||||||
|
{
|
||||||
|
'nvim-neo-tree/neo-tree.nvim',
|
||||||
|
branch = 'v3.x',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
|
||||||
|
'MunifTanjim/nui.nvim',
|
||||||
|
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
|
||||||
|
},
|
||||||
|
|
||||||
|
cmd = 'Neotree',
|
||||||
|
keys = {
|
||||||
|
{ '<leader>e', ':Neotree toggle<CR>', desc = 'Explorer', silent = true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
return {
|
||||||
|
'debugloop/telescope-undo.nvim',
|
||||||
|
dependencies = { -- note how they're inverted to above example
|
||||||
|
{
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ -- lazy style key map
|
||||||
|
'<leader>fu',
|
||||||
|
'<cmd>Telescope undo<cr>',
|
||||||
|
desc = 'Telescope Undo History',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
-- don't use `defaults = { }` here, do this in the main telescope spec
|
||||||
|
extensions = {
|
||||||
|
undo = {
|
||||||
|
-- telescope-undo.nvim config, see below
|
||||||
|
},
|
||||||
|
-- no other extensions here, they can have their own spec too
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
-- Calling telescope's setup from multiple specs does not hurt, it will happily merge the
|
||||||
|
-- configs for us. We won't use data, as everything is in it's own namespace (telescope
|
||||||
|
-- defaults, as well as each extension).
|
||||||
|
require('telescope').setup(opts)
|
||||||
|
require('telescope').load_extension 'undo'
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
@ -39,7 +39,7 @@ return {
|
||||||
-- lint.linters_by_ft['rst'] = nil
|
-- lint.linters_by_ft['rst'] = nil
|
||||||
-- lint.linters_by_ft['ruby'] = nil
|
-- lint.linters_by_ft['ruby'] = nil
|
||||||
-- lint.linters_by_ft['terraform'] = nil
|
-- lint.linters_by_ft['terraform'] = nil
|
||||||
-- lint.linters_by_ft['text'] = nil
|
lint.linters_by_ft['text'] = nil
|
||||||
|
|
||||||
-- Create autocommand which carries out the actual linting
|
-- Create autocommand which carries out the actual linting
|
||||||
-- on the specified events.
|
-- on the specified events.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
local s = ls.snippet
|
||||||
|
local sn = ls.snippet_node
|
||||||
|
local isn = ls.indent_snippet_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local c = ls.choice_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local r = ls.restore_node
|
||||||
|
local events = require 'luasnip.util.events'
|
||||||
|
local ai = require 'luasnip.nodes.absolute_indexer'
|
||||||
|
local extras = require 'luasnip.extras'
|
||||||
|
local l = extras.lambda
|
||||||
|
local rep = extras.rep
|
||||||
|
local p = extras.partial
|
||||||
|
local m = extras.match
|
||||||
|
local n = extras.nonempty
|
||||||
|
local dl = extras.dynamic_lambda
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
local fmta = require('luasnip.extras.fmt').fmta
|
||||||
|
local conds = require 'luasnip.extras.expand_conditions'
|
||||||
|
local postfix = require('luasnip.extras.postfix').postfix
|
||||||
|
local types = require 'luasnip.util.types'
|
||||||
|
local parse = require('luasnip.util.parser').parse_snippet
|
||||||
|
local ms = ls.multi_snippet
|
||||||
|
local k = require('luasnip.nodes.key_indexer').new_key
|
||||||
|
|
||||||
|
return {
|
||||||
|
s('date', t(os.date '%Y-%m-%d')),
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
--[
|
||||||
|
-- LuaSnip Conditions
|
||||||
|
--]
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- math / not math zones
|
||||||
|
|
||||||
|
function M.in_math()
|
||||||
|
return vim.api.nvim_eval 'vimtex#syntax#in_mathzone()' == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- comment detection
|
||||||
|
function M.in_comment()
|
||||||
|
return vim.fn['vimtex#syntax#in_comment']() == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- document class
|
||||||
|
function M.in_beamer()
|
||||||
|
return vim.b.vimtex['documentclass'] == 'beamer'
|
||||||
|
end
|
||||||
|
|
||||||
|
-- general env function
|
||||||
|
local function env(name)
|
||||||
|
local is_inside = vim.fn['vimtex#env#is_inside'](name)
|
||||||
|
return (is_inside[1] > 0 and is_inside[2] > 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.in_preamble()
|
||||||
|
return not env 'document'
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.in_text()
|
||||||
|
return env 'document' and not M.in_math()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.in_tikz()
|
||||||
|
return env 'tikzpicture'
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.in_bullets()
|
||||||
|
return env 'itemize' or env 'enumerate'
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.in_align()
|
||||||
|
return env 'align' or env 'align*' or env 'aligned'
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
local s = ls.snippet
|
||||||
|
local sn = ls.snippet_node
|
||||||
|
local isn = ls.indent_snippet_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local c = ls.choice_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local r = ls.restore_node
|
||||||
|
local events = require 'luasnip.util.events'
|
||||||
|
local ai = require 'luasnip.nodes.absolute_indexer'
|
||||||
|
local extras = require 'luasnip.extras'
|
||||||
|
local l = extras.lambda
|
||||||
|
local rep = extras.rep
|
||||||
|
local p = extras.partial
|
||||||
|
local m = extras.match
|
||||||
|
local n = extras.nonempty
|
||||||
|
local dl = extras.dynamic_lambda
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
local fmta = require('luasnip.extras.fmt').fmta
|
||||||
|
local conds = require 'luasnip.extras.expand_conditions'
|
||||||
|
local postfix = require('luasnip.extras.postfix').postfix
|
||||||
|
local types = require 'luasnip.util.types'
|
||||||
|
local parse = require('luasnip.util.parser').parse_snippet
|
||||||
|
local ms = ls.multi_snippet
|
||||||
|
local k = require('luasnip.nodes.key_indexer').new_key
|
||||||
|
|
||||||
|
local conditions = require 'luasnippets.tex.conditions'
|
||||||
|
local is_math = conditions.is_math
|
||||||
|
|
||||||
|
local as = require('luasnip').extend_decorator.apply(s, { snippetType = 'autosnippet' })
|
||||||
|
|
||||||
|
local ret = {}
|
||||||
|
|
||||||
|
-- dynamic node
|
||||||
|
-- generally, postfix comes in the form PRE-CAPTURE-POST, so in this case, arg1 is the "pre" text, arg2 the "post" text
|
||||||
|
local dynamic_postfix = function(_, parent, _, user_arg1, user_arg2)
|
||||||
|
print(table.concat(parent.snippet, '\n'))
|
||||||
|
local capture = parent.snippet.env.POSTFIX_MATCH
|
||||||
|
if #capture > 0 then
|
||||||
|
return sn(
|
||||||
|
nil,
|
||||||
|
fmta(
|
||||||
|
[[
|
||||||
|
<><><><>
|
||||||
|
]],
|
||||||
|
{ t(user_arg1), t(capture), t(user_arg2), i(0) }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
local visual_placeholder = ''
|
||||||
|
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||||
|
visual_placeholder = parent.snippet.env.SELECT_RAW
|
||||||
|
end
|
||||||
|
return sn(
|
||||||
|
nil,
|
||||||
|
fmta(
|
||||||
|
[[
|
||||||
|
<><><><>
|
||||||
|
]],
|
||||||
|
{ t(user_arg1), i(1, visual_placeholder), t(user_arg2), i(0) }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- local function postfix_std(trig, result_start, result_end)
|
||||||
|
-- return postfix(
|
||||||
|
-- { trig = trig, snippetType = 'autosnippet' },
|
||||||
|
-- { d(1, dynamic_postfix, {}, { user_args = { result_start, result_end } }) },
|
||||||
|
-- { condition = is_math, show_condition = is_math }
|
||||||
|
-- )
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- Helper: creates a regex-triggered snippet that wraps the next character(s)
|
||||||
|
-- after <prefix> in <before> ... <after>
|
||||||
|
local function postfix_std(prefix, before, after)
|
||||||
|
return s(
|
||||||
|
{ trig = prefix .. '(%a)', regTrig = true, wordTrig = false, snippetType = 'autosnippet' },
|
||||||
|
f(function(_, snip)
|
||||||
|
local captured = snip.captures[1]
|
||||||
|
return before .. captured .. after
|
||||||
|
end)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(ret, postfix_std('vec', '\\vec{', '}'))
|
||||||
|
table.insert(ret, postfix_std('hat', '\\hat{', '}'))
|
||||||
|
table.insert(ret, postfix_std('dot', '\\dot{', '}'))
|
||||||
|
table.insert(ret, postfix_std('bar', '\\bar{', '}'))
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
local s = ls.snippet
|
||||||
|
local sn = ls.snippet_node
|
||||||
|
local isn = ls.indent_snippet_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local c = ls.choice_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local r = ls.restore_node
|
||||||
|
local events = require 'luasnip.util.events'
|
||||||
|
local ai = require 'luasnip.nodes.absolute_indexer'
|
||||||
|
local extras = require 'luasnip.extras'
|
||||||
|
local l = extras.lambda
|
||||||
|
local rep = extras.rep
|
||||||
|
local p = extras.partial
|
||||||
|
local m = extras.match
|
||||||
|
local n = extras.nonempty
|
||||||
|
local dl = extras.dynamic_lambda
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
local fmta = require('luasnip.extras.fmt').fmta
|
||||||
|
local conds = require 'luasnip.extras.expand_conditions'
|
||||||
|
local postfix = require('luasnip.extras.postfix').postfix
|
||||||
|
local types = require 'luasnip.util.types'
|
||||||
|
local parse = require('luasnip.util.parser').parse_snippet
|
||||||
|
local ms = ls.multi_snippet
|
||||||
|
local k = require('luasnip.nodes.key_indexer').new_key
|
||||||
|
|
||||||
|
local conditions = require 'luasnippets.tex.conditions'
|
||||||
|
|
||||||
|
local is_math = conditions.is_math
|
||||||
|
local as = require('luasnip').extend_decorator.apply(s, { snippetType = 'autosnippet' })
|
||||||
|
|
||||||
|
local ret = {}
|
||||||
|
--
|
||||||
|
-- table.insert(
|
||||||
|
-- ret,
|
||||||
|
-- as(
|
||||||
|
-- {
|
||||||
|
-- trig = 'rancc',
|
||||||
|
-- regTrig = true,
|
||||||
|
-- name = 'range closed close',
|
||||||
|
-- dscr = 'ranges typing x_ -> x_{}',
|
||||||
|
-- },
|
||||||
|
-- fmta([[ \left[ <> ; <> \right] ]], {
|
||||||
|
-- i(1),
|
||||||
|
-- i(2),
|
||||||
|
-- }),
|
||||||
|
-- { condition = is_math }
|
||||||
|
-- )
|
||||||
|
-- )
|
||||||
|
|
||||||
|
local leters = { 'c', 'o' }
|
||||||
|
for index, value in ipairs(leters) do
|
||||||
|
for index2, value2 in ipairs(leters) do
|
||||||
|
local char1
|
||||||
|
local char2
|
||||||
|
if index == 1 then
|
||||||
|
char1 = '['
|
||||||
|
else
|
||||||
|
char1 = ']'
|
||||||
|
end
|
||||||
|
if index2 == 1 then
|
||||||
|
char2 = ']'
|
||||||
|
else
|
||||||
|
char2 = '['
|
||||||
|
end
|
||||||
|
table.insert(
|
||||||
|
ret,
|
||||||
|
as(
|
||||||
|
{
|
||||||
|
trig = 'ran' .. value .. value2,
|
||||||
|
regTrig = true,
|
||||||
|
name = 'range ' .. value .. value2 .. ' - ' .. char1 .. char2,
|
||||||
|
dscr = 'ranges',
|
||||||
|
},
|
||||||
|
fmta('\\left' .. char1 .. ' <> ; <> \\right' .. char2, {
|
||||||
|
i(1),
|
||||||
|
i(2),
|
||||||
|
}),
|
||||||
|
{ condition = is_math }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
local s = ls.snippet
|
||||||
|
local sn = ls.snippet_node
|
||||||
|
local isn = ls.indent_snippet_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local c = ls.choice_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local r = ls.restore_node
|
||||||
|
local events = require 'luasnip.util.events'
|
||||||
|
local ai = require 'luasnip.nodes.absolute_indexer'
|
||||||
|
local extras = require 'luasnip.extras'
|
||||||
|
local l = extras.lambda
|
||||||
|
local rep = extras.rep
|
||||||
|
local p = extras.partial
|
||||||
|
local m = extras.match
|
||||||
|
local n = extras.nonempty
|
||||||
|
local dl = extras.dynamic_lambda
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
local fmta = require('luasnip.extras.fmt').fmta
|
||||||
|
local conds = require 'luasnip.extras.expand_conditions'
|
||||||
|
local postfix = require('luasnip.extras.postfix').postfix
|
||||||
|
local types = require 'luasnip.util.types'
|
||||||
|
local parse = require('luasnip.util.parser').parse_snippet
|
||||||
|
local ms = ls.multi_snippet
|
||||||
|
local k = require('luasnip.nodes.key_indexer').new_key
|
||||||
|
|
||||||
|
local conditions = require 'luasnippets.tex.conditions'
|
||||||
|
|
||||||
|
local is_math = conditions.is_math
|
||||||
|
local as = require('luasnip').extend_decorator.apply(s, { snippetType = 'autosnippet' })
|
||||||
|
|
||||||
|
local ret = {
|
||||||
|
as(
|
||||||
|
{
|
||||||
|
trig = '(%a)_',
|
||||||
|
regTrig = true,
|
||||||
|
name = 'auto subscript underscore',
|
||||||
|
dscr = 'Auto subscript: typing x_ -> x_{}',
|
||||||
|
},
|
||||||
|
fmta([[<>_{<>}]], {
|
||||||
|
f(function(_, snip)
|
||||||
|
return snip.captures[1]
|
||||||
|
end),
|
||||||
|
i(1),
|
||||||
|
}),
|
||||||
|
{ condition = is_math }
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
Loading…
Reference in New Issue