Browse Source

initial

master
alistair 1 year ago
commit
5677cf234b
  1. 24
      init.lua
  2. 148
      init.vim
  3. 675
      snippets/tex.snippets

24
init.lua

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
vim.cmd("source /home/alistair/.config/nvim/lua/user/init.vim")
return {
colorscheme = "gruvbox",
plugins = {
{
"L3MON4D3/LuaSnip",
config = function(plugin, opts)
require "plugins.configs.luasnip" (plugin, opts) -- include the default astronvim config that calls the setup call
--require("luasnip.loaders.from_vscode").lazy_load { paths = { "/home/alistair/.config/nvim/lua/user/snippets/" } } -- load snippets paths
end,
},
{
"ellisonleao/gruvbox.nvim",
as = "gruvbox",
config = function()
require("gruvbox").setup {}
end,
},
{
"lervag/vimtex",
lazy = false
},
},
}

148
init.vim

@ -0,0 +1,148 @@ @@ -0,0 +1,148 @@
syntax on
" stolen from andy
set undofile
set colorcolumn=80
"set formatoptions=tc
"set fo+=a
"set textwidth=80
set scrolloff=6
set number
" set relativenumber
set tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab
"set nofoldenable
"set foldmethod=syntax
set foldlevelstart=2
"set foldnestmax=10 " 10 nested fold max
set laststatus=2
set noshowmode
set cursorline
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
nnoremap j gj
nnoremap k gk
""""""""""""""""""""""""""""""""""""""
" clipboard stuff
""""""""""""""""""""""""""""""""""""""
" Copy to clipboard
vnoremap <C-c> "+y
vnoremap <C-v> "+p
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" Copy to clipboard
vnoremap <leader>d "+d
nnoremap <leader>D "+Dg_
nnoremap <leader>d "+d
nnoremap <leader>dd "+dd
" Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P
" invert parenth highlighting
hi MatchParen ctermfg=208 ctermbg=233 cterm=bold" Fuzzy File Opening with :find
set path+=**
set wildmenu
" Search
set ignorecase smartcase incsearch hlsearch
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" Or map each action separately
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
function SetLSPShortcuts()
nnoremap <leader>ld :call LanguageClient#textDocument_definition()<CR>
nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR>
nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR>
nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR>
nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <leader>lm :call LanguageClient_contextMenu()<CR>
endfunction()
"augroup LSP
" autocmd!
" autocmd FileType cpp,c call SetLSPShortcuts()
"augroup END
set hlsearch
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
"nmap <F3> i<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
"imap <F3> <C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR>
"REMAPS
nnoremap <silent><esc> :nohlsearch<CR>
" vertical resize shortcuts
nnoremap <M-=> :res +1<CR>
nnoremap <M--> :res -1<CR>
" horizontal resize shortcuts
nnoremap <M-+> :res +1<CR>
nnoremap <M-_> :res -1<CR>
" quick terminal open
nnoremap <leader>t :12sp<CR>:term<CR>i
" better pane switching
set splitbelow
set splitright
set hlsearch
let g:vimtex_view_method = 'zathura'
tnoremap <C-h> <C-\><C-N><C-w>h
tnoremap <C-j> <C-\><C-N><C-w>j
tnoremap <C-k> <C-\><C-N><C-w>k
tnoremap <C-l> <C-\><C-N><C-w>l
inoremap <C-h> <C-\><C-N><C-w>h
inoremap <C-j> <C-\><C-N><C-w>j
inoremap <C-k> <C-\><C-N><C-w>k
inoremap <C-l> <C-\><C-N><C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
tnoremap <Esc> <C-\><C-n>
tnoremap <C-w> <C-\><C-n><C-w>
" Highight Keywords in code comments and notes
"match Todo /TODO:\|DEFN:\|REF:\|Q:/
" means you can just start writing shit at some random point on the page which
" is quite nice
set virtualedit=all
map <C-enter> :VimtexView<cr>

675
snippets/tex.snippets

@ -0,0 +1,675 @@ @@ -0,0 +1,675 @@
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
snippet template "Basic template" b
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[dutch]{babel}
\usepackage{amsmath, amssymb}
% 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
\begin{document}
$0
\end{document}
endsnippet
snippet beg "begin{} / end{}" bA
\\begin{$1}
$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 thm "Theorem" bA
\begin{thm}{}{}
$0
\end{thm}
endsnippet
snippet lemma "Lemma" bA
\begin{lemma}
$0
\end{lemma}
endsnippet
snippet claim "Claim" bA
\begin{claim}
$0
\end{claim}
endsnippet
snippet proof "Proof" bA
\begin{proof}
$0
\end{proof}
endsnippet
snippet corr "Corrolary" bA
\begin{corr}
$0
\end{corr}
endsnippet
snippet ex "Example" bA
\begin{ex}
$0
\end{ex}
endsnippet
snippet defin "Definition" bA
\begin{definition}{}{}
$0
\end{definition}
endsnippet
snippet rmk "Remark" bA
\begin{remark}{}{}
$0
\end{remark}
endsnippet
snippet prop "Proposition" bA
\begin{prop}
$0
\end{prop}
endsnippet
snippet enum "Enumerate" bA
\begin{enumerate}
\item $0
\end{enumerate}
endsnippet
snippet item "Itemize" bA
\begin{itemize}
\item $0
\end{itemize}
endsnippet
snippet desc "Description" b
\begin{description}
\item[$1] $0
\end{description}
endsnippet
snippet pac "Package" b
\usepackage[${1:options}]{${2:package}}$0
endsnippet
snippet => "implies" Ai
\implies
endsnippet
snippet =< "implied by" Ai
\impliedby
endsnippet
context "math()"
snippet iff "iff" Ai
\iff
endsnippet
snippet mk "Math" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dm "Math" wA
\[
${1:${VISUAL}}
.\] $0
endsnippet
snippet ali "Align" bA
\begin{align*}
${1:${VISUAL}}
\end{align*}
endsnippet
context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet
snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet
context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet
priority 1000
context "math()"
snippet '^.*\)/' "() frac" 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
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
snippet sympy "sympyblock " w
sympy $1 sympy$0
endsnippet
priority 10000
snippet 'sympy(.*)sympy' "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
snippet == "equals" iA
&= $1 \\\\
endsnippet
snippet != "equals" iA
\neq
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
context "math()"
snippet conj "conjugate" iA
\overline{$1}$0
endsnippet
snippet sum "sum" w
\sum_{n=${1:1}}^{${2:\infty}} ${3:a_n z^n}
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:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}} $0
endsnippet
snippet part "d/dx" w
\frac{\partial ${1:V}}{\partial ${2:x}} $0
endsnippet
context "math()"
snippet \sqrt "\sqrt{}" iA
\sqrt{${1:${VISUAL}}} $0
endsnippet
context "math()"
snippet sr "^2" iA
^2
endsnippet
context "math()"
snippet cb "^3" iA
^3
endsnippet
context "math()"
snippet td "to the ... power" iA
^{$1}$0
endsnippet
context "math()"
snippet rd "to the ... power" iA
^{($1)}$0
endsnippet
snippet __ "subscript" iA
_{$1}$0
endsnippet
snippet ooo "\infty" iA
\infty
endsnippet
snippet rij "mrij" i
(${1:x}_${2:n})_{${3:$2}\\in${4:\\N}}$0
endsnippet
snippet <= "leq" iA
\le
endsnippet
snippet >= "geq" iA
\ge
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
snippet R0+ "R0+" iA
\\R_0^+
endsnippet
snippet plot "Plot" w
\begin{figure}[$1]
\centering
\begin{tikzpicture}
\begin{axis}[
xmin= ${2:-10}, xmax= ${3:10},
ymin= ${4:-10}, ymax = ${5:10},
axis lines = middle,
]
\addplot[domain=$2:$3, samples=${6:100}]{$7};
\end{axis}
\end{tikzpicture}
\caption{$8}
\label{${9:$8}}
\end{figure}
endsnippet
snippet nn "Tikz node" w
\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$};
$0
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|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
snippet >> ">>" iA
\gg
endsnippet
snippet << "<<" iA
\ll
endsnippet
snippet ~~ "~" iA
\sim
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
snippet <! "normal" iA
\triangleleft
endsnippet
snippet <> "hokje" iA
\diamond
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 SI "SI" iA
\SI{$1}{$2}
endsnippet
snippet bigfun "Big function" iA
\begin{align*}
$1: $2 &\longrightarrow $3 \\\\
$4 &\longmapsto $1($4) = $0
.\end{align*}
endsnippet
snippet cvec "column vector" iA
\begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix}
endsnippet
snippet " bf" "textbf" iA
\textbf{$0}
endsnippet
snippet letw "let omega" iA
Let $\Omega \subset \C$ be open.
endsnippet
snippet HH "H" iA
\mathbb{H}
endsnippet
snippet DD "D" iA
\mathbb{D}
endsnippet
# vim:ft=snippets
Loading…
Cancel
Save