diff --git a/init.vim b/init.vim index 71f1777..9f8ec4b 100644 --- a/init.vim +++ b/init.vim @@ -137,7 +137,7 @@ " vim-instant-markdown " Plug 'suan/vim-instant-markdown', {'for': 'markdown'} - Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown'} + Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'} " SageMath Plug 'petRUShka/vim-sage' @@ -198,6 +198,8 @@ filetype plugin indent on au BufRead,BufNewFile *.html+itjdk.ep set filetype=html.epl au BufRead,BufNewFile *.html+stedk.ep set filetype=html.epl au BufRead,BufNewFile *.html+isbdk.ep set filetype=html.epl + + au BufRead,BufNewFile *.cpp.snip set filetype=cpp " }}} " escape terminal on tnoremap @@ -517,10 +519,10 @@ endif " 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() + " " 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() " }}} @@ -541,19 +543,20 @@ endif " Configure for C++ let g:cpp_syntax_for_h=1 - let g:neomake_cpp_enabled_makers = ['clang'] ", 'clangtidy', 'clangcheck'] - clangtidy and/or clangcheck requires a compilation database + let g:neomake_cpp_enabled_makers = ['clang', 'gcc'] ", 'clangtidy', 'clangcheck'] - clangtidy and/or clangcheck requires a compilation database let g:neomake_clang_args = [ \ '-fsyntax-only', \ '-Wall', \ '-Wextra', \ '-Wfloat-equal', - \ '-std=c++20', + \ '-std=c++17', \ '-I.', \ '-fopenmp' \ ] " Configure for Rust - let g:neomake_rust_enabled_makers = ['rustc', 'cargo'] + " let g:neomake_rust_enabled_makers = ['rustc', 'cargo'] + let g:neomake_rust_enabled_makers = ['cargo'] " Configure for Haskell let g:neomake_haskell_enabled_makers = ['hlint'] @@ -718,8 +721,13 @@ endif " }}} " Configure Vim-Commentary -autocmd FileType matlab setlocal commentstring=%\ %s -autocmd FileType julia setlocal commentstring=#\ %s +augroup CustomCommentDefinitions + autocmd! + autocmd FileType matlab setlocal commentstring=%\ %s + autocmd FileType julia setlocal commentstring=#\ %s + autocmd FileType cpp setlocal commentstring=\/\/\ %s +augroup END + " NCM2 augroup NCM2 @@ -753,14 +761,14 @@ augroup NCM2 \ }) " C/C++ - let g:ncm2_pyclang#library_path = 'usr/lib' + " let g:ncm2_pyclang#library_path = '/usr/lib' " goto declaration (TODO: is the ¬ on purpose???) autocmd FileType c,cpp nnoremap gd :call ncm2_pyclang#goto_declaration()¬ augroup END " VimTex {{ let g:tex_flavor = 'latex' - let g:vimtex_syntax_conceal_default = 0 + let g:vimtex_syntax_conceal_disable = 1 let g:vimtex_fold_manual = 1 let g:vimtex_compiler_enabled = 1 " continuous compilation if has('nvim') @@ -817,9 +825,18 @@ augroup END " }} " Add spell checking to LaTeX documents {{ - augroup LaTeXSpelling + let g:spellfile_URL = 'http://ftp.vim.org/vim/runtime/spell' + function! SetLanguageSpecificSpellFile() + if &spelllang =~ '^en' + setlocal spellfile+=~/.config/nvim/spell/en.utf-8.add + endif + if &spelllang =~ '^da' + setlocal spellfile+=~/.config/nvim/spell/dk.utf-8.add + endif + endfunction + augroup spelling au! - au FileType tex setlocal spell spelllang=en_gb + au FileType tex,markdown setlocal spell spelllang=en_gb " As a reminder: " ]s [s jumps between spelling mistakes " zg adds the word to the dictionary @@ -827,26 +844,39 @@ augroup END " in insert mode Ctrl-X s shows the suggestions " We only want the 10 best suggestions - not over 50 - au FileType tex setlocal spellsuggest+=10 + au FileType tex,markdown setlocal spellsuggest+=10 " Add a file for custom suggestions - au FileType tex setlocal spellsuggest+=file:~/.config/nvim/spell/suggestions + au FileType tex,markdown setlocal spellsuggest+=file:~/.config/nvim/spell/suggestions " Add the default spelling file - au FileType tex setlocal spellfile+=~/.config/nvim/spell/en.utf-8.add + au FileType tex,markdown execute SetLanguageSpecificSpellFile() + " au FileType tex,markdown setlocal spellfile+=~/.config/nvim/spell/en.utf-8.add " zg or 1zg adds a word to the dictionary " Add a file specific wordlist for one-off words that shouldn't be part of " the dictionary - au FileType tex setlocal spellfile+=oneoff.utf-8.add + au FileType tex,markdown setlocal spellfile+=oneoff.utf-8.add " 2zg adds a word to the dictionary " Add a LaTeX specific wordlist for e.g. chktex au FileType tex setlocal spellfile+=~/.config/nvim/spell/LaTeX.utf-8.add " 3zg adds a word to the dictionary + + " Add a Markdown specific wordlist + au FileType markdown setlocal spellfile+=~/.config/nvim/spell/Markdown.utf-8.add + " 3zg adds a word to the dictionary augroup END " }} +" Add 80 character line limit {{ + augroup textwrapping + au! + au FileType tex,markdown setlocal textwidth=80 + augroup END + set colorcolumn=82 +" }} + " Change window directory to the same as the open buffer command! LCDCurrDir lcd %:p:h @@ -909,10 +939,12 @@ nnoremap :nohl function! InsertSnip(snip_name) " Find the template - if a:snip_name =~ '^JIX/' - let l:fname = stdpath('config') . '/snippets/' . a:snip_name . '.pm' + echo a:snip_name + if a:snip_name =~ '^/' || a:snip_name =~ '^\~/' + let l:fname = a:snip_name + echo l:fname else - let l:fname = stdpath('config') . '/snippets/' . a:snip_name . '.snip' + let l:fname = stdpath('config') . '/snippets/' . a:snip_name . '.*' endif execute "r ". l:fname @@ -928,7 +960,12 @@ function! InsertSnip(snip_name) endif endfunction +function! FzySnip() + call picker#File('find -type f -name "*.snip"', 'R', {'cwd': stdpath('config') . '/snippets'}) +endfunction + command! -nargs=1 R call InsertSnip() +command! -nargs=0 RR call FzySnip() function! GenerateMarkdownHeaderAnchors() let l:winview = winsaveview() " save cursor position diff --git a/install_configfiles.sh b/install_configfiles.sh new file mode 100644 index 0000000..0c5649c --- /dev/null +++ b/install_configfiles.sh @@ -0,0 +1,3 @@ +#!/bin/bash +mkdir -p ~/.config/nvim; +ln -s ~/Nextcloud/configfiles/vim/vimrc/init.vim ~/.config/nvim/init.vim;