init.vim 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. call plug#begin('~/.config/nvim/plugged')
  2. Plug 'junegunn/fzf'
  3. Plug 'junegunn/fzf.vim' "recent files, search and many more
  4. Plug 'ap/vim-css-color' "colorful hex decimals
  5. Plug 'luochen1990/rainbow' "colorful brackets
  6. Plug 'tpope/vim-commentary' "comment code section
  7. Plug 'vimwiki/vimwiki' "markup language highlight
  8. Plug 'itchyny/lightline.vim' "nicer status bar
  9. Plug 'airblade/vim-gitgutter' "shows you lines that have been added, removed or modified
  10. Plug 'dense-analysis/ale' "syntax checking
  11. Plug 'sheerun/vim-polyglot' "collection of language packs
  12. Plug 'godlygeek/tabular' "aligning text
  13. Plug 'plasticboy/vim-markdown' "live preview
  14. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
  15. Plug 'tpope/vim-surround' "surround in barckets and stuff
  16. Plug 'jceb/vim-orgmode' "orgmode in vim
  17. Plug 'AndrewRadev/linediff.vim'
  18. call plug#end()
  19. set number relativenumber
  20. set clipboard+=unnamedplus
  21. set ignorecase " same as set ic
  22. set nowrap
  23. set mouse=a " enable mouse support
  24. set hidden
  25. set tabstop=4
  26. set softtabstop=4
  27. set shiftwidth=4
  28. set expandtab
  29. set title " name of current opened file
  30. set nohlsearch " dont highlight search
  31. set go=a
  32. set encoding=utf-8
  33. set wildcharm=<TAB> " tab as autocomplete mapping than 4 spaces
  34. set splitbelow splitright " Splits open at the bottom and right
  35. set wildmode=longest,list,full " Enable autocompletion
  36. " colorscheme industry
  37. syntax on
  38. syntax enable on
  39. filetype plugin indent on
  40. " undo
  41. if has('persistent_undo') "check if your vim version supports it
  42. set undofile "turn on the feature
  43. silent !mkdir -p "${HOME}/.config/nvim/undo" "create directory if not exist
  44. set undodir="${HOME}/.config/nvim/undo" "directory where the undo files will be stored
  45. endif
  46. let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
  47. " highlight line in insert mode
  48. autocmd InsertEnter * set cul
  49. autocmd InsertLeave * set nocul
  50. " save and load folds
  51. augroup remember_folds
  52. autocmd!
  53. autocmd BufWinLeave * silent! mkview
  54. autocmd BufWinEnter * silent! loadview
  55. augroup END
  56. " autocomplete brackets
  57. inoremap " ""<left>
  58. inoremap ' ''<left>
  59. inoremap ( ()<left>
  60. inoremap [ []<left>
  61. inoremap { {}<left>
  62. " Automatically deletes all trailing whitespace and newlines at end of file on save.
  63. autocmd BufWritePre * %s/\s\+$//e
  64. autocmd BufWritePre * %s/\n\+\%$//e
  65. autocmd BufWritePre *.[ch] %s/\%$/\r/e
  66. " Save file as sudo on files that require root permission
  67. cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
  68. " Disables automatic commenting on newline:
  69. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  70. " what does it do?
  71. nnoremap c "_c
  72. " set default folder to buffer folder
  73. autocmd BufEnter * silent! lcd %:p:h
  74. " some emacs keybindins
  75. cnoremap <C-g> <C-c>
  76. nnoremap <C-x><C-s> :w<CR>
  77. nnoremap <C-x><C-w> :write<SPACE><TAB>
  78. nnoremap <C-x>0 :quit<CR>
  79. nnoremap <C-x>1 :only<CR>
  80. nnoremap <C-x>2 :split<CR>
  81. nnoremap <C-x>3 :vsplit<CR>
  82. nnoremap <C-x>d :Explore<SPACE><TAB>
  83. nnoremap <C-x><C-f> :edit<SPACE><TAB>
  84. nnoremap <C-x>k :b#<bar>bd#<CR>
  85. nnoremap <C-x>b :buffers<CR>:buffer<SPACE>
  86. nnoremap <C-x>xt :set wrap!<CR>
  87. nnoremap <C-x>y :%yank<CR>
  88. nnoremap <C-x><C-e> :exec '!'.getline('.')<CR>
  89. nnoremap <C-c><C-e> :!detach.sh emacsclient -a '' -c %<CR><CR>
  90. nnoremap <C-c>e :e $MYVIMRC<CR>
  91. nnoremap <C-c>r :source $MYVIMRC<CR>
  92. nnoremap <C-c>ot :!<SPACE>
  93. nnoremap <C-c>oT :call termopen($SHELL, {'curwin' : 1})<CR>
  94. nnoremap <C-c>oe :!detach.sh kitty -- tmux<CR><CR>
  95. nnoremap <C-c><C-c> :!compile.sh %<CR>
  96. tnoremap <esc> <C-\><C-n><CR>
  97. " Mappings to move lines
  98. nnoremap <A-j> :m .+1<CR>==
  99. nnoremap <A-k> :m .-2<CR>==
  100. inoremap <A-j> <Esc>:m .+1<CR>==gi
  101. inoremap <A-k> <Esc>:m .-2<CR>==gi
  102. vnoremap <A-j> :m '>+1<CR>gv=gv
  103. vnoremap <A-k> :m '<-2<CR>gv=gv
  104. nnoremap <SPACE> <Nop>
  105. let mapleader=" " "leader as space
  106. " fzf keybindings
  107. nnoremap <Leader>f :Files<ESC>
  108. nnoremap <Leader>b :Buffers<ESC>
  109. nnoremap <C-x>pf :GFiles<ESC>