Advertisement
mosaid

my vimrc

Dec 9th, 2020
2,727
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 27.68 KB | None | 0 0
  1. " vim: set foldmethod=marker foldlevel=0 nomodeline:
  2. " Plugins {{{
  3. " -----------------------------------------------------------------------------
  4.  
  5. " Specify a directory for plugins.
  6. call plug#begin('~/.vim/bundle')
  7.  
  8. " Gruvbox theme.
  9. Plug 'gruvbox-community/gruvbox'
  10.  
  11. " Integrate fzf with Vim.
  12. Plug '~/.fzf'
  13. Plug 'junegunn/fzf', { 'do': './install --all' }
  14. Plug 'junegunn/fzf.vim'
  15.  
  16. " Better manage Vim sessions.
  17. Plug 'tpope/vim-obsession'
  18.  
  19. " Zoom in and out of a specific split pane (similar to tmux).
  20. Plug 'dhruvasagar/vim-zoom'
  21.  
  22. " Pass focus events from tmux to Vim (useful for autoread and linting tools).
  23. Plug 'tmux-plugins/vim-tmux-focus-events'
  24.  
  25. " Navigate and manipulate files in a tree view.
  26. Plug 'scrooloose/nerdtree'
  27.  
  28. " Helpers for moving and manipulating files / directories.
  29. Plug 'tpope/vim-eunuch'
  30.  
  31. " Launch Ranger from Vim.
  32. Plug 'francoiscabrol/ranger.vim'
  33.  
  34. " Run a diff on 2 directories.
  35. Plug 'will133/vim-dirdiff'
  36.  
  37. " Run a diff on 2 blocks of text.
  38. Plug 'AndrewRadev/linediff.vim'
  39.  
  40. " Add spelling errors to the quickfix list (vim-ingo-library is a dependency).
  41. Plug 'inkarkat/vim-ingo-library' | Plug 'inkarkat/vim-SpellCheck'
  42.  
  43. " Briefly highlight which text was yanked.
  44. Plug 'machakann/vim-highlightedyank'
  45.  
  46. " Modify * to also work with visual selections.
  47. Plug 'nelstrom/vim-visual-star-search'
  48.  
  49. " Automatically clear search highlights after you move your cursor.
  50. Plug 'haya14busa/is.vim'
  51.  
  52. " Handle multi-file find and replace.
  53. Plug 'mhinz/vim-grepper'
  54.  
  55. " Better display unwanted whitespace.
  56. Plug 'ntpeters/vim-better-whitespace'
  57.  
  58. " Toggle comments in various ways.
  59. Plug 'tpope/vim-commentary'
  60.  
  61. " Automatically set 'shiftwidth' + 'expandtab' (indention) based on file type.
  62. Plug 'tpope/vim-sleuth'
  63.  
  64. " A number of useful motions for the quickfix list, pasting and more.
  65. Plug 'tpope/vim-unimpaired'
  66.  
  67. " Drastically improve insert mode performance in files with folds.
  68. Plug 'Konfekt/FastFold'
  69.  
  70. " Show git file changes in the gutter.
  71. "Plug 'mhinz/vim-signify'
  72.  
  73. " A git wrapper.
  74. Plug 'tpope/vim-fugitive'
  75.  
  76. " Dim paragraphs above and below the active paragraph.
  77. Plug 'junegunn/limelight.vim'
  78.  
  79. " Distraction free writing by removing UI elements and centering everything.
  80. Plug 'junegunn/goyo.vim'
  81.  
  82. " A bunch of useful language related snippets (ultisnips is the engine).
  83. Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
  84.  
  85. " Run test suites for various languages.
  86. Plug 'janko/vim-test'
  87.  
  88. "C family languages completion
  89. Plug 'Valloric/YouCompleteMe'
  90.  
  91. " IDE-like bar
  92. Plug 'bagrat/vim-buffet'
  93.  
  94. " Languages and file types.
  95. Plug 'cakebaker/scss-syntax.vim'
  96. Plug 'chr4/nginx.vim'
  97. Plug 'chrisbra/csv.vim'
  98. Plug 'ekalinin/dockerfile.vim'
  99. Plug 'elixir-editors/vim-elixir'
  100. Plug 'Glench/Vim-Jinja2-Syntax'
  101. Plug 'godlygeek/tabular' | Plug 'tpope/vim-markdown'
  102. Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
  103. Plug 'lifepillar/pgsql.vim'
  104. Plug 'othree/html5.vim'
  105. Plug 'pangloss/vim-javascript'
  106. Plug 'PotatoesMaster/i3-vim-syntax'
  107. Plug 'stephpy/vim-yaml'
  108. Plug 'tmux-plugins/vim-tmux'
  109. "Plug 'tpope/vim-git'
  110. Plug 'tpope/vim-liquid'
  111. Plug 'tpope/vim-rails'
  112. Plug 'vim-python/python-syntax'
  113. Plug 'vim-ruby/vim-ruby'
  114. Plug 'wgwoods/vim-systemd-syntax'
  115. "Plug 'psf/black'
  116.  
  117. call plug#end()
  118.  
  119. " }}}
  120. " leader {{{
  121. " -----------------------------------------------------------------------------
  122.  
  123. let mapleader=";"
  124. "noremap <leader><leader> <C-^>
  125. noremap <leader>cc :<ESC>gg"+yG<ESC>
  126. noremap <leader>y yiW
  127.  
  128.  
  129. " }}}
  130. " General Config {{{
  131. " -----------------------------------------------------------------------------
  132.  
  133. set backspace=indent,eol,start  "Allow backspace in insert mode
  134. set showcmd                     "Show incomplete cmds down the bottom
  135. set showmode                    "Show current mode down the bottom
  136. set gcr=a:blinkon0              "Disable cursor blink
  137. set visualbell                  "No sounds
  138. set autoread                    "Reload files changed outside vim
  139. set hidden
  140. set cursorline
  141. set modeline
  142. set mouse=n
  143. set encoding=utf-8
  144. set isfname+=32
  145. set showmatch                   "highlight matching [{{{()}}}]
  146. set lazyredraw
  147. set tw=100
  148. set complete+=kspell
  149. "set colorcolumn=100
  150. set formatoptions=tcqrn1
  151. set matchpairs+=<:>             " Use % to jump between pairs
  152. set nocompatible
  153. set noerrorbells visualbell t_vb=
  154. set noshiftround
  155. set nospell
  156. set nostartofline
  157. set regexpengine=1
  158. set ruler
  159. set ttimeout
  160. set whichwrap=b,s,<,>
  161. set t_Co=256
  162. set title titlestring=
  163. set completeopt-=preview
  164. set splitbelow
  165. set splitright
  166.  
  167.  
  168. " }}}
  169. " history, undo and backup {{{
  170. " -----------------------------------------------------------------------------
  171. set history=1000
  172. set undofile
  173. set undodir=~/.vim/undo
  174. set undolevels=1000
  175. set undoreload=10000
  176. set backupdir=~/.vim/backup
  177. set directory=~/.vim/backup
  178. set viminfo='100000
  179.  
  180. " }}}
  181. " Scrolling {{{
  182. " -----------------------------------------------------------------------------
  183. set scrolloff=8         "Start scrolling when we're 8 lines away from margins
  184. set sidescrolloff=0
  185. set sidescroll=0
  186. "set grepprg=grep\ -nH\ $*
  187. set runtimepath+=~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after
  188.  
  189. " }}}
  190. " Folds and search {{{
  191. " -----------------------------------------------------------------------------
  192.  
  193. " set foldenable          " enable folding
  194. " set foldlevelstart=0    " open most folds by default
  195. " set foldnestmax=10      " 10 nested fold max
  196. " set foldmethod=marker   " fold based on marker
  197. " toggle folding
  198. nnoremap <space> za
  199. " unfold all
  200. nnoremap <F7> zR
  201. " fold all
  202. nnoremap <F8> :foldc!<CR>
  203.  
  204. " Search
  205. set incsearch       " Find the next match as we type the search
  206. set hlsearch        " Highlight searches by default
  207. set ignorecase      " Ignore case when searching...
  208. set smartcase       " ...unless we type a capital
  209.  
  210. " }}}
  211. " relative numbers, TOP bar, statusline {{{
  212. " -----------------------------------------------------------------------------
  213. nnoremap <silent><leader>l :set number! relativenumber!<CR>
  214.  
  215. "augroup numbertoggle
  216. "  autocmd!
  217. "  autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
  218. "  autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber
  219. "augroup END
  220.  
  221. "
  222. " status line and top bar
  223. " IDE BAR
  224. nnoremap <silent><leader>k :execute 'set showtabline=' . (&showtabline ==# 2 ? 0 : 2)<CR>
  225. " status line
  226. "
  227. "set statusline=" %F%m%r%h %w  CWD: %r%{getcwd()}%h   Line: %1"
  228. set laststatus=1
  229.  
  230. " }}}
  231. "alphsubs ---------------------- {{{
  232. "        execute "digraphs ks " . 0x2096
  233. "        execute "digraphs as " . 0x2090
  234. "        execute "digraphs es " . 0x2091
  235. "        execute "digraphs hs " . 0x2095
  236. "        execute "digraphs is " . 0x1D62
  237. "        execute "digraphs ks " . 0x2096
  238. "        execute "digraphs ls " . 0x2097
  239. "        execute "digraphs ms " . 0x2098
  240. "        execute "digraphs ns " . 0x2099
  241. "        execute "digraphs os " . 0x2092
  242. "        execute "digraphs ps " . 0x209A
  243. "        execute "digraphs rs " . 0x1D63
  244. "        execute "digraphs ss " . 0x209B
  245. "        execute "digraphs ts " . 0x209C
  246. "        execute "digraphs us " . 0x1D64
  247. "        execute "digraphs vs " . 0x1D65
  248. "        execute "digraphs xs " . 0x2093
  249. "}}}
  250.  
  251.  
  252. " arabic/english {{{
  253.  
  254. " Switch to English - mapping
  255. "nnoremap <Leader>z :<C-U>call EngType()<CR>
  256. " Switch to Arabic - mapping
  257. "nnoremap <Leader>a :<C-U>call AraType()<CR>
  258.  
  259. " Switch to English - function
  260. function! EngType()
  261.   " To switch back from Arabic
  262.   set norightleft
  263. endfunction
  264.  
  265. " Switch to Arabic - function
  266. function! AraType()
  267.   set rightleft
  268.   set arabicshape
  269.   set arabic
  270. endfunction
  271.  
  272. au BufNewFile,BufRead *.txt call ConfigureTxtFile()
  273.  
  274. func! ConfigureTxtFile()
  275.   setlocal spell spelllang=en_us
  276.   set wrapmargin=80
  277.   set textwidth=80
  278. endfunction
  279.  
  280.  
  281. " }}}
  282. " Indentation {{{
  283.  
  284. set cindent
  285. set autoindent
  286. set smartindent
  287. set smarttab
  288. set shiftwidth=4
  289. set softtabstop=4
  290. set tabstop=4
  291. set expandtab smarttab
  292. set shiftround
  293.  
  294. " Auto indent pasted text
  295. nnoremap p p=`]<C-o>
  296. nnoremap P P=`]<C-o>
  297.  
  298. filetype plugin on
  299. filetype indent on
  300.  
  301. " Display tabs and trailing spaces visually
  302. set list listchars=tab:\ \ ,trail:ยท
  303.  
  304. set nowrap       "Don't wrap lines
  305.  
  306. " }}}
  307. " Completion {{{
  308.  
  309. set wildmode=list:longest
  310. set wildmenu                "enable ctrl-n and ctrl-p to scroll thru matches
  311. set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
  312. set wildignore+=*vim/backups*
  313. set wildignore+=*sass-cache*
  314. set wildignore+=*DS_Store*
  315. set wildignore+=vendor/rails/**
  316. set wildignore+=vendor/cache/**
  317. set wildignore+=*.gem
  318. set wildignore+=log/**
  319. set wildignore+=tmp/**
  320. set wildignore+=*.png,*.jpg,*.gif
  321.  
  322. " }}}
  323. " Color {{{
  324. " -----------------------------------------------------------------------------
  325.  
  326. colorscheme gruvbox
  327. " For Gruvbox to look correct in terminal Vim you'll want to source a palette
  328. " script that comes with the Gruvbox plugin.
  329. "
  330. " Add this to your ~/.profile file:
  331. "   source "$HOME/.vim/bundle/gruvbox/gruvbox_256palette.sh"
  332.  
  333. " Gruvbox comes with both a dark and light theme.
  334. set background=dark
  335.  
  336. " Gruvbox has 'hard', 'medium' (default) and 'soft' contrast options.
  337. let g:gruvbox_contrast_light='hard'
  338.  
  339. " This needs to come last, otherwise the colors aren't correct.
  340. syntax on
  341.  
  342. if (&background == 'dark')
  343.     " Fix the disgusting visual selection colors of gruvbox (thanks @romainl).
  344.     hi Visual cterm=NONE ctermfg=NONE ctermbg=237 guibg=#3a3a3a
  345.  
  346.     " Set a custom highlight color when yanking text.
  347.     "   This requires having the plugin: machakann/vim-highlightedyank
  348.     hi HighlightedyankRegion cterm=NONE ctermbg=239 guibg=#4e4e4e
  349. else
  350.     hi Visual cterm=NONE ctermfg=NONE ctermbg=223 guibg=#ffd7af
  351.     hi HighlightedyankRegion cterm=NONE ctermbg=228 guibg=ffff87
  352. endif
  353.  
  354. " }}}
  355. " highlighting and cursor {{{
  356.  
  357. "hi CursorLine      ctermbg=darkgrey   ctermfg=none    term=bold cterm=bold
  358. hi CursorColumn     ctermbg=darkred    ctermfg=white    term=bold cterm=bold
  359. hi StatusLine       ctermbg=darkred    ctermfg=white    term=bold cterm=bold
  360. hi Normal           ctermbg=black      ctermfg=none     term=bold cterm=bold
  361. hi Visual           ctermbg=lightred   ctermfg=black    term=bold cterm=bold
  362. hi Folded           ctermbg=black      ctermfg=red      term=bold cterm=bold
  363. hi FoldColumn       ctermbg=green      ctermfg=yellow   term=bold cterm=bold
  364. hi Search           ctermbg=yellow     ctermfg=black    term=bold cterm=bold
  365. hi Cursor           ctermbg=yellow     ctermfg=yellow   term=bold cterm=bold
  366. hi iCursor          ctermbg=yellow     ctermfg=yellow   term=bold cterm=bold
  367.  
  368. hi SpellBad cterm=underline ctermfg=9
  369. hi SpellLocal cterm=underline ctermfg=9
  370. hi SpellRare cterm=underline ctermfg=9
  371. hi SpellCap cterm=underline
  372.  
  373. ":hi MyGroup cterm=bold
  374. ":match MyGroup /./
  375.  
  376. "make block cursor
  377. let &t_ti.="\e[1 q"
  378. let &t_SI.="\e[5 q"
  379. let &t_EI.="\e[1 q"
  380. let &t_te.="\e[0 q"
  381. "
  382.  
  383. au InsertEnter * :hi StatusLine      ctermbg=darkgreen    ctermfg=white    term=bold cterm=bold
  384. au InsertLeave * :hi StatusLine      ctermbg=darkred    ctermfg=white    term=bold cterm=bold
  385.  
  386.  
  387. " }}}
  388. " differnt settings {{{
  389.  
  390. "
  391. runtime! macros/matchit.vim
  392. "
  393. " open file externally
  394. nnoremap <leader>o :silent !xdg-open <cfile>&<CR>
  395.  
  396. "leader n highlight current word and search it
  397. :nnoremap <leader>n :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
  398.  
  399. " set current directory to the directory of the current file
  400. autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif
  401.  
  402. " Quick write session with F2
  403. map <F2> :mksession! ~/.vim/vim_session <cr>
  404.  
  405. " And load session with F3
  406. map <F3> :source ~/.vim/vim_session <cr>
  407.  
  408. " Automatically deletes all trailing whitespace on save.
  409. autocmd BufWritePre * %s/\s\+$//e
  410. " remember last position
  411. if has("autocmd")
  412.   au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  413. endif
  414.  
  415. " }}}
  416. " mouvements and buffers {{{
  417.  
  418. "f5 to show buffers
  419. :nnoremap <F5> :buffers<CR>:buffer<Space>
  420. nmap <F6> :TagbarToggle<CR>
  421.  
  422. "window mouvements
  423. nnoremap <down>     <C-W><C-J>
  424. nnoremap <up>       <C-W><C-K>
  425. nnoremap <right>    <C-W><C-L>
  426. nnoremap <left>     <C-W><C-H>
  427.  
  428. " moving around
  429. nmap <silent> <A-Up>    :wincmd k<CR>
  430. nmap <silent> <A-Down>  :wincmd j<CR>
  431. nmap <silent> <A-Left>  :wincmd h<CR>
  432. nmap <silent> <A-Right> :wincmd l<CR>
  433.  
  434. " moving blocks of code
  435. vnoremap < <gv
  436. vnoremap > >gv
  437.  
  438. " cycle through buffers
  439. nnoremap <Tab> :bnext<CR>
  440. nnoremap <S-Tab> :bprevious<CR>
  441. "nnoremap <Tab> <C-W><C-L>
  442. "nnoremap <S-Tab> <C-W><C-H>
  443.  
  444. " this function is a great way to open old files
  445. function! Output()
  446.   enew | 0put =v:oldfiles| nnoremap <buffer> <CR> :e <C-r>=getline('.')<CR><CR>|normal gg<CR>
  447.   setlocal buftype=nofile bufhidden=wipe noswapfile nowrap
  448.   "setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
  449. endfunction
  450.  
  451. :command! Browse call Output()
  452. :command! Mm     call Output()
  453. :command! MM     call Output()
  454.  
  455. " ????
  456. "command! -nargs=1 -complete=help H :enew | :set buftype=help | :h <args>
  457.  
  458. " ????
  459. "if has("autocmd")
  460. "    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  461. "endif
  462.  
  463. " }}}
  464. " Basic mappings {{{
  465. " -----------------------------------------------------------------------------
  466.  
  467. "" Seamlessly treat visual lines as actual lines when moving around.
  468. "noremap j gj
  469. "noremap k gk
  470. "noremap <Down> gj
  471. "noremap <Up> gk
  472. "inoremap <Down> <C-o>gj
  473. "inoremap <Up> <C-o>gk
  474. "
  475. "" Navigate around splits with a single key combo.
  476. "nnoremap <C-l> <C-w><C-l>
  477. "nnoremap <C-h> <C-w><C-h>
  478. "nnoremap <C-k> <C-w><C-k>
  479. "nnoremap <C-j> <C-w><C-j>
  480. "
  481. "" Cycle through splits.
  482. "nnoremap <S-Tab> <C-w>w
  483. "
  484. "" Press * to search for the term under the cursor or a visual selection and
  485. "" then press a key below to replace all instances of it in the current file.
  486. "nnoremap <Leader>r :%s///g<Left><Left>
  487. "nnoremap <Leader>rc :%s///gc<Left><Left><Left>
  488. "
  489. "" The same as above but instead of acting on the whole file it will be
  490. "" restricted to the previously visually selected range. You can do that by
  491. "" pressing *, visually selecting the range you want it to apply to and then
  492. "" press a key below to replace all instances of it in the current selection.
  493. "xnoremap <Leader>r :s///g<Left><Left>
  494. "xnoremap <Leader>rc :s///gc<Left><Left><Left>
  495. "
  496. "" Type a replacement term and press . to repeat the replacement again. Useful
  497. "" for replacing a few instances of the term (comparable to multiple cursors).
  498. "nnoremap <silent> s* :let @/='\<'.expand('<cword>').'\>'<CR>cgn
  499. "xnoremap <silent> s* "sy:let @/=@s<CR>cgn
  500. "
  501. "" Clear search highlights.
  502. "map <Leader><Space> :let @/=''<CR>
  503. "
  504. "" Format paragraph (selected or not) to 80 character lines.
  505. "nnoremap <Leader>g gqap
  506. "xnoremap <Leader>g gqa
  507. "
  508. "" Prevent x from overriding what's in the clipboard.
  509. "noremap x "_x
  510. "noremap X "_x
  511. "
  512. "" Prevent selecting and pasting from overwriting what you originally copied.
  513. "xnoremap p pgvy
  514. "
  515. "" Keep cursor at the bottom of the visual selection after you yank it.
  516. "vmap y ygv<Esc>
  517. "
  518. "" Edit Vim config file in a new tab.
  519. "map <Leader>ev :tabnew $MYVIMRC<CR>
  520. "
  521. "" Source Vim config file.
  522. "map <Leader>sv :source $MYVIMRC<CR>
  523. "
  524. "" Toggle spell check.
  525. "map <F5> :setlocal spell!<CR>
  526. "
  527. "" Toggle relative line numbers and regular line numbers.
  528. "nmap <F6> :set invrelativenumber<CR>
  529. "
  530. "" Automatically fix the last misspelled word and jump back to where you were.
  531. ""   Taken from this talk: https://www.youtube.com/watch?v=lwD8G1P52Sk
  532. "nnoremap <leader>sp :normal! mz[s1z=`z<CR>
  533. "
  534. "" Toggle quickfix window.
  535. "function! QuickFix_toggle()
  536. "    for i in range(1, winnr('$'))
  537. "        let bnum = winbufnr(i)
  538. "        if getbufvar(bnum, '&buftype') == 'quickfix'
  539. "            cclose
  540. "            return
  541. "        endif
  542. "    endfor
  543. "
  544. "    copen
  545. "endfunction
  546. "nnoremap <silent> <Leader>c :call QuickFix_toggle()<CR>
  547. "
  548. "" Convert the selected text's title case using the external tcc script.
  549. ""   Requires: https://github.com/nickjj/title-case-converter
  550. "vnoremap <Leader>tc c<C-r>=system('tcc', getreg('"'))[:-2]<CR>
  551. "
  552. " }}}
  553. " Basic autocommands {{{
  554. " -----------------------------------------------------------------------------
  555. "
  556. "" Auto-resize splits when Vim gets resized.
  557. "autocmd VimResized * wincmd =
  558. "
  559. "" Update a buffer's contents on focus if it changed outside of Vim.
  560. "au FocusGained,BufEnter * :checktime
  561. "
  562. "" Unset paste on InsertLeave.
  563. "autocmd InsertLeave * silent! set nopaste
  564. "
  565. "" Make sure all types of requirements.txt files get syntax highlighting.
  566. "autocmd BufNewFile,BufRead requirements*.txt set syntax=python
  567. "
  568. "" Ensure tabs don't get converted to spaces in Makefiles.
  569. "autocmd FileType make setlocal noexpandtab
  570. "
  571. "" Only show the cursor line in the active buffer.
  572. "augroup CursorLine
  573. "    au!
  574. "    au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
  575. "    au WinLeave * setlocal nocursorline
  576. "augroup END
  577. "
  578. " ----------------------------------------------------------------------------
  579. "" Basic commands
  580. "" ----------------------------------------------------------------------------
  581. "
  582. "" Add all TODO items to the quickfix list relative to where you opened Vim.
  583. "function! s:todo() abort
  584. "    let entries = []
  585. "    for cmd in ['git grep -niIw -e TODO -e FIXME 2> /dev/null',
  586. "                \ 'grep -rniIw -e TODO -e FIXME . 2> /dev/null']
  587. "        let lines = split(system(cmd), '\n')
  588. "        if v:shell_error != 0 | continue | endif
  589. "        for line in lines
  590. "            let [fname, lno, text] = matchlist(line, '^\([^:]*\):\([^:]*\):\(.*\)')[1:3]
  591. "            call add(entries, { 'filename': fname, 'lnum': lno, 'text': text })
  592. "        endfor
  593. "        break
  594. "    endfor
  595. "
  596. "    if !empty(entries)
  597. "        call setqflist(entries)
  598. "        copen
  599. "    endif
  600. "endfunction
  601. "
  602. "command! Todo call s:todo()
  603. "
  604. "" Profile Vim by running this command once to start it and again to stop it.
  605. "function! s:profile(bang)
  606. "    if a:bang
  607. "        profile pause
  608. "        noautocmd qall
  609. "    else
  610. "        profile start /tmp/profile.log
  611. "        profile func *
  612. "        profile file *
  613. "    endif
  614. "endfunction
  615. "
  616. "command! -bang Profile call s:profile(<bang>0)
  617.  
  618. " }}}
  619. " Plugin settings, mappings and autocommands {{{
  620. " -----------------------------------------------------------------------------
  621.  
  622. " .............................................................................
  623. " junegunn/fzf.vim
  624. " .............................................................................
  625.  
  626. let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'
  627.  
  628. let g:fzf_action = {
  629.            \ 'ctrl-t': 'tab split',
  630.            \ 'ctrl-x': 'split',
  631.            \ 'ctrl-v': 'vsplit',
  632.            \ 'ctrl-y': {lines -> setreg('*', join(lines, "\n"))}}
  633.  
  634. " Launch fzf with CTRL+P.
  635. nnoremap <silent> <C-p> :FZF -m<CR>
  636.  
  637. " Map a few common things to do with FZF.
  638. nnoremap <silent> <Leader>, :Buffers<CR>
  639. nnoremap <silent> <Leader>j :Lines<CR>
  640. nnoremap <silent> <Leader>h :Commands<CR>
  641. nnoremap <silent> <Leader><leader> :History<CR>
  642.  
  643. " Allow passing optional flags into the Rg command.
  644. "   Example: :Rg myterm -g '*.md'
  645. command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case " . <q-args>, 1, <bang>0)
  646.  
  647.  
  648. " .............................................................................
  649. " mhinz/vim-grepper
  650. " .............................................................................
  651.  
  652. let g:grepper={}
  653. let g:grepper.tools=["rg"]
  654.  
  655. xmap gr <plug>(GrepperOperator)
  656.  
  657. " After searching for text, press this mapping to do a project wide find and
  658. " replace. It's similar to <leader>r except this one applies to all matches
  659. " across all files instead of just the current file.
  660. nnoremap <Leader>R
  661.             \ :let @s='\<'.expand('<cword>').'\>'<CR>
  662.             \ :Grepper -cword -noprompt<CR>
  663.             \ :cfdo %s/<C-r>s//g \| update
  664.             \<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
  665.  
  666. " The same as above except it works with a visual selection.
  667. xmap <Leader>R
  668.             \ "sy
  669.             \ gvgr
  670.             \ :cfdo %s/<C-r>s//g \| update
  671.             \<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
  672.  
  673. " .............................................................................
  674. " ntpeters/vim-better-whitespace
  675. " .............................................................................
  676.  
  677. let g:strip_whitespace_confirm=0
  678. let g:strip_whitelines_at_eof=1
  679. let g:strip_whitespace_on_save=1
  680.  
  681. " .............................................................................
  682. " Konfekt/FastFold
  683. " .............................................................................
  684.  
  685. let g:fastfold_savehook=0
  686. let g:fastfold_fold_command_suffixes=[]
  687.  
  688. " .............................................................................
  689. " junegunn/limelight.vim
  690. " .............................................................................
  691.  
  692. let g:limelight_conceal_ctermfg=244
  693.  
  694. " .............................................................................
  695. " iamcco/markdown-preview.nvim
  696. " .............................................................................
  697.  
  698. let g:mkdp_auto_close=0
  699. let g:mkdp_refresh_slow=1
  700. let g:mkdp_markdown_css='/home/mosaid/.local/lib/github-markdown-css/github-markdown.css'
  701.  
  702. " .............................................................................
  703. " iamcco/markdown-preview.nvim
  704. " .............................................................................
  705.  
  706. let g:mkdp_refresh_slow=1
  707. let g:mkdp_markdown_css='/home/mosaid/.local/lib/github-markdown-css/github-markdown.css'
  708.  
  709. " .............................................................................
  710. " YouCompleteMe
  711. " .............................................................................
  712.  
  713. let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py'
  714. let g:ycm_add_preview_to_completeopt = 0
  715. "let g:ycm_autoclose_preview_window_after_insertion = 1
  716. "let g:ycm_autoclose_preview_window_after_completion = 1
  717. let g:ycm_collect_identifiers_from_tags_files = 1
  718. "set tags+=~/.vim/tags/testtags
  719.  
  720. let g:ycm_key_list_select_completion = ['<C-j>', '<Down>']
  721. let g:ycm_key_list_previous_completion = ['<C-k>', '<Up>']
  722. let g:ycm_key_list_accept_completion = ['<C-y>']
  723.  
  724. " Additional YouCompleteMe config.
  725. let g:ycm_complete_in_comments = 1
  726. let g:ycm_collect_identifiers_from_comments_and_strings = 1
  727. let g:ycm_seed_identifiers_with_syntax = 1
  728.  
  729. let g:ycm_server_python_interpreter='python3'
  730. map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
  731.  
  732.  
  733. " Disable unhelpful semantic completions.
  734. "let g:ycm_filetype_specific_completion_to_disable = {
  735. "            \   'c': 1,
  736. "            \   'gitcommit': 1,
  737. "            \   'haskell': 1,
  738. "            \   'javascript': 1,
  739. "            \   'ruby': 1
  740. "            \ }
  741. "
  742. let g:ycm_semantic_triggers = {
  743.             \   'haskell': [
  744.             \     '.',
  745.             \     '(',
  746.             \     ',',
  747.             \     ', '
  748.             \   ]
  749.             \ }
  750.  
  751. " Same as default, but with "markdown" and "text" removed.
  752. let g:ycm_filetype_blacklist = {
  753.             \   'notes': 1,
  754.             \   'unite': 1,
  755.             \   'tagbar': 1,
  756.             \   'pandoc': 1,
  757.             \   'qf': 1,
  758.             \   'vimwiki': 1,
  759.             \   'infolog': 1,
  760.             \   'mail': 1
  761.             \ }
  762.  
  763.  
  764.  
  765. " }}}
  766. " latex-suite {{{
  767. " let g:tex_flavor='latex'
  768. " " }}}
  769. " Ranger   {{{
  770. "
  771.  let g:ranger_map_keys = 1
  772. "
  773. " " add this line if you use NERDTree
  774.  let g:NERDTreeHijackNetrw = 0
  775. "
  776. " " open ranger when vim open a directory
  777. " let g:ranger_replace_netrw = 1
  778. "
  779. "
  780. " " }}}
  781. " nerdtree   {{{
  782. "
  783.  let NERDTreeIgnore = ['__pycache__', '\.pyc$', '\.o$', '\.so$',
  784.  \ '\.a$', '\.swp',  '*\.swp', '\.swo', '\.swn', '\.swh',
  785.  \ '\.swm', '\.swl', '\.swk', '\.sw*$',  '[a-zA-Z]*egg[a-zA-Z]*',
  786.  \ '.DS_Store']
  787.  
  788.  let g:NERDTreeMinimalUI = 1
  789.  let g:NERDTreeDirArrows=1
  790.  let g:NERDTreeShowHidden=1
  791.  let g:NERDTreeAutoDeleteBuffer=1
  792.  let g:NERDTreeWinPos="left"
  793.  let g:NERDTreeMenuUp='<UP>'
  794.  let g:NERDTreeMenuDown='<DOWN>'
  795.  
  796.  map <C-t> :NERDTreeToggle %<CR>
  797.  " Open nerd tree at the current file or close nerd tree if pressed again.
  798.  nnoremap <silent> <expr> <Leader>n g:NERDTree.IsOpen() ? "\:NERDTreeClose<CR>" : bufexists(expand('%')) ? "\:NERDTreeFind<CR>" : "\:NERDTree<CR>"
  799. "
  800. " " }}}
  801. " dragvisuals   {{{
  802. "
  803. " runtime plugin/dragvisuals.vim
  804. "
  805. " vmap  <expr>  <LEFT>   DVB_Drag('left')
  806. " vmap  <expr>  <RIGHT>  DVB_Drag('right')
  807. " vmap  <expr>  <DOWN>   DVB_Drag('down')
  808. " vmap  <expr>  <UP>     DVB_Drag('up')
  809. " vmap  <expr>  D        DVB_Duplicate()
  810. "
  811. " " Remove any introduced trailing whitespace after moving...
  812. " let g:DVB_TrimWS = 1
  813. "
  814. " vmap <expr>  ++  VMATH_YankAndAnalyse()
  815. " nmap         ++  vip++
  816. "
  817. " " }}}
  818. " HardMode   {{{
  819. "
  820. " "autocmd VimEnter,BufNewFile,BufReadPost * silent! call HardMode()
  821. " nnoremap <leader>h <Esc>:call EasyMode()<CR>
  822. " nnoremap <leader>H <Esc>:call HardMode()<CR>
  823. "
  824. " " }}}
  825. " CommandT   {{{
  826. "
  827. " let g:CommandTMaxFiles=2000000
  828. "
  829. " " }}}
  830. " ultisnips   {{{
  831. "
  832. "     " YouCompleteMe and UltiSnips compatibility.
  833. "     let g:UltiSnipsExpandTrigger = '<Tab>'
  834. "     let g:UltiSnipsJumpForwardTrigger = '<Tab>'
  835. "     let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'
  836. "
  837. "     " Prevent UltiSnips from removing our carefully-crafted mappings.
  838. "     let g:UltiSnipsMappingsToIgnore = ['autocomplete']
  839. "
  840. "     "" Additional UltiSnips config.
  841. "     "let g:UltiSnipsSnippetsDir = '~/.vim/ultisnips'
  842. "     "let g:UltiSnipsSnippetDirectories = ['ultisnips']
  843. " " }}}
  844. " vim-latex-preview   {{{
  845. "     let g:livepreview_previewer = 'okular'
  846. "     let g:livepreview_engine = 'xelatex'
  847. "     let g:livepreview_cursorhold_recompile = 0
  848. " " }}}
  849. " vim prettier {{{
  850. " " max line length that prettier will wrap on
  851. " " Prettier default: 80
  852. " let g:prettier#config#print_width = 120
  853. "
  854. " " number of spaces per indentation level
  855. " " Prettier default: 2
  856. " let g:prettier#config#tab_width = 4
  857. "
  858. " " use tabs over spaces
  859. " " Prettier default: false
  860. " let g:prettier#config#use_tabs = 'true'
  861. "
  862. " " print semicolons
  863. " " Prettier default: true
  864. " let g:prettier#config#semi = 'true'
  865. "
  866. " " single quotes over double quotes
  867. " " Prettier default: false
  868. " let g:prettier#config#single_quote = 'true'
  869. "
  870. " " print spaces between brackets
  871. " " Prettier default: true
  872. " let g:prettier#config#bracket_spacing = 'false'
  873. "
  874. " " put > on the last line instead of new line
  875. " " Prettier default: false
  876. " let g:prettier#config#jsx_bracket_same_line = 'true'
  877. "
  878. " " avoid|always
  879. " " Prettier default: avoid
  880. " let g:prettier#config#arrow_parens = 'always'
  881. "
  882. " " none|es5|all
  883. " " Prettier default: none
  884. " let g:prettier#config#trailing_comma = 'all'
  885. "
  886. " " flow|babylon|typescript|css|less|scss|json|graphql|markdown
  887. " " Prettier default: babylon
  888. " let g:prettier#config#parser = 'flow'
  889. "
  890. " " cli-override|file-override|prefer-file
  891. " let g:prettier#config#config_precedence = 'prefer-file'
  892. "
  893. " " always|never|preserve
  894. " let g:prettier#config#prose_wrap = 'preserve'
  895. "
  896. " " css|strict|ignore
  897. " let g:prettier#config#html_whitespace_sensitivity = 'css'
  898. "
  899. " " when running at every change you may want to disable quickfix
  900. " let g:prettier#quickfix_enabled = 0
  901. "
  902. " let g:prettier#autoformat = 0
  903. " autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
  904. "
  905. " "  }}}
  906. " my snippets   {{{
  907. "      "inoremap <leader><leader> <esc>/<++><Enter>"_c4l
  908. "      "vnoremap <leader><leader> <esc>/<++><Enter>"_c4l
  909. "
  910. "
  911. "
  912. "     let g:jedi#goto_command = "<leader>d"
  913. "     let g:jedi#goto_assignments_command = "<leader>g"
  914. "     let g:jedi#goto_definitions_command = "enew"
  915. "     let g:jedi#documentation_command = "K"
  916. "     let g:jedi#usages_command = "<leader>n"
  917. "     let g:jedi#completions_command = "<C-Space>"
  918. "     let g:jedi#rename_command = "<leader>r"
  919. "
  920. "
  921. " " }}}
  922. "
  923. "runtime! macros/matchit.vim
  924. "
  925.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement