Я переустановил операционную систему (элементарную операционную систему) и перенес конфигурацию vim. Теперь автотриггер на UltiSnips перестал работать. Ниже я публикую уменьшенную версию моего .vimr c, который порождает проблему:
set cindent shiftwidth=4
setlocal spell
set spelllang=de,en_gb
set textwidth=100
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
nnoremap , :
nnoremap : ,
imap ö (
imap ä )
imap Ö [
imap Ä ]
imap ü {
imap Ü }
imap ß \
nmap ß \
nmap ö /
set termguicolors
set background=dark
" turn hybrid line numbers on
:set number relativenumber
:set nu rnu
let g:vimtex_compiler_progname = 'nvr'
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
let g:tex_flavor='latex'
let g:vimtex_quickfix_mode=0
let g:vimtex_view_method='zathura'
let g:vimtex_indent_on_ampersands=0
let g:vimtex_fold_enabled=1
nnoremap <space> za
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
"ret g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
" let g:UltiSnipsListSnippets="<C-i>"
Plug 'lifepillar/vim-solarized8'
call plug#end()
colorscheme solarized8
Я использовал neovim, но так как я думал, что проблема может быть вызвана этим, я установил vim, но это все еще сохраняется. Может быть, я забыл установить необходимый пакет?
РЕДАКТИРОВАТЬ: Я обнаружил, что некоторые автотриггеры работают, но не все. Например, ', l' для \lambda
или //
для \frac{}{}
не работают, а lra
для \langle \rangle
работают. Ниже я публикую все свои фрагменты для справки:
global !p
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C',
'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS',
'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]
texIgnoreMathZones = ['texMathText']
texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")
ignore = texIgnoreMathZoneIds[0]
def math():
synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
try:
first = next(
i for i in reversed(synstackids)
if i in texIgnoreMathZoneIds or i in texMathZoneIds
)
return first != ignore
except StopIteration:
return False
endglobal
# instead of autocomplete
#snippet { "brackets" iA
#{$1}$0
#endsnippet
#snippet ( "round brackes" iA
#($1)$0
#endsnippet
snippet macros "macro preamble"
\newcommand*{\N}{\mathbb{N}}%
\newcommand*{\Z}{\mathbb{Z}}%
\newcommand*{\R}{\mathbb{R}}%
\newcommand*{\C}{\mathbb{C}}%
\newcommand*{\Q}{\mathbb{Q}}%
\newcommand*{\E}{\mathbb{E}}%
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\providecommand{\inlinecode}[1]{\texttt{#1}}
endsnippet
snippet tbold "text bold" i
\textbf{$1}$0
endsnippet
priority 100
snippet ... "ldots" iA
\ldots
endsnippet
snippet beg "Latex Environment" b
\begin{${1:align*}}
$0
\end{$1}
endsnippet
snippet table "Table environment" b
\begin{table}[${1:htpb}]
\centering
\caption{${2:caption}}
\label{tab:${3:label}}
\begin{tabular}{${5:c}}
$0${5/((?<=.)c|l|r)|./(?1: & )/g}
\end{tabular}
\end{table}
endsnippet
snippet fig "Figure environment" b
\begin{figure}[${1:htpb}]
\centering
${2:\includegraphics[width=0.8\textwidth]{$3}}
\caption{${4:$3}}
\label{fig:${5:${3/\W+/-/g}}}
\end{figure}
endsnippet
snippet enum "Enumerate" bA
\begin{enumerate}
\item $0
\end{enumerate}
endsnippet
snippet item "Itemize" bA
\begin{itemize}
\item $0
\end{itemize}
endsnippet
snippet iii "item" i
\item $0
endsnippet
snippet pac "Package" b
\usepackage[${1:options}]{${2:package}}$0
endsnippet
context "math()"
snippet => "implies" Ai
\implies
endsnippet
context "math()"
snippet =< "implied by" Ai
\impliedby
endsnippet
context "math()"
snippet iff "iff" Ai
\iff
endsnippet
snippet alg "Unnumbered align environment" b
\begin{align*}
$1
\end{align*}$0
endsnippet
context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet
context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet
priority 1000
context "math()"
snippet '^.*\)/' "() Fraction" wrA
`!p
stripped = match.string[:-1]
depth = 0
i = len(stripped) - 1
while True:
if stripped[i] == ')': depth += 1
if stripped[i] == '(': depth -= 1
if depth == 0: break;
i -= 1
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
`{$1}$0
endsnippet
snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet
snippet mk "Inline math" wA
$ ${1} $`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
context "math()"
snippet '([A-Za-z])(\d)' "auto subscript" wrA
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
endsnippet
context "math()"
snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
endsnippet
context "math()"
snippet qd "^2" iA
^2
endsnippet
context "math()"
snippet cb "^3" iA
^3
endsnippet
context "math()"
snippet pv "superscript" iA
^{$1}$0
endsnippet
context "math()"
snippet tp "transpose" iA
^{T}$0
endsnippet
context "math()"
snippet rd "to the ... power" iA
^{($1)}$0
endsnippet
context "math()"
snippet sympy "sympy block " w
sympy $1 sympy$0
endsnippet
priority 10000
context "math()"
snippet 'sympy(.*)sympy' "evaluate sympy" wr
`!p
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()
snip.rv = eval('latex(' + match.group(1).replace('\\', '') \
.replace('^', '**') \
.replace('{', '(') \
.replace('}', ')') + ')')
`
endsnippet
priority 1000
snippet math "mathematicablock" w
math $1 math$0
endsnippet
priority 10000
snippet 'math(.*)math' "math" wr
`!p
import subprocess
code = match.group(1)
code = 'ToString[' + code + ', TeXForm]'
snip.rv = subprocess.check_output(['wolframscript', '-code', code])
`
endsnippet
priority 10
context "math()"
snippet "bar" "bar" riA
\overline{$1}$0
endsnippet
#priority 100
#context "math()"
#snippet "([a-zA-Z])bar" "bar" riA
#\overline{`!p snip.rv=match.group(1)`}
#endsnippet
priority 100
context "math()"
snippet "((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)bar" "bar" riA
\overline{`!p snip.rv=match.group(1)`}
endsnippet
priority 10
context "math()"
snippet "hat" "hat" riA
\hat{$1}$0
endsnippet
priority 10
context "math()"
snippet "til" "tilde" riA
\tilde{$1}$0
endsnippet
priority 10
context "math()"
snippet "bld" "math bold" riA
\mathbf{$1}$0
endsnippet
priority 100
context "math()"
snippet "((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)bld" "math bold" riA
\mathbf{`!p snip.rv=match.group(1)`}
endsnippet
priority 100
context "math()"
snippet "((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)hat" "hat" riA
\hat{`!p snip.rv=match.group(1)`}
endsnippet
priority 100
context "math()"
snippet "((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)tld" "tilde" riA
\tilde{`!p snip.rv=match.group(1)`}
endsnippet
context "math()"
snippet "(\\?\w+)(,\.|\.,)" "Vector postfix" riA
\vec{`!p snip.rv=match.group(1)`}
endsnippet
context "math()"
snippet == "equals" iA
&= $1 \\\\
endsnippet
context "math()"
snippet != "equals" iA
\neq
endsnippet
context "math()"
snippet >= "greater equal" iA
\geq
endsnippet
context "math()"
snippet <= "less equal" iA
\leq
endsnippet
context "math()"
snippet ceil "ceil" iA
\left\lceil $1 \right\rceil $0
endsnippet
context "math()"
snippet floor "floor" iA
\left\lfloor $1 \right\rfloor$0
endsnippet
snippet pmat "pmat" iA
\begin{pmatrix}
$1
\end{pmatrix} $0
endsnippet
snippet bmat "bmat" iA
\begin{bmatrix}
$1
\end{bmatrix} $0
endsnippet
#context "math()"
#snippet () "left( right)" iA
#\left( ${1:${VISUAL}} \right) $0
#endsnippet
snippet lr "left( right)" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr( "left( right)" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr| "left| right|" i
\left| ${1:${VISUAL}} \right| $0
endsnippet
snippet lr{ "left\{ right\}" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
snippet lrb "left\{ right\}" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
snippet lr[ "left[ right]" i
\left[ ${1:${VISUAL}} \right] $0
endsnippet
snippet lra "leftangle rightangle" iA
\left<${1:${VISUAL}} \right>$0
endsnippet
snippet sum "sum" w
\sum_{${1:i=1}}^{${2:N}} ${3:w_i x_i}
endsnippet
snippet taylor "taylor" w
\sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1 $0
endsnippet
snippet lim "limit" w
\lim_{${1:n} \to ${2:\infty}}
endsnippet
snippet limsup "limsup" w
\limsup_{${1:n} \to ${2:\infty}}
endsnippet
snippet prod "product" w
\prod_{${1:i=1}}^{${2:N}} ${3:x_i}
endsnippet
snippet part "d/dx" w
\frac{\partial $1}{\partial ${2:w_i}} $0
endsnippet
snippet partq "d2/dx2" w
\frac{\partial^2 $1}{\partial ${2:w_i}^2} $0
endsnippet
context "math()"
snippet sq "\sqrt{}" iA
\sqrt{${1:${VISUAL}}} $0
endsnippet
context "math()"
snippet ooo "\infty" iA
\infty
endsnippet
context "math()"
snippet EE "geq" iA
\exists
endsnippet
context "math()"
snippet AA "forall" iA
\forall
endsnippet
context "math()"
snippet xnn "xn" iA
x_{n}
endsnippet
context "math()"
snippet ynn "yn" iA
y_{n}
endsnippet
context "math()"
snippet xii "xi" iA
x_{i}
endsnippet
context "math()"
snippet yii "yi" iA
y_{i}
endsnippet
context "math()"
snippet xjj "xj" iA
x_{j}
endsnippet
context "math()"
snippet yjj "yj" iA
y_{j}
endsnippet
context "math()"
snippet xp1 "x" iA
x_{n+1}
endsnippet
context "math()"
snippet xmm "x" iA
x_{m}
endsnippet
context "math()"
snippet mcal "mathcal" iA
\mathcal{$1}$0
endsnippet
snippet lll "l" iA
\ell
endsnippet
context "math()"
snippet nabl "nabla" iA
\nabla
endsnippet
context "math()"
snippet xx "cross" iA
\times
endsnippet
priority 100
snippet ** "cdot" iA
\cdot
endsnippet
context "math()"
snippet norm "norm" iA
\|$1\|$0
endsnippet
priority 100
context "math()"
snippet '(?<!\\)(sin|cos|tan|arccot|cot|csc|ln|log|exp|star|perp)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet
priority 300
context "math()"
snippet dint "integral" wA
\int_{${1:-\infty}}^{${2:\infty}} ${3:${VISUAL}} $0
endsnippet
priority 200
context "math()"
snippet '(?<!\\)(arcsin|arccos|arctan|arccot|arccsc|arcsec|pi|zeta|int)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet
priority 100
context "math()"
snippet -> "to" iA
\to
endsnippet
priority 200
context "math()"
snippet <-> "leftrightarrow" iA
\leftrightarrow
endsnippet
context "math()"
snippet !> "mapsto" iA
\mapsto
endsnippet
context "math()"
snippet invs "inverse" iA
^{-1}
endsnippet
context "math()"
snippet compl "complement" iA
^{c}
endsnippet
context "math()"
snippet \\\ "setminus" iA
\setminus $0
endsnippet
snippet >> ">>" iA
\gg $0
endsnippet
snippet << "<<" iA
\ll $0
endsnippet
snippet ~~ "~" iA
\sim $0
endsnippet
context "math()"
snippet set "set" wA
\\{$1\\} $0
endsnippet
snippet || "mid" iA
\mid
endsnippet
context "math()"
snippet cc "subset" Ai
\subset
endsnippet
snippet notin "not in " iA
\not\in
endsnippet
context "math()"
snippet inn "in " iA
\in
endsnippet
snippet NN "n" iA
\N
endsnippet
snippet Nn "cap" iA
\cap
endsnippet
snippet UU "cup" iA
\cup
endsnippet
snippet uuu "bigcup" iA
\bigcup_{${1:i \in ${2: I}}} $0
endsnippet
snippet nnn "bigcap" iA
\bigcap_{${1:i \in ${2: I}}} $0
endsnippet
snippet OO "emptyset" iA
\O
endsnippet
snippet RR "real" iA
\R
endsnippet
snippet QQ "Q" iA
\Q
endsnippet
snippet ZZ "Z" iA
\Z
endsnippet
context "math()"
snippet '(?<!i)sts' "text subscript" irA
_\text{$1} $0
endsnippet
context "math()"
snippet tt "text" iA
\text{$1}$0
endsnippet
context "math()"
snippet case "cases" wA
\begin{cases}
$1
\end{cases}
endsnippet
snippet cvec "column vector" iA
\begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix}
endsnippet
context "math()"
snippet mean "mean" iA
\left<${1:${VISUAL}} \right>_{$2}$0
endsnippet
context "math()"
snippet evl "expected value" iA
\E_{$2}\left[${1:${VISUAL}}\right]$0
endsnippet
context "math()"
snippet var "variance" iA
\Var\left[${1:${VISUAL}}\right]$0
endsnippet
context "math()"
snippet cov "variance" iA
\Cov\left[${1:${VISUAL}}\right]$0
endsnippet
context "math()"
snippet dkl "DKL" iA
D_{KL}\left[p($1)\mid\mid p($2)\right]$0
endsnippet
context "math()"
snippet binom "binomial coefficient" iA
\binom{$1}{$2}$0
endsnippet
priority 0
context "math()"
snippet ,G "Gamma" iA
\Gamma
endsnippet
context "math()"
snippet ,D "Delta" iA
\Delta
endsnippet
context "math()"
snippet ,U "Theta" iA
\Theta
endsnippet
context "math()"
snippet ,L "Lambda" iA
\Lambda
endsnippet
context "math()"
snippet ,X "Xi" iA
\Xi
endsnippet
context "math()"
snippet ,P "Pi" iA
\Pi
endsnippet
context "math()"
snippet ,S "Sigma" iA
\Sigma
endsnippet
context "math()"
snippet ,Y "Upsilon" iA
\Upsilon
endsnippet
context "math()"
snippet ,F "Phi" iA
\Phi
endsnippet
context "math()"
snippet ,C "Psi" iA
\Psi
endsnippet
context "math()"
snippet ,O "Omega" iA
\Omega
endsnippet
context "math()"
snippet ,a "alpha" iA
\alpha
endsnippet
context "math()"
snippet ,b "beta" iA
\beta
endsnippet
context "math()"
snippet ,g "gamma" iA
\gamma
endsnippet
context "math()"
snippet ,d "delta" iA
\delta
endsnippet
context "math()"
snippet ,e "epsilon" iA
\epsilon
endsnippet
context "math()"
snippet ,z "zeta" iA
\zeta
endsnippet
context "math()"
snippet ,q "eta" iA
\eta
endsnippet
context "math()"
snippet ,u "theta" iA
\theta
endsnippet
context "math()"
snippet ,i "iota" iA
\iota
endsnippet
context "math()"
snippet ,k "kappa" iA
\kappa
endsnippet
context "math()"
snippet ,l "lambda" iA
\lambda
endsnippet
context "math()"
snippet ,m "mu" iA
\mu
endsnippet
context "math()"
snippet ,n "nu" iA
\nu
endsnippet
context "math()"
snippet ,x "xi" iA
\xi
endsnippet
context "math()"
snippet ,p "pi" iA
\pi
endsnippet
context "math()"
snippet ,r "rho" iA
\rho
endsnippet
context "math()"
snippet ,s "sigma" iA
\sigma
endsnippet
context "math()"
snippet ,t "tau" iA
\tau
endsnippet
context "math()"
snippet ,y "upsilon" iA
\upsilon
endsnippet
context "math()"
snippet ,f "phi" iA
\phi
endsnippet
context "math()"
snippet ,j "chi" iA
\chi
endsnippet
context "math()"
snippet ,c "psi" iA
\Theta
endsnippet
context "math()"
snippet ,o "omega" iA
\omega
endsnippet
context "math()"
snippet evin "evaluate integral" iA
\biggr\rvert_{$1}^{$2}$0
endsnippet
context "math()"
snippet __ "subscript" iA
_{$1}$0
endsnippet
snippet mathdoc "math document" b
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{amssymb}
\usepackage[margin=1.5in]{geometry}
\newcommand*{\N}{\mathbb{N}}%
\newcommand*{\Z}{\mathbb{Z}}%
\newcommand*{\R}{\mathbb{R}}%
\newcommand*{\C}{\mathbb{C}}%
\newcommand*{\Q}{\mathbb{Q}}%
\newcommand*{\E}{\mathbb{E}}%
\newcommand*{\Var}{\mathrm{Var}}%
\newcommand*{\Cov}{\mathrm{Cov}}%
\title{$1}
\author{${2:Georg Chechelnizki}}
\begin{document}
\maketitle
$0
\end{document}
endsnippet
snippet incd "inline code" A
\inlinecode{$1}$0
endsnippet
snippet ndist "normal distribution"
\mathcal{N}($1, $2)$0
endsnippet
context "math()"
snippet min "minimum" wA
\min_{$1}$0
endsnippet
context "math()"
snippet max "maximum" wA
\max_{$1}$0
endsnippet
context "math()"
snippet argmin "arg-min" wA
\arg\min_{$1}$0
endsnippet
context "math()"
snippet argmax "arg-max" wA
\arg\max_{$1}$0
endsnippet
context "math()"
snippet det "determinant" wA
\text{det}\left[$1 \right]$0
endsnippet
context "math()"
snippet tr "trace" wA
\text{Tr}\left[$1 \right]$0
endsnippet
EDIT2: я только что узнал, что виновником является математический контекст в самом начале файла фрагмента. Он хорошо работает со средой $...$
, но не с \begin{align*}...\end{align*}
. Что странно, потому что раньше работало. Честно говоря, я скопировал этот код и не знаю точно, что он делает.