2019-01-31 09:41:03 +01:00
#+TITLE : Vim Config
2021-01-01 20:12:34 +01:00
#+SETUPFILE : ./setup/org-setup-file.org
2020-11-05 17:04:10 +01:00
#+PROPERTY : header-args :comments none
2019-01-31 09:41:03 +01:00
#+PROPERTY : header-args+ :mkdirp yes
#+PROPERTY : header-args+ :tangle ~/.vimrc
* Plugins Install
** Plug start
2019-12-16 11:38:48 +01:00
#+BEGIN_SRC vimrc
2021-01-08 01:26:27 +01:00
call plug#begin('~/.vim/plugged')
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Manage Files
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'tpope/vim-vinegar' " Combine with netrw to create a delicious salad dressing
Plug 'junegunn/fzf', { 'dir': '~/ .fzf', 'do': './install --bin' } " A command-line fuzzy finder written in Go
Plug 'junegunn/fzf.vim' " Fzf for vim
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Text Objects
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'kana/vim-textobj-user' " Create your own text objects
Plug 'kana/vim-textobj-line' " Text objects for the current line
Plug 'kana/vim-textobj-entire' " Text objects for entire buffer
Plug 'michaeljsmith/vim-indent-object' " Defines a new text object representing lines of code at the same indent level
Plug 'jiangmiao/auto-pairs' " Vim plugin, insert or delete brackets, parens, quotes in pair
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Git
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'jreybert/vimagit'
Plug 'tpope/vim-fugitive' " A Git wrapper so awesome, it should be illegal
Plug 'junegunn/gv.vim' " A git commit browser
Plug 'mhinz/vim-signify' " Show a diff using Vim its sign column
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Motions, Search
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'terryma/vim-expand-region' " Vim plugin that allows you to visually select increasingly larger regions of text using the same key combination
Plug 'justinmk/vim-sneak' " The missing motion for Vim
Plug 'haya14busa/is.vim' " Improved incremental searching for Vim
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Manipulate Things
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'tpope/vim-surround' " Quoting/parenthesizing made simple
Plug 'tpope/vim-commentary' " Comment stuff out
Plug 'junegunn/vim-easy-align' " A Vim alignment plugin
Plug 'Olical/vim-enmasse' " Edit every line in a quickfix list at the same time
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug >(GrepperOperator)'] } "
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Utils
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'tpope/vim-repeat' " Enable repeating supported plugin maps with '.'
Plug 'tpope/vim-obsession' " Continuously updated session files
Plug 'tpope/vim-eunuch' " eunuch.vim: helpers for UNIX
Plug 'kana/vim-operator-user' " Define your own operator easily
Plug 'majutsushi/tagbar' " Vim plugin that displays tags in a window, ordered by scope
Plug 'tpope/vim-speeddating' " use CTRL-A/CTRL-X to increment dates, times, and more
Plug 'liuchengxu/vim-which-key' " Vim plugin that shows keybindings in popup
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Visual
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'itchyny/lightline.vim' " A light and configurable statusline/tabline for Vim
Plug 'Yggdroot/indentLine' " A vim plugin to display the indention levels with thin vertical lines
Plug 'ryanoasis/vim-devicons' " Adds file type glyphs/icons to many popular Vim plugins such as: NERDTree, vim-airline, unite, vim-startify and many more
Plug 'mhinz/vim-startify' " The fancy start screen for Vim
Plug 'junegunn/goyo.vim' " Distraction-free writing in Vim
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Themes
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'morhetz/gruvbox' " Retro groove color scheme for Vim
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2020-11-03 16:45:31 +01:00
Other nice themes are [[https://github.com/mhartington/oceanic-next ][oceanic-next ]] and [[https://github.com/jacoborus/tender.vim ][tender ]].
2019-08-23 10:02:52 +02:00
** Language Server Protocol
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
2019-08-23 10:02:52 +02:00
#+end_src
2019-01-31 09:41:03 +01:00
** Snippnets and autocompletion
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'SirVer/ultisnips' " The ultimate snippet solution for Vim
Plug 'honza/vim-snippets' " Vim-snipmate default snippets
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Syntax Checking and Build Utils
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'neomake/neomake' " Asynchronous linting and make framework for Neovim/Vim
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Auto Completion
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Nelyah/deoplete-mu'
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'Nelyah/deoplete-mu'
endif
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Tmux
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'christoomey/vim-tmux-navigator' " Seamless navigation between tmux panes and vim splits
Plug 'jpalardy/vim-slime' " Used to type text into a REPL
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Syntax
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'sheerun/vim-polyglot' " A solid language pack for Vim
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Markdown
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } " Markdown Vim Mode
Plug 'mzlogin/vim-markdown-toc', { 'for': 'markdown' } " A vim plugin to generate table of contents for Markdown files
Plug 'JamshedVesuna/vim-markdown-preview', { 'for': 'markdown' } " A light Vim plugin for previewing markdown files in a browser
Plug 'nelstrom/vim-markdown-folding' " Fold markdown documents by section
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** LaTeX
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'lervag/vimtex', { 'for': 'tex' } " A modern vim plugin for editing LaTeX files.
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Matlab
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'tdehaeze/matlab-vim', { 'for': 'matlab' } " Edit Matlab M-files in Vim editor
Plug 'djoshea/vim-matlab-fold', { 'for': 'matlab' } " Vim code folding for Matlab files
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Org Mode
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
Plug 'jceb/vim-orgmode' " Text outlining and task management for Vim
Plug 'vim-scripts/SyntaxRange' " Define a different filetype syntax on regions of a buffer
Plug 'chrisbra/NrrwRgn' " A Narrow Region Plugin for vim
Plug 'mattn/calendar-vim' " calendar vimscript
Plug 'vim-scripts/utl.vim' " Univeral Text Linking - Execute URLs, footnotes, open emails, organize ideas
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Plug End
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
call plug#end()
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
* Basic
** General
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
set runtimepath+=~/.vim
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Sets how many lines of history VIM has to remember
set history=500
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Enable filetype plugins
filetype plugin on
filetype indent on
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Set to auto read when a file is changed from the outside
set autoread
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" writes the content of the file automatically if you call :make
set autowrite
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Share clipboard with system
set clipboard+=unnamedplus
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Define Leader Key as Space key
let mapleader = "\<Space >"
let g:mapleader = "\<Space >"
let maplocalleader = ","
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** VIM user interface
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
set langmenu=en
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Set Timeout config
set timeout
set ttimeout
set timeoutlen=500
set ttimeoutlen=50
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Turn on the wild menu
set wildmenu
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Ignore compiled files
set wildignore=*.o,* ~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\* ,.svn\*
else
set wildignore+=*/.git/* ,*/.hg/* ,*/.svn/* ,*/.DS_Store
endif
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
set wildmode=full
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
"Always show current position
set ruler
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Height of the command bar
set cmdheight=1
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" A buffer becomes hidden when it is abandoned
set hid
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<, >,h,l
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Ignore case when searching
set ignorecase
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" When searching try to be smart about cases
set smartcase
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Option for smarter completions that will be case aware
set infercase
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Highlight search results
set hlsearch
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Makes search act like search in modern browsers
set incsearch
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Don't redraw while executing macros (good performance config)
set lazyredraw
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" For regular expressions turn magic on
set magic
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Show matching brackets when text indicator is over them
set showmatch
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Don't show tab line if there is only one tab
set showtabline=1
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" How tany tenths of a second to blink when matching brackets
set mat=2
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Add a bit extra margin to the left
set foldcolumn=0
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Improve VIM scrolling
set ttyfast
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Relative Numbers
set relativenumber
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Smarter J and K navigation
nnoremap <expr > j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr > k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
2019-05-16 21:13:08 +02:00
2021-01-08 01:26:27 +01:00
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Foldings
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
if has('folding')
if has('windows')
let &fillchars='vert: ' " less cluttered vertical window separators
endif
set foldmethod=indent " not as cool as syntax, but faster
set foldlevelstart=99 " start unfolded
endif
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Colors and Fonts
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
syntax enable
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
set background=dark
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let base16colorspace=256
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let g:gruvbox_contrast_dark = 'soft'
2019-05-16 21:13:08 +02:00
2021-01-08 01:26:27 +01:00
try
colorscheme gruvbox
catch
endtry
2019-04-10 16:53:26 +02:00
2021-01-08 01:26:27 +01:00
" set cursor shapes for insert and replace modes
set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Set utf8 as standard encoding
set encoding=utf-8
set fileencoding=utf-8
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Use Unix as the standard file type
set ffs=unix,dos,mac
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Do not highlight the cursor line : http://vim.wikia.com/wiki/Highlight_current_line
set nocursorline
set nocursorcolumn
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Always show the status line
set laststatus=2
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Underline for bad spelled words
hi clear SpellBad
hi SpellBad cterm=underline
" Set style for gVim
hi SpellBad gui=undercurl
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Files, backups and undo
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Text, tab and indent related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Use spaces instead of tabs
set expandtab
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Be smart when using tabs
set smarttab
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Enable Line Number
set number
2020-11-05 17:04:10 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2020-11-05 17:04:10 +01:00
From https://stackoverflow.com/questions/36950231/auto-wrap-lines-in-vim-without-inserting-newlines.
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Word wrap without line breaks
set textwidth=0
set wrapmargin=0
set wrap
set linebreak
" set columns=160
2020-11-05 17:04:10 +01:00
#+end_src
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
set autoindent " Auto Indentation
set nosmartindent " No Smart Indentation
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Moving around, tabs, windows and buffers
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab
catch
endtry
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
set splitbelow
set splitright
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" This enables mouse in all modes
set mouse=a
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Automatically equalize splits when Vim is resized
autocmd VimResized * wincmd =
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Misc
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Speed up cursor movments : http://superuser.com/a/625994/587300
set regexpengine=1 " https://github.com/xolox/vim-easytags/issues/88
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Set the maximum column for syntax highlighting
set synmaxcol=250
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Helper functions
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
if a:direction == 'gv'
call CmdLine("Ag \"" . l:pattern . "\" " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/ ')
endif
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let @/ = l:pattern
let @" = l:saved_reg
endfunction
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Don't close window, when deleting a buffer
command! Bclose call <SID >BufcloseCloseIt()
function! <SID >BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
if bufnr("%") == l:currentBufNum
new
endif
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** GUI related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
set guifont=Hack\ Nerd\ Font\ Mono:h13
set gfn=Hack\ Nerd\ Font\ Mono:h13
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Disable scrollbars
set guioptions-=r
set guioptions-=R
set guioptions-=l
set guioptions-=L
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Turn persistent undo on
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
try
set undodir=~/.vim_runtime/temp_dirs/undodir
set undofile
catch
endtry
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
* Mappings
** Normal mode related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Smart way to move between windows
noremap <C-j > <C-W >j
noremap <C-k > <C-W >k
noremap <C-h > <C-W >h
noremap <C-l > <C-W >l
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Insert mode related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Paste while in insert mode
inoremap <C-v > <C-r >*
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Go to the end of line
inoremap <C-e > <Esc >A
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Go to the beginning of line
inoremap <C-a > <Esc >I
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Visual mode related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Visual mode pressing / or ? searches for the current selection
vnoremap <silent > / :<C-u>call VisualSelection('', '')<CR>/ <C-R >=@/<CR ><CR >
vnoremap <silent > ? :<C-u >call VisualSelection('', '')<CR >?<C-R >=@/<CR ><CR >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Re-select visual block after indenting
vnoremap < <gv
vnoremap > >gv
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Move visual block
vnoremap J :m '>+1<CR >gv=gv
vnoremap K :m '<-2<CR >gv=gv
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Add some delimiters
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" use $ as a delimiter
xnoremap i$ :<C-u >normal! T$vt$<CR >
xnoremap a$ :<C-u >normal! T$hvt$l<CR >
onoremap i$ :normal vi$<CR >
onoremap a$ :normal va$<CR >
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Command mode related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Bash like keys for the command line
cnoremap <C-A > <Home >
cnoremap <C-E > <End >
cnoremap <C-K > <C-U >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
cnoremap <C-P > <Up >
cnoremap <C-N > <Down >
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Terminal mode related
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" tnoremap <Esc > <C-\ ><C-n >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
tnoremap <C-w >h <C-\ ><C-n ><C-w >h
tnoremap <C-w >j <C-\ ><C-n ><C-w >j
tnoremap <C-w >k <C-\ ><C-n ><C-w >k
tnoremap <C-w >l <C-\ ><C-n ><C-w >l
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2019-05-16 21:13:08 +02:00
** Correct misspelled works
Taken from: https://vi.stackexchange.com/questions/68/autocorrect-spelling-mistakes
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Go back to last misspelled word and pick first suggestion.
inoremap <C-L > <C-G >u<Esc >[s1z=`]a<C-G >u
2019-05-16 21:13:08 +02:00
2021-01-08 01:26:27 +01:00
" Select last misspelled word (typing will edit).
nnoremap <C-K > <Esc >[sve<C-G >
inoremap <C-K > <Esc >[sve<C-G >
snoremap <C-K > <Esc >b[sviw<C-G >
2019-12-16 11:38:48 +01:00
#+end_src
2019-05-16 21:13:08 +02:00
2019-01-31 09:41:03 +01:00
* Filetypes
** Vim Which Key
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
nnoremap <silent > <leader > :WhichKey '<Space >'<cr >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let g:which_key_map_local = {}
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2019-05-16 21:13:08 +02:00
** Mails
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
autocmd FileType mail set spell spelllang=en_us,fr
2021-02-14 19:14:10 +01:00
autocmd FileType mail set textwidth=0
2019-05-16 21:13:08 +02:00
#+end_src
2020-11-05 17:04:10 +01:00
2019-01-31 09:41:03 +01:00
** MarkDown
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Automatically turn on spell-checking for Markdown files
au BufRead,BufNewFile *.md setlocal spell spelllang=fr,en
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** LaTeX
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
au BufRead,BufNewFile *.tikz set filetype=tex
let tex_no_error=1 " used to not highlight underscores
au BufRead,BufNewFile *.tex set filetype=tex
au BufRead,BufNewFile *.tex let b:AutoPairs={'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`', '$':'$'}
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
au BufRead,BufNewFile *.tex set iskeyword+=-
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" " clear the current list of matches that cause error-highlighting
" syn clear texOnlyMath
" " still mark '^' as an error outside of math mode
" syn match texOnlyMath /[\^]/
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" autocmd FileType tex,tikz nnoremap <leader >lt <plug >(vimtex-toc-toggle)
" autocmd FileType tex,tikz nnoremap <leader >ll <plug >(vimtex-labels-open)
" autocmd FileType tex,tikz nnoremap <leader >lv <plug >(vimtex-view)
" autocmd FileType tex,tikz nnoremap <leader >lf <plug >(vimtex-reverse-search)
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" " Make Tikz
" nnoremap <leader >mt :Make pdf t=tikz f= %:t:r<cr >
" nnoremap <leader >mto :make open t=tikz f= %:t:r<cr >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" " Make LaTeX
" nnoremap <leader >ml :Make pdf f=%:t:r<cr >
" nnoremap <leader >mlo :make open f=%:t:r<cr >
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Arduino
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
au BufRead,BufNewFile *.pde set filetype=arduino
au BufRead,BufNewFile *.ino set filetype=arduino
" au FileType arduino map <leader >ac :!platformio run<CR >
" au FileType arduino map <leader >au :!platformio run -s --target=upload<CR >
" au FileType arduino map <leader >am :!platformio serialports monitor --port=/dev/cu
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Python
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:slime_python_ipython = 1
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
au FileType python setlocal expandtab
au FileType python setlocal tabstop=4
au FileType python setlocal shiftwidth=4
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Run Section
au FileType python nmap <buffer > <localleader ><localleader > <Plug >SlimeParagraphSend
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Run Selected text
au FileType python vmap <buffer > <localleader ><localleader > <Plug >SlimeRegionSend
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CD to directory of current file
au FileType python nmap <buffer > <localleader >c :SlimeSend0('cd '.expand('%:p:h'))<CR >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" let python_highlight_all = 1
" au FileType python syn keyword pythonDecorator True None False self
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" au BufNewFile,BufRead *.jinja set syntax=htmljinja
" au BufNewFile,BufRead *.mako set ft=mako
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" au FileType python map <buffer > F :set foldmethod=indent<cr >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" au FileType python inoremap <buffer > $r return
" au FileType python inoremap <buffer > $i import
" au FileType python inoremap <buffer > $p print
" au FileType python inoremap <buffer > $f #--- <esc >a
" au FileType python map <buffer > <leader >1 /class
" au FileType python map <buffer > <leader >2 /def
" au FileType python map <buffer > <leader >C ?class
" au FileType python map <buffer > <leader >D ?def
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Matlab
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Run Section (delimited by %%)
au FileType matlab nmap <buffer > <localleader >mm <Plug >SlimeParagraphSend
let g:which_key_map_local.m = { 'name' : '+matlab' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Run either Selected text
au FileType matlab vmap <buffer > <localleader >mm <Plug >SlimeRegionSend
let g:which_key_map_local.mm = 'run-code'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
func! GetSelectedText()
normal gv"xy
let result = getreg("x")
normal gv
return result
endfunc
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Help on the current selection
au FileType matlab vmap <buffer > <localleader >mh :<C-U >SlimeSend0('help '.expand(GetSelectedText()))<CR >
let g:which_key_map_local.mh = 'help'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Documentation on the current selection
au FileType matlab vmap <buffer > <localleader >mH :<C-U >SlimeSend0('doc '.expand(GetSelectedText()))<CR >
let g:which_key_map_local.mh = 'help'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Open the current file in the Matlab Editor (usefull for debuging)
au FileType matlab nmap <buffer > <localleader >me :SlimeSend0('edit '.expand('%:p'))<CR >
let g:which_key_map_local.me = 'edit-gui'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Run all the file
au FileType matlab nmap <buffer > <localleader >mr :SlimeSend0('run '.expand('%:t'))<CR >
let g:which_key_map_local.mr = 'run-file'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Send "cd filepath" to matlab
au FileType matlab nmap <buffer > <localleader >mc :SlimeSend0('cd '.expand('%:p:h'))<CR >
let g:which_key_map_local.mr = 'cd-file'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Open workspace
au FileType matlab nmap <buffer > <localleader >mw :SlimeSend0('workspace')<CR >
let g:which_key_map_local.mr = 'workspace'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Save Which Key Configuration
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
call which_key#register('<Space >', "g:which_key_map")
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
* Plugins Config
** junegunn/fzf
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-h': 'split',
\ 'ctrl-v': 'vsplit' }
" [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format= "%C(auto)%h%d %s %C(black)%C(bold)%cr"'
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
function! s:fzf_statusline()
" Override statusline as you like
highlight fzf1 ctermfg=161 ctermbg=251
highlight fzf2 ctermfg=23 ctermbg=251
highlight fzf3 ctermfg=237 ctermbg=251
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endfunction
autocmd! User FzfStatusLine call <SID >fzf_statusline()
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2019-08-23 10:02:52 +02:00
** autozimu/LanguageClient-neovim
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:LanguageClient_serverCommands = {
\ 'matlab': ['java', ' -Djava.library.path=$MATLABROOT/bin/glnxa64 -cp $MATLABROOT/extern/engines/java/jar/engine.jar:$MATLABROOT/java/jar/jmi.jar:/home/thomas/github/matlab-langserver/build/libs/lsp-matlab-0.1.jar org.tokor.lspmatlab.Application'],
\ }
2019-08-23 10:02:52 +02:00
2021-01-08 01:26:27 +01:00
nnoremap <F5 > :call LanguageClient_contextMenu()<CR >
" Or map each action separately
nnoremap <silent > K :call LanguageClient#textDocument_hover()<CR >
nnoremap <silent > gd :call LanguageClient#textDocument_definition()<CR >
nnoremap <silent > <F2 > :call LanguageClient#textDocument_rename()<CR >
2019-08-23 10:02:52 +02:00
#+end_src
2019-01-31 09:41:03 +01:00
** JamshedVesuna/vim-markdown-preview
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let vim_markdown_preview_github=1
let vim_markdown_preview_browser='Google Chrome'
let vim_markdown_preview_temp_file=1
" let vim_markdown_preview_pandoc=1
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** mhinz/vim-signify
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:signify_vcs_list = ['git']
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let g:signify_disable_by_default = 1
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Deoplete
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:deoplete#enable_at_startup = 1
2019-12-16 11:38:48 +01:00
2021-01-08 01:26:27 +01:00
" let g:deoplete#omni#functions = {}
" set completeopt=longest,menuone,preview
" let g:deoplete#sources = {}
" let g:deoplete#enable_smart_case = 1
" call deoplete#custom#set('ultisnips', 'matchers', ['matcher_fuzzy'])
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** SirVer/ultisnips
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnip'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" inoremap <silent ><expr ><TAB > pumvisible() ? "\<C-n >" : "\<TAB >"
let g:UltiSnipsExpandTrigger="<C-j >"
" let g:UltiSnipsJumpForwardTrigger="<tab >"
" let g:UltiSnipsJumpBackwardTrigger="<s-tab >"
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** honza/vim-snippets
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:snipMate = {}
let g:snipMate.scope_aliases = {}
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** itchyny/lightline.vim
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
function! LightlineObsession()
return '%{ObsessionStatus("")}'
endfunction
" \ 'colorscheme': 'gruvbox',
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'filename', 'modified', 'fugitive', 'obsession' ] ]
\ },
\ 'component': {
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_expand': {
\ 'obsession': 'LightlineObsession'
\ },
\ 'component_visible_condition': {
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': "|", 'right': "|" }
\ }
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Autopairs
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Incompatibilité entre auto-pairs et clang-complete
let g:AutoPairsMapCR = 0
imap <silent ><CR > <CR ><Plug >AutoPairsReturn
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Yggdroot/indentLine
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" :IndentLinesToggle toggles lines on and off.
let g:indentLine_color_term = 239
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** ryanoasis/vim-devicons
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:webdevicons_enable_ctrlp = 1
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2019-05-16 21:13:08 +02:00
** junegunn/goyo.vim
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
2019-12-16 11:38:48 +01:00
#+end_src
2019-02-03 17:49:24 +01:00
This is for soft line breaks
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
function! s:goyo_enter()
let b:quitting = 0
let b:quitting_bang = 0
autocmd QuitPre <buffer > let b:quitting = 1
cabbrev <buffer > q! let b:quitting_bang = 1 <bar > q!
endfunction
2019-12-16 11:38:48 +01:00
#+end_src
2019-02-03 17:49:24 +01:00
Quit Vim if this is the only remaining buffer
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
function! s:goyo_leave()
if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
if b:quitting_bang
qa!
else
qa
endif
endif
endfunction
2019-12-16 11:38:48 +01:00
#+end_src
2019-02-03 17:49:24 +01:00
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
autocmd! User GoyoEnter call <SID >goyo_enter()
autocmd! User GoyoLeave call <SID >goyo_leave()
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** tpope/vim-surround
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
vmap Si S(i_<esc >f)
au FileType mako vmap Si S"i${ _(<esc >2f"a) }<esc >
" surroung un visual mode : use S, then b to make the text bold in markdown
let g:surround_{char2nr('b')} = "__\r__"
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Vim-Markdown
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_toml_frontmatter = 1
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let g:tex_conceal = ""
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Neomake
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Latex
autocmd! BufWritePost *.tex Neomake
let g:neomake_tex_chktex_maker = {
\ 'exe': 'chktex',
\ 'args': ['--inputfiles'],
\ 'errorformat':
\ '%EError %n in %f line %l: %m,' .
\ '%WWarning %n in %f line %l: %m,' .
\ '%WMessage %n in %f line %l: %m,' .
\ '%Z%p^,' .
\ '%-G%.%#'
\ }
let g:neomake_tex_enabled_makers = ['chktex']
" Matlab
autocmd! BufWritePost *.m Neomake
let g:neomake_matlab_mlint_maker = {
\ 'exe': 'mlint',
\ 'mapexpr': "neomake_bufname.':'.v:val",
\ 'errorformat':
\ '%f:L %l (C %c): %m,' .
\ '%f:L %l (C %c-%*[0-9]): %m,',
\ }
let g:neomake_matlab_enabled_makers = ['mlint']
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** lervag/vimtex
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" let g:tex_conceal=""
" autocmd FileType tex let b:vimtex_main = 'main.tex'
" let g:vimtex_mappings_enabled=0
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** jpalardy/vim-slime
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
if exists('$TMUX')
let g:slime_target = "tmux"
let g:slime_default_config = {"socket_name": split($TMUX, ",")[0], "target_pane": ":.2"}
let g:slime_dont_ask_default = 1
endif
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** mhinz/vim-grepper
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" nnoremap <leader >G :Grepper -tool ag<cr >
" nmap gs <plug >(GrepperOperator)
" xmap gs <plug >(GrepperOperator)
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Editor config
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" To ensure that this plugin works well with Tim Pope's fugitive, use the following patterns array:
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
* Bindings
** Vim Which Key
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
nnoremap <silent > <leader > :WhichKey '<Space >'<cr >
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
let g:which_key_map = {}
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Direct ones
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
" Switch with last buffer
nnoremap <leader ><Tab > :e #<cr >
" let g:which_key_map.<Tab > = 'last-buffer'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Quit
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.q = { 'name' : '+quit' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quit
nnoremap <leader >qq :qa<cr >
let g:which_key_map.q.q = 'quit'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quit - Force
nnoremap <leader >qQ :qa!<cr >
let g:which_key_map.q.Q = 'quit-force'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quit - Save
nnoremap <leader >qw :wq<cr >
let g:which_key_map.q.w = 'quit-save'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quit - Save all
nnoremap <leader >qW :wqa<cr >
let g:which_key_map.q.W = 'quit-save-all'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Files
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.f = { 'name' : '+files' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Fast saving
nnoremap <leader >fs :w!<cr >
let g:which_key_map.f.s = 'save-file'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Fast saving all
nnoremap <leader >fS :wa!<cr >
let g:which_key_map.f.S = 'save-all'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Find Files
noremap <leader >ff :Files<CR >
let g:which_key_map.f.f = 'find-file'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Find File corresping to Word
nnoremap <leader >fw
\ :call fzf#vim#files('.', fzf#vim#with_preview({'options': ['--query', expand('<cword >')]}))<cr >
2020-11-03 11:31:16 +01:00
2021-01-08 01:26:27 +01:00
let g:which_key_map.f.w = 'find-file-word'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Buffers
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.b = { 'name' : '+buffers' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Buffer Create
noremap <leader >bc :enew<cr >
let g:which_key_map.b.c = 'buffer-create'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Buffer Delete
noremap <leader >bd :Bclose<cr >
let g:which_key_map.b.d = 'buffer-delete'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Buffer Delete all others
noremap <leader >bD :bufdo bd<cr >
let g:which_key_map.b.D = 'buffer-delete-others'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Buffer Next
noremap <leader >bn :bnext<cr >
let g:which_key_map.b.n = 'buffer-next'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Buffer Previous
noremap <leader >bp :bprevious<cr >
let g:which_key_map.b.p = 'buffer-previous'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Find Buffers
noremap <leader >bf :Buffers<CR >
let g:which_key_map.b.f = 'buffer-find'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Buffer Home (startify)
noremap <leader >bh :Startify<CR >
let g:which_key_map.b.h = 'buffer-home'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CD to buffer path
noremap <leader >bw :cd %:p:h<CR >:pwd<CR >
let g:which_key_map.b.w = 'buffer-pwd'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Tabs
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.t = { 'name' : '+tabs' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Let 'tt' toggle between this and the last accessed tab
let g:lasttab = 1
au TabLeave * let g:lasttab = tabpagenr()
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab New
nnoremap <leader >tc :tabnew<cr >
let g:which_key_map.t.c = 'tab-create'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Delete
nnoremap <leader >td :tabclose<cr >
let g:which_key_map.t.d = 'tab-delete'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Maximize
nnoremap <leader >tD :tabonly<cr >
let g:which_key_map.t.D = 'tab-delete-others'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Left
nnoremap <leader >th gt<cr >
let g:which_key_map.t.h = 'tab-left'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Right
nnoremap <leader >tl gT<cr >
let g:which_key_map.t.l = 'tab-right'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Move Left
nnoremap <leader >tH :tabmove -1<cr >
let g:which_key_map.t.H = 'tab-move-left'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Move Right
nnoremap <leader >tL :tabmove +1<cr >
let g:which_key_map.t.L = 'tab-move-right'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Tab Toggle
nnoremap <Leader >tt :exe "tabn ".g:lasttab<CR >
let g:which_key_map.t.t = 'tab-toggle'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Terminals
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.T = { 'name' : '+terminals' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quickly create a new terminal in a new tab
nnoremap <Leader >Tc :tab new<CR >:term<CR >
let g:which_key_map.T.c = 'term-create'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quickly create a new terminal in a vertical split
nnoremap <Leader >T/ :vsplit<CR >:term<CR >
" let g:which_key_map.T./ = 'term-vert'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Quickly create a new terminal in a horizontal split
nnoremap <Leader >T- :split<CR >:term<CR >
" let g:which_key_map.T.- = 'term-hor'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Splits / Windows
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.w = { 'name' : '+windows' }
" Split Horizontal
nnoremap <leader >w- :split<cr >
" let g:which_key_map.w.- = 'win-hor'
" Split Vertical
nnoremap <leader >w/ :vsplit<cr >
" let g:which_key_map.w./ = 'win-vert'
" Split Maximize
nnoremap <leader >wD <C-w >o
let g:which_key_map.w.D = 'win-delete-others'
" Split Delete
nnoremap <leader >wd <C-w >q
let g:which_key_map.w.d = 'win-delete'
" Split Go Left
nnoremap <leader >wh :wincmd h<CR >
let g:which_key_map.w.h = 'win-left'
" Split Go Down
nnoremap <leader >wj :wincmd j<CR >
let g:which_key_map.w.j = 'win-down'
" Split Go Up
nnoremap <leader >wk :wincmd k<CR >
let g:which_key_map.w.k = 'win-up'
" Split Go Right
nnoremap <leader >wl :wincmd l<CR >
let g:which_key_map.w.l = 'win-right'
" Split to Tab
nnoremap <leader >wt <C-w >T
let g:which_key_map.w.t = 'win-make-tab'
" Find window
nnoremap <leader >wf :Windows<CR >
let g:which_key_map.w.f = 'win-find'
" Maximize window
nnoremap <leader >wm :call MaximizeToggle()<CR >
let g:which_key_map.w.m = 'win-maximize'
function! MaximizeToggle()
if exists("s:maximize_session")
exec "source " . s:maximize_session
call delete(s:maximize_session)
unlet s:maximize_session
let &hidden=s:maximize_hidden_save
unlet s:maximize_hidden_save
else
let s:maximize_hidden_save = &hidden
let s:maximize_session = tempname()
set hidden
exec "mksession! " . s:maximize_session
only
endif
endfunction
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Check Spell
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.S = { 'name' : '+spell-check' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Toggle
noremap <leader >St :setlocal spell!<cr >
let g:which_key_map.S.t = 'spell-toggle'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Correct
noremap <leader >Sc z=
let g:which_key_map.S.c = 'spell-correct'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Do first
noremap <leader >SC 1z=
let g:which_key_map.S.C = 'spell-correct-first'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Language
noremap <leader >Sl :set spelllang=
let g:which_key_map.S.l = 'spell-language'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Next
noremap <leader >Sn ]s
let g:which_key_map.S.n = 'spell-next'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Next and correct
noremap <leader >SN ]s1z=
let g:which_key_map.S.N = 'spell-next-correct'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Previous
noremap <leader >Sp [s
let g:which_key_map.S.p = 'spell-prev'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Previous and correct
noremap <leader >SP [s1z=
let g:which_key_map.S.P = 'spell-prev-correct'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" CheckSpell Add to dictionnary
noremap <leader >Sa zg
let g:which_key_map.S.a = 'spell-add-dict'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Make
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.m = { 'name' : '+make' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Make Make
nnoremap <leader >mm :Make -B<CR >
let g:which_key_map.m.m = 'make'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Make Clean
nnoremap <leader >mc :Make clean<CR >
let g:which_key_map.m.c = 'make-clean'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Make Force
nnoremap <leader >mf :Make! -B<CR >
let g:which_key_map.m.f = 'make-force'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Make Run
nnoremap <leader >mr :Make! run<cr >
let g:which_key_map.m.r = 'make-run'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Make Open
nnoremap <leader >mo :make! open<cr >
let g:which_key_map.m.o = 'make-open'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Search
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.s = { 'name' : '+search' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Search History
noremap <leader >sh :History<CR >
let g:which_key_map.s.h = 'search-history'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Search Tags
noremap <leader >sT :Tags<CR >
let g:which_key_map.s.T = 'search-tags'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Search All
noremap <leader >sa :Rg<CR >
let g:which_key_map.s.g = 'search-all'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Search Word
noremap <leader >sw :exe ':Rg ' . expand('<cword >')<CR >
let g:which_key_map.s.w = 'search-word'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Search todo keyboard
nnoremap <leader >st :Grepper -tool rg -query TODO<CR >
let g:which_key_map.s.t = 'search-todos'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
2020-03-22 23:21:26 +01:00
** GIT
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.g = { 'name' : '+git' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Gutter
nnoremap <silent ><leader >gg :SignifyToggle<cr >
let g:which_key_map.g.g = 'git-'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Gutter Highlight
nnoremap <silent ><leader >gG :SignifyToggleHighlight<cr >
let g:which_key_map.g.G = 'git-'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Commit
nnoremap <leader >gc :Gcommit<CR >
let g:which_key_map.g.c = 'git-commit'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Status
nnoremap <leader >gs :Gstatus<CR >
let g:which_key_map.g.s = 'git-status'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Diff
nnoremap <leader >gd :Gdiff<CR >
let g:which_key_map.g.d = 'git-diff'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Blame
nnoremap <leader >gb :Gblame<CR >
let g:which_key_map.g.b = 'git-blame'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Visualise
nnoremap <leader >gv :GV<CR >
let g:which_key_map.g.v = 'git-visualize'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git File (visualise)
nnoremap <leader >gF :GV!<CR >
let g:which_key_map.g.F = 'git-file'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Git Find Commits
noremap <leader >gf :Commits<CR >
let g:which_key_map.g.f = 'git-find-commit'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Errors
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.e = { 'name' : '+errors' }
function! s:GetBufferList()
redir =>buflist
silent! ls
redir END
return buflist
endfunction
function! ToggleLocationList()
let curbufnr = winbufnr(0)
for bufnum in map(filter(split(s:GetBufferList(), '\n'), 'v:val =~ "Location List"'), 'str2nr(matchstr(v:val, "\\d\\+"))')
if curbufnr == bufnum
lclose
return
endif
endfor
let winnr = winnr()
let prevwinnr = winnr("#")
let nextbufnr = winbufnr(winnr + 1)
try
lopen
catch /E776/
echohl ErrorMsg
echo "Location List is Empty."
echohl None
return
endtry
if winbufnr(0) == nextbufnr
lclose
if prevwinnr > winnr
let prevwinnr-=1
endif
else
if prevwinnr > winnr
let prevwinnr+=1
endif
endif
" restore previous window
exec prevwinnr."wincmd w"
exec winnr."wincmd w"
endfunction
" Error Toggle
nnoremap <silent ><leader >ee :call ToggleLocationList()<CR >
let g:which_key_map.e.e = 'error-toggle'
" Error Open
nnoremap <silent ><leader >eo :lopen<CR >
let g:which_key_map.e.o = 'error-open'
" Error Close
nnoremap <silent ><leader >ec :lclose<CR >
let g:which_key_map.e.c = 'error-close'
" Error Next
nnoremap <silent ><leader >en :lnext<CR >
let g:which_key_map.e.n = 'error-next'
" Error Previous
nnoremap <silent ><leader >ep :lprevious<CR >
let g:which_key_map.e.p = 'error-previous'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Text
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.x = { 'name' : '+text' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Start interactive EasyAlign in visual mode (e.g. vipga) and for a motion
xmap <leader >xa <Plug >(EasyAlign)
nmap <leader >xa <Plug >(EasyAlign)
let g:which_key_map.x.a = 'text-align'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Indent all file
nnoremap <leader >x= mzgg=G`z
" let g:which_key_map.x.= = 'text-indent-file'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Custom Multiple Cursor
" http://www.kevinli.co/posts/2017-01-19-multiple-cursors-in-500-bytes-of-vimscript/
let g:mc = "y/\\V\<C-r>=escape(@\", '/ ')\<CR >\<CR >"
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Multiple Cursor
nnoremap <leader >xm *``cgn
vnoremap <expr > <leader >xm g:mc . "``cgn"
let g:which_key_map.x.m = 'multiple-cursor'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Multiple Cursor - reserve direction
nnoremap <leader >xM *``cgN
vnoremap <expr > <leader >xM g:mc . "``cgN"
let g:which_key_map.x.M = 'multiple-cursor-reverse'
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Delete trainling Whitespaces
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$/ /e
call winrestview(l:save)
endfun
nnoremap <leader >xt :call TrimWhitespace()<CR >
let g:which_key_map.x.t = 'delete-trailing-whitespaces'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Config
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.c = { 'name' : '+config' }
let s:activatedsh = 0
function! ToggleSyntaxH()
if s:activatedsh == 0
let s:activatedsh = 1
set synmaxcol=800
else
let s:activatedsh = 0
set synmaxcol=100
endif
endfunction
" Toggle Syntax column
nnoremap <leader >cs :call ToggleSyntaxH()<CR >
let g:which_key_map.c.s = 'toggle-syntax-col'
let s:activatedh = 0
function! ToggleH()
if s:activatedh == 0
let s:activatedh = 1
match Search '\%>80v.\+'
else
let s:activatedh = 0
match none
endif
endfunction
" Toggle Highlight
nnoremap <leader >ch :call ToggleH()<CR >
let g:which_key_map.c.h = 'toggle-highlight'
" Reload vim config
noremap <Leader >cr :source $MYVIMRC<CR >
let g:which_key_map.c.e = 'reload-config'
" Edit vim config
noremap <Leader >ce :e $MYVIMRC<CR >
let g:which_key_map.c.e = 'edit-config'
" Disable highlight
noremap <silent > <leader >c<CR > :noh<CR >
let g:which_key_map.c.enter = 'disable-highlight'
" Theme
noremap <silent > <leader >ct :noh<CR >
let g:which_key_map.c.t = 'choose-theme'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Insert
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
let g:which_key_map.i = { 'name' : '+insert' }
2019-01-31 09:41:03 +01:00
2021-01-08 01:26:27 +01:00
" Insert Snippet
noremap <Leader >is :Snippets<CR >
let g:which_key_map.i.s = 'insert-snippet'
2019-12-16 11:38:48 +01:00
#+end_src
2019-01-31 09:41:03 +01:00
** Save Which Key Configuration
2019-12-16 11:38:48 +01:00
#+begin_src vimrc
2021-01-08 01:26:27 +01:00
call which_key#register('<Space >', "g:which_key_map")
2019-12-16 11:38:48 +01:00
#+end_src