init.vim 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. " _ _|_|_____ ___ ___
  2. " | | | | | _| _|
  3. " \_/|_|_|_|_|_| |___|
  4. " Menu:
  5. " 1...................Plugins
  6. " 2....................Basics
  7. " 3................Remappings
  8. " 4......Plugin Configuration
  9. " 3.......................GUI
  10. " 4................Statusline
  11. " 5.....................Fonts
  12. " 6....................Panels
  13. " 7................MS Windows
  14. "set laststatus=2
  15. "set showtabline=2
  16. " -----[ PLUGINS ]----- "
  17. call plug#begin('~/.vim/plugged')
  18. Plug 'itchyny/lightline.vim' " simple, goodlooking statusline
  19. Plug 'junegunn/fzf.vim' " fuzzy finder for files/buffers ..
  20. "Plug 'ervandew/supertab' " tabcompletion
  21. Plug 'junegunn/goyo.vim' " Goyo, distraction free writing for LaTeX
  22. Plug 'HansMartin/inline-python' " Inline Python exec.
  23. Plug 'dylanaraps/wal.vim' " Set coloscheme from pywal
  24. Plug 'rust-lang/rust.vim' " For Rust
  25. Plug 'preservim/nerdtree' " Not sure if needed
  26. Plug 'tpope/vim-fugitive' " Git for Vim
  27. Plug 'zah/nim.vim' " Nim Plugin
  28. Plug 'neovim/nvim-lspconfig' " Official Language Server Protocol
  29. " All the lua completion plugins
  30. Plug 'hrsh7th/nvim-cmp', {'branch': 'main'}
  31. Plug 'hrsh7th/cmp-nvim-lsp', {'branch': 'main'}
  32. Plug 'hrsh7th/cmp-buffer', {'branch': 'main'}
  33. Plug 'hrsh7th/cmp-path', {'branch': 'main'}
  34. Plug 'nvim-lua/plenary.nvim'
  35. Plug 'nvim-telescope/telescope.nvim'
  36. Plug 'catppuccin/nvim', {'as': 'catppuccin', 'branch':'main'}
  37. "Plug 'neoclide/coc.nvim', {'branch': 'release'} " Testing
  38. Plug 'chriskempson/base16-vim'
  39. call plug#end()
  40. " Loads lua config from lua/init.lua
  41. lua require('init')
  42. " -----[ BASICS ]----- "
  43. " Color Settings
  44. colorscheme wal " using the wal colorscheme
  45. set mouse=a " for moving splits with the mouse
  46. " Encoding
  47. set encoding=utf-8 " set UTF-8 Encoding per Defautl (render glyphs and co)
  48. set nocompatible
  49. set conceallevel=0 " conceallevel for markdown/latex files
  50. " disable any (terminal-)bells
  51. set noeb
  52. set novb
  53. set belloff=all
  54. " Path settings
  55. set backupdir=$HOME/.config/nvim/backups
  56. set noswapfile
  57. set undodir=$HOME/.config/nvim/undo
  58. " Syntax and Lines
  59. syntax enable
  60. set number
  61. set relativenumber
  62. filetype plugin indent on
  63. " CursorLine
  64. " set cursorline
  65. " hi CursorLine term=none cterm=none
  66. " Tab/Spacing settings
  67. set expandtab " use spaces instead of tabs
  68. set shiftwidth=4 " number of columns when indenting with > or <
  69. set softtabstop=4 " number of spaces when hitting tab
  70. set autoindent " set indentation from previous line
  71. " searching...
  72. set ignorecase " case insensitive
  73. set nohlsearch " no search highlighting after the search is done
  74. set noshowmatch " disable that blinking bracket stuff
  75. set wildmenu " shows menu for tab completion
  76. set incsearch " search if you type the letters
  77. set path+=** " include all subdirs for finding files (eg. :find)
  78. set backspace=2
  79. set scrolloff=2
  80. " -----[ Remappings ]----- "
  81. " Bind 'n' to nzz (center current line)
  82. nnoremap n nzz
  83. nnoremap N Nzz
  84. " Jump 5 lines at once with Ctr+e and Ctr+y
  85. nnoremap <C-e> 5<C-e>
  86. nnoremap <C-y> 5<C-y>
  87. " mapping for fast buffer switching
  88. nnoremap <leader>a :bp!<CR>
  89. noremap <leader>s :bn!<CR>
  90. " When selecting Text, keep the Block selected
  91. vmap < <gv
  92. vmap > >gv
  93. " Remove Trailling Whitespaces on Buffer Write
  94. autocmd BufWritePre * :%s/\s\+$//e
  95. " auto execute xrdb when .Xresources is saved
  96. autocmd BufWritePost ~/.Xresources !xrdb %
  97. " automatically adjust splits
  98. autocmd VimResized * wincmd =
  99. " use Ctr+C for Copy Pasterino into sys. clipboard
  100. vnoremap <C-c> "*y :let @+=@*<CR>
  101. " Bind Goyo to shortcut
  102. map <F3> <ESC>:Goyo <CR>
  103. " Markdown viewer script
  104. map <F9> <ESC>:silent !md-viewer % <CR>
  105. " Auto make
  106. map <F8> <ESC>:silent !make <CR>
  107. " -----[ Plugin Configuration ]----- "
  108. " Lightline - Status Line
  109. " To use the wombat colorscheme
  110. set noshowmode " no required when having lightline in place
  111. let g:lightline = {
  112. \ 'colorscheme': 'wombat',
  113. \ }
  114. " FZF - Best Tool ever
  115. nnoremap <C-b> :Telescope buffers<CR>
  116. nnoremap <C-n> :Telescope find_files<CR>
  117. " Map the Python Evaluation into the vim-expression command(Q)
  118. nnoremap Q :EvalPython <CR>
  119. let g:il_append=1
  120. let g:il_use_nextline=0
  121. " Goyo Configuration
  122. let g:goyo_width=100
  123. let g:goyo_height=100
  124. " --- LaTeX Mappings ---
  125. " stolen from Luke Smith's vimrc "
  126. " will only work in .tex files
  127. " Navigating with guides
  128. autocmd FileType tex inoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  129. autocmd FileType tex vnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  130. autocmd FileType tex nnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  131. " Compile document using xelatex:
  132. autocmd FileType tex inoremap <F5> <Esc>:!pdflatex<space><c-r>%<Enter>a
  133. autocmd FileType tex nnoremap <F5> :!pdflatex<space><c-r>%<Enter>
  134. " Shortcuts
  135. autocmd FileType tex inoremap ,em \emph{}<Space><++><Esc>T{i
  136. autocmd FileType tex inoremap ,bf \textbf{}<Space><++><Esc>T{i
  137. autocmd FileType tex vnoremap , <ESC>`<i\{<ESC>`>2la}<ESC>?\\{<Enter>a
  138. autocmd FileType tex inoremap ,it \textit{}<Space><++><Esc>T{i
  139. autocmd FileType tex inoremap ,ol \begin{enumerate}<Enter><Enter>\end{enumerate}<Enter><Enter><++><Esc>3kA\item<Space>
  140. autocmd FileType tex inoremap ,ul \begin{itemize}<Enter><Enter>\end{itemize}<Enter><Enter><++><Esc>3kA\item<Space>
  141. autocmd FileType tex inoremap ,li <Enter>\item<Space>
  142. autocmd FileType tex inoremap ,ref \ref{}<Space><++><Esc>T{i
  143. autocmd FileType tex inoremap ,tab \begin{tabular}<Enter><++><Enter>\end{tabular}<Enter><Enter><++><Esc>4kA{}<Esc>i
  144. autocmd FileType tex inoremap ,sc \textsc{}<Space><++><Esc>T{i
  145. autocmd FileType tex inoremap ,chap \chapter{}<Enter><Enter><++><Esc>2kf}i
  146. autocmd FileType tex inoremap ,sec \section{}<Enter><Enter><++><Esc>2kf}i
  147. autocmd FileType tex inoremap ,ssec \subsection{}<Enter><Enter><++><Esc>2kf}i
  148. autocmd FileType tex inoremap ,sssec \subsubsection{}<Enter><Enter><++><Esc>2kf}i
  149. autocmd FileType tex inoremap ,col \begin{columns}[T]<Enter>\begin{column}{.5\textwidth}<Enter><Enter>\end{column}<Enter>\begin{column}{.5\textwidth}<Enter><++><Enter>\end{column}<Enter>\end{columns}<Esc>5kA
  150. " -----[ GUI ]----- "
  151. " This hides the Toolbar, Menubar and left/right scrollbar in gvim
  152. if has("gui_running")
  153. set guioptions -=T
  154. set guioptions -=m
  155. set guioptions -=r
  156. set guioptions -=L
  157. endif
  158. " -----[ Fonts ]----- "
  159. if has("gui_running")
  160. if has("gui_gtk2")
  161. set guifont=Hack\ 9 elseif has("gui_macvim")
  162. set guifont=Menlo\ Regular:h14
  163. elseif has("gui_win32")
  164. set guifont=Hack:h9:cANSI,Consolas:h11:cANSI
  165. endif
  166. endif
  167. " -----[ Panels ]----- "
  168. " This remaps Ctrl+W +<direction> to Ctr+HJKL for changig the Panel in a
  169. " splitted mode
  170. map <C-h> <C-W>h
  171. map <C-j> <C-W>j
  172. map <C-k> <C-W>k
  173. map <C-l> <C-W>l
  174. " This is to get Tabs by using the <leader> Key (Leader Key: '\')
  175. nmap <leader>1 1gt
  176. nmap <leader>2 2gt
  177. nmap <leader>3 3gt
  178. nmap <leader>4 4gt
  179. nmap <leader>5 5gt
  180. nmap <leader>6 6gt
  181. " -----[ MS Windows ]----- "
  182. " Getting the Windows mswin behaviour
  183. if has("win32")
  184. source $VIMRUNTIME/mswin.vim
  185. behave mswin
  186. endif
  187. if exists("b:current_syntax")
  188. finish
  189. endif
  190. " Conceal
  191. "hi Conceal guibg=NONE
  192. setlocal cole=1
  193. if exists("g:neovide")
  194. colorscheme catppuccin
  195. let g:neovide_cursor_animation_length=0.15
  196. let g:neovide_cursor_trail_length=0.3
  197. nnoremap <C-p> "+p
  198. inoremap <C-p> <c-r>+
  199. cnoremap <C-p> <c-r>+
  200. endif
  201. " -----[ Completion ]----- "
  202. " --> Completion is handled in `init.lua`
  203. " LSP / Completion Stuff
  204. " keep the left column for hinte.g. structs in nim)
  205. set signcolumn=yes