init.vim 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. Plug 'nvim-lua/completion-nvim'
  30. Plug 'nvim-lua/plenary.nvim'
  31. Plug 'nvim-telescope/telescope.nvim'
  32. Plug 'catppuccin/nvim', {'as': 'catppuccin', 'branch':'main'}
  33. Plug 'neoclide/coc.nvim', {'branch': 'release'} " Testing
  34. Plug 'chriskempson/base16-vim'
  35. call plug#end()
  36. " Loads lua config from lua/init.lua
  37. lua require('init')
  38. " -----[ BASICS ]----- "
  39. " Color Settings
  40. colorscheme wal " using the wal colorscheme
  41. "colorscheme catppuccin " using the wal colorscheme
  42. set mouse=a " for moving splits with the mouse
  43. " Encoding
  44. set encoding=utf-8 " set UTF-8 Encoding per Defautl (render glyphs and co)
  45. set nocompatible
  46. set conceallevel=0 " conceallevel for markdown/latex files
  47. " disable any (terminal-)bells
  48. set noeb
  49. set novb
  50. set belloff=all
  51. " Path settings
  52. set backupdir=$HOME/.config/nvim/backups
  53. set noswapfile
  54. set undodir=$HOME/.config/nvim/undo
  55. " Syntax and Lines
  56. syntax enable
  57. set number
  58. set relativenumber
  59. filetype plugin indent on
  60. " CursorLine
  61. " set cursorline
  62. " hi CursorLine term=none cterm=none
  63. " Tab/Spacing settings
  64. set expandtab " use spaces instead of tabs
  65. set shiftwidth=4 " number of columns when indenting with > or <
  66. set softtabstop=4 " number of spaces when hitting tab
  67. set autoindent " set indentation from previous line
  68. " searching...
  69. set ignorecase " case insensitive
  70. set nohlsearch " no search highlighting after the search is done
  71. set noshowmatch " disable that blinking bracket stuff
  72. set wildmenu " shows menu for tab completion
  73. set incsearch " search if you type the letters
  74. set path+=** " include all subdirs for finding files (eg. :find)
  75. set backspace=2
  76. set scrolloff=2
  77. " -----[ Remappings ]----- "
  78. " Bind 'n' to nzz (center current line)
  79. nnoremap n nzz
  80. nnoremap N Nzz
  81. " Jump 5 lines at once with Ctr+e and Ctr+y
  82. nnoremap <C-e> 5<C-e>
  83. nnoremap <C-y> 5<C-y>
  84. " mapping for fast buffer switching
  85. nnoremap <leader>a :bp!<CR>
  86. noremap <leader>s :bn!<CR>
  87. " When selecting Text, keep the Block selected
  88. vmap < <gv
  89. vmap > >gv
  90. " Remove Trailling Whitespaces on Buffer Write
  91. autocmd BufWritePre * :%s/\s\+$//e
  92. " auto execute xrdb when .Xresources is saved
  93. autocmd BufWritePost ~/.Xresources !xrdb %
  94. " automatically adjust splits
  95. autocmd VimResized * wincmd =
  96. " use Ctr+C for Copy Pasterino into sys. clipboard
  97. vnoremap <C-c> "*y :let @+=@*<CR>
  98. nnoremap <C-S-V> "+p
  99. inoremap <C-S-V> <c-r>+
  100. cnoremap <C-S-V> <c-r>+
  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-t> :Tags<CR>
  116. nnoremap <C-b> :Telescope buffers<CR>
  117. nnoremap <C-n> :Telescope find_files<CR>
  118. " Nerdtree (tmp replacement with Vifm
  119. nnoremap <C-t> :NERDTreeToggle<CR>
  120. " Map the Python Evaluation into the vim-expression command(Q)
  121. nnoremap Q :EvalPython <CR>
  122. let g:il_append=1
  123. let g:il_use_nextline=0
  124. " UltiSnips (Ancient, but could come in handy at some day)
  125. "let g:UltiSnipsExpandTrigger = '<tab>'
  126. let g:UltiSnipsExpandTrigger = '<c-s>'
  127. let g:UltiSnipsJumpForwardTrigger = '<tab>'
  128. let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
  129. let g:UltiSnipsSnippetsDir='~/.vim/UltiSnips/'
  130. " Goyo Configuration
  131. let g:goyo_width=100
  132. let g:goyo_height=100
  133. " --- LaTeX Mappings ---
  134. " stolen from Luke Smith's vimrc "
  135. " will only work in .tex files
  136. " Navigating with guides
  137. autocmd FileType tex inoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  138. autocmd FileType tex vnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  139. autocmd FileType tex nnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  140. " Compile document using xelatex:
  141. autocmd FileType tex inoremap <F5> <Esc>:!pdflatex<space><c-r>%<Enter>a
  142. autocmd FileType tex nnoremap <F5> :!pdflatex<space><c-r>%<Enter>
  143. " Shortcuts
  144. autocmd FileType tex inoremap ,em \emph{}<Space><++><Esc>T{i
  145. autocmd FileType tex inoremap ,bf \textbf{}<Space><++><Esc>T{i
  146. autocmd FileType tex vnoremap , <ESC>`<i\{<ESC>`>2la}<ESC>?\\{<Enter>a
  147. autocmd FileType tex inoremap ,it \textit{}<Space><++><Esc>T{i
  148. autocmd FileType tex inoremap ,ol \begin{enumerate}<Enter><Enter>\end{enumerate}<Enter><Enter><++><Esc>3kA\item<Space>
  149. autocmd FileType tex inoremap ,ul \begin{itemize}<Enter><Enter>\end{itemize}<Enter><Enter><++><Esc>3kA\item<Space>
  150. autocmd FileType tex inoremap ,li <Enter>\item<Space>
  151. autocmd FileType tex inoremap ,ref \ref{}<Space><++><Esc>T{i
  152. autocmd FileType tex inoremap ,tab \begin{tabular}<Enter><++><Enter>\end{tabular}<Enter><Enter><++><Esc>4kA{}<Esc>i
  153. autocmd FileType tex inoremap ,sc \textsc{}<Space><++><Esc>T{i
  154. autocmd FileType tex inoremap ,chap \chapter{}<Enter><Enter><++><Esc>2kf}i
  155. autocmd FileType tex inoremap ,sec \section{}<Enter><Enter><++><Esc>2kf}i
  156. autocmd FileType tex inoremap ,ssec \subsection{}<Enter><Enter><++><Esc>2kf}i
  157. autocmd FileType tex inoremap ,sssec \subsubsection{}<Enter><Enter><++><Esc>2kf}i
  158. 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
  159. " -----[ GUI ]----- "
  160. " This hides the Toolbar, Menubar and left/right scrollbar in gvim
  161. if has("gui_running")
  162. set guioptions -=T
  163. set guioptions -=m
  164. set guioptions -=r
  165. set guioptions -=L
  166. endif
  167. " -----[ Fonts ]----- "
  168. if has("gui_running")
  169. if has("gui_gtk2")
  170. set guifont=Hack\ 9 elseif has("gui_macvim")
  171. set guifont=Menlo\ Regular:h14
  172. elseif has("gui_win32")
  173. set guifont=Hack:h9:cANSI,Consolas:h11:cANSI
  174. endif
  175. endif
  176. " -----[ Panels ]----- "
  177. " This remaps Ctrl+W +<direction> to Ctr+HJKL for changig the Panel in a
  178. " splitted mode
  179. map <C-h> <C-W>h
  180. map <C-j> <C-W>j
  181. map <C-k> <C-W>k
  182. map <C-l> <C-W>l
  183. " This is to get Tabs by using the <leader> Key (Leader Key: '\')
  184. nmap <leader>1 1gt
  185. nmap <leader>2 2gt
  186. nmap <leader>3 3gt
  187. nmap <leader>4 4gt
  188. nmap <leader>5 5gt
  189. nmap <leader>6 6gt
  190. " -----[ MS Windows ]----- "
  191. " Getting the Windows mswin behaviour
  192. if has("win32")
  193. source $VIMRUNTIME/mswin.vim
  194. behave mswin
  195. endif
  196. if exists("b:current_syntax")
  197. finish
  198. endif
  199. " Conceal
  200. "hi Conceal guibg=NONE
  201. setlocal cole=1
  202. if exists("g:neovide")
  203. colorscheme catppuccin
  204. let g:neovide_cursor_animation_length=0.15
  205. let g:neovide_cursor_trail_length=0.3
  206. endif
  207. " -----[ Completion ]----- "
  208. " Use <Tab> and <S-Tab> to navigate through popup menu
  209. "inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
  210. "inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
  211. " imap <silent> <c-space> :<Plug>(completion_trigger)
  212. " Set completeopt to have a better completion experience
  213. set completeopt=menuone,noinsert,noselect
  214. " Avoid showing message extra message when using completion
  215. set shortmess+=c
  216. let g:completion_trigger_character = ['.', '::']
  217. " -----[ COC ]----- "
  218. set signcolumn=number
  219. " use <tab> for trigger completion and navigate to the next complete item
  220. function! CheckBackspace() abort
  221. let col = col('.') - 1
  222. return !col || getline('.')[col - 1] =~# '\s'
  223. endfunction
  224. inoremap <silent><expr> <Tab>
  225. \ coc#pum#visible() ? coc#pum#next(1) :
  226. \ CheckBackspace() ? "\<Tab>" :
  227. \ coc#refresh()
  228. inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
  229. inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"