config.nvim

NeoVim config
git clone git://popovic.xyz/nvim.config.git/
Log | Files | Refs

commit 43d1e7dc6dc85efe304c3e61f30e34eacd379493
Author: Milutin Popovic <milutin@popovic.xyz>
Date:   Fri, 10 Apr 2026 22:26:12 +0100

init

Diffstat:
Aafter/ftplugin/css.lua | 3+++
Aafter/ftplugin/html.lua | 4++++
Aafter/ftplugin/javascript.lua | 2++
Aafter/ftplugin/javascriptreact.lua | 3+++
Aafter/ftplugin/json.lua | 3+++
Aafter/ftplugin/julia.lua | 1+
Aafter/ftplugin/lua.lua | 10++++++++++
Aafter/ftplugin/md.lua | 2++
Aafter/ftplugin/nix.lua | 5+++++
Aafter/ftplugin/sql.lua | 2++
Aafter/ftplugin/tex.lua | 3+++
Aafter/ftplugin/typescript.lua | 3+++
Aafter/ftplugin/typescriptreact.lua | 3+++
Ainit.lua | 1+
Alua/config/autocmd.lua | 22++++++++++++++++++++++
Alua/config/diagnostics.lua | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/config/init.lua | 11+++++++++++
Alua/config/keymaps.lua | 22++++++++++++++++++++++
Alua/config/lazy.lua | 35+++++++++++++++++++++++++++++++++++
Alua/config/set.lua | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/autorepair.lua | 6++++++
Alua/plugins/color.lua | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/colorizer.lua | 6++++++
Alua/plugins/completions.lua | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/copilot.lua | 24++++++++++++++++++++++++
Alua/plugins/copilotchat.lua | 45+++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/floaterm.lua | 8++++++++
Alua/plugins/hints.lua | 46++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/ibl.lua | 14++++++++++++++
Alua/plugins/lsp.lua | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/luasnip.lua | 18++++++++++++++++++
Alua/plugins/rustacean.lua | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/telescope.lua | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/plugins/treesitter.lua | 37+++++++++++++++++++++++++++++++++++++
Alua/plugins/undotree.lua | 6++++++
Alua/plugins/vimtex.lua | 29+++++++++++++++++++++++++++++
Alua/snippets/basic.lua | 18++++++++++++++++++
Alua/snippets/latex.lua | 623+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/snippets/rust.lua | 19+++++++++++++++++++
39 files changed, 1705 insertions(+), 0 deletions(-)

diff --git a/after/ftplugin/css.lua b/after/ftplugin/css.lua @@ -0,0 +1,3 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 diff --git a/after/ftplugin/html.lua b/after/ftplugin/html.lua @@ -0,0 +1,4 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 +vim.opt_local.syntax = "on" diff --git a/after/ftplugin/javascript.lua b/after/ftplugin/javascript.lua @@ -0,0 +1,2 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 diff --git a/after/ftplugin/javascriptreact.lua b/after/ftplugin/javascriptreact.lua @@ -0,0 +1,3 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 diff --git a/after/ftplugin/json.lua b/after/ftplugin/json.lua @@ -0,0 +1,3 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 diff --git a/after/ftplugin/julia.lua b/after/ftplugin/julia.lua @@ -0,0 +1 @@ +vim.bo.textwidth = 77 diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua @@ -0,0 +1,10 @@ +vim.opt_local.suffixesadd:prepend('.lua') +vim.opt_local.suffixesadd:prepend('init.lua') +vim.opt_local.path:prepend(vim.fn.stdpath('config')..'/lua') + +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 +vim.opt.syntax = "off" + + diff --git a/after/ftplugin/md.lua b/after/ftplugin/md.lua @@ -0,0 +1,2 @@ +vim.bo.textwidth = 77 +vim.wo.wrap = true diff --git a/after/ftplugin/nix.lua b/after/ftplugin/nix.lua @@ -0,0 +1,5 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 + + diff --git a/after/ftplugin/sql.lua b/after/ftplugin/sql.lua @@ -0,0 +1,2 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua @@ -0,0 +1,3 @@ +vim.g.tex_flavor = "latex" +vim.bo.textwidth = 77 +vim.wo.wrap = true diff --git a/after/ftplugin/typescript.lua b/after/ftplugin/typescript.lua @@ -0,0 +1,3 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 + diff --git a/after/ftplugin/typescriptreact.lua b/after/ftplugin/typescriptreact.lua @@ -0,0 +1,3 @@ +vim.opt_local.tabstop = 2 +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 diff --git a/init.lua b/init.lua @@ -0,0 +1 @@ +require("config") diff --git a/lua/config/autocmd.lua b/lua/config/autocmd.lua @@ -0,0 +1,22 @@ +local autocmd = vim.api.nvim_create_autocmd + +-- Delete trailing whitespace +autocmd({'BufWritePre'}, { + pattern = '*', + command = [[%s/\s\+$//e]], +}) + +autocmd({'BufEnter'}, { + pattern = 'justfile', + command = "set filetype=make"; +}) + +autocmd({'BufWritePost'}, { + pattern = vim.fn.expand('~') .. '/.config/X/Xresources', + command = '!xrdb %', +}) + +autocmd({'BufWritePost'}, { + pattern = vim.fn.expand('~') .. '/.config/X/Xresources.mon', + command = '!xrdb %', +}) diff --git a/lua/config/diagnostics.lua b/lua/config/diagnostics.lua @@ -0,0 +1,71 @@ + +local palette = { + err = "#51202A", + warn = "#3B3B1B", + info = "#1F3342", + hint = "#1E2E1E", +} + +vim.api.nvim_set_hl(0, "DiagnosticErrorLine", { bg = palette.err, blend = 20 }) +vim.api.nvim_set_hl(0, "DiagnosticWarnLine", { bg = palette.warn, blend = 15 }) +vim.api.nvim_set_hl(0, "DiagnosticInfoLine", { bg = palette.info, blend = 10 }) +vim.api.nvim_set_hl(0, "DiagnosticHintLine", { bg = palette.hint, blend = 10 }) + +vim.api.nvim_set_hl(0, "DapBreakpointSign", { fg = "#FF0000", bg = nil, bold = true }) +vim.fn.sign_define("DapBreakpoint", { + text = "●", -- a large dot; change as desired + texthl = "DapBreakpointSign", -- the highlight group you just defined + linehl = "", -- no full-line highlight + numhl = "", -- no number-column highlight +}) + +local sev = vim.diagnostic.severity + +vim.diagnostic.config({ + -- keep underline & severity_sort on for quick scanning + underline = true, + severity_sort = true, + update_in_insert = false, -- less flicker + float = { + border = "rounded", + source = true, + }, + -- keep signs & virtual text, but tune them as you like + signs = { + text = { + [sev.ERROR] = " ", + [sev.WARN] = " ", + [sev.INFO] = " ", + [sev.HINT] = "󰌵 ", + }, + }, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + }, + -- NEW in 0.11 — dim whole line + linehl = { + [sev.ERROR] = "DiagnosticErrorLine", + [sev.WARN] = "DiagnosticWarnLine", + [sev.INFO] = "DiagnosticInfoLine", + [sev.HINT] = "DiagnosticHintLine", + }, +}) + +-- diagnostic keymaps +local diagnostic_goto = function(next, severity) + severity = severity and vim.diagnostic.severity[severity] or nil + return function() + vim.diagnostic.jump({ count = next and 1 or -1, float = true, severity = severity }) + end +end + +map = vim.keymap.set +map("n", "<C-w>d", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) +map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" }) +map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" }) +map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" }) +map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" }) +map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" }) +map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) diff --git a/lua/config/init.lua b/lua/config/init.lua @@ -0,0 +1,11 @@ +require("config.keymaps") +require("config.set") +require("config.autocmd") +require("config.diagnostics") + +local lazyconfpath = vim.fn.stdpath("config") .. "/lua/config/lazy.lua" +local pluginspath = vim.fn.stdpath("config") .. "/lua/plugins" +if vim.uv.fs_stat(lazyconfpath) and vim.uv.fs_stat(pluginspath) then + require("config.lazy") +end + diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua @@ -0,0 +1,22 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = "," +vim.keymap.set("n", "<leader>pv", vim.cmd.Ex) + +vim.keymap.set("n", "<leader>ce", ":setlocal spell! spelllang=en_us<cr>") +vim.keymap.set("n", "<leader>cd", ":setlocal spell! spelllang=de<cr>") +vim.keymap.set("n", "<leader>cs", ":setlocal spell! spelllang=sr@latin<cr>") + +vim.keymap.set("n", "<C-h>", "<C-w>h") +vim.keymap.set("n", "<C-j>", "<C-w>j") +vim.keymap.set("n", "<C-k>", "<C-w>k") +vim.keymap.set("n", "<C-l>", "<C-w>l") + +vim.keymap.set("n", "<leader>b", ":! firefox %") + +vim.keymap.set('c', 'w!!', ':w ! sudo tee % > /dev/null') + +vim.keymap.set('n', '<C-S>', function() + local bad = vim.fn.expand("<cword>") + local word_list = vim.fn.spellsuggest(bad) + end +) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "," + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = false }, +}) diff --git a/lua/config/set.lua b/lua/config/set.lua @@ -0,0 +1,68 @@ +vim.cmd('filetype on') +vim.cmd('filetype plugin indent on') + +vim.bo.filetype = "on" +vim.opt.number = true +vim.opt.relativenumber = true +vim.g.show_whitespace = 1 +vim.g.loaded_perl_provider = false +vim.opt.termguicolors = true + +vim.opt.clipboard = "unnamedplus" + +vim.opt.textwidth = 80 +vim.opt.wrap = true + +vim.opt.ignorecase = true +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.smartindent = true +vim.opt.smartcase = true +vim.opt.expandtab = true + +vim.opt.viminfofile = os.getenv("HOME") .. "/.local/state/nvim/viminfo" +vim.opt.undodir = os.getenv("HOME") .. "/.local/state/nvim/undodir" +vim.opt.undofile = true + +vim.opt.scrolloff = 10 +vim.opt.hlsearch = false + +vim.opt.ttimeoutlen = 0 +vim.opt.timeoutlen = 1000 + +vim.opt.scrolloff = 10 +vim.opt.mouse = "" +vim.opt.mousescroll = "ver:0,hor:0" +vim.opt.wildmode = "longest,list,full" +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.splitbelow = true +vim.opt.splitright = true + +vim.opt.spellsuggest = { "best", 5 } + +-- Undotree toggle +vim.cmd("packadd nvim.undotree") +vim.keymap.set("n", "<leader>u", function() + require("undotree").open({ + command = math.floor(vim.api.nvim_win_get_width(0) / 3) .. "vnew", + }) +end, { desc = "[U]ndotree toggle" }) + +-- incremental selection treesitter/lsp +vim.keymap.set({ "n", "x", "o" }, "<A-o>", function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require("vim.treesitter._select").select_parent(vim.v.count1) + else + vim.lsp.buf.selection_range(vim.v.count1) + end +end, { desc = "Select parent treesitter node or outer incremental lsp selections" }) + +vim.keymap.set({ "n", "x", "o" }, "<A-i>", function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require("vim.treesitter._select").select_child(vim.v.count1) + else + vim.lsp.buf.selection_range(-vim.v.count1) + end +end, { desc = "Select child treesitter node or inner incremental lsp selections" }) diff --git a/lua/plugins/autorepair.lua b/lua/plugins/autorepair.lua @@ -0,0 +1,6 @@ +return { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true, + disable_filetype = { "TelescopePrompt" , "vim" }, +} diff --git a/lua/plugins/color.lua b/lua/plugins/color.lua @@ -0,0 +1,58 @@ +function ColorMyPencils(color) + color = color or "rose-pine-moon" + vim.cmd.colorscheme(color) + vim.opt.cursorline = true + + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" }) + vim.api.nvim_set_hl(0, "MatchParen", { bg= "darkred" }) + vim.api.nvim_set_hl(0, "SpellBad", { bold=true, underline=true, fg= "red" }) + + -- separators + vim.api.nvim_set_hl(0, "WinSeparator", { fg="#A96C8A", bold=true }) + vim.api.nvim_set_hl(0, "StatusLine", { fg="#6CA98A" }) + + vim.fn.matchadd("ExtraWhiteSpace", '\\v\\s+$') + vim.api.nvim_set_hl(0, "ExtraWhiteSpace", { ctermbg="red", bg="red" }) + local nontexthl = vim.api.nvim_get_hl_by_name("NonText", true) + + -- colpilot chat + vim.api.nvim_set_hl(0, 'CopilotChatHeader', { fg = '#7C3AED', bold = true }) + vim.api.nvim_set_hl(0, 'CopilotChatSeparator', { fg = '#374151' }) + + -- TelescopeBorder + vim.api.nvim_set_hl(0, 'TelescopeBorder', { fg = '#A96C8A', bold=true }) + vim.api.nvim_set_hl(0, 'TelescopeTitle', { fg = '#6CA98A', bold=true }) + + -- lsp hints + vim.api.nvim_set_hl(0, "LspInlayHint", { bg = "none", fg = nontexthl.foreground }) + vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none", fg = "#6CA98A", bold = true }) +end + +return { + { + "rose-pine/neovim", + name = "rose-pine", + config = function() + require('rose-pine').setup({ + dark_variant = "main", + dim_inactive_windows = true, + disable_background = true, + disable_nc_background = true, + disable_float_background = true, + extend_background_behind_borders = true, + enable = { + terminal = true, + legacy_highlights = true, + migrations = true, + }, + styles = { + bold = true, + italic = true, + transparency = false, + }, + }) + ColorMyPencils(); + end + }, +} diff --git a/lua/plugins/colorizer.lua b/lua/plugins/colorizer.lua @@ -0,0 +1,6 @@ +return { + "brenoprata10/nvim-highlight-colors", + config = function() + require 'nvim-highlight-colors'.setup() + end +} diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua @@ -0,0 +1,105 @@ +return { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "zbirenbaum/copilot-cmp" + }, + config = function () + vim.o.winborder = 'single' + require("copilot_cmp").setup() + local cmp = require('cmp') + cmp.setup({ + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + mapping = { + ["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + ["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + ['<`-j>'] = cmp.mapping.scroll_docs(-4), + ['<`-k>'] = cmp.mapping.scroll_docs(4), + ['<C-a>'] = cmp.mapping( + cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + { "i", "c" } + ), + }, + sources = { + { name = 'copilot' }, + { name = 'nvim_lsp'}, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + }, + window = { + documentation = { + winhighlight = 'Normal:CmpPmenu,CursorLine:PmenuSel,Search:None,NormalFloat:Normal', + }, + completion = { + winhighlight = 'Normal:CmpPmenu,CursorLine:PmenuSel,Search:None,NormalFloat:Normal', + }, + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon ={ + nvim_lsp = 'λ', + luasnip = '⋗', + buffer = 'Ω', + path = '🖫', + copilot = " " + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, + }) + + local endhints = require("lsp-endhints") + endhints.enable() + endhints.setup { + icons = { + type = "-> ", + parameter = "<= ", + offspec = "<= ", -- hint kind not defined in official LSP spec + unknown = "? ", -- hint kind is nil + }, + label = { + truncateAtChars = 50, + padding = 1, + marginLeft = 0, + sameKindSeparator = ", ", + }, + extmark = { + priority = 50, + }, + autoEnableHints = true, + } + + map('n', '<leader>h', function(bufnr) + if vim.lsp.inlay_hint.is_enabled() then + print("Inlay Hitnts OFF") + else + print("Inlay Hitnts ON") + end + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled(), bufnr) + end, { silent = true, noremap = true }) + + map('n', '<leader>d', function() + if vim.diagnostic.is_enabled() then + print("Diagnostics OFF") + else + print("Diagnostics ON") + end + vim.diagnostic.enable(not vim.diagnostic.is_enabled()) + end, { silent = true, noremap = true }) + end +} diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua @@ -0,0 +1,24 @@ +return { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + event = "InsertEnter", + requires = { + "copilotlsp-nvim/copilot-lsp", -- (optional) for NES functionality + }, + config = function() + require("copilot").setup({ + filetypes = { + yaml = false, + markdown = false, + help = false, + gitcommit = false, + gitrebase = false, + hgcommit = false, + txt = false, + svn = false, + cvs = false, + ["."] = false, + }, + }) + end, +} diff --git a/lua/plugins/copilotchat.lua b/lua/plugins/copilotchat.lua @@ -0,0 +1,45 @@ +return { + "CopilotC-Nvim/CopilotChat.nvim", + dependencies = { + "zbirenbaum/copilot.lua", + "nvim-lua/plenary.nvim", + }, + event = "VeryLazy", + build = "make tiktoken", + opts = { + model = "gpt-5.2", + window = { + layout = 'horizontal', + width = 1, + height = 0.3, + title = '🤖 AI Assistant', + }, + headers = { + user = '👤 You', + assistant = '🤖 Copilot', + tool = '🔧 Tool', + }, + suggestion = { enabled = true }, + separator = '━━', + auto_fold = true, + }, + config = function(_, opts) + require("CopilotChat").setup(opts) + end, + keys = { + { + "<leader>ao", + function() + vim.cmd("CopilotChatOpen") + end, + desc = "CopilotChat - Activate", + }, + { + "<leader>ar", + function() + vim.cmd("CopilotChatReset") + end, + desc = "CopilotChat - Reset", + }, + }, +} diff --git a/lua/plugins/floaterm.lua b/lua/plugins/floaterm.lua @@ -0,0 +1,8 @@ +return { + "voldikss/vim-floaterm", + config = function() + vim.keymap.set('n', "<leader>ft", ":FloatermNew --name=myfloat --height=0.6 --width=0.7 --autoclose=2 zsh<CR> ") + vim.keymap.set('n', "t", ":FloatermToggle myfloat<CR>") + vim.keymap.set('t', "<C-t>", "<C-\\><C-n>:q<CR>") + end +} diff --git a/lua/plugins/hints.lua b/lua/plugins/hints.lua @@ -0,0 +1,46 @@ +return { + "chrisgrieser/nvim-lsp-endhints", + event = "VeryLazy", + config = function () + local endhints = require("lsp-endhints") + endhints.enable() + endhints.setup { + icons = { + type = "-> ", + parameter = "<= ", + offspec = "<= ", -- hint kind not defined in official LSP spec + unknown = "? ", -- hint kind is nil + }, + label = { + truncateAtChars = 50, + padding = 1, + marginLeft = 0, + sameKindSeparator = ", ", + }, + extmark = { + priority = 50, + }, + autoEnableHints = true, + } + + map = vim.keymap.set + map('n', '<leader>h', function(bufnr) + if vim.lsp.inlay_hint.is_enabled() then + print("Inlay Hitnts OFF") + else + print("Inlay Hitnts ON") + end + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled(), bufnr) + end, { silent = true, noremap = true }) + + map('n', '<leader>d', function() + if vim.diagnostic.is_enabled() then + print("Diagnostics OFF") + else + print("Diagnostics ON") + end + vim.diagnostic.enable(not vim.diagnostic.is_enabled()) + end, { silent = true, noremap = true }) + end + +} diff --git a/lua/plugins/ibl.lua b/lua/plugins/ibl.lua @@ -0,0 +1,14 @@ +return { + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + event = 'VeryLazy', + opts = { + indent = { + char = '│' + }, + scope = { + show_start = false, + show_end = false, + }, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua @@ -0,0 +1,158 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "stevearc/conform.nvim", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "j-hui/fidget.nvim", + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + map = vim.keymap.set + vim.opt.signcolumn = "yes" + vim.lsp.inlay_hint.enable(true) + + local lspconfig_defaults = require("lspconfig").util.default_config + require("conform").setup({ + formatters_by_ft = { + javascript = { "prettier" }, + javascriptreact = { "prettier" }, + typescript = { "prettier" }, + typescriptreact = { "prettier" }, + vue = { "prettier" }, + css = { "prettier" }, + scss = { "prettier" }, + less = { "prettier" }, + html = { "prettier" }, + json = { "prettier" }, + jsonc = { "prettier" }, + yaml = { "prettier" }, + markdown = { "prettier" }, + graphql = { "prettier" }, + svelte = { "prettier" }, + astro = { "prettier" }, + rust = { "rustfmt" }, + }, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + }) + + local cmp = require("cmp") + local cmp_lsp = require("cmp_nvim_lsp") + local capabilities = + vim.tbl_deep_extend("force", lspconfig_defaults.capabilities, cmp_lsp.default_capabilities()) + lspconfig_defaults.capabilities = capabilities + + vim.api.nvim_create_autocmd("LspAttach", { + desc = "LSP actions", + callback = function(event) + local opts = { buffer = event.buf } + + map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", opts) + map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", opts) + map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", opts) + map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<cr>", opts) + map("n", "go", "<cmd>lua vim.lsp.buf.type_definition()<cr>", opts) + map("n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>", opts) + map("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts) + map("n", "gq", function() + require("conform").format({ async = true, lsp_fallback = true }) + end, opts) + map("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>", opts) + map({ "n", "x" }, "<F3>", "<cmd>lua vim.lsp.buf.format({async = true})<cr>", opts) + map("n", "<F4>", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts) + end, + }) + + require("fidget").setup({}) + + require("mason").setup() + require("mason-lspconfig").setup({ + handlers = { + + function(server_name) + if server_name == "rust_analyzer" then + return + end + + require("lspconfig")[server_name].setup({ + capabilities = capabilities, + }) + end, + ["eslint"] = function() + local lspconfig = require("lspconfig") + lspconfig.eslint.setup({ + cmd = { "vscode-eslint-language-server", "--stdio" }, + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + "vue", + "svelte", + "astro", + "htmlangular", + }, + on_attach = function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()") + end, + capabilities = capabilities, + -- ESLint will automatically look for config files in the project + settings = { + workingDirectory = { mode = "auto" }, + }, + }) + end, + ["bashls"] = function() + local lspconfig = require("lspconfig") + lspconfig.bashls.setup({ + cmd = { "bash-language-server", "start" }, + filetypes = { "zsh", "bash", "sh" }, + capabilities = capabilities, + }) + end, + ["tailwindcss"] = function() + local lspconfig = require("lspconfig") + lspconfig.tailwindcss.setup({ + includeLangauges = { + javascript = "js", + html = "html", + typescript = "ts", + typescriptreact = "tsx", + javascriptreact = "jsx", + }, + }) + end, + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({ + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = { + 'vim', + 'require' + }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, + }) + end, + }, + }) + end, +} diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua @@ -0,0 +1,18 @@ +return { + "L3MON4D3/LuaSnip", + version = "v2.3.0", + build = "make install_jsregexp", + config = function() + local ls = require("luasnip") + ls.config.setup({ + enable_autosnippets = true, + store_selection_keys = "<c-s>", + }) + for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", true)) do + loadfile(ft_path)() + end + + + + end +} diff --git a/lua/plugins/rustacean.lua b/lua/plugins/rustacean.lua @@ -0,0 +1,100 @@ +return { + 'mrcjkb/rustaceanvim', + version = '^8', + lazy = false, + dependencies = { + "mason-org/mason-registry", + }, + config = function() + vim.g.rustaceanvim = { + tools = { + float_win_config = { + border = "rounded", + } + }, + server = { + on_attach = function(client, bufnr) + vim.keymap.set( + "n", + "<leader>a", + function() + vim.cmd.RustLsp('codeAction') + end, + { silent = true, buffer = bufnr } + ) + vim.keymap.set( + "n", + "K", + function() + vim.cmd.RustLsp({'hover', 'actions'}) + end, + { silent = true, buffer = bufnr } + ) + end, + cmd = { 'rust-analyzer' }, + default_settings = { + ['rust-analyzer'] = { + diagnostics = { + enable = true; + }, + cargo = { + loadOutDirsFromCheck = true, + allFeatures = true, + }, + }, + }, + settings = { + ['rust-analyzer'] = { + inlayHints = { + maxLength = 50, + renderColons = true, + bindingModeHints = { + enable = false, + }, + chainingHints = { + enable = true, + }, + closingBraceHints = { + enable = true, + minLines = 50, + }, + closureCaptureTypeHints = { + enable = true, + }, + closureReturnTypeHints = { + enable = true, + }, + lifetimeElisionHints = { + enable = true, + useParameterNames = false, + }, + genericParameterHints = { + const = { + enable = true, + }, + lifetime = { + enable = true, + }, + type = { + enable = true, + }, + }, + parameterHints = { + enable = true, + }, + reborrowHints = { + enable = "never", + }, + typeHints = { + enable = true, + hideClosureInitialization = false, + hideNamedConstructor = false, + }, + }, + }, + }, + }, + } + + end +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua @@ -0,0 +1,111 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-lua/popup.nvim", + "nvim-telescope/telescope-fzy-native.nvim", + }, + + config = function() + local previewers = require("telescope.previewers") + local _bad = { ".*%.tex", ".*%.md", ".*%.html" } + local bad_files = function(filepath) + for _, v in ipairs(_bad) do + if filepath:match(v) then + return false + end + end + return true + end + local new_maker = function(filepath, bufnr, opts) + opts = opts or {} + if opts.use_ft_detect == nil then opts.use_ft_detect = true end + opts.use_ft_detect = opts.use_ft_detect == false and false or bad_files(filepath) + previewers.buffer_previewer_maker(filepath, bufnr, opts) + end + + + local edge_borders = { + prompt = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + results = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + preview = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + } + + + require("telescope").setup { + defaults = + vim.tbl_extend( + "force", + require("telescope.themes").get_dropdown({}), + { + borderchars = edge_borders, + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + }, + } + ), + extentions = { + fzf = {} + } + } + + local builtin = require('telescope.builtin') + require('telescope').load_extension('fzy_native') + + vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) + vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) + vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) + vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) + + vim.api.nvim_create_user_command( + 'FindConfig', + function() + builtin.find_files({ + search_dirs = { + os.getenv("XDG_CONFIG_HOME") .. "/nvim/lua", + os.getenv("XDG_CONFIG_HOME") .. "/nvim/after", + os.getenv("XDG_CONFIG_HOME") .. "/zsh", + os.getenv("XDG_CONFIG_HOME") .. "/shell", + os.getenv("XDG_CONFIG_HOME") .. "/X", + os.getenv("XDG_CONFIG_HOME") .. "/X11", + os.getenv("XDG_LOCAL_HOME") .. "/src", + os.getenv("XDG_LOCAL_HOME") .. "/bin", + os.getenv("XDG_DOTFILES"), + }, + hidden = true, + }) + end, + {} + ) + vim.keymap.set('n', '<leader>lf', ":FindConfig<CR>") + + vim.api.nvim_create_user_command( + 'GrepConfig', + function() + builtin.live_grep({ + search_dirs = { + os.getenv("XDG_CONFIG_HOME") .. "/nvim/lua", + os.getenv("XDG_CONFIG_HOME") .. "/nvim/after", + os.getenv("XDG_CONFIG_HOME") .. "/zsh", + os.getenv("XDG_CONFIG_HOME") .. "/shell", + os.getenv("XDG_CONFIG_HOME") .. "/X", + os.getenv("XDG_CONFIG_HOME") .. "/X11", + os.getenv("XDG_LOCAL_HOME") .. "/src", + os.getenv("XDG_LOCAL_HOME") .. "/bin", + os.getenv("XDG_DOTFILES"), + }, + hidden = true, + }) + end, + {} + ) + vim.keymap.set('n', '<leader>lg', ":GrepConfig<CR>") + + vim.keymap.set('n', '<C-s>', builtin.spell_suggest, {}) + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua @@ -0,0 +1,37 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function () + require("nvim-treesitter").setup({ +-- ensure_installed = "none", + auto_install = true, + indent = { + enable = true + }, + highlight = { + enable = true, + disable = function(lang, buf) + local langs = { "latex", "html" , "markdown", "text"} + for i=1,#langs do + if lang == langs[i] then + return true + end + end + + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + vim.notify( + "File larger than 100KB treesitter disabled for performance", + vim.log.levels.WARN, + {title = "Treesitter"} + ) + return true + end + end, + additional_vim_regex_highlighting=false, + }, + }) + end + +} diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + "mbbill/undotree", + config = function() + vim.keymap.set('n', '<leader>u', ":UndotreeToggle<CR>") + end +} diff --git a/lua/plugins/vimtex.lua b/lua/plugins/vimtex.lua @@ -0,0 +1,29 @@ +return { + "lervag/vimtex", + lazy = false, + init = function() + vim.opt.conceallevel = 2 + vim.g.vimtex_view_method = "zathura" + vim.g.latex_to_unicode_auto = 1 + vim.g.tex_flavour = "latex" + vim.g.vimtex_compiler_latexmk = { + executable = "latexmk", + options = { + "-synctex=0", + "-verbose", + "-file-line-error", + "-interaction=nonstopmode", + "-shell-escape", + "-synctex=1" + }, + out_dir = "build", + aux_dir = "build" + } + vim.g.vimtex_quickfix_mode = 0 + vim.g.tex_conceal = "abdmg" + + vim.keymap.set('n', '<leader>tp', "<Esc>:w<CR>:VimtexCompile<CR>") + vim.keymap.set('n', '<leader>te', "<Esc>:w<CR>:VimtexErrors<CR>") + + end +} diff --git a/lua/snippets/basic.lua b/lua/snippets/basic.lua @@ -0,0 +1,18 @@ +local ls = require("luasnip") + +local s = ls.snippet + +local date = function() return {os.date('%Y-%m-%d')} end +local func = ls.function_node + +ls.add_snippets(nil, { + all = { + s({ + trig = "date", + namr = "Date", + dscr = "Date in the form of YYYY-MM-DD", + }, { + func(date, {}), + }), + }, +}) diff --git a/lua/snippets/latex.lua b/lua/snippets/latex.lua @@ -0,0 +1,623 @@ +local ls = require("luasnip") +local s = ls.snippet +local i = ls.insert_node +local t = ls.text_node +local fmt = require("luasnip.extras.fmt").fmt +local extras = require("luasnip.extras") +local rep = extras.rep + +local function math() + return vim.api.nvim_eval('vimtex#syntax#in_mathzone()') == 1 +end +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 +local function tikz() + return env("tikzpicture") +end + +ls.add_snippets("tex", { +s({ trig = "beg", snippetType = "snippet", descr = "begin env"}, fmt([[ + \begin{<>} + <> + \end{<>}]], + { i(1, "env"), i(0), rep(1) }, + { delimiters = "<>" } +)), +s({ trig = "...", wordTrig = false, snippetType = "autosnippet", descr = "ldots" }, { t("\\ldots") }), +s("template", fmt([[ + \documentclass[a4paper]{article} + + \usepackage[T1]{fontenc} + \usepackage[utf8]{inputenc} + \usepackage{mlmodern} + + \usepackage[parfill]{parskip} + \usepackage[colorlinks=true,naturalnames=true,plainpages=false,pdfpagelabels=true]{hyperref} + \usepackage[parfill]{parskip} + \usepackage{lipsum} + + \usepackage{amsmath, amssymb} + \usepackage{subcaption} + \usepackage[shortlabels]{enumitem} + \usepackage{amsthm} + \usepackage{mathtools} + \usepackage{braket} + \usepackage{bbm} + + \usepackage{graphicx} + \usepackage{geometry} + \geometry{a4paper, top=15mm} + + % figure support + \usepackage{import} + \usepackage{xifthen} + \pdfminorversion=7 + \usepackage{pdfpages} + \usepackage{transparent} + \newcommand{\incfig}[1]{% + \def\svgwidth{\columnwidth} + \import{./figures/}{#1.pdf_tex} + } + + \pdfsuppresswarningpagegroup=1 + + %\usepackage[backend=biber, sorting=none]{biblatex} + %\addbibresource{uni.bib} + + \title{<>} + \author{Milutin Popović} + + \begin{document} + %\tableofcontents + \maketitle + <> + %\printbibliography + \end{document} + ]], + { i(1, "Title"), i(0) }, + { + delimiters = "<>", + })), +s({ trig = "document", descr = "document environment", snippetType = "snippet" }, + fmt([[ + \begin{document} + \tableofcontents + <> + \printbibliography + \end{document} + ]], + { i(0) }, + { delimiters = "<>" } + )), +s({ trig = "table", descr = "table environment" , snippetType = "snippet" }, + fmt([[ + \begin{table}[htb] + \centering + \caption{<>} + \label{tab:<>} + \begin{tabular}{<>} + <> + \end{tabular} + \end{table} + ]], + { i(1, "caption"), i(2, "label"), i(3, "c"), i(0) }, + { delimiters = "<>" } + )), +s({ trig = "fig", descr = "figure environment" }, + fmt([[ + \begin{figure}[htb!] + \centering + \includegraphics[width=0.8\textwidth]{<>} + \caption{<>} + \label{fig:<>} + \end{figure} + ]], + { i(1, "path"), i(2, "caption"), i(3, "0") }, + { delimiters = "<>" } + )), +s({ trig = "align", descr = "align", snippetType = "autosnippet" }, + fmt([[ + \begin{align} + <> + \end{align} + ]], + { i(1) }, + { delimiters = "<>" } + )), +s({ trig = "enumerate", descr = "enumerate", snippetType = "autosnippet" }, + fmt([[ + \begin{enumerate} + \item <> + \end{enumerate} + ]], + { i(1) }, + { delimiters = "<>" } + )), +s({ trig = "itemize", descr = "itemize", snippetType = "autosnippet" }, + fmt([[ + \begin{itemize} + \item <> + \end{itemize} + ]], + { i(1) }, + { delimiters = "<>" } + )), +s({ trig = "frame", descr = "frame", snippetType = "snippet" }, + fmt([[ + \begin{frame}{<>} + <> + \end{frame} + ]], + { i(1), i(0) }, + { delimiters = "<>" } + )), +s({ trig = "desc", descr = "description", snippetType = "snippet" }, + fmt([[ + \begin{description} + \item[<>] <> + \end{description} + ]], + { i(1), i(0) }, + { delimiters = "<>" } + )), +s({ trig = "pac", descr = "package", snippetType = "snippet" }, + fmt([[\usepackage[<>]{<>}<> ]], + { i(1, "options"), i(2, "package"), i(0) }, + { delimiters = "<>" } + )), +s({ trig = "=>", wordTrig = false, descr = "implies", snippetType = "autosnippet" }, + { t("\\implies") }, + { condition = math, show_condition = math } + ), +s({ trig = "=<", wordTrig = false, descr = "impliedby", snippetType = "autosnippet" }, + { t("\\impliedby") }, + { condition = math, show_condition = math } + ), +s({ trig = "iff", wordTrig = false, descr = "iff", snippetType = "autosnippet" }, + { t("\\iff") }, + { condition = math, show_condition = math } + ), +s({ trig = "//", wordTrig = false, descr = "Fraction", snippetType = "autosnippet" }, + fmt([[\frac{<>}{<>}<>]], { i(1), i(2), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "==", wordTrig = false, descr = "equals", snippetType = "autosnippet" }, + fmt([[ + &= <> \\ + ]], { i(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "!=", wordTrig = false, descr = "not equals", snippetType = "autosnippet" }, + { t("\\neq") }, + { condition = math, show_condition = math } + ), +s({ trig = "ceil", wordTrig = false, descr = "ceiling function", snippetType = "autosnippet" }, + fmt([[\left\lceil <> \right\rceil <>]], { i(1), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "floor", wordTrig = false, descr = "floor function", snippetType = "autosnippet" }, + fmt([[\left\lfloor <> \right\rfloor <>]], { i(1), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "pmat", wordTrig = false, descr = "pmatrix", snippetType = "autosnippet" }, + fmt([[\begin{pmatrix} <> \end{pmatrix} <>]], { i(1), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "bmat", wordTrig = false, descr = "pmatrix", snippetType = "autosnippet" }, + fmt([[\begin{bmatrix} <> \end{bmatrix} <>]], { i(1), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lr", wordTrig = false, descr = "left* right*", snippetType = "snippet" }, + fmt([[\left<> <> \right<>]], { i(1), i(0), rep(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lr(", wordTrig = false, descr = "left( right)", snippetType = "autosnippet" }, + fmt([[\left( <> \right)]], { i(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lr|", wordTrig = false, descr = "left| right|", snippetType = "autosnippet" }, + fmt([[\left| <> \right|]], { i(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lr{", wordTrig = false, descr = "left{ right}", snippetType = "autosnippet" }, + fmt([[\left\{ <> \right\}]], { i(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lr[", wordTrig = false, descr = "left{ right}", snippetType = "autosnippet" }, + fmt([[\left[ <> \right] ]], { i(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lra", wordTrig = false, descr = "left< right>", snippetType = "autosnippet" }, + fmt([[\left\langle <> \right\rangle] ]], { i(1) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "conj", descr = "conjugate", snippetType = "autosnippet" }, + fmt([[\overline{<>}<>]], { i(1), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "sum", wordTrig = false, descr = "sum", snippetType = "autosnippet" }, + fmt([[\sum_{<>}^{<>} <>]], { i(1), i(2), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "lim", wordTrig = false, descr = "lim", snippetType = "autosnippet" }, + fmt([[\lim_{<> \to <>} <>]], { i(1), i(2, "\\infty"), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "limsup", wordTrig = false, descr = "limsup", snippetType = "autosnippet" }, + fmt([[\limsup_{<> \to <>} <>]], { i(1), i(2, "\\infty"), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "prod", wordTrig = false, descr = "product", snippetType = "autosnippet" }, + fmt([[\prod_{<>}^{<>} <>]], { i(1), i(2), i(0) }, { delimiters = "<>" }), + { condition = math, show_condition = math } + ), +s({ trig = "part", wordTrig = false, descr = "d/dx", snippetType = "snippet" }, + fmt( + [[\frac{\partial <>}{\partial <>} <>]], + { i(1, "f"), i(2, "x"), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "sqrt", wordTrig = false, descr = "sqrt", snippetType = "autosnippet" }, + fmt( + [[\sqrt{<>} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "hat", wordTrig = false, descr = "hat", snippetType = "autosnippet" }, + fmt( + [[\hat{<>}<>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "tilde", wordTrig = false, descr = "tilde", snippetType = "autosnippet" }, + fmt( + [[\tilde{<>}<>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "td", wordTrig = false, descr = "to the .. power", snippetType = "autosnippet" }, + fmt( + [[^{<>} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "rd", wordTrig = false, descr = "to the .. (power)", snippetType = "autosnippet" }, + fmt( + [[^{(<>)} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "rd", wordTrig = false, descr = "to the .. (power)", snippetType = "autosnippet" }, + fmt( + [[^{(<>)} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "__", wordTrig = false, descr = "subscript", snippetType = "autosnippet" }, + fmt( + [[_{<>}<>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "ooo", wordTrig = false, descr = "infty", snippetType = "autosnippet" }, + { t("\\infty") }, + { condition = math, show_condition = math } + ), +s({ trig = "<=", wordTrig = false, descr = "leq", snippetType = "autosnippet" }, + { t("\\le") }, + { condition = math, show_condition = math } + ), +s({ trig = ">=", wordTrig = false, descr = "geq", snippetType = "autosnippet" }, + { t("\\ge") }, + { condition = math, show_condition = math } + ), +s({ trig = "EE", wordTrig = false, descr = "exists", snippetType = "autosnippet" }, + { t("\\exists") }, + { condition = math, show_condition = math } + ), +s({ trig = "AA", wordTrig = false, descr = "forall", snippetType = "autosnippet" }, + { t("\\forall") }, + { condition = math, show_condition = math } + ), +s({ trig = "xnn", wordTrig = false, descr = "x_n", snippetType = "autosnippet" }, + { t("x_{n}") }, + { condition = math, show_condition = math } + ), +s({ trig = "ynn", wordTrig = false, descr = "y_n", snippetType = "autosnippet" }, + { t("y_{n}") }, + { condition = math, show_condition = math } + ), +s({ trig = "xii", wordTrig = false, descr = "x_i", snippetType = "autosnippet" }, + { t("x_{i}") }, + { condition = math, show_condition = math } + ), +s({ trig = "yii", wordTrig = false, descr = "y_i", snippetType = "autosnippet" }, + { t("y_{i}") }, + { condition = math, show_condition = math } + ), +s({ trig = "xjj", wordTrig = false, descr = "x_j", snippetType = "autosnippet" }, + { t("x_{j}") }, + { condition = math, show_condition = math } + ), +s({ trig = "yjj", wordTrig = false, descr = "y_j", snippetType = "autosnippet" }, + { t("y_{j}") }, + { condition = math, show_condition = math } + ), +s({ trig = "mcal", wordTrig = false, descr = "mathcal", snippetType = "autosnippet" }, + fmt( + [[\mathcal{<>}<>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "lll", wordTrig = false, descr = "l", snippetType = "autosnippet" }, + { t("\\ell") }, + { condition = math, show_condition = math } + ), +s({ trig = "nabl", wordTrig = false, descr = "nabla", snippetType = "autosnippet" }, + { t("\\nabla") }, + { condition = math, show_condition = math } + ), +s({ trig = "xx", wordTrig = false, descr = "cross", snippetType = "autosnippet" }, + { t("\\times") }, + { condition = math, show_condition = math } + ), +s({ trig = "**", wordTrig = false, descr = "cdot", snippetType = "autosnippet" }, + { t("\\cdot") }, + { condition = math, show_condition = math } + ), +s({ trig = "pi", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\pi") }, + { condition = math, show_condition = math } + ), +s({ trig = "arcsin", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\arcsin") }, + { condition = math, show_condition = math } + ), +s({ trig = "sin", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\sin") }, + { condition = math, show_condition = math } + ), +s({ trig = "cos", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\cos") }, + { condition = math, show_condition = math } + ), +s({ trig = "arccot", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\arrcot") }, + { condition = math, show_condition = math } + ), +s({ trig = "cot", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\cot") }, + { condition = math, show_condition = math } + ), +s({ trig = "csc", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\csc") }, + { condition = math, show_condition = math } + ), +s({ trig = "ln", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\ln") }, + { condition = math, show_condition = math } + ), +s({ trig = "log", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\log") }, + { condition = math, show_condition = math } + ), +s({ trig = "exp", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\exp") }, + { condition = math, show_condition = math } + ), +s({ trig = "star", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\star") }, + { condition = math, show_condition = math } + ), +s({ trig = "perp", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\perp") }, + { condition = math, show_condition = math } + ), +s({ trig = "int ", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\int") }, + { condition = math, show_condition = math } + ), +s({ trig = "zeta", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\zeta") }, + { condition = math, show_condition = math } + ), +s({ trig = "arccos", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\arccos") }, + { condition = math, show_condition = math } + ), +s({ trig = "actan", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\arctan") }, + { condition = math, show_condition = math } + ), +s({ trig = "tan", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\tan") }, + { condition = math, show_condition = math } + ), +s({ trig = "arccsc", wordTrig = false, descr = "fill", snippetType = "autosnippet" }, + { t("\\arcsc") }, + { condition = math, show_condition = math } + ), +s({ trig = "dint", wordTrig = false, descr = "integral", snippetType = "autosnippet" }, + fmt( + [[\int_{<>}^{<>} <> <>]], + { i(1), i(2), i(3), i(4) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "->", wordTrig = false, descr = "to", snippetType = "autosnippet" }, + { t("\\to") }, + { condition = math, show_condition = math } + ), +s({ trig = "<->", wordTrig = false, descr = "leftrightarrow", snippetType = "autosnippet" }, + { t("\\leftrightarrow") }, + { condition = math, show_condition = math } + ), +s({ trig = "!>", wordTrig = false, descr = "mapsto", snippetType = "autosnippet" }, + { t("\\mapsto") }, + { condition = math, show_condition = math } + ), +s({ trig = "ivs", wordTrig = false, descr = "inverse", snippetType = "autosnippet" }, + { t("^{-1}") }, + { condition = math, show_condition = math } + ), +s({ trig = "compl", wordTrig = false, descr = "compliment", snippetType = "autosnippet" }, + { t("^{c}") }, + { condition = math, show_condition = math } + ), +s({ trig = "\\\\\\", wordTrig = false, descr = "setminus", snippetType = "autosnippet" }, + { t("\\setminus") }, + { condition = math, show_condition = math } + ), +s({ trig = ">>", wordTrig = false, descr = ">>", snippetType = "autosnippet" }, + { t("\\gg") }, + { condition = math, show_condition = math } + ), +s({ trig = "<<", wordTrig = false, descr = "<<", snippetType = "autosnippet" }, + { t("\\ll") }, + { condition = math, show_condition = math } + ), +s({ trig = "~~", wordTrig = false, descr = "~", snippetType = "autosnippet" }, + { t("\\sim") }, + { condition = math, show_condition = math } + ), +s({ trig = "sub", wordTrig = false, descr = "~", snippetType = "autosnippet" }, + { t("\\subseteq") }, + { condition = math, show_condition = math } + ), +s({ trig = "set", wordTrig = false, descr = "set", snippetType = "autosnippet" }, + fmt( + [[\{<>\} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "||", wordTrig = false, descr = "mid", snippetType = "autosnippet" }, + { t("\\mid") }, + { condition = math, show_condition = math } + ), +s({ trig = "cc", wordTrig = false, descr = "subseet", snippetType = "autosnippet" }, + { t("\\subset") }, + { condition = math, show_condition = math } + ), +s({ trig = "notin", wordTrig = false, descr = "not in", snippetType = "autosnippet" }, + { t("\\not\\in") }, + { condition = math, show_condition = math } + ), +s({ trig = "inn", wordTrig = false, descr = "in", snippetType = "autosnippet" }, + { t("\\in") }, + { condition = math, show_condition = math } + ), +s({ trig = "Nn", wordTrig = false, descr = "cap", snippetType = "autosnippet" }, + { t("\\cap") }, + { condition = math, show_condition = math } + ), +s({ trig = "UU", wordTrig = false, descr = "cup", snippetType = "autosnippet" }, + { t("\\cup") }, + { condition = math, show_condition = math } + ), +s({ trig = "uuu", wordTrig = false, descr = "bigcup", snippetType = "autosnippet" }, + fmt( + [[\bigcup_{<>} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "nnn", wordTrig = false, descr = "bigcap", snippetType = "autosnippet" }, + fmt( + [[\bigcap_{<>} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "OO", wordTrig = false, descr = "emptyset", snippetType = "autosnippet" }, + { t("\\O") }, + { condition = math, show_condition = math } + ), +s({ trig = "<!", wordTrig = false, descr = "normal", snippetType = "autosnippet" }, + { t("\\triangleleft") }, + { condition = math, show_condition = math } + ), +s({ trig = "<>", wordTrig = false, descr = "hokje", snippetType = "autosnippet" }, + { t("\\diamond") }, + { condition = math, show_condition = math } + ), +s({ trig = "tt", wordTrig = false, descr = "text", snippetType = "autosnippet" }, + fmt( + [[\text{<>} <>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "case", wordTrig = false, descr = "cases", snippetType = "autosnippet" }, + fmt([[ + \begin{cases} + <> + \end{cases} + ]], + { i(1) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "cvec", wordTrig = false, descr = "column vector", snippetType = "autosnippet" }, + fmt( + [[\begin{pmatrix} <>_<> \\ \vdots \\ <>_<> \end{pmatrix}]], + { i(1, "x"), i(2, "1"), i(3, "x"), i(4, "n") }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "bar", wordTrig = false, descr = "bar", snippetType = "autosnippet" }, + fmt( + [[\overline{<>}<>]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "dL", wordTrig = false, descr = "double letter", snippetType = "autosnippet" }, + fmt( + [[ \mathbb{<>}<> ]], + { i(1), i(0) }, + { delimiters = "<>" } + ), + { condition = math, show_condition = math } + ), +s({ trig = "eps", wordTrig = false, descr = "varepsilon", snippetType = "autosnippet" }, + { t("\\varepsilon") }, + { condition = math, show_condition = math } + ), +s({ trig = "vrho", wordTrig = false, descr = "varrho", snippetType = "autosnippet" }, + { t("\\varrho") }, + { condition = math, show_condition = math } + ), +s({ trig = "vphi", wordTrig = false, descr = "varphi", snippetType = "autosnippet" }, + { t("\\varphi") }, + { condition = math, show_condition = math } + ), +}) diff --git a/lua/snippets/rust.lua b/lua/snippets/rust.lua @@ -0,0 +1,19 @@ +local ls = require("luasnip") +local s = ls.snippet +local i = ls.insert_node +local fmt = require("luasnip.extras.fmt").fmt + +ls.add_snippets("rust", { + s( + "match", + fmt([[ + match {} {{ + {} => {{ + {} + }} + {} => {{ + {} + }} + }};]], { i(1), i(2), i(3), i(4), i(5) } + )), +})