1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
vim9script
set nocompatible
set encoding=utf-8
set number
set relativenumber
set scrolloff=3
set sidescroll=3
set ignorecase
set smartcase
set splitbelow
set noswapfile
set autoindent
set backspace=indent,eol,start
set ttimeout
set ttimeoutlen=50
set incsearch
set hlsearch
g:mapleader = " "
g:maplocalleader = " "
filetype indent plugin on
filetype plugin on
set omnifunc=syntaxcomplete#Complete
set completefunc=syntaxcomplete#Complete
# Don't scan #include'd files for completions
set complete-=i
# Delete comment character when joining commented lines
set formatoptions+=j
set termguicolors
colorscheme catppuccin_macchiato
syntax enable
g:is_posix = 1
set laststatus=2
set statusline=%f\ %y%h%w%m%r%=%l:%c\ %P
&t_SI = "\<Esc>[6 q"
&t_SR = "\<Esc>[4 q"
&t_EI = "\<Esc>[2 q"
nnoremap \ :noh<cr>
nnoremap <leader>n :bnext!<cr>
nnoremap <leader>p :bprev!<cr>
nnoremap <leader>d :bdelete<cr>
nnoremap <leader>D :bdelete!<cr>
g:buftabline_indicators = 1
g:tex_flavor = "latex"
g:vimtex_view_method = "zathura_simple"
set conceallevel=2
g:tex_conceal = "abdmg"
hi Conceal ctermbg=none
autocmd FileType tex b:vcm_tab_complete = "omni"
g:UltiSnipsExpandTrigger = "<tab>"
g:UltiSnipsJumpForwardTrigger = "<tab>"
g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
def FigModifiedCallback(job: job, status: number)
const path = job_info(job).cmd[-1]
system("inkscape "
.. "--export-latex "
.. "--export-filename=" .. shellescape(fnamemodify(path, ":r")) .. ".pdf "
.. shellescape(path))
if job_status(g:inkscape_job) == "run"
g:inotify_job = job_start(["inotifywait", "-e", "modify", path], {
in_io: "null",
out_io: "null",
err_io: "null",
exit_cb: "FigModifiedCallback",
})
endif
enddef
def FigInkscapeCallback(job: job, status: number)
job_stop(g:inotify_job)
enddef
def FigOpenInkscape(path: string)
g:inkscape_job = job_start(["inkscape", path], {
in_io: "null",
out_io: "null",
err_io: "null",
exit_cb: "FigInkscapeCallback",
})
g:inotify_job = job_start(["inotifywait", "-e", "modify", path], {
in_io: "null",
out_io: "null",
err_io: "null",
exit_cb: "FigModifiedCallback",
})
enddef
def FigAdd()
const name = input("Name of figure file: ")
const figures_dir = b:vimtex.root .. "/figures/"
mkdir(figures_dir, "p")
const path = figures_dir .. name .. ".svg"
if !filewritable(path)
const svg =<< trim END
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg1"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
sodipodi:docname="drawing.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="0.77949635"
inkscape:cx="396.40981"
inkscape:cy="561.25984"
inkscape:window-width="1918"
inkscape:window-height="1054"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1" />
</svg>
END
writefile(svg, path)
endif
append(line("."), [
'\begin{figure}[ht]',
' \centering',
' \incfig{' .. name .. '}',
' \caption{}',
' \label{fig:' .. name .. '}',
'\end{figure}',
])
execute("w")
cursor(line(".") + 4, 11)
execute("startinsert")
FigOpenInkscape(path)
enddef
def FigEdit()
const figures = split(globpath(b:vimtex.root .. "/figures", "*.svg"), "\n")
final choices = map(copy(figures), '(v:key + 1) .. ". " .. fnamemodify(v:val, ":t:r")')
const idx = inputlist(insert(choices, "Select a figure to edit:"))
const path = figures[idx - 1]
FigOpenInkscape(path)
enddef
command! FigAdd call FigAdd()
command! FigEdit call FigEdit()
nnoremap <leader>fa :FigAdd<CR>
nnoremap <leader>fe :FigEdit<CR>
nnoremap <leader>ev :vsplit $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
runtime! macros/matchit.vim
runtime! ftplugin/man.vim
|