1
0
Fork 0
nixos-config/home-manager/roles/neovim/vimrc
2022-01-07 15:03:11 +01:00

255 lines
6.9 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

set spell spelllang=de,en
let g:airline_powerline_fonts = 1
let g:airline_skip_empty_sections = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#nvimlsp#enabled = 0
let g:tex_flavor = 'latex'
function! MyExplorer()
if &filetype == 'coc-explorer'
wincmd w
else
CocCommand explorer --no-toggle
endif
endfunction
nnoremap <space>e :call MyExplorer()<CR>
set nofoldenable
set background=light
set autoindent
set nosmartindent
set listchars=tab:»\ ,trail:.,extends:#
set list
set ts=3
set number
set scrolloff=5
set sidescrolloff=5
set laststatus=2
set incsearch
set mouse=
set showcmd
set title
" Set this here so that nothing gets overriden later
filetype plugin indent on
syntax on
set undodir=~/.vimhist/
set undofile
set undolevels=100
set undoreload=1000
augroup focus
au!
au TabLeave * silent! wall
au FocusLost * silent! wall
au BufLeave * silent! wall
augroup END
nnoremap <silent><cr> :nohlsearch<CR>
vnoremap < <gv
vnoremap > >gv
nnoremap <c-down> <c-w><c-j>
nnoremap <c-up> <c-w><c-k>
nnoremap <c-right> <c-w><c-l>
nnoremap <c-left> <c-w><c-h>
let mapleader=","
set winaltkeys=no
set noai
set cursorline
set cursorcolumn
set si
set expandtab
set sw=3
set pt=<F4>
set ignorecase
set wildmenu
set hlsearch
noremap <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:formatdef_my_cabal = '"cabal-fmt"'
let g:formatters_cabal = ['my_cabal']
let g:formatdef_my_nix = '"nixfmt"'
let g:formatters_nix = ['my_nix']
let g:formatdef_my_dhall = '"dhall format"'
let g:formatters_dhall = ['my_dhall']
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:languagetool_server_command = "languagetool-http-server"
colorscheme PaperColor
highlight CursorColumn ctermbg=8
highlight CursorLine ctermbg=8
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
nnoremap <silent> gp <Plug>(coc-diagnostic-prev)
nnoremap <silent> gn <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nnoremap <silent> gd <Plug>(coc-definition)
nnoremap <silent> gy <Plug>(coc-type-definition)
nnoremap <silent> gr <Plug>(coc-references)
nnoremap <silent> gs :Git status<CR>
nnoremap <silent> gu :CocCommand git.chunkUndo<CR>
nnoremap <silent> gi :CocCommand git.chunkInfo<CR>
nnoremap <silent> ga :CocCommand git.chunkStage<CR>
nnoremap <silent> gb :CocCommand git.showCommit<CR>
nnoremap <silent> gc :Git commit<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
nnoremap <silent> <space>i :call <SID>show_documentation()<CR>
" Remap for rename current word
nnoremap <space>r <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
nnoremap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nnoremap <leader>a <Plug>(coc-codeaction-selected)
nnoremap <silent> <space>f :Format<CR>
nnoremap <space>l <Plug>(coc-codelens-action)
" Create mappings for function text object, requires document symbols feature of languageserver.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" FZF ctrl-p style search
nnoremap <space>p :Files<CR>
nnoremap <space>g :Rg<CR>
nnoremap <space>h :History<CR>
nnoremap <space>b :Buffers<CR>
function MyClose()
if &readonly
quit
else
write
quit
endif
endfunction
function MyCloseAll()
if &readonly
quitall
else
wall
quitall
endif
endfunction
nnoremap <space>q :call MyClose()<CR>
nnoremap <space>k :call MyCloseAll()<CR>
nnoremap <space>s :w<CR>
nnoremap <a-left> :bp<CR>
nnoremap <a-right> :bn<CR>
inoremap <a-left> <ESC>:bp<CR>
inoremap <a-right> <ESC>:bn<CR>
" Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
nnoremap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
imap <ESC>[1~ <HOME>
imap <ESC>[4~ <End>
" Using CocList
" Show all diagnostics
nnoremap <silent> <space>d :<C-u>CocFzfList diagnostics<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocFzfList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocFzfList outline<cr>
" Find symbol of current document
nnoremap <silent> <space>a :<C-u>CocFzfList actions<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
imap <Enter> <CR>
" Load this after theme
hi Normal ctermbg=NONE