Update neovim init file

This commit is contained in:
Midgard 2022-06-11 19:53:51 +02:00
parent 1215d7270f
commit 1ae04a2715
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -18,12 +18,12 @@ set autoread " autoreload file on change
set nomodeline " after the latest modeline vulnerability I've had it
set inccommand=split
set inccommand=split " live previews of search-and-replace s///
set conceallevel=0 " don't use conceals, seriously
let g:tex_conceal='' " I said no conceals
set shell=/bin/zsh " use zsh instead of bash
"set shell=/bin/zsh " use zsh instead of bash
set number " line numbers on the left side
"set relativenumber " number+relativenumber = relative numbers for all but current line
@ -43,11 +43,50 @@ set textwidth=99
set ignorecase smartcase " don't match case if typing in all-lowercase
" Ctrl+Backspace deletes previous word like in most text editors
inoremap  <esc>dba<bs>
"inoremap  <esc>dba<bs>
inoremap  
inoremap heigth height
inoremap heihgt height
inoremap heihtg height
inoremap heitgh height
inoremap heithg height
inoremap Heigth Height
inoremap Heihgt Height
inoremap Heihtg Height
inoremap Heitgh Height
inoremap Heithg Height
inoremap HEIGTH HEIGHT
inoremap HEIHGT HEIGHT
inoremap HEIHTG HEIGHT
inoremap HEITGH HEIGHT
inoremap HEITHG HEIGHT
" Useless mode that I only activate accidentally
nnoremap Q <Nop>
" ABC macro to align system
nmap <silent> <leader>A mb?%<cr>jV/%<cr>k;a*<C-x>[^:.]\zs\|\ze<cr>`b
nmap <silent> <leader>q v3j
nmap <silent> <leader>Q v3jA
" Set terminal title {{{2
" From eevee's dotfiles
set titlestring=vim\ %{expand(\"%t\")}
if $TERM =~ "^screen"
" pretend this is xterm. if term is left as `screen`, vim doesn't understand ctrl-arrow.
if $TERM == "screen-256color"
set term=xterm-256color
else
set term=xterm
endif
" gotta set these *last*, since `set term` resets everything
set t_ts=k
set t_fs=\
endif
set title
" Remove trailing whitespace on save {{{2
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
@ -58,18 +97,22 @@ fun! CleanExtraSpaces()
endfun
if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee,*.css,*.scss,*.html :call CleanExtraSpaces()
endif
" Filetype
au BufRead,BufNewFile *.mapcss set filetype=css
" Switching buffers {{{2
nnoremap <silent> <F14> :bprev<cr> " s-F2
nnoremap <silent> <F15> :bnext<cr> " s-F3
nnoremap <silent> <F16> :bwipeout<cr> " s-F4
" Indentation {{{2
set tabstop=2 " tab is 2 wide
set shiftwidth=2 " for use with > and <
set tabstop=3 " tab is 3 wide
set shiftwidth=3 " for use with > and <
set noexpandtab " tab key puts tabs
set copyindent " when opening new line, indent with same characters
"set list listchars=tab:‧\ ,trail:· " display tabs with a leading \cdot. Alternatives: \mapsto ↦, U+16EB runic single punctuation ᛫
" trailing whitespace looks like \cdot
set list listchars=tab:¦\ ,trail" show indentation lines for tabs, trailing whitespace looks like \cdot
@ -83,11 +126,36 @@ vnoremap > >gv
" Folds {{{2
set foldlevelstart=3 " Not too much folding
set foldmethod=marker
set foldlevelstart=2 " Not too much folding
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" {{{2
function! s:line_handler(l)
let keys = split(a:l, ':\t')
exec 'buf' keys[0]
exec keys[1]
normal! ^zz
endfunction
function! s:buffer_lines()
let res = []
for b in filter(range(1, bufnr('$')), 'buflisted(v:val)')
call extend(res, map(getbufline(b,0,"$"), 'b . ":\t" . (v:key + 1) . ":\t" . v:val '))
endfor
return res
endfunction
command! FZFLines call fzf#run({
\ 'source': <sid>buffer_lines(),
\ 'sink': function('<sid>line_handler'),
\ 'options': '--extended --nth=3..',
\ 'down': '60%'
\})
" Misc {{{2
" Change cursor shape according to mode
@ -110,6 +178,9 @@ command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
" Navigate to bookmark, AZERTY has no backtick key
noremap <leader>m `
inoremap :w<cr> <esc>:w<cr>
inoremap :q<cr> <esc>:q<cr>
" Consistent aliases to jump to first non-whitespace character and last character
noremap <a-h> ^
noremap <a-l> $
@ -126,15 +197,15 @@ nnoremap <leader>Y "+yg_ | nnoremap <leader>D "+dg_ | nnoremap <leader>P
nnoremap <leader>y "+y | nnoremap <leader>y "+d | vnoremap <leader>p "+p
nnoremap <leader>yy "+yy | nnoremap <leader>dd "+dd | vnoremap <leader>P "+P
" Opening windows {{{2
" Moving across windows {{{2
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-h> <C-w>h
imap <C-w> <esc><C-w>
vmap <C-w> <esc><C-w>
" Opening windows {{{2
nnoremap <C-b> <C-w>n
nnoremap <C-n> <C-w>v
nnoremap <C-c> <C-w>q
@ -177,32 +248,34 @@ inoremap <leader>-\| ⊣
inoremap <leader>int
inoremap <leader>sum
nnoremap <Leader>r :%s/\<<C-r><C-w>\>/
vnoremap <Leader>r "hy:%s/<C-r>y/
" Default visual block {{{2
nnoremap v <C-v>
nnoremap <C-v> v
" Adding modeline {{{2
" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <leader>ml :call AppendModeline()<CR>
" Spell check {{{2
" ================
set spelllang=en_uk,nl
set spellfile=$HOME/.local/share/nvim/spellfile.utf-8.add
inoremap <C-p> <c-g>u<Esc>[s1z=`]a<c-g>u
"nnoremap <C-l> m][s1z=`]
augroup spellcheck_textfiles
au! BufNewFile,BufRead *.md,*.txt,*.tex setlocal spell
augroup END
"let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
"augroup ocaml_support
"au! BufNewFile,BufRead *.ml execute "set rtp+=" . g:opamshare . "/merlin/vim"
"augroup END
augroup json_prettyprint
au! BufNewFile,BufRead *.json,*.geojson nnoremap ;ff :%!python -m json.tool \| sed -r ':begin;s/^(\t*) /\1\t/;t begin'<cr>
augroup END
" Keep undo history {{{2
" ======================
set undodir=/tmp/vim-undodir
@ -231,6 +304,10 @@ call plug#begin('~/.config/nvim/plug')
"Plug 'LaTeX-Box-Team/LaTeX-Box', { 'for': 'tex' } " included in vim-polyglot
"Plug 'rust-lang/rust.vim', { 'for': 'rust' } " included in vim-polyglot
Plug 'ap/vim-css-color' " CSS color names
"Plug 'Twinside/vim-hoogle' " search on hoogle
Plug 'ledger/vim-ledger', { 'for': ['journal'] } " accounting with ledger
Plug 'freitass/todo.txt-vim',
Plug 'gentoo/gentoo-syntax'
" C/C++
"Plug 'vim-scripts/c.vim', { 'for': ['c', 'cpp', 'objc'] } " various IDE-like C features
@ -254,10 +331,18 @@ call plug#begin('~/.config/nvim/plug')
"Plug 'kana/vim-operator-user' " define your own operator easily
"Plug 'junegunn/vim-peekaboo' " preview registers when pressing \" or @
Plug 'gcmt/wildfire.vim' " smart selection of the closest text object
Plug 'Valloric/YouCompleteMe', { 'do': 'git submodule update --init --recursive && ./install.py --system-libclang --all' } " code-completion engine
Plug 'Valloric/YouCompleteMe', { 'for': ['c', 'cpp', 'python', 'haskell'], 'do': 'git submodule update --init --recursive && ./install.py --system-libclang --system-abseil --system-boost --clang-completer --ts-completer' } " code-completion engine
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " code-completion engine
"Plug 'deoplete-plugins/deoplete-jedi', { 'for': ['python'] } " complete python
"Plug 'Shougo/deoplete-clangx', { 'for': ['c', 'cpp', 'objc'] } " complete C, C++, Objective-C
"Plug 'copy/deoplete-ocaml', { 'for': ['ocaml'] } " complete OCaml
"Plug 'Shougo/neco-syntax' " complete based on syntax files
"Plug 'paretje/deoplete-notmuch', { 'for': 'mail' } " complete addresses from notmuch
"Plug 'Thyrum/vim-stabs'
Plug 'tpope/vim-speeddating' " increment dates and more with Ctrl-A/Ctrl-X
" Navigation
"Plug 'ctrlpvim/ctrlp.vim' " fuzzy file, buffer, mru, tag, etc. finder
Plug 'ctrlpvim/ctrlp.vim' " fuzzy file, buffer, mru, tag, etc. finder
Plug 'dyng/ctrlsf.vim' " search for code, edit it in-place, have multiple cursors
Plug 'scrooloose/nerdtree' " filesystem tree explorer
"Plug 'majutsushi/tagbar' " display tags in a window, ordered by scope
@ -267,7 +352,7 @@ call plug#begin('~/.config/nvim/plug')
"Plug 'ludovicchabant/vim-gutentags' " unobtrusively manage tag files
"Plug 'tpope/vim-obsession' " continuously updated session files
" Powerline
"" Powerline
Plug 'vim-airline/vim-airline' " statusline plugin in pure Vimscript
Plug 'vim-airline/vim-airline-themes' " themes for airline
@ -282,7 +367,6 @@ call plug#begin('~/.config/nvim/plug')
"Plug 'kassio/neoterm', { 'on': 'T' } " wrapper of some neovim's :terminal functions
"Plug 'tpope/vim-fugitive' " a Git wrapper
"Plug 'vim-scripts/TeTrIs.vim' " Tetris clone
Plug 'ledger/vim-ledger', { 'for': ['journal'] } " accounting with ledger
call plug#end()"
@ -293,13 +377,15 @@ set cursorline
let g:one_allow_italics = 1
colorscheme one
set background=dark
"set background=light
hi Normal guibg=NONE ctermbg=NONE
hi SpellBad guibg=NONE ctermbg=NONE
hi Comment guifg=#888888
hi link Whitespace Conceal
hi CursorLine guibg=NONE ctermbg=NONE
hi CursorLineNr guibg=NONE ctermbg=NONE
hi Folded guifg=#3b4048 ctermfg=16 guibg=NONE ctermbg=NONE gui=italic cterm=italic
"hi Folded guifg=#3b4048 ctermfg=16 guibg=NONE ctermbg=NONE gui=italic cterm=italic
hi Folded gui=bold cterm=bold
" Haskell {{{2
" ------------
@ -326,6 +412,7 @@ setlocal textwidth=99
" Markdown {{{2
" -------------
let g:vim_markdown_conceal = 0
let g:markdown_folding = 1
" CSV.vim {{{2
" ------------
@ -385,6 +472,7 @@ let g:vebugger_leader=','
" Gundo {{{2
" ----------
nnoremap <F3> :GundoToggle<CR>
let g:gundo_prefer_python3 = 1
" NERDCommenter {{{2
" ------------------
@ -393,7 +481,12 @@ vmap & <leader>c<space>
" UltiSnips {{{2
" ---------------
let g:UltiSnipsExpandTrigger='²'
let g:UltiSnipsExpandTrigger='<c-j>'
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsSnippetDir=[$HOME.'/.config/nvim/ultisnips']
let g:UltiSnipsSnippetDirectories=[$HOME.'/.config/nvim/ultisnips']
let g:UltiSnipsEditSplit="context"
" EasyAlign {{{2
" --------------
@ -416,7 +509,7 @@ let g:wildfire_objects = ["iw", "i'", "i`", 'i"', "i)", "i]", "i}", "ip", "it"]
" YouCompleteMe {{{2
" ------------------
"noremap <leader>g :YcmCompleter GoToImprecise<CR>
noremap <leader>g :YcmCompleter GoToImprecise<CR>
noremap <leader>gg <esc>:YcmCompleter GoTo<CR>
noremap <leader>gi <esc>:YcmCompleter GoToImprecise<CR>
noremap <leader>gf <esc>:YcmCompleter FixIt<CR>
@ -433,15 +526,30 @@ let g:ycm_autoclose_preview_window_after_insertion=1
let g:ycm_server_python_interpreter='/usr/bin/python3'
let g:ycm_global_ycm_extra_conf='~/.config/nvim/ycm_extra_conf.py'
let g:ycm_extra_conf_globlist = ['~/wlk/*', '~/doc/*','~/dev/*','~/uni/*'] " ,'!~/*'
let g:ycm_extra_conf_globlist = ['~/wlk/*', '~/doc/*','~/dev/planet-warrior/*','~/uni/*'] " ,'!~/*'
"let g:ycm_rust_src_path='/data/programming/rustc-1.7.0/src'
set completeopt=menu
" deoplete {{{2
" -------------
"let g:deoplete#enable_at_startup = 1
"let g:python3_host_prog = "/usr/bin/python3"
"
"call deoplete#custom#option({
"\ 'camel_case': v:true,
"\ 'smart_case': v:true,
"\ })
"
"set completeopt=menu,preview
"set completeopt-=noinsert
" CtrlP {{{2
" ----------
let g:ctrlp_map='<C-Space>'
"let g:ctrlp_map='<C-Space>'
let g:ctrlp_map='<C-P>'
let g:ctrlp_user_command=['.git/', 'git --git-dir=%s/.git ls-files . -co --exclude-standard']
"nnoremap <leader>s :CtrlPTag<CR>"
nnoremap <leader>s :CtrlPTag<CR>"
" Ctrl-S-F {{{2
" -------------
@ -456,6 +564,7 @@ nmap <C-F><Up> <Plug>CtrlSFPwordPath
nnoremap <silent> <C-F>o :CtrlSFOpen<CR>
nnoremap <silent> <C-F>t :CtrlSFToggle<CR>
inoremap <silent> <C-F>t <Esc>:CtrlSFToggle<CR>
nnoremap <silent> <C-F>l mx:FZFLines<CR>
let g:ctrlsf_regex_pattern = 1
" IndentLine {{{2
@ -544,7 +653,11 @@ let g:gutentags_cache_dir = '~/.cache/gutentag'
" Airline {{{2
" ------------
if $TERM == "linux"
let g:airline_powerline_fonts=0
else
let g:airline_powerline_fonts=1
endif
let g:airline_theme='minimalist'
let g:airline#extensions#ycm#enabled=1
let g:airline#extensions#tabline#enabled=1
@ -553,16 +666,39 @@ let g:airline#extensions#ale#enabled=1
" Ale {{{2
" --------
let g:ale_linters = {
\ 'c': [],
\ 'cpp': [],
\ 'python': ['pylint', 'mypy'],
\ 'markdown': [],
\ 'cpp': [],
\}
"\ 'c': [],
let g:ale_lint_on_text_change='normal'
let g:ale_lint_on_insert_leave=1
let g:ale_completion_delay=''
let g:ale_lint_delay=500
let g:ale_sign_error = '»'
let g:ale_sign_warning = '·'
let g:ale_python_mypy_auto_pipenv=1
let g:ale_python_mypy_options='--python-executable venv/bin/python'
let g:ale_python_pylint_auto_pipenv=1
let g:ale_python_pylint_options='--rcfile $HOME/.config/pylintrc'
let g:ale_completion_enabled=0
"let g:ale_completion_enabled=1
"let g:ale_completion_delay=''
"inoremap <C-Space> <C-X><C-O>
"set omnifunc=ale#completion#OmniFunc
"noremap <leader>gg <esc>:ALEGoToDefinition<CR>
"noremap <leader>ga <esc>:ALEFindReferences<CR>
"noremap <leader>gn <esc>:ALENext<CR>
"noremap <leader>gp <esc>:ALEPrevious<CR>
"noremap <leader>sr <esc>:ALERename<CR>
"noremap <leader>sq <esc>:ALECodeAction<CR>
"noremap <leader>ss <esc>:ALEHover<CR>
"noremap <leader>sf <esc>:ALESymbolSearch<CR>
"noremap <leader>sd <esc>:ALEDocumentation<CR>
"highlight ALEWarning cterm=undercurl gui=undercurl guibg=none guisp=DarkYellow
highlight ALEWarning none
@ -579,6 +715,7 @@ nmap <silent> <leader>tl :TestLast<CR>
nmap <silent> <leader>tg :TestVisit<CR>
let test#strategy = "neovim"
let test#python#runner = "pytest"
" EditorConfig {{{2
@ -587,8 +724,8 @@ let test#strategy = "neovim"
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
let g:EditorConfig_max_line_indicator = 'exceeding'
let g:EditorConfig_exec_path = '/usr/bin/editorconfig'
let g:EditorConfig_core_mode = 'external_command'
"let g:EditorConfig_exec_path = '/usr/bin/editorconfig'
"let g:EditorConfig_core_mode = 'external_command'
" Neoterm {{{2
" ------------
@ -601,9 +738,10 @@ let g:EditorConfig_core_mode = 'external_command'
" Ledger {{{2
" -----------
autocmd BufEnter,BufRead *.journal | setlocal modelines=1
autocmd BufEnter,BufRead *.journal | inoremap <buffer><silent> !! <esc>:call ledger#entry()<cr>:call CleanLedgerEntry()<cr>
autocmd BufEnter,BufRead *.journal | vnoremap <buffer> <tab> <esc>:call NextEntry()<cr>
autocmd BufEnter,BufReadPost *.journal | silent setlocal modelines=1
autocmd BufEnter,BufReadPost *.journal | silent setlocal foldlevel=1
autocmd BufEnter,BufReadPost *.journal | silent inoremap <buffer><silent> !! <esc>:call ledger#entry()<cr>:call CleanLedgerEntry()<cr>
autocmd BufEnter,BufReadPost *.journal | silent vnoremap <buffer> <tab> <esc>:call NextEntry()<cr>
" modeline {{{1
" vim: set foldmethod=marker foldlevel=1 noet ft=vim nowrap :