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
|
" Plugins
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
Plug 'NewComer00/octavetui.vim', {'branch': 'main'}
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug'] }
Plug 'vlime/vlime', {'rtp': 'vim/'}
call plug#end()
" Speed up making new reports
autocmd BufNewFile report.tex 0r ~/.vim/templates/skeleton.tex
" Octave IDE
let g:octavetui_octave_executable = '/usr/bin/octave'
let g:octavetui_user_keymaps = {
\ 'OctaveTUISetBreakpoint': '',
\ 'OctaveTUIDelBreakpoint': '',
\ 'OctaveTUINext': '',
\ 'OctaveTUIStepIn': '',
\ 'OctaveTUIStepOut': '',
\ 'OctaveTUIRun': '<F9>',
\ 'OctaveTUIRunStacked': '',
\ 'OctaveTUIQuit': 'q',
\ 'OctaveTUIQuitStacked': '',
\ 'OctaveTUIContinue': '',
\ 'OctaveTUIAddToWatch': '',
\ 'OctaveTUIRemoveFromWatch': '',
\ 'OctaveTUIGoToLastError': 'E',
\ }
" Hotkey for viewing pdf for vimtex
function! SyncZathura()
" Get the window ID of the CURRENT terminal (where Vim is running)
let l:term_id = system('xdotool getactivewindow')
" 1. Raise Zathura using its Class name (-x)
" 2. Raise the terminal back up using the ID we just captured
silent exec '!wmctrl -xa Zathura && wmctrl -ia ' . l:term_id
redraw!
endfunction
nnoremap <leader>z :call SyncZathura()<CR>
" Vimtex setup
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_automatic = 1
let g:vimtex_compiler_method = 'latexmk'
" Tab autocomplete (but only when wanted)
function! SmartTab()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<Tab>"
else
return "\<C-n>"
endif
endfunction
" Map it to easily go forward and backwards
inoremap <Tab> <C-r>=SmartTab()<CR>
inoremap <S-Tab> <C-p>
" Make it nice like bash
set completeopt=menu,menuone,noselect
set wildmode=list:longest
" Basic settings
filetype plugin indent on
syntax enable
set number
set ts=4
set sw=4
set smarttab
set expandtab
set autoindent
" Move easily between splits
nnoremap h <C-w>h
nnoremap j <C-w>j
nnoremap k <C-w>k
nnoremap l <C-w>l
" Compile/run hotkeys (when not using make)
autocmd FileType python map <buffer> <F9> :w<CR>:exec '!clear && python3' shellescape(@%, 1)<CR>
autocmd FileType python imap <buffer> <F9> <esc>:w<CR>:exec '!clear && python3' shellescape(@%, 1)<CR>
autocmd FileType python map <buffer> <F8> :!python3 -m openmc_plotter<CR>
autocmd FileType python map <buffer> <F8> <esc>:!python3 -m openmc_plotter<CR>
autocmd FileType java map <buffer> <F9> :w<CR>:exec '!clear && java' shellescape(@%, 1)<CR>
autocmd FileType java imap <buffer> <F9> <esc>:w<CR>:exec '!clear && java' shellescape(@%, 1)<CR>
autocmd FileType fortran map <buffer> <F9> :w<CR>:exec '!clear && gfortran -o %:r.x % && ./%:r.x'<CR>
"autocmd FileType fortran imap <buffer> <F9> <esc>:w<CR>:exec '!clear && gfortran -o %:r.out' shellescape(@%, 1) ' && ./prog'<CR>
autocmd FileType gnuplot map <buffer> <F9> :w<CR>:!gnuplot %<CR>
"autocmd FileType gnuplot imap <buffer> <F9> <esc>:w<CR>:!gnuplot % -e "pause mouse close,key"<CR>
autocmd FileType sh map <buffer> <F9> :w<CR> :!clear && ./% <CR>
autocmd FileType sh imap <buffer> <F9> <esc>:w<CR> :!clear && ./% <CR>
" Starting and closing OctaveTUI
autocmd FileType matlab map <buffer> <F5> :w<CR> :OctaveTUIStart<CR>
autocmd FileType matlab imap <buffer> <F5> <esc>:w<CR> :OctaveTUIStart <CR>
autocmd FileType matlab map <buffer> <F6> :w<CR> :OctaveTUIStop <CR>
autocmd FileType matlab imap <buffer> <F6> <esc>:w<CR> :OctaveTUIStop <CR>
" Big day for ZZ ZQ fans!
map q: <Nop>
nnoremap Q <nop>
|