init.vim 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. " ########## General ########## {{{
  2. syntax on
  3. colorscheme elflord
  4. let g:airline_theme='atomic'
  5. set encoding=utf-8
  6. set fileencoding=utf-8
  7. set wildmenu
  8. set autoindent
  9. set smartindent
  10. set incsearch
  11. set hlsearch
  12. set smarttab
  13. set ignorecase
  14. set smartcase
  15. set mouse=
  16. set number relativenumber
  17. set so=7
  18. set tabstop=4 shiftwidth=4
  19. set expandtab
  20. let mapleader = ","
  21. let maplocalleader = "\\"
  22. " }}}
  23. " ########## Highlighting ########## {{{
  24. highlight ExtraWhitespace ctermbg=red guibg=red
  25. match ExtraWhitespace /\s\+$/
  26. augroup trailingwhitespace
  27. autocmd!
  28. autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/
  29. augroup END
  30. " Tabs
  31. set list
  32. set listchars=tab:\|\ ,
  33. " }}}
  34. " ########## Keybinds ########## {{{
  35. nnoremap <leader>ev :vsplit $MYVIMRC<cr>
  36. nnoremap <leader>sv :source $MYVIMRC<cr>
  37. nnoremap <leader>f :FZF<cr>
  38. nnoremap <leader>gs :Gstatus<cr>
  39. nnoremap <leader>gc :Gcommit<cr>
  40. nnoremap <leader>gr :Git rebase -i
  41. noremap <leader>c :w! \| !compiler <c-r>%<CR><CR>
  42. noremap <leader>o :!open <c-r>%<CR><CR>
  43. noremap <leader>p :!opout <c-r>%<CR><CR>
  44. nnoremap <leader>u :!ctags -R .<CR>
  45. " Local (scope) replace
  46. nnoremap gr gd[{V%::s/<C-R>///gc<left><left><left>
  47. " Global replace
  48. nnoremap gR gD:%s/<C-R>///gc<left><left><left>
  49. " Cscope keybinds
  50. map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR>
  51. map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR>
  52. nnoremap Y y$
  53. nnoremap H ^
  54. nnoremap L $
  55. vnoremap H ^
  56. vnoremap L $
  57. inoremap jk <esc>
  58. inoremap <esc> <nop>
  59. inoremap <Left> <nop>
  60. inoremap <Right> <nop>
  61. inoremap <Up> <nop>
  62. inoremap <Down> <nop>
  63. " Dragvisuals keybinds
  64. vmap <expr> <LEFT> DVB_Drag('left')
  65. vmap <expr> <RIGHT> DVB_Drag('right')
  66. vmap <expr> <DOWN> DVB_Drag('down')
  67. vmap <expr> <UP> DVB_Drag('up')
  68. vmap <expr> D DVB_Duplicate()
  69. " Remove any introduced trailing whitespace after moving...
  70. let g:DVB_TrimWS = 1
  71. " }}}
  72. " ########## Abbreviations ########## {{{
  73. iabbrev @@ frans@tankernn.eu
  74. iabbrev ssig -- <cr>Frans Bergman<cr>frans@tankernn.eu
  75. " }}}
  76. " ########## File-specific settings ########## {{{
  77. autocmd FileType gitcommit,groff :set spell
  78. autocmd FileType vim :set foldmethod=marker
  79. autocmd BufNewFile,BufRead *.ms,*.me,*.mom,*.man set filetype=groff
  80. " }}}
  81. " ########## Plugins ########## {{{
  82. call plug#begin()
  83. Plug 'tpope/vim-fugitive'
  84. Plug 'bling/vim-airline'
  85. Plug 'vim-airline/vim-airline-themes'
  86. Plug 'mkitt/tabline.vim'
  87. Plug 'tpope/vim-surround'
  88. Plug 'tpope/vim-repeat'
  89. Plug 'raimondi/delimitmate'
  90. Plug 'fisadev/dragvisuals.vim'
  91. Plug 'dense-analysis/ale'
  92. Plug 'maralla/completor.vim'
  93. Plug 'junegunn/fzf'
  94. Plug 'Chiel92/vim-autoformat'
  95. Plug 'preservim/nerdtree'
  96. Plug 'vim-scripts/taglist.vim'
  97. Plug 'ashinkarov/nvim-agda'
  98. Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  99. call plug#end()
  100. " }}}
  101. " ########## Plugin Settings ########## {{{
  102. let g:ale_linters = {'rust': ['cargo', 'rls']}
  103. let g:deoplete#enable_at_startup = 1
  104. nmap <leader>an <Plug>(ale_next)
  105. nmap <leader>ap <Plug>(ale_previous)
  106. let g:completor_filetype_map = {}
  107. " Enable lsp for rust by using rls
  108. let g:completor_filetype_map.rust = {'ft': 'lsp', 'cmd': 'rls'}
  109. augroup rust
  110. autocmd!
  111. autocmd FileType rust au BufWrite <buffer> :Autoformat
  112. autocmd FileType rust let b:delimitMate_smart_quotes='\%(\w\|[^[:punct:][:space:]]\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]]\)\|\<\%#\|\&\%#'
  113. augroup END
  114. " Use TAB to complete when typing words, else inserts TABs as usual. Uses
  115. " dictionary, source files, and completor to find matching words to complete.
  116. " Note: usual completion is on <C-n> but more trouble to press all the time.
  117. " Never type the same word twice and maybe learn a new spellings!
  118. " Use the Linux dictionary when spelling is in doubt.
  119. function! Tab_Or_Complete() abort
  120. " If completor is already open the `tab` cycles through suggested completions.
  121. if pumvisible()
  122. return "\<C-N>"
  123. " If completor is not open and we are in the middle of typing a word then
  124. " `tab` opens completor menu.
  125. elseif col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^[[:keyword:][:ident:]]'
  126. return "\<C-R>=completor#do('complete')\<CR>"
  127. else
  128. " If we aren't typing a word and we press `tab` simply do the normal `tab`
  129. " action.
  130. return "\<Tab>"
  131. endif
  132. endfunction
  133. " Use `tab` key to select completions. Default is arrow keys.
  134. inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
  135. inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
  136. " Use tab to trigger auto completion.
  137. inoremap <expr> <Tab> Tab_Or_Complete()
  138. " }}}