Compare commits

...

17 Commits

Author SHA1 Message Date
Franchioping 87846dc87c new laptop 2026-01-27 16:04:08 +00:00
Franchioping a882fc5d24 fix esp32 2025-12-08 20:44:13 +00:00
Franchioping bd4d79f7f3 neovim stuffs, tex, esp32 2025-11-26 21:21:58 +00:00
Franchioping 044ebe7bff changes 2025-11-05 10:02:56 +00:00
Franchioping 1b6c7bdf45 readme repo change 2025-10-29 17:57:46 +00:00
Franchioping 3fc7120f1b change local leader 2025-10-29 17:54:55 +00:00
Franchioping 5ed85f9cf9 working kind of base for nix??? 2025-10-29 17:00:40 +00:00
Franchioping 4ec5add8ce working kind of base for nix?? 2025-10-29 17:00:34 +00:00
Franchioping 8402b24466 Merge branch 'master' of github.com:franchioping/kickstart.nvim
disk dying fuck me
2025-10-14 22:35:19 +01:00
Franchioping 1418ed2435 disk dying 2025-10-14 22:34:32 +01:00
Francisco Lima a57e14db1a
Update README with installation instructions
Added installation instructions for cloning the repository.
2025-09-12 00:03:02 +01:00
Franchioping 2b4f2987c2 update lock 2025-08-21 20:32:22 +01:00
franchioping 2adcea052c add file 2025-04-18 00:20:04 +01:00
franchioping 48e9082bf8 chanes 2025-04-18 00:18:58 +01:00
franchioping 1fd3c1d354 changes 2025-04-12 16:42:14 +01:00
franchioping f976a7cba6 changed opts to option 2025-01-22 16:02:21 +00:00
franchioping 0081252e35 changes 2025-01-22 15:41:21 +00:00
17 changed files with 824 additions and 121 deletions

View File

@ -1,5 +1,9 @@
# kickstart.nvim
```sh
git clone ssh://git@forgejo.galard.uk:222/franchioping/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
```
## Introduction
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
External Requirements:
- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`)
- [ripgrep](https://github.com/BurntSushi/ripgrep#installation)
- Clipboard tool (xclip/xsel/win32yank or other depending on the platform)
- 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
- Language Setup:
- If you want to write Typescript, you need `npm`
- If you want to write Golang, you will need `go`
- etc.
* Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`)
* [ripgrep](https://github.com/BurntSushi/ripgrep#installation)
* Clipboard tool (xclip/xsel/win32yank or other depending on the platform)
* 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
* Language Setup:
* If you want to write Typescript, you need `npm`
* If you want to write Golang, you will need `go`
* etc.
> **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
### Install Kickstart
> **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:
@ -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).
#### Clone kickstart.nvim
>
> **NOTE**
> If following the recommended step above (i.e., forking the repo), replace
> `nvim-lua` with `<your_github_username>` in the commands below
@ -112,7 +117,6 @@ examples of adding popularly requested plugins.
> [!NOTE]
> For more information about a particular plugin check its repository's documentation.
### Getting Started
[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`
to maintain multiple configurations. For example, you can install the kickstart
configuration in `~/.config/nvim-kickstart` and create an alias:
```
alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim'
```
When you run Neovim using `nvim-kickstart` alias it will use the alternative
config directory and the matching local directory
`~/.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.
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
@ -162,11 +168,12 @@ See `telescope-fzf-native` documentation for [more details](https://github.com/n
This requires:
- Install CMake and the Microsoft C++ Build Tools on Windows
* Install CMake and the Microsoft C++ Build Tools on Windows
```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' }
```
</details>
<details><summary>Windows with gcc/make using chocolatey</summary>
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)
either follow the instructions on the page or use winget,
run in cmd as **admin**:
```
winget install --accept-source-agreements chocolatey.chocolatey
```
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**:
```
choco install -y neovim git ripgrep wget fd unzip gzip mingw make
```
</details>
<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 install make gcc ripgrep unzip git xclip neovim
```
</details>
#### Linux Install
<details><summary>Ubuntu Install Steps</summary>
```
@ -204,6 +216,7 @@ sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt update
sudo apt install make gcc ripgrep unzip git xclip neovim
```
</details>
<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
sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/
```
</details>
<details><summary>Fedora Install Steps</summary>
```
sudo dnf install -y gcc make git ripgrep fd-find unzip neovim
```
</details>
<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
```
</details>
</details>

View File

@ -0,0 +1,2 @@
vim.opt_local.spell = true
vim.opt_local.spelllang = { 'en_us', 'pt_PT' }

311
init.lua
View File

@ -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
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
--
-- autocomplete
vim.o.pumheight = 20
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
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.opt`
@ -102,7 +108,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- 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!
vim.opt.mouse = 'a'
@ -156,6 +162,10 @@ vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
-- vim.cmd 'set expandtab'
vim.opt.smartindent = false
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
@ -164,7 +174,7 @@ vim.opt.scrolloff = 10
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- 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
-- 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
spec = {
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
{ '<leader>f', group = 'Telescope Find' },
{ '<leader>c', group = 'Config Toggle' },
{ '<leader>h', group = 'Help Errors', mode = { 'n', 'v' } },
},
},
},
@ -402,39 +408,39 @@ require('lazy').setup({
-- See `:help 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>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope Help Tags' })
vim.keymap.set('n', '<leader>fk', builtin.keymaps, { desc = 'Telescope Keymaps' })
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope Find Files' })
-- vim.keymap.set('n', '<leader>fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' })
-- vim.keymap.set('n', '<leader>fw', builtin.grep_string, { desc = '[F]ind current [W]ord' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope Live Grep' })
-- vim.keymap.set('n', '<leader>fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' })
-- vim.keymap.set('n', '<leader>fr', builtin.resume, { desc = '[F]ind [R]esume' })
-- vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = 'Telescope Buffers' })
-- 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.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
-- builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
-- winblend = 10,
-- previewer = false,
-- })
-- end, { desc = '[/] Fuzzily search in current buffer' })
-- It's also possible to pass additional configuration options.
-- 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 {
grep_open_files = true,
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
vim.keymap.set('n', '<leader>sn', function()
vim.keymap.set('n', '<leader>fn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' })
end, { desc = 'Telescope Nvim Files' })
end,
},
@ -460,7 +466,7 @@ require('lazy').setup({
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ 'williamboman/mason.nvim', opts = {} },
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
-- 'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP.
{ 'j-hui/fidget.nvim', opts = {} },
@ -469,6 +475,37 @@ require('lazy').setup({
'hrsh7th/cmp-nvim-lsp',
},
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?**
--
-- 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.
-- This is where a variable was first declared, or where a function is defined, etc.
-- 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.
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.
-- 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.
-- 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*.
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.
-- 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.
-- 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.
-- 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
-- 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.
-- 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
-- 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
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 })
end, '[T]oggle Inlay [H]ints')
end, 'Toggle Inlay Hints')
end
end,
})
@ -606,6 +643,13 @@ require('lazy').setup({
local capabilities = vim.lsp.protocol.make_client_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
-- 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.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
rust_analyzer = {},
-- ... 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:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
ts_ls = {},
--
lua_ls = {
@ -639,7 +681,7 @@ require('lazy').setup({
callSnippet = 'Replace',
},
-- 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
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
-- local ensure_installed = vim.tbl_keys(servers or {})
-- vim.list_extend(ensure_installed, {
-- 'stylua', -- Used to format Lua code
-- })
-- require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
handlers = {
@ -675,6 +717,7 @@ require('lazy').setup({
require('lspconfig')[server_name].setup(server)
end,
},
-- automatic_installation = true,
}
end,
},
@ -685,36 +728,28 @@ require('lazy').setup({
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
'<leader>p',
function()
require('conform').format { async = true, lsp_format = 'fallback' }
end,
mode = '',
desc = '[F]ormat buffer',
desc = 'format',
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- 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,
format_on_save = {
timeout_ms = 5000,
lsp_format = true,
},
formatters_by_ft = {
lua = { 'stylua' },
markdown = { 'markdownlint' },
json = { 'fixjson', 'jq' },
c = { 'clang-format' },
cpp = { 'clang-format' },
-- 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
-- javascript = { "prettierd", "prettier", stop_after_first = true },
@ -738,6 +773,9 @@ require('lazy').setup({
end
return 'make install_jsregexp'
end)(),
config = function(_, _)
require('luasnip.loaders.from_lua').lazy_load { paths = './lua/luasnippets/' }
end,
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
@ -750,8 +788,10 @@ require('lazy').setup({
-- },
},
},
{
'saadparwaiz1/cmp_luasnip',
-- dev = true,
},
-- Adds other completion capabilities.
-- nvim-cmp does not ship with all sources by default. They are split
-- into multiple repos for maintenance purposes.
@ -762,9 +802,56 @@ require('lazy').setup({
-- See `:help cmp`
local cmp = require 'cmp'
local luasnip = require 'luasnip'
luasnip.config.setup {}
luasnip.config.setup { enable_autosnippets = true }
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 = {
expand = function(args)
luasnip.lsp_expand(args.body)
@ -789,7 +876,7 @@ require('lazy').setup({
-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- 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,
-- you can uncomment the following lines
@ -800,7 +887,7 @@ require('lazy').setup({
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- 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.
-- 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-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
['<Tab>'] = cmp.mapping(function()
if luasnip.locally_jumpable(1) then
luasnip.jump(1)
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
['<S-Tab>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
@ -831,28 +918,46 @@ require('lazy').setup({
group_index = 0,
},
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{
name = 'luasnip',
option = {
show_autosnippets = true,
use_show_condition = false,
-- label_aliases = {
-- ['(?<!\\\\)(sec)'] = 'sec',
-- ['(?<!\\\\)(sec*)'] = 'sec*',
-- },
},
},
{ name = 'path' },
},
}
end,
},
{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is.
-- { -- You can easily change to a different colorscheme.
-- -- Change the name of the colorscheme plugin below, and then
-- -- 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`.
'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
-- -- You can configure highlights by doing something like:
-- vim.cmd.hi 'Comment gui=none'
-- end,
-- },
{
'ellisonleao/gruvbox.nvim',
priority = 1000,
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'
-- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none'
vim.o.background = 'dark'
vim.cmd.colorscheme 'gruvbox'
end,
},
@ -911,6 +1016,7 @@ require('lazy').setup({
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
disable = { 'latex' },
},
indent = { enable = true, disable = { 'ruby' } },
},
@ -933,8 +1039,8 @@ require('lazy').setup({
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
require 'kickstart.plugins.lint',
require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
@ -942,7 +1048,7 @@ require('lazy').setup({
-- 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.
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
--
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope!
@ -968,7 +1074,18 @@ require('lazy').setup({
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`
-- vim: ts=2 sts=2 sw=2 et

38
lazy-lock.json Normal file
View File

@ -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" }
}

View File

@ -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, {})

View File

@ -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' },
},
}

View File

@ -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 {}

View File

@ -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,
-- },
}

View File

@ -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() {}',
},
},
},
},
}

View File

@ -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 },
},
},
}

View File

@ -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,
}

View File

@ -39,7 +39,7 @@ return {
-- lint.linters_by_ft['rst'] = nil
-- lint.linters_by_ft['ruby'] = 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
-- on the specified events.

31
lua/luasnippets/all.lua Normal file
View File

@ -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')),
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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