summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vimrc194
1 files changed, 194 insertions, 0 deletions
diff --git a/.vimrc b/.vimrc
new file mode 100644
index 0000000..f1fb52a
--- /dev/null
+++ b/.vimrc
@@ -0,0 +1,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