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 = "\[6 q" &t_SR = "\[4 q" &t_EI = "\[2 q" nnoremap \ :noh nnoremap Y y$ nnoremap n :bnext! nnoremap p :bprev! nnoremap d :bdelete nnoremap D :bdelete! 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 g:UltiSnipsExpandTrigger = "" g:UltiSnipsJumpForwardTrigger = "" g:UltiSnipsJumpBackwardTrigger = "" 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 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 fa :FigAdd nnoremap fe :FigEdit nnoremap ev :vsplit $MYVIMRC nnoremap sv :source $MYVIMRC autocmd FileType tex g:UltiSnipsSnippetDirectories += [b:vimtex.root .. "/UltiSnips"] runtime! macros/matchit.vim runtime! ftplugin/man.vim