Compare commits
2 Commits
3ac8878b0e
...
1619646611
Author | SHA1 | Date | |
---|---|---|---|
1619646611 | |||
13bfac82df |
179
init.vim
179
init.vim
@ -44,6 +44,12 @@
|
|||||||
endif
|
endif
|
||||||
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')
|
if has('win32') || has('win64')
|
||||||
let g:plugged_home = stdpath('data') . '\plugged' " neovim path
|
let g:plugged_home = stdpath('data') . '\plugged' " neovim path
|
||||||
else
|
else
|
||||||
@ -53,6 +59,11 @@
|
|||||||
|
|
||||||
call plug#begin(g:plugged_home)
|
call plug#begin(g:plugged_home)
|
||||||
" vim-plug bundles {{{
|
" 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
|
" UI related
|
||||||
Plug 'chriskempson/base16-vim'
|
Plug 'chriskempson/base16-vim'
|
||||||
@ -119,7 +130,11 @@
|
|||||||
Plug 'lervag/vimtex'
|
Plug 'lervag/vimtex'
|
||||||
|
|
||||||
" vim-instant-markdown
|
" vim-instant-markdown
|
||||||
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
|
" Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
|
||||||
|
Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown'}
|
||||||
|
|
||||||
|
" SageMath
|
||||||
|
Plug 'petRUShka/vim-sage'
|
||||||
|
|
||||||
" Git {{{
|
" Git {{{
|
||||||
|
|
||||||
@ -209,6 +224,11 @@ tnoremap <Esc> <C-\><C-n>
|
|||||||
" autocmd BufWinEnter,InsertLeave,CursorMovedI * if index(HighlightWhitespacesBlacklist, &ft) < 0 | match ExtraWhitespace /\s\+\%#\@<!$\| \+\ze\t/
|
" autocmd BufWinEnter,InsertLeave,CursorMovedI * if index(HighlightWhitespacesBlacklist, &ft) < 0 | match ExtraWhitespace /\s\+\%#\@<!$\| \+\ze\t/
|
||||||
" autocmd FileType markdown autocmd BufWinEnter,InsertLeave,CursorMovedI *
|
" autocmd FileType markdown autocmd BufWinEnter,InsertLeave,CursorMovedI *
|
||||||
augroup END
|
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
|
" " Colorscheme
|
||||||
" let base16colorspace=256
|
" let base16colorspace=256
|
||||||
@ -231,6 +251,8 @@ tnoremap <Esc> <C-\><C-n>
|
|||||||
|
|
||||||
" dichromatic
|
" dichromatic
|
||||||
colorscheme dichromatic
|
colorscheme dichromatic
|
||||||
|
" Recolor selected line in QuickFix window
|
||||||
|
hi QuickFixLine ctermbg=15 ctermfg=240 cterm=NONE guibg=#585858 guifg=#FFFFFF gui=NONE
|
||||||
|
|
||||||
" Lightline
|
" Lightline
|
||||||
"\ 'colorscheme': 'solarized',
|
"\ 'colorscheme': 'solarized',
|
||||||
@ -307,7 +329,8 @@ set smartcase
|
|||||||
set tabstop=4
|
set tabstop=4
|
||||||
|
|
||||||
" set to the same as tabstop
|
" set to the same as tabstop
|
||||||
set shiftwidth=4
|
" 0 automatically defaults to the current value of tabstop
|
||||||
|
set shiftwidth=0
|
||||||
|
|
||||||
" if it looks like a tab, we can delete it like a tab
|
" if it looks like a tab, we can delete it like a tab
|
||||||
set softtabstop=4
|
set softtabstop=4
|
||||||
@ -319,18 +342,31 @@ set smartcase
|
|||||||
set shiftround
|
set shiftround
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" highlight tabs and trailing whitespace {{{
|
" Highlight tabs and trailing whitespace {{{
|
||||||
set listchars=tab:>-,trail:·,nbsp:¬,extends:…,precedes:…
|
set listchars=tab:>-,trail:·,nbsp:¬,extends:…,precedes:…
|
||||||
set list
|
set list
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" TODO: jry: disable this in favor of vim-stay
|
" TODO: jry: disable this in favor of vim-stay
|
||||||
" save folds in files {{{
|
" Save folds in files {{{
|
||||||
|
fun! LoadFoldsOnEnter()
|
||||||
|
" Filetypes to skip in favor of other types folding
|
||||||
|
if &ft =~ 'markdown'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
silent! loadview
|
||||||
|
endfun
|
||||||
|
|
||||||
augroup autofolding
|
augroup autofolding
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWinLeave,BufLeave,BufWritePost * nested if filereadable(expand('%')) | silent mkview!
|
autocmd BufWinLeave,BufLeave,BufWritePost * nested if filereadable(expand('%')) | silent mkview!
|
||||||
autocmd BufWinEnter,BufEnter,BufReadPost * silent! loadview
|
" autocmd BufWinEnter,BufEnter,BufReadPost * silent! loadview
|
||||||
|
autocmd BufWinEnter,BufEnter,BufReadPost * call LoadFoldsOnEnter()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
" Enable automatic markdown folding
|
||||||
|
let g:markdown_folding = 1
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Retain undo-history between sessions
|
" Retain undo-history between sessions
|
||||||
@ -452,10 +488,36 @@ endif
|
|||||||
|
|
||||||
" Full config: when writing or reading a buffer, and on changes in insert and
|
" Full config: when writing or reading a buffer, and on changes in insert and
|
||||||
" normal mode (after 1s; no delay when writing).
|
" normal mode (after 1s; no delay when writing).
|
||||||
call neomake#configure#automake('nrwi', 500)
|
call neomake#configure#automake('nrwi', 2000)
|
||||||
|
|
||||||
" Autoopen error list
|
" " 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
|
" 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()
|
||||||
|
" }}}
|
||||||
|
" }}}
|
||||||
|
|
||||||
" Configure for C
|
" Configure for C
|
||||||
let g:c_syntax_for_h=1
|
let g:c_syntax_for_h=1
|
||||||
@ -478,7 +540,7 @@ endif
|
|||||||
\ '-Wall',
|
\ '-Wall',
|
||||||
\ '-Wextra',
|
\ '-Wextra',
|
||||||
\ '-Wfloat-equal',
|
\ '-Wfloat-equal',
|
||||||
\ '-std=c++17',
|
\ '-std=c++20',
|
||||||
\ '-I.',
|
\ '-I.',
|
||||||
\ '-fopenmp'
|
\ '-fopenmp'
|
||||||
\ ]
|
\ ]
|
||||||
@ -515,6 +577,12 @@ endif
|
|||||||
|
|
||||||
" \ || (expand('%:t') =~# 'Test.pm')
|
" \ || (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
|
" Configure for latex
|
||||||
let g:neomake_tex_enabled_makers = ['chktex']
|
let g:neomake_tex_enabled_makers = ['chktex']
|
||||||
augroup NeomakeTex
|
augroup NeomakeTex
|
||||||
@ -542,6 +610,25 @@ endif
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
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
|
" augroup perlcritic_config
|
||||||
" au!
|
" au!
|
||||||
" au FileType perl call Configure_perlcritic_for_test(expand("<afile>:p"))
|
" au FileType perl call Configure_perlcritic_for_test(expand("<afile>:p"))
|
||||||
@ -560,6 +647,12 @@ endif
|
|||||||
|
|
||||||
" Goto previous linting error
|
" Goto previous linting error
|
||||||
nnoremap [d :lprev<cr>
|
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 {{{
|
" add a proper delete line command {{{
|
||||||
@ -719,7 +812,7 @@ augroup END
|
|||||||
let g:instant_markdown_mathjax = 1
|
let g:instant_markdown_mathjax = 1
|
||||||
let g:instant_markdown_browser = "firefox --new-window"
|
let g:instant_markdown_browser = "firefox --new-window"
|
||||||
"let g:instant_markdown_port = 8888
|
"let g:instant_markdown_port = 8888
|
||||||
"let g:instant_markdown_autoscroll = 0
|
let g:instant_markdown_autoscroll = 1
|
||||||
"let g:instant_markdown_python = 1
|
"let g:instant_markdown_python = 1
|
||||||
" }}
|
" }}
|
||||||
|
|
||||||
@ -805,11 +898,11 @@ nnoremap * *zz
|
|||||||
nnoremap # #zz
|
nnoremap # #zz
|
||||||
nnoremap g* g*zz
|
nnoremap g* g*zz
|
||||||
nnoremap g# g#zz
|
nnoremap g# g#zz
|
||||||
function! ZZWrap(...)
|
function! ZZWrap(...)
|
||||||
exec ':set so=999'
|
exec ':set so=999'
|
||||||
exec join(a:000, ' ')
|
exec join(a:000, ' ')
|
||||||
exec ':set so=0'
|
exec ':set so=0'
|
||||||
endfunction
|
endfunction
|
||||||
command! -nargs=* ZZ call ZZWrap(<f-args>)
|
command! -nargs=* ZZ call ZZWrap(<f-args>)
|
||||||
|
|
||||||
nnoremap <Space> :nohl<CR>
|
nnoremap <Space> :nohl<CR>
|
||||||
@ -836,3 +929,65 @@ function! InsertSnip(snip_name)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! -nargs=1 R call InsertSnip(<f-args>)
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user