Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2019
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 25.90 KB | None | 0 0
  1. "======================================================================
  2. "
  3. " init.vim -
  4. "
  5. " Created by me on 2023/07/06
  6. " Last Modified: 2020/07/06 16:59:26
  7. "
  8. "======================================================================
  9.  
  10. " -----> Table of Contents <------
  11. " => SETTINGS
  12. " => USEFUL MAPPINGS
  13. "    => terminal
  14. " => PLUGIN SETTINGS
  15. "    => vim-plug
  16. "    => choosewin
  17. "    => syntastic
  18. "    => airline
  19. "    => devicons
  20. "    => startify
  21. "    => quickmenu
  22. "    => easymotion
  23. "    => easyalign
  24. "    => indentline
  25. "    => fzf & ripgrep
  26. "    => suckless & termopen
  27. " => AUTOCOMMANDS
  28. " --------------------------------
  29.  
  30. "===========================================================
  31.  
  32. " => SETTINGS
  33. "===========================================================
  34.  
  35. set termguicolors               " enable true colors in your terminal
  36. set mouse=""                    " disables mouse support (so I can copy/paste like normal)
  37. set hlsearch                    " switch highlighting on for searched patterns
  38. set path+=**                    " enables fuzzy find, so you can recursively search for files via: find someFile ; type: set path? in insert mode to see what paths it searches through
  39. set complete=.,w,b,u,t,i,kspell " modifies ^p to look for matches in: current buffer / windows / other buffers / unloaded buffers / tags file / included files / dictionary (when 'set spell' is enabled)
  40. set ignorecase                  " case insensitive searching
  41. set smartcase                   " case-sensitive if case expression contains contains a capital letter
  42. set scrolloff=8                 " how many lines before or after the cursor, for the screen to scroll up/down
  43. set hidden                      " current buffer can be put into the background so that you can modify a file and move to another without having to write to it then and there
  44. set showmatch                   " when a bracket is inserted briefly jump to it's matching one, to show you its location
  45. set noshowmode                  " dont show which mode i'm in (since airline already does it)
  46. set relativenumber              " turn on line numbers (relative line numbers)
  47. set numberwidth=3               " don't use an annoyingly wide number column (he value given is a minimum width to use for the number column, not a fixed size)
  48. set title                       " set terminal tital
  49. set nowrap                      " prevent long lines from breaking into multiple lines (see how use a symbol to denote would-be line breaks)
  50. set textwidth=150               " width of text rows (I set to 150 which is the max before it reaches the undotree side window)
  51. set undofile                    " maintain undo history between sessions
  52. set undodir=~/.config/nvim/undodir " store all the undo history files in that directory
  53. set backup                                                  " enable backups
  54. set backupdir=/run/media/manjaro/nan0/.vim_back,~/Documents " specify where backups will be stored
  55. set thesaurus=~/.config/nvim/thesaurus/mthesaur.txt         " Specify a thesaurus to use (you use thesaurus via ^x+^t)
  56. set matchpairs+=<:>                                         " Highlight matching pairs of brackets. Use the '%' character to jump between them.
  57. set noet ci pi
  58.  
  59. "===========================================================
  60.  
  61. " => USEFUL MAPPINGS
  62. "===========================================================
  63.  
  64. let mapleader = "-" " another good leader key is <Space> or the the Windows key
  65. let maplocalleader = ""
  66.  
  67. " Press F2 in normal mode to toggle set spell
  68. nnoremap <F2> :set spell!<CR>
  69.  
  70. " Type jk to copy a paragraph and paste a copy of it just below. This is great when you're about to create a block of code that
  71. " will be similar, but not different enough to abstract (e.g. it blocks in rspec).
  72. nnoremap jj yap<S-}>p
  73.  
  74. " Some new mappings that are more enhanced versions of commands like ci), di), yi)... The first one allows you to type cin(, yin(,
  75. " din(, etc and that will perform the same functions as ci), di), etc, BUT without needing to place your cursor in the parenthesis,
  76. " but rather you can be on any word in front of the parenthesis.. The second mapping does the samething but backwords (i.e. if the
  77. " parens if before your cursor). And the rest do the same thing but for different enclosing characters.
  78. onoremap in) :<c-u>normal! f(vi(<cr>
  79. onoremap il) :<c-u>normal! F)vi(<cr>
  80. onoremap in' :<c-u>normal! f'vi'<cr>
  81. onoremap il' :<c-u>normal! F'vi'<cr>
  82. onoremap in" :<c-u>normal! f"vi"<cr>
  83. onoremap il" :<c-u>normal! F"vi"<cr>
  84. onoremap in} :<c-u>normal! f{vi}<cr>
  85. onoremap il} :<c-u>normal! F}vi}<cr>
  86. onoremap in] :<c-u>normal! f[vi]<cr>
  87. onoremap il] :<c-u>normal! F]vi]<cr>
  88. onoremap in` :<c-u>normal! f`vi`<cr>
  89. onoremap il` :<c-u>normal! F`vi`<cr>
  90. onoremap in> :<c-u>normal! f<vi><cr>
  91. onoremap il> :<c-u>normal! F>vi><cr>
  92.  
  93. " Use space+a to align a block of code as defined by your tw,ts, etc
  94. nnoremap <Space>a =ip
  95.  
  96. " A slight improvement to <ESC> in that when you use it to go back into normal mode your cursor will no longer move a space to the left.
  97. inoremap <ESC> <ESC>`^
  98.  
  99. " Use F6 to append date/time in a file
  100. nnoremap <F6> a<C-R>=strftime("%c")<CR><Esc>
  101.  
  102. " Simply type 'q' in normal mode to quit out of windows, alt+q to close all windows, and alt+= to close a tab
  103. map q :q<CR>
  104. nnoremap <A-q> :qa<CR>
  105.  
  106. " Remap the text justifier command 'gq' to just 'Q'
  107. map Q gq
  108.  
  109. " Hover over a word and use ]c to correct the spelling (remember you can use ]s and [s to navigate to mispelled words)
  110. nnoremap [c z=1<CR><CR>
  111.  
  112. " Chdir to that of the current file
  113. command! -bar Cd exec "chdir" expand("%:p:h")
  114.  
  115. " Automatically puts the current word in %s/currentWord//g, and places you in the // to quickly search and replace text.
  116. nnoremap s :%s/<C-r><C-w>//g<Left><Left>
  117.  
  118. " Window short-cuts
  119. nnoremap <silent> sp :split<CR>
  120. nnoremap <silent> ss :new<CR>
  121. nnoremap <silent> <A-w> :tabnew<CR>
  122. nnoremap <silent> so :only<CR>
  123.  
  124. " Type vd to see the difference between the current buffer and the file it was loaded from, sd to to turn diffoff, ,s to save the changes, and ,q
  125. " to write quit out of the file
  126. nnoremap <silent> vd :vert new<CR>:set bt=nofile<CR>:r #<CR>:0d_<CR>:diffthis<CR>:wincmd l<CR>:diffthis<CR>
  127. nnoremap <silent> sd :winc p<CR>:set nodiff<CR>:bdelete%<CR>:diffoff<CR>
  128. nnoremap <silent> ,s :w<CR>:winc h<CR>:set nodiff<CR>:bdelete%<CR>:diffoff<CR>
  129. nnoremap <silent> ,a :w<CR>:winc h<CR>:set nodiff<CR>:bdelete%<CR>:diffoff<CR>:q<CR>
  130.  
  131. " h,j,k, and l are considered moves not jumps so they are not added to the jumplist.. This mapping adds stores j/k moves
  132. " to the jumplist.. So not you can do 18j and then ^o to jump back..
  133. nnoremap <expr> k (v:count > 5 ? "m'" . v:count : '') . 'k'
  134. nnoremap <expr> j (v:count > 5 ? "m'" . v:count : '') . 'j'
  135.  
  136. " Use Alt+left or Alt+right to move between buffers
  137. nnoremap <A-right> <CR>:bnext<CR>
  138. nnoremap <A-left>  <CR>:bprevious<CR>
  139.  
  140. " Use F3 to toggle a vertical cursorcolumn that you can use to visually see if you're code is going
  141. " past your textwidth limit
  142. nnoremap <expr> <F3> ToggleColorColumn()
  143. func ToggleColorColumn()
  144.     if strlen(&cc)
  145.         set cc=
  146.     else
  147.         set cc=79
  148.     endif
  149. endfunc
  150.  
  151. "==============================================================================
  152. " => Terminal
  153. "==============================================================================
  154.  
  155. tnoremap <Esc> <C-\><C-n> " allows me to use <Esc> instead of ^\^n in terminals to get back into normal mode
  156. map <silent> <A-e> :tabnew<CR><S-:>:terminal bash --rcfile ~/.bash_it/.bashrc<CR>
  157.  
  158. " Switch to insert mode when focusing on terminal window
  159. autocmd BufWinEnter,WinEnter * if &buftype == 'terminal' | silent! normal i | endif
  160.  
  161. "==============================================================================
  162. " => Folds
  163. "==============================================================================
  164.  
  165. " Map the <Space> key to toggle a selected fold opened/closed.
  166. nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
  167. vnoremap <Space> zf
  168.  
  169. " Automatically save and load folds
  170. """autocmd BufWinLeave *.* mkview
  171. autocmd BufWinEnter *.* silent loadview"
  172.  
  173. "===========================================================
  174.  
  175. " => PLUGIN SETTINGS
  176. "===========================================================
  177.  
  178. "==============================================================================
  179. " => Vim-plug
  180. "==============================================================================
  181.  
  182. command! PU PlugUpdate | PlugUpgrade " type :PU to both update and upgrade vimplug
  183.  
  184. " Auto-install vim-plug
  185. if empty(glob('~/.config/nvim/autoload/plug.vim'))
  186.     echo '==> Installing vim-plug...'
  187.     silent !torsocks curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
  188.     \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  189.     autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  190. endif
  191.  
  192. " Auto-install pip
  193. if empty(glob('~/.local/bin/pip'))
  194.     echo '==> Installing pip...'
  195.     silent !torsocks curl https://bootstrap.pypa.io/get-pip.py -o ~/get-pip.py   " Download pip from github
  196.     silent !torsocks python ~/get-pip.py --user && rm ~/get-pip.py               " Install pip which also installs setuptools and wheel
  197.     " silent !torsocks ~/.local/bin/pip install virtualenv --user                " Install virualenv
  198.     " silent !~/.local/bin/virtualenv ~/.python                                  " Initialize a python virtual environment
  199.     " silent !source ~/.python/bin/activate                                      " Change to the virtual environment
  200. endif
  201.  
  202. " Auto-install ranger file manager
  203. if empty(glob('~/.ranger'))
  204.     echo '==> Installing ranger...'
  205.     silent !git clone --depth=1 https://github.com/ranger/ranger.git ~/.ranger
  206. endif
  207.  
  208. " Auto-install powerline font
  209.  if empty(glob('~/.local/share/fonts/PowerlineSymbols.otf'))
  210.      echo '==> Installing powerline-font...'
  211.      silent !torsocks curl -fLo ~/.local/share/fonts/PowerlineSymbols.otf --create-dirs https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
  212.      silent !torsocks curl -fLo ~/.config/fontconfig/conf.d/10-powerline-symbols.conf --create-dirs https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
  213.      silent !torsocks curl -fLo ~/.local/share/fonts/DroidSansMonoNerdFontComplete.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf
  214.      silent !fc-cache -fv ~/.local/share/fonts
  215.  endif
  216.  
  217. " Auto-install bash-it
  218. if empty(glob('~/.bash_it'))
  219.     echo '==> Installing bash-it...'
  220.     silent !git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
  221.     silent !~/.bash_it/install.sh --silent
  222.     silent !mv ~/.bashrc ~/.bash_it && mv ~/.bashrc.bak ~/.bashrc
  223.     silent !sed -i 's/bobby/powerline/' ~/.bash_it/.bashrc
  224. endif
  225.  
  226. " Auto-install en.ascii.spl
  227. if empty(glob('~/.config/nvim/spell'))
  228.     echo '==> Installing en.ascii.spl...'
  229.     silent !torsocks curl -fLo ~/.config/nvim/spell/en.ascii.spl --create-dirs 'http://ftp.vim.org/pub/vim/runtime/spell/en.ascii.spl'
  230. endif
  231.  
  232. " Specify a directory for plugins
  233. call plug#begin('~/.config/nvim/plugged')
  234.  
  235. " Have vim-sensible load first (sensible vim settings everyone can agree on; should not remove). Also I modify is to C-l is changed to
  236. " C-n (to clear highlighting of searches) cause I have C-l mapped already to resizing windows.
  237. Plug 'https://github.com/tpope/vim-sensible.git', { 'do': 'sed -i \"34,35s/C-L/C-n/g\" ./plugin/sensible.vim' }
  238. call plug#load('vim-sensible')
  239.  
  240. "Visuals:
  241.  
  242. Plug 'https://github.com/mhinz/vim-startify.git'
  243. Plug 'https://github.com/vim-airline/vim-airline.git'
  244. Plug 'https://github.com/vim-airline/vim-airline-themes.git'
  245. Plug 'https://github.com/ryanoasis/vim-devicons.git'
  246.  
  247. "Color Schemes:
  248.  
  249. Plug 'https://github.com/rj-white/vim-colors-paramountblue.git'
  250. Plug 'https://github.com/morhetz/gruvbox.git'
  251.  
  252. "Aesthetics:
  253.  
  254. Plug 'https://github.com/andymass/vim-matchup.git'
  255. Plug 'https://github.com/Yggdroot/indentLine.git'
  256. Plug 'https://github.com/sheerun/vim-polyglot.git'
  257.  
  258. "Performance:
  259.  
  260. Plug 'https://github.com/t9md/vim-choosewin.git'
  261. Plug 'https://github.com/roxma/vim-window-resize-easy.git'
  262. Plug 'https://github.com/fabi1cazenave/suckless.vim.git'
  263. Plug 'https://github.com/fabi1cazenave/termopen.vim.git', { 'do': 'sed -i \"55s/signcolumn=no //\" ./plugin/termopen.vim' }
  264. Plug 'https://github.com/tpope/vim-commentary.git'
  265. Plug 'https://github.com/junegunn/vim-easy-align.git'
  266. Plug 'https://github.com/easymotion/vim-easymotion.git'
  267. Plug 'https://github.com/tpope/vim-repeat.git'
  268. Plug 'https://github.com/junegunn/fzf.git', { 'dir': '~/.fzf', 'do': './install --all' } | Plug 'https://github.com/junegunn/fzf.vim.git'
  269. Plug 'https://github.com/tpope/vim-surround.git'
  270. Plug 'https://github.com/Raimondi/delimitMate.git'
  271. Plug 'https://github.com/wsdjeg/FlyGrep.vim.git'
  272.  
  273. "Utilities:
  274.  
  275. Plug 'https://github.com/thoughtbot/vim-rspec.git'
  276. Plug 'https://github.com/vim-syntastic/syntastic.git'
  277. Plug 'https://github.com/tpope/vim-fugitive.git'
  278. "Plug 'https://github.com/lambdalisue/suda.vim.git'
  279. "Plug 'https://github.com/vim-scripts/sudo.vim.git'
  280. Plug 'https://github.com/christoomey/vim-system-copy.git'
  281. Plug 'https://github.com/szw/vim-dict.git'
  282. Plug 'https://github.com/beloglazov/vim-online-thesaurus.git'
  283.  
  284. "Snippets:
  285.  
  286. Plug 'https://github.com/honza/vim-snippets.git'
  287. Plug 'https://github.com/Shougo/neosnippet-snippets.git'
  288. Plug 'https://github.com/Shougo/neosnippet.vim.git'
  289.  
  290. " Initialize plugin system
  291. call plug#end()
  292.  
  293. " A vim-plug function that checks if a plugin is loaded or not
  294. function! PlugLoaded(name)
  295.     return (
  296.         \ has_key(g:plugs, a:name) &&
  297.         \ isdirectory(g:plugs[a:name].dir) &&
  298.         \ stridx(&rtp, g:plugs[a:name].dir) >= 0)
  299. endfunction
  300. if PlugLoaded('gruvbox')
  301.    colorscheme gruvbox
  302. endif
  303. set background=dark " some colorschemes (like gruvbox) use this setting to determine what colors to use
  304.  
  305. hi clear SpellBad
  306. hi SpellBad guifg=#EBDBB2 guibg=#FB4934 gui=none
  307.  
  308. "==============================================================================
  309. " => Choosewin
  310. "==============================================================================
  311.  
  312. " Use '-' to bring up the choosewin prompt
  313. nmap  -  <Plug>(choosewin)
  314.  
  315. "==============================================================================
  316. " => Syntastic
  317. "==============================================================================
  318.  
  319. let g:syntastic_always_populate_loc_list = 1
  320. let g:syntastic_auto_loc_list = 1
  321. let g:syntastic_check_on_open = 0
  322. let g:syntastic_check_on_wq = 1
  323.  
  324. "==============================================================================
  325. " => Airline
  326. "==============================================================================
  327.  
  328. let g:airline_theme='gruvbox'
  329. "set statusline=%!getcwd() " always show the CWD in the status line
  330. let g:airline_powerline_fonts = 1
  331. let g:airline_section_b = '%{getcwd()}' " In Section B of the status line display the CWD
  332.  
  333. "Tabline:
  334.  
  335. let g:airline#extensions#tabline#enabled = 1        " enable airline tabline
  336. let g:airline#extensions#tabline#tab_nr_type= 1     " configure how numbers are displayed in tab mode from 0-2 (1 is just tab number)
  337. let g:airline#extensions#tabline#tabs_label = ''    " can put text here like BUFFERS to denote buffers (I clear it so nothing is shown)
  338. let g:airline#extensions#tabline#buffers_label = '' " can put text here like TABS to denote tabs (I clear it so nothing is shown)
  339. let g:airline#extensions#tabline#fnamemod = ':t'    " disable file paths in the tab
  340. let g:airline#extensions#tabline#show_buffers = 0   " dont show buffers in the tabline
  341.  
  342. "==============================================================================
  343. " => Devicons
  344. "==============================================================================
  345.  
  346. let g:WebDevIconsUnicodeDecorateFolderNodes = 1
  347.  
  348. "==============================================================================
  349. " => Startify
  350. "==============================================================================
  351.  
  352. let g:startify_session_dir = '~/.config/nvim/session' " the directory to save/load sessions to/from
  353. let g:startify_files_number = 4
  354. let g:startify_update_oldfiles = 1                    " updates the 'recently used files' while in the same vim session.
  355. let g:startify_session_persistence = 1
  356. let g:startify_change_to_dir = 1
  357. let g:startify_custom_header = [
  358.         \ '',
  359.         \ '',
  360.         \ '       ##############..... ##############      ',
  361.         \ '       ##############......##############      ',
  362.         \ '         ##########..........##########        ',
  363.         \ '         ##########........##########          ',
  364.         \ '         ##########.......##########           ',
  365.         \ '         ##########.....##########..           ',
  366.         \ '         ##########....##########.....         ',
  367.         \ '       ..##########..##########.........       ',
  368.         \ '     ....##########.#########.............     ',
  369.         \ '       ..################JJJ............       ',
  370.         \ '         ################.............         ',
  371.         \ '         ##############.JJJ.JJJJJJJJJJ         ',
  372.         \ '         ############...JJ...JJ..JJ  JJ        ',
  373.         \ '         ##########....JJ...JJ..JJ  JJ         ',
  374.         \ '         ########......JJJ..JJJ JJJ JJJ        ',
  375.         \ '         ######    .........                   ',
  376.         \ '                     .....                     ',
  377.         \ '                       .                       ',
  378.         \ '',
  379.         \ '',
  380.         \ ]
  381.  
  382. let g:startify_lists = [
  383.   \ { 'type': 'bookmarks', 'header': ['   My bookmarks:'] },
  384.   \ { 'type': 'dir',       'header': ['   My most recently used files in the current directory:'] },
  385.   \ { 'type': 'files',     'header': ['   My most recently used files:'] },
  386.   \ { 'type': 'sessions',  'header': ['   Saved sessions:'] },
  387.   \ ]
  388.  
  389. let g:startify_bookmarks = [ '~/.config/nvim/init.vim' ]
  390.  
  391. "==============================================================================
  392. " => Easymotion
  393. "==============================================================================
  394.  
  395. let g:EasyMotion_smartcase = 1        " turn on case smart-insensitivity
  396. let g:EasyMotion_use_smartsign_us = 1 " turn on smart symbols matching
  397. let g:EasyMotion_do_mapping = 0       " disable default mappings (they slow vim down by having already used leaders waiting for other possible options)
  398.  
  399. " Allow motioning over to words in other windows via w
  400. nmap f <Plug>(easymotion-overwin-w)
  401.  
  402. " Replace the default search of Vim. Also you can use `<Tab>` and `<S-Tab>` to
  403. " scroll down/up a page. If you press `<CR>`, you get the usual EasyMotion
  404. " highlighting and can jump to any matching target destination with a single
  405. " keystroke.  The `n` & `N` mappings are options. You do not have to map `n` &
  406. " `N` to EasyMotion.  Without these mappings, `n` & `N` works fine. (These
  407. " mappings just provide different highlight method and have some other features )
  408. " The . mapping makes used of vim-repeat to allow you to repeat your last search
  409. map  / <Plug>(easymotion-sn)
  410. omap / <Plug>(easymotion-tn)
  411. map  ? <Plug>(easymotion-sn)
  412. omap ? <Plug>(easymotion-tn)
  413. map  n <Plug>(easymotion-next)
  414. map  N <Plug>(easymotion-prev)
  415.  
  416. " Allows you to repeat the last search with / and ? using
  417. nmap <Space>s <Plug>(easymotion-repeat)
  418.  
  419. "==============================================================================
  420. " => Easyalign
  421. "==============================================================================
  422.  
  423. " Start interactive EasyAlign in visual mode (e.g. vipga)
  424. xmap ga <Plug>(EasyAlign)
  425.  
  426. " Start interactive EasyAlign for a motion/text object (e.g. gaip)
  427. nmap ga <Plug>(EasyAlign)
  428.  
  429. "==============================================================================
  430. " => IdentLine
  431. "==============================================================================
  432.  
  433. let g:indentLine_char_list = ['¦']
  434. let g:indentLine_bufTypeExclude = ['help', 'terminal']     " specify a list of file types, when opening these types of files the plugin is disabled
  435. let g:indentLine_fileTypeExclude = ['text', '']            " specify a list of buffer types, when opening these types of buffers, the plugin is disabled    
  436. let g:indentLine_bufNameExclude = ['*.txt', 'NERD_tree.*'] " specify names or regexs. If the buffer's name fall into this list, the plugin is disabled
  437.  
  438. " The identline plugin only displays whitespace indents. The following display chars for other types.. I.e. '•' is whitespace on
  439. " blank lines, and '›' is tabs.
  440. set list lcs=tab:›\ ,trail:•,extends:#,nbsp:.
  441.  
  442. "==============================================================================
  443. " => Fzf & Ripgrep
  444. "==============================================================================
  445.  
  446. " Now you can do :grep searchtext and rg will search recursively through the current directory for files containing "searchtext". ripgrep is much faster than
  447. " standard grep, and has sensible defaults such as using your .gitignore file and only performing case-sensitive searches if you have a mixed case
  448. " search term.
  449. if executable('rg')
  450.     let &grepprg = "rg --vimgrep"
  451. endif
  452.  
  453. nmap <space>f :Files<cr>|     " fuzzy find files in the working directory (where you launched Vim from)
  454. nmap <space>/ :BLines<cr>|    " fuzzy find lines in the current file
  455. nmap <space>b :Buffers<cr>|   " fuzzy find an open buffer
  456. nmap <space>r :Rg |           " fuzzy find text in the working directory
  457. nmap <space>c :Commands<cr>|  " fuzzy find Vim commands (like Ctrl-Shift-P in Sublime/Atom/VSC)
  458.  
  459. "==============================================================================
  460. " => Suckless & Termopen
  461. "==============================================================================
  462.  
  463. " i3 style mappings:
  464. let g:suckless_mappings = {
  465. \        '<M-[sdf]>'      :   'SetTilingMode("[sdf]")'    ,
  466. \        '<M-[hjkl]>'     :    'SelectWindow("[hjkl]")'   ,
  467. \        '<M-[HJKL]>'     :      'MoveWindow("[hjkl]")'   ,
  468. \      '<C-M-[hjkl]>'     :    'ResizeWindow("[hjkl]")'   ,
  469. \        '<M-[oO]>'       :    'CreateWindow("[sv]")'     ,
  470. \       '<M-[123456789]>' :       'SelectTab([123456789])',
  471. \       '<M-[!@#$%^&*(]>' : 'MoveWindowToTab([123456789])',
  472. \     '<C-M-[123456789]>' : 'CopyWindowToTab([123456789])',
  473. \}
  474.  
  475.  
  476. " To be more consistent with most tiling window managers (wmii, i3, awesome…) the following two settings are recommended:
  477. set splitbelow
  478. set splitright
  479.  
  480. let g:suckless_tmap = 1 " all Alt-* shortcuts can be used on terminal windows in insert mode if this is set
  481. nmap <silent> <M-Return>    :call TermOpen('bash --rcfile ~/.bash_it/.bashrc')<CR><C-\><C-n>
  482. nmap <silent> <M-Backspace> :call TermOpen('~/.ranger/ranger.py')<CR>
  483.  
  484. "My Custom Mappings:
  485.  
  486. " These are mappings I made to automatically open terminals (up to 6) in a newtab in a stacked format
  487. map <A-t>6 :tabnew<CR><A-CR><A-CR><A-CR><A-CR><A-CR><A-CR><A-s><A-j><ESC>:bd!<CR><A-k>
  488. map <A-t>5 :tabnew<CR><A-CR><A-CR><A-CR><A-CR><A-CR><A-s><A-j><ESC>:bd!<CR><A-k>
  489. map <A-t>4 :tabnew<CR><A-CR><A-CR><A-CR><A-CR><A-s><A-j><ESC>:bd!<CR><A-k>
  490. map <A-t>3 :tabnew<CR><A-CR><A-CR><A-CR><A-s><A-j><ESC>:bd!<CR><A-k>
  491. map <A-t>2 :tabnew<CR><A-CR><A-CR><A-s><A-j><ESC>:bd!<CR><A-k>
  492.  
  493. " Note: https://github.com/neovim/neovim/issues/5541 (planned enhancements to openining terminal in a new tab by default)
  494. " When this those enchanments happen the terminals will open as smoothly as the following stacked buffers do.
  495. " map <A-t>2 :terminal<CR><ESC><A-CR><A-s>
  496.  
  497. " Same as the previous set of mappings except these open up stacked buffers in a new tab
  498. map <A-r>6 :tabnew<CR><A-o><A-o><A-o><A-o><A-o><A-s>
  499. map <A-r>5 :tabnew<CR><A-o><A-o><A-o><A-o><A-s>
  500. map <A-r>4 :tabnew<CR><A-o><A-o><A-o><A-s>
  501. map <A-r>3 :tabnew<CR><A-o><A-o><A-s>
  502. map <A-r>2 :tabnew<CR><A-o><A-s>
  503.  
  504. " Use alt+u to open up 1 stacked terminal and 1 stacked buffer
  505. map <A-u> :tabnew<CR><A-CR><A-s><A-j><ESC>:bd!<CR><A-k><A-o>
  506.  
  507. " Use alt+p open up a new stacked terminal, and and alt+P to open a new vertical terminal
  508. map <A-p> <A-CR><A-s>
  509. map <A-P> <S-A-o>:terminal bash --rcfile ~/.bash_it/.bashrc<CR>
  510.  
  511. " This plugin modifies the tab labels to show: the tab number between brackets, with a * sign if a buffer in this tab is modified;
  512. " the current buffer name, with a trailing + sign if modified.  To leave tabs unchanged use:
  513. let g:suckless_guitablabel = 0
  514.  
  515. "===========================================================
  516.  
  517. " => AUTOCOMMANDS
  518. "===========================================================
  519.  
  520. if has('autocmd') && !exists('autocommands_loaded')
  521.   let autocommands_loaded = 1
  522.  
  523.   " Put these in an autocmd group, so that we can delete them easily
  524.   augroup vimrcEx
  525.   au!
  526.  
  527. " File type specific settings for tabstop, softtabstop, shiftwidth, and textwidth values...  'sw' is for how many spaces to move when you hit tab, 'ts'
  528. " automatically idents expressions (not control structures!) of the file you open to your liking 'sts' is pretty much the same thing as 'sw' except it
  529. " uses a combination of spaces+tabs which is dumb. E.g. if you're ts is set to 8 and you have a sts of 4 then it'll use a 4 length tab + four spaces.. I
  530. " dont see any point in this so just keep it's value equal to ts to ensure to always use tabs.. In either case your sts and sw should always be the same
  531. " value.  Also note sts work with the expandtab setting, as if that's set then th
  532.   autocmd Filetype vim,css setlocal ts=2 sts=2 sw=2
  533.   autocmd Filetype yaml setlocal ts=3 sts=3 sw=3 tw=80
  534.   autocmd Filetype sh,bash,pl,py setlocal ts=8 sts=8 sw=8
  535.  
  536.   " Append a time/date to backups
  537.   au BufWritePre * let &bex = '-' . strftime("%Y-%b%d-%X") . '~'
  538.  
  539.   " When editing a file, always jump to the last known cursor position
  540.   autocmd BufReadPost *
  541.     \ if line("'\"") >= 1 && line("'\"") <= line("$") |
  542.     \   exe "normal! g`\"" |
  543.     \ endif
  544.  
  545.   " Allows transparent background to work with various color schemes (note, you're using your terminal's color palette, and not your color scheme's)
  546.   "autocmd VimEnter * hi Normal guibg=none
  547.  
  548.   augroup END
  549. endif
  550.  
  551. " vim:set ft=vim et sw=2:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement