From be59725d526a68e1484744996bc67f35790b749a Mon Sep 17 00:00:00 2001 From: Knyffen Date: Fri, 6 Oct 2023 08:23:32 +0200 Subject: [PATCH] tpope/vim-spedddating mjbrownie/swapit markdown-preview liuchengxu/graphviz.vim rlue/vim-barbaric Some comment strings Some markdown latex math macro and spelloff settings --- init.vim | 80 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/init.vim b/init.vim index b769640..c60ed21 100644 --- a/init.vim +++ b/init.vim @@ -106,6 +106,10 @@ " shell commands without having to leave vim (eg. rename) Plug 'tpope/vim-eunuch' + " Improve incrementing/decrementing functionality + Plug 'tpope/vim-speeddating' + Plug 'mjbrownie/swapit' + " open file at linenumber via : Plug 'wsdjeg/vim-fetch' @@ -141,11 +145,25 @@ Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'} " markdown-preview (alternative to vim-instant-markdown) TODO - Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } + function! InstallMarkdownIt(info) + " info is a dictionary with 3 fields + " - name: name of the plugin + " - status: 'installed', 'updated', or 'unchanged' + " - force: set on PlugInstall! or PlugUpdate! + if a:info.status == 'installed' || a:info.force + !cd app && yarn install + " Enable showing file:// urls + !cd app && sed -i -e "s/vbscript|javascript|file|data/|vbscript|javascript|data/" $(rg --files-with-matches "\|file\|") + endif + endfunction + Plug 'iamcco/markdown-preview.nvim', { 'for': ['markdown'], 'do': function('InstallMarkdownIt') } " Better table handling (for markdown) Plug 'dhruvasagar/vim-table-mode' + " Graphviz + Plug 'liuchengxu/graphviz.vim' + " SageMath Plug 'petRUShka/vim-sage' @@ -163,6 +181,9 @@ " }}} + " Automatically switch fcitx5 modes based on the current vim mode + Plug 'rlue/vim-barbaric' + " vim-test - run perl-tests from inside the editor Plug 'janko-m/vim-test' @@ -706,6 +727,13 @@ endif let g:haskell_indent_guard = 4 " 2 " }}} +" vim-barbaric {{ + let g:barbaric_ime = 'fcitx' + let g:barbaric_scope = 'buffer' + let g:barbaric_timeout = -1 + let g:barbaric_fcitx_cmd = 'fcitx5-remote' +" }} + "au BufRead,BufNewFile *.scad lua require('openscad') " openscad {{{ @@ -777,9 +805,11 @@ augroup CustomCommentDefinitions autocmd FileType cpp setlocal commentstring=\/\/\ %s autocmd FileType cuda setlocal commentstring=\/\/\ %s autocmd FileType openscad setlocal commentstring=\/\/\ %s + autocmd FileType nix setlocal commentstring=#\ %s + autocmd FileType dot setlocal commentstring=\/\/\ %s + autocmd FileType markdown setlocal commentstring= augroup END - " NCM2 augroup NCM2 autocmd! @@ -856,6 +886,7 @@ augroup END " au FileType tex :call TexNewMathZone("N","align*",1) " }} + " vim-instant-markdown {{ au FileType markdown setlocal conceallevel=0 "Uncomment to override defaults: @@ -876,6 +907,9 @@ augroup END " markdown-preview {{ au FileType markdown nnoremap ll :MarkdownPreview + function OpenMarkdownPreview (url) + execute "silent ! firefox --new-window " . a:url + endfunction " See https://github.com/iamcco/markdown-preview.nvim#markdownpreview-config let g:mkdp_auto_start = 0 " default 0 let g:mkdp_auto_close = 0 " default 1 @@ -885,17 +919,22 @@ augroup END let g:mkdp_open_ip = '' " default '' let g:mkdp_browser = '' " default '' let g:mkdp_echo_preview_url = 1 " default 0 - let g:mkdp_browserfunc = '' " default '' + let g:mkdp_browserfunc = 'OpenMarkdownPreview' " default '' let g:mkdp_preview_options = { \ 'mkit': {}, \ 'katex': { - \ 'macros': { - \ "\\doubleR": "\\mathbb{R}", - \ "\\doubleN": "\\mathbb{N}", - \ "\\doubleZ": "\\mathbb{Z}", - \ "\\doubleF": "\\mathbb{F}", - \ "\\ds": "\\displaystyle", - \ }, + \ 'macros': { + \ "\\RR": "\\mathbb{R}", + \ "\\NN": "\\mathbb{N}", + \ "\\ZZ": "\\mathbb{Z}", + \ "\\QQ": "\\mathbb{Q}", + \ "\\CC": "\\mathbb{C}", + \ "\\FF": "\\mathbb{F}", + \ "\\ds": "\\displaystyle", + \ "\\lc": "\\operatorname*{lc}", + \ "\\quo": "\\operatorname*{quo}", + \ "\\rem": "\\operatorname*{rem}", + \ }, \ }, \ 'uml': {}, \ 'maid': {}, @@ -920,6 +959,17 @@ augroup END let g:table_mode_corner='|' " make the tables work with markdown " }} +" graphviz.vim {{ + let g:graphviz_viewer = 'feh' + let g:graphviz_output_format = 'svg' + " TODO create argument and pull request for giving arguments to the viewer program + augroup graphviz + au! + au FileType dot nnoremap ll :Graphviz!! + au BufWritePost *.dot :GraphvizCompile " TODO create toggle command and add pull request to github + augroup END +" }} + " Add spell checking to LaTeX documents {{ let g:spellfile_URL = 'http://ftp.vim.org/vim/runtime/spell' function! SetLanguageSpecificSpellFile() @@ -964,7 +1014,9 @@ augroup END " 3zg adds a word to the dictionary " Disable spelling in math environments - au FileType markdown syntax match quoteblock /\$[^$]\+\$/ contains=@NoSpell + au FileType markdown syntax match texMath /\$[^$]\+\$/ contains=@NoSpell containedin=markdownBlock,markdownBlockquote + au FileType markdown syntax region texMath start="\$\$" end="\$\$" contains=@NoSpell + augroup END " }} @@ -1052,6 +1104,12 @@ nnoremap :nohl augroup END " }}} +" Configure swapit and speeddating {{ + nmap SwapItFallbackIncrement SpeedDatingUp + nmap SwapItFallbackDecrement SpeedDatingDown + vmap SwapItFallbackIncrement SpeedDatingUp + vmap SwapItFallbackDecrement SpeedDatingDown +" }} function! InsertSnip(snip_name) " Find the template