Compare commits

..

No commits in common. "1619646611120540a52e89ddb50c47ba69931880" and "3ac8878b0e925706976db4d3a1bfe313edf66eca" have entirely different histories.

179
init.vim
View File

@ -44,12 +44,6 @@
endif
endif
" if empty(glob(stdpath('data') . '/site/autoload/let-modeline.vim'))
" silent execute '!curl -fLo ' . stdpath('data') . '/site/autoload/let-modeline.vim' . ' --create-dirs ' .
" \ 'https://raw.githubusercontent.com/LucHermitte/lh-misc/master/plugin/let-modeline.vim'
" endif
" call let-modeline#hello()
if has('win32') || has('win64')
let g:plugged_home = stdpath('data') . '\plugged' " neovim path
else
@ -59,11 +53,6 @@
call plug#begin(g:plugged_home)
" vim-plug bundles {{{
" VimScript Library
Plug 'inkarkat/vim-ingo-library'
" Enable 'let' in modelines (replace the modeline with VIM:)
Plug 'vim-scripts/let-modeline.vim'
" UI related
Plug 'chriskempson/base16-vim'
@ -130,11 +119,7 @@
Plug 'lervag/vimtex'
" vim-instant-markdown
" Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown'}
" SageMath
Plug 'petRUShka/vim-sage'
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
" Git {{{
@ -224,11 +209,6 @@ tnoremap <Esc> <C-\><C-n>
" autocmd BufWinEnter,InsertLeave,CursorMovedI * if index(HighlightWhitespacesBlacklist, &ft) < 0 | match ExtraWhitespace /\s\+\%#\@<!$\| \+\ze\t/
" autocmd FileType markdown autocmd BufWinEnter,InsertLeave,CursorMovedI *
augroup END
augroup DontItalicMarkdownLatexUnderscore
autocmd filetype markdown syntax match markdownIgnore "\$.*_.*\$" containedin=markdown
" autocmd filetype markdown syntax match markdownIgnore \M(\\begin\{)?(\$|gather\*?|align\*?|).*_.*(\\end\{)?\2" containedin=markdown
" autocmd filetype markdown syntax match markdownIgnore "\\begin{\(\$\|gather\*\?\|align\*\?\)}.*_.*\\end{\1}" containedin=markdown
augroup END
" " Colorscheme
" let base16colorspace=256
@ -251,8 +231,6 @@ tnoremap <Esc> <C-\><C-n>
" dichromatic
colorscheme dichromatic
" Recolor selected line in QuickFix window
hi QuickFixLine ctermbg=15 ctermfg=240 cterm=NONE guibg=#585858 guifg=#FFFFFF gui=NONE
" Lightline
"\ 'colorscheme': 'solarized',
@ -329,8 +307,7 @@ set smartcase
set tabstop=4
" set to the same as tabstop
" 0 automatically defaults to the current value of tabstop
set shiftwidth=0
set shiftwidth=4
" if it looks like a tab, we can delete it like a tab
set softtabstop=4
@ -342,31 +319,18 @@ set smartcase
set shiftround
"}}}
" Highlight tabs and trailing whitespace {{{
" highlight tabs and trailing whitespace {{{
set listchars=tab:>-,trail,nbsp,extends:…,precedes:…
set list
" }}}
" TODO: jry: disable this in favor of vim-stay
" Save folds in files {{{
fun! LoadFoldsOnEnter()
" Filetypes to skip in favor of other types folding
if &ft =~ 'markdown'
return
endif
silent! loadview
endfun
" save folds in files {{{
augroup autofolding
autocmd!
autocmd BufWinLeave,BufLeave,BufWritePost * nested if filereadable(expand('%')) | silent mkview!
" autocmd BufWinEnter,BufEnter,BufReadPost * silent! loadview
autocmd BufWinEnter,BufEnter,BufReadPost * call LoadFoldsOnEnter()
autocmd BufWinEnter,BufEnter,BufReadPost * silent! loadview
augroup END
" Enable automatic markdown folding
let g:markdown_folding = 1
" }}}
" Retain undo-history between sessions
@ -488,36 +452,10 @@ endif
" Full config: when writing or reading a buffer, and on changes in insert and
" normal mode (after 1s; no delay when writing).
call neomake#configure#automake('nrwi', 2000)
call neomake#configure#automake('nrwi', 500)
" " Autoopen error list
" let g:neomake_open_list = 2 " 0: show hints, 1: show list and move cursor to list, 2: show list, but don't move cursor
" Autoopen error list {{{
let g:neomake_open_list = 0 " Don't let Neomake do it!
" Preserve view (don't automatically scroll) when moving back to
" previous buffer {{
function! SaveWinID()
let t:curWinID = win_getid()
endfunction
function! LoadWinID()
call win_gotoid( t:curWinID )
endfunction
" When switching buffers, open location window, but preserve
" cursor location and view
augroup NeomakeJumpBackHooks
au!
" autocmd User NeomakeJobInit nested lexpr [] | call AutoSaveWinView() | call SaveWinID()
" autocmd User NeomakeFinished nested lwindow | call LoadWinID() | call AutoRestoreWinView()
autocmd User NeomakeJobInit lexpr [] | call SaveWinID()
autocmd User NeomakeFinished lwindow | call LoadWinID()
augroup END
" autocmd BufLeave * call AutoSaveWinView()
" }}}
" }}}
" Autoopen error list
let g:neomake_open_list = 2 " 0: show hints, 1: show list and move cursor to list, 2: show list, but don't move cursor
" Configure for C
let g:c_syntax_for_h=1
@ -540,7 +478,7 @@ endif
\ '-Wall',
\ '-Wextra',
\ '-Wfloat-equal',
\ '-std=c++20',
\ '-std=c++17',
\ '-I.',
\ '-fopenmp'
\ ]
@ -577,12 +515,6 @@ endif
" \ || (expand('%:t') =~# 'Test.pm')
" Configure for SageMath
augroup NeomakeSageMath
autocmd!
autocmd BufReadPre,BufEnter *sage.python let b:neomake_python_enabled_makers = []
augroup END
" Configure for latex
let g:neomake_tex_enabled_makers = ['chktex']
augroup NeomakeTex
@ -610,25 +542,6 @@ endif
endfor
endfunction
" Configure for Keymapper (https://github.com/houmain/keymapper) config
" file
let g:neomake_keymapper_enabled_makers = ['keymapper']
let g:neomake_keymapper_maker = {
\ 'exe': 'keymapper',
\ 'args': ['--check', '--no-color'],
\ 'output_stream': 'both',
\ 'append_file': 0,
\ 'errorformat':
\ "%m in line %l",
\ }
" augroup NeomakeKeymapper
" au!
" autocmd BufNewFile,BufRead *.keymapper.conf set syntax=conf
" " autocmd BufReadPre keymapper.conf let b:neomake_conf_enabled_makers = ['keymapper']
" " autocmd BufEnter keymapper.conf let b:neomake_keymapper_enabled_makers = ['keymapper']
" augroup END
" augroup perlcritic_config
" au!
" au FileType perl call Configure_perlcritic_for_test(expand("<afile>:p"))
@ -647,12 +560,6 @@ endif
" Goto previous linting error
nnoremap [d :lprev<cr>
" Fit the QuickFix window to the number of errors
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
endfunction
" }}}
" add a proper delete line command {{{
@ -812,7 +719,7 @@ augroup END
let g:instant_markdown_mathjax = 1
let g:instant_markdown_browser = "firefox --new-window"
"let g:instant_markdown_port = 8888
let g:instant_markdown_autoscroll = 1
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_python = 1
" }}
@ -898,11 +805,11 @@ nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
function! ZZWrap(...)
function! ZZWrap(...)
exec ':set so=999'
exec join(a:000, ' ')
exec ':set so=0'
endfunction
endfunction
command! -nargs=* ZZ call ZZWrap(<f-args>)
nnoremap <Space> :nohl<CR>
@ -929,65 +836,3 @@ function! InsertSnip(snip_name)
endfunction
command! -nargs=1 R call InsertSnip(<f-args>)
function! GenerateMarkdownHeaderAnchors()
let l:winview = winsaveview() " save cursor position
exec 'normal! gg'
let l:match = ingo#area#frompattern#Get(0, line('$'), '\v(^#+\s+)@<=.*')
for i in range(0, len(l:match)-1)
let l:line_nr = l:match[i][0][0]
let l:valid = 0 == len(ingo#area#frompattern#Get(l:line_nr, l:line_nr, '\v<a\s+.*name\=.*>'))
if l:valid
let l:line = getbufline(bufname(), l:line_nr)[0]
let l:title = join(split(l:line)[1:-1], '-')
let l:title = tolower(l:title)
let l:title = substitute(l:title, '\V%', '%25', 'g') " MUST be first!
let l:title = substitute(l:title, '\V\', '%5C', 'g')
let l:title = substitute(l:title, '\V^', '%5E', 'g')
let l:title = substitute(l:title, '\V&\|.\|/\|,\|=\|!\|@\|#\|(\|)\|*\|$\|<\|>\|"\|', '', 'g')
let l:title = substitute(l:title, "'", '', 'g')
let l:anchor = '<a name="' . l:title . '"></a>'
let l:next_line = l:line_nr+1
let l:failed = append(l:line_nr, l:anchor)
exec ':' . l:line_nr . ',' . l:next_line .'j'
" use append for appending to the line?
endif
endfor
call winrestview(l:winview) " restore cursor position
endfunction
function! RemoveMarkdownHeaderAnchors()
let l:winview = winsaveview() " save cursor position
exec 'normal! gg'
let l:match = ingo#area#frompattern#Get(0, line('$'), '\v(^#+\s+.*)@<=\s\<a\sname\=.*\>\</a\>')
for i in range(0, len(l:match)-1)
call winrestview({'lnum': l:match[i][0][0], 'col': l:match[i][0][1]-1})
let l:string_length = l:match[i][1][1] - l:match[i][0][1] + 1
exec "normal" '"_d' . l:string_length . "l"
endfor
call winrestview(l:winview) " restore cursor position
endfunction
function! GenerateMarkdownTOC()
" We need remove the anchors before we run doctoc. Otherwise it would
" include the anchors in the link, and the anchors would become incorrect
" Doctoc also doesn't like folds, so disable them beforehand
set nofoldenable
call RemoveMarkdownHeaderAnchors()
exec ":w"
silent exec "!doctoc " . bufname()
exec ":e"
call GenerateMarkdownHeaderAnchors()
set foldenable
exec ":w"
endfunction
augroup MarkdownKeyBinds
autocmd!
autocmd FileType markdown nmap <Leader>lt :call GenerateMarkdownTOC()<CR>
augroup END