From e17e650295f986d0c91973e90c60eaaef073f2db Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Thu, 5 Nov 2020 17:04:10 +0100 Subject: [PATCH] Update linebreak settings with vim --- vim.org | 880 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 436 insertions(+), 444 deletions(-) diff --git a/vim.org b/vim.org index 234fc23..8e38a8f 100644 --- a/vim.org +++ b/vim.org @@ -7,7 +7,7 @@ #+AUTHOR: Dehaeze Thomas #+HTML_LINK_HOME: ./index.html -#+HTML_LINK_UP: ./index.html +#+HTML_LINK_UP: ./index.html #+HTML_HEAD: #+HTML_HEAD: @@ -16,7 +16,7 @@ #+HTML_HEAD: #+HTML_HEAD: -#+PROPERTY: header-args+ :comments none +#+PROPERTY: header-args :comments none #+PROPERTY: header-args+ :mkdirp yes #+PROPERTY: header-args+ :tangle ~/.vimrc :END: @@ -97,9 +97,9 @@ Other nice themes are [[https://github.com/mhartington/oceanic-next][oceanic-nex ** Language Server Protocol #+begin_src vimrc Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'bash install.sh', - \ } + \ 'branch': 'next', + \ 'do': 'bash install.sh', + \ } #+end_src ** Snippnets and autocompletion @@ -116,13 +116,13 @@ Other nice themes are [[https://github.com/mhartington/oceanic-next][oceanic-nex ** Auto Completion #+begin_src vimrc if has('nvim') - Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } - Plug 'Nelyah/deoplete-mu' + 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' + Plug 'Shougo/deoplete.nvim' + Plug 'roxma/nvim-yarp' + Plug 'roxma/vim-hug-neovim-rpc' + Plug 'Nelyah/deoplete-mu' endif #+end_src @@ -165,15 +165,6 @@ Other nice themes are [[https://github.com/mhartington/oceanic-next][oceanic-nex Plug 'vim-scripts/utl.vim' " Univeral Text Linking - Execute URLs, footnotes, open emails, organize ideas #+end_src -** Others / To test -#+begin_src vimrc - " Plug 'francoiscabrol/ranger.vim' " Ranger integration in vim and neovim - " Plug 'brooth/far.vim' " Find And Replace Vim plugin - " Plug 'justinmk/vim-gtfo' " Go to Terminal or File manager - " Plug 'sjl/gundo.vim', { 'on': 'GundoToggle' } " Vim plugin to visualize your Vim undo tree - " Plug 'drzel/vim-line-no-indicator' " Simple and expressive line number indicator -#+end_src - ** Plug End #+begin_src vimrc call plug#end() @@ -182,133 +173,133 @@ Other nice themes are [[https://github.com/mhartington/oceanic-next][oceanic-nex * Basic ** General #+begin_src vimrc -set runtimepath+=~/.vim + set runtimepath+=~/.vim -" Sets how many lines of history VIM has to remember -set history=500 + " Sets how many lines of history VIM has to remember + set history=500 -" Enable filetype plugins -filetype plugin on -filetype indent on + " Enable filetype plugins + filetype plugin on + filetype indent on -" Set to auto read when a file is changed from the outside -set autoread + " Set to auto read when a file is changed from the outside + set autoread -" writes the content of the file automatically if you call :make -set autowrite + " writes the content of the file automatically if you call :make + set autowrite -" Share clipboard with system -set clipboard+=unnamedplus + " Share clipboard with system + set clipboard+=unnamedplus -" Define Leader Key as Space key -let mapleader = "\" -let g:mapleader = "\" -let maplocalleader = "," + " Define Leader Key as Space key + let mapleader = "\" + let g:mapleader = "\" + let maplocalleader = "," #+end_src ** VIM user interface #+begin_src vimrc -" Set 7 lines to the cursor - when moving vertically using j/k -set so=7 + " Set 7 lines to the cursor - when moving vertically using j/k + set so=7 -" Avoid garbled characters in Chinese language windows OS -let $LANG='en' -set langmenu=en + " Avoid garbled characters in Chinese language windows OS + let $LANG='en' + set langmenu=en -" Set Timeout config -set timeout -set ttimeout -set timeoutlen=500 -set ttimeoutlen=50 + " Set Timeout config + set timeout + set ttimeout + set timeoutlen=500 + set ttimeoutlen=50 -" Turn on the wild menu -set wildmenu + " Turn on the wild menu + set wildmenu -" 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 + " 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 -set wildmode=full + set wildmode=full -"Always show current position -set ruler + "Always show current position + set ruler -" Height of the command bar -set cmdheight=1 + " Height of the command bar + set cmdheight=1 -" A buffer becomes hidden when it is abandoned -set hid + " A buffer becomes hidden when it is abandoned + set hid -" Configure backspace so it acts as it should act -set backspace=eol,start,indent -set whichwrap+=<,>,h,l + " Configure backspace so it acts as it should act + set backspace=eol,start,indent + set whichwrap+=<,>,h,l -" Ignore case when searching -set ignorecase + " Ignore case when searching + set ignorecase -" When searching try to be smart about cases -set smartcase + " When searching try to be smart about cases + set smartcase -" Option for smarter completions that will be case aware -set infercase + " Option for smarter completions that will be case aware + set infercase -" Highlight search results -set hlsearch + " Highlight search results + set hlsearch -" Makes search act like search in modern browsers -set incsearch + " Makes search act like search in modern browsers + set incsearch -" Don't redraw while executing macros (good performance config) -set lazyredraw + " Don't redraw while executing macros (good performance config) + set lazyredraw -" For regular expressions turn magic on -set magic + " For regular expressions turn magic on + set magic -" Show matching brackets when text indicator is over them -set showmatch + " Show matching brackets when text indicator is over them + set showmatch -" Don't show tab line if there is only one tab -set showtabline=1 + " Don't show tab line if there is only one tab + set showtabline=1 -" How tany tenths of a second to blink when matching brackets -set mat=2 + " How tany tenths of a second to blink when matching brackets + set mat=2 -" No annoying sound on errors -set noerrorbells -set novisualbell -set t_vb= -set tm=500 + " No annoying sound on errors + set noerrorbells + set novisualbell + set t_vb= + set tm=500 -" Add a bit extra margin to the left -set foldcolumn=0 + " Add a bit extra margin to the left + set foldcolumn=0 -" Improve VIM scrolling -set ttyfast + " Improve VIM scrolling + set ttyfast -" Relative Numbers -set relativenumber + " Relative Numbers + set relativenumber -" Smarter J and K navigation -nnoremap j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj' -nnoremap k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk' + " Smarter J and K navigation + nnoremap j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj' + nnoremap k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk' -" Splits open at the bottom and right, which is non-retarded, unlike vim defaults. -set splitbelow splitright + " Splits open at the bottom and right, which is non-retarded, unlike vim defaults. + set splitbelow splitright #+end_src ** Foldings #+begin_src vimrc -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 + 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 #+end_src ** Colors and Fonts @@ -352,111 +343,118 @@ endif ** Files, backups and undo #+begin_src vimrc -" Turn backup off, since most stuff is in SVN, git et.c anyway... -set nobackup -set nowb -set noswapfile + " Turn backup off, since most stuff is in SVN, git et.c anyway... + set nobackup + set nowb + set noswapfile #+end_src ** Text, tab and indent related #+begin_src vimrc -" Use spaces instead of tabs -set expandtab + " Use spaces instead of tabs + set expandtab -" Be smart when using tabs -set smarttab + " Be smart when using tabs + set smarttab -" 1 tab == 4 spaces -set shiftwidth=4 -set tabstop=4 + " 1 tab == 4 spaces + set shiftwidth=4 + set tabstop=4 -" Word wrap without line breaks -set wrap -set linebreak -set nolist " list disables linebreak + " Enable Line Number + set number +#+end_src -set autoindent " Auto Indentation -set nosmartindent " No Smart Indentation +From https://stackoverflow.com/questions/36950231/auto-wrap-lines-in-vim-without-inserting-newlines. +#+begin_src vimrc + " Word wrap without line breaks + set textwidth=0 + set wrapmargin=0 + set wrap + set linebreak + " set columns=160 +#+end_src + +#+begin_src vimrc + set autoindent " Auto Indentation + set nosmartindent " No Smart Indentation #+end_src ** Moving around, tabs, windows and buffers #+begin_src vimrc -" Specify the behavior when switching between buffers -try - set switchbuf=useopen,usetab -catch -endtry + " Specify the behavior when switching between buffers + try + set switchbuf=useopen,usetab + catch + endtry -" Return to last edit position when opening files (You want this!) -au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + " Return to last edit position when opening files (You want this!) + au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif -set splitbelow -set splitright + set splitbelow + set splitright -" This enables mouse in all modes -set mouse=a + " This enables mouse in all modes + set mouse=a -" Automatically equalize splits when Vim is resized -autocmd VimResized * wincmd = + " Automatically equalize splits when Vim is resized + autocmd VimResized * wincmd = #+end_src ** Misc #+begin_src vimrc -" Enable Line Number -set number + " Speed up cursor movments : http://superuser.com/a/625994/587300 + set regexpengine=1 " https://github.com/xolox/vim-easytags/issues/88 -" Speed up cursor movments : http://superuser.com/a/625994/587300 -set regexpengine=1 " https://github.com/xolox/vim-easytags/issues/88 - -" Set the maximum column for syntax highlighting -set synmaxcol=250 + " Set the maximum column for syntax highlighting + set synmaxcol=250 #+end_src ** Helper functions #+begin_src vimrc -function! CmdLine(str) - exe "menu Foo.Bar :" . a:str - emenu Foo.Bar - unmenu Foo -endfunction + function! CmdLine(str) + exe "menu Foo.Bar :" . a:str + emenu Foo.Bar + unmenu Foo + endfunction -function! VisualSelection(direction, extra_filter) range - let l:saved_reg = @" - execute "normal! vgvy" + function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" - let l:pattern = escape(@", '\\/.*$^~[]') - let l:pattern = substitute(l:pattern, "\n$", "", "") + let l:pattern = escape(@", '\\/.*$^~[]') + let l:pattern = substitute(l:pattern, "\n$", "", "") - if a:direction == 'gv' - call CmdLine("Ag \"" . l:pattern . "\" " ) - elseif a:direction == 'replace' - call CmdLine("%s" . '/'. l:pattern . '/') - endif + if a:direction == 'gv' + call CmdLine("Ag \"" . l:pattern . "\" " ) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + endif - let @/ = l:pattern - let @" = l:saved_reg -endfunction + let @/ = l:pattern + let @" = l:saved_reg + endfunction -" Don't close window, when deleting a buffer -command! Bclose call BufcloseCloseIt() -function! BufcloseCloseIt() - let l:currentBufNum = bufnr("%") - let l:alternateBufNum = bufnr("#") + " Don't close window, when deleting a buffer + command! Bclose call BufcloseCloseIt() + function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") - if buflisted(l:alternateBufNum) - buffer # - else - bnext - endif + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif - if bufnr("%") == l:currentBufNum - new - endif + if bufnr("%") == l:currentBufNum + new + endif - if buflisted(l:currentBufNum) - execute("bdelete! ".l:currentBufNum) - endif -endfunction + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif + endfunction #+end_src ** GUI related @@ -473,11 +471,11 @@ endfunction ** Turn persistent undo on #+begin_src vimrc -try - set undodir=~/.vim_runtime/temp_dirs/undodir - set undofile -catch -endtry + try + set undodir=~/.vim_runtime/temp_dirs/undodir + set undofile + catch + endtry #+end_src * Mappings @@ -504,47 +502,47 @@ endtry ** Visual mode related #+begin_src vimrc -" Visual mode pressing / or ? searches for the current selection -vnoremap / :call VisualSelection('', '')/=@/ -vnoremap ? :call VisualSelection('', '')?=@/ + " Visual mode pressing / or ? searches for the current selection + vnoremap / :call VisualSelection('', '')/=@/ + vnoremap ? :call VisualSelection('', '')?=@/ -" Re-select visual block after indenting -vnoremap < >gv + " Re-select visual block after indenting + vnoremap < >gv -" Move visual block -vnoremap J :m '>+1gv=gv -vnoremap K :m '<-2gv=gv + " Move visual block + vnoremap J :m '>+1gv=gv + vnoremap K :m '<-2gv=gv #+end_src ** Add some delimiters #+begin_src vimrc -" use $ as a delimiter -xnoremap i$ :normal! T$vt$ -xnoremap a$ :normal! T$hvt$l -onoremap i$ :normal vi$ -onoremap a$ :normal va$ + " use $ as a delimiter + xnoremap i$ :normal! T$vt$ + xnoremap a$ :normal! T$hvt$l + onoremap i$ :normal vi$ + onoremap a$ :normal va$ #+end_src ** Command mode related #+begin_src vimrc -" Bash like keys for the command line -cnoremap -cnoremap -cnoremap + " Bash like keys for the command line + cnoremap + cnoremap + cnoremap -cnoremap -cnoremap + cnoremap + cnoremap #+end_src ** Terminal mode related #+begin_src vimrc -" tnoremap + " tnoremap -tnoremap h h -tnoremap j j -tnoremap k k -tnoremap l l + tnoremap h h + tnoremap j j + tnoremap k k + tnoremap l l #+end_src ** Correct misspelled works @@ -562,19 +560,20 @@ Taken from: https://vi.stackexchange.com/questions/68/autocorrect-spelling-mista * Filetypes ** Vim Which Key #+begin_src vimrc -nnoremap :WhichKey ',' + nnoremap :WhichKey '' -let g:which_key_map_local = {} + let g:which_key_map_local = {} #+end_src ** Mails #+begin_src vimrc autocmd FileType mail set spell spelllang=en_us,fr #+end_src + ** MarkDown #+begin_src vimrc -" Automatically turn on spell-checking for Markdown files -au BufRead,BufNewFile *.md setlocal spell spelllang=fr,en + " Automatically turn on spell-checking for Markdown files + au BufRead,BufNewFile *.md setlocal spell spelllang=fr,en #+end_src ** LaTeX @@ -607,11 +606,11 @@ au BufRead,BufNewFile *.md setlocal spell spelllang=fr,en ** Arduino #+begin_src vimrc -au BufRead,BufNewFile *.pde set filetype=arduino -au BufRead,BufNewFile *.ino set filetype=arduino -" au FileType arduino map ac :!platformio run -" au FileType arduino map au :!platformio run -s --target=upload -" au FileType arduino map am :!platformio serialports monitor --port=/dev/cu + au BufRead,BufNewFile *.pde set filetype=arduino + au BufRead,BufNewFile *.ino set filetype=arduino + " au FileType arduino map ac :!platformio run + " au FileType arduino map au :!platformio run -s --target=upload + " au FileType arduino map am :!platformio serialports monitor --port=/dev/cu #+end_src ** Python @@ -693,22 +692,22 @@ au BufRead,BufNewFile *.ino set filetype=arduino ** Save Which Key Configuration #+begin_src vimrc -call which_key#register(',', "g:which_key_map_local") + call which_key#register('', "g:which_key_map") #+end_src * Plugins Config ** junegunn/fzf #+begin_src vimrc -" This is the default extra key bindings -let g:fzf_action = { + " 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"' + " [[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'], + let g:fzf_colors = + \ { 'fg': ['fg', 'Normal'], \ 'bg': ['bg', 'Normal'], \ 'hl': ['fg', 'Comment'], \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], @@ -721,22 +720,22 @@ let g:fzf_colors = \ 'spinner': ['fg', 'Label'], \ 'header': ['fg', 'Comment'] } -function! s:fzf_statusline() + 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 + endfunction -autocmd! User FzfStatusLine call fzf_statusline() + autocmd! User FzfStatusLine call fzf_statusline() #+end_src ** autozimu/LanguageClient-neovim #+begin_src vimrc 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'], - \ } + \ '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'], + \ } nnoremap :call LanguageClient_contextMenu() " Or map each action separately @@ -747,17 +746,17 @@ autocmd! User FzfStatusLine call fzf_statusline() ** JamshedVesuna/vim-markdown-preview #+begin_src vimrc -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 + 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 #+end_src ** mhinz/vim-signify #+begin_src vimrc -let g:signify_vcs_list = ['git'] + let g:signify_vcs_list = ['git'] -let g:signify_disable_by_default = 1 + let g:signify_disable_by_default = 1 #+end_src ** Deoplete @@ -773,63 +772,63 @@ let g:signify_disable_by_default = 1 ** SirVer/ultisnips #+begin_src vimrc -let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnip' + let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnip' -" inoremap pumvisible() ? "\" : "\" -let g:UltiSnipsExpandTrigger="" -" let g:UltiSnipsJumpForwardTrigger="" -" let g:UltiSnipsJumpBackwardTrigger="" + " inoremap pumvisible() ? "\" : "\" + let g:UltiSnipsExpandTrigger="" + " let g:UltiSnipsJumpForwardTrigger="" + " let g:UltiSnipsJumpBackwardTrigger="" #+end_src ** honza/vim-snippets #+begin_src vimrc -let g:snipMate = {} -let g:snipMate.scope_aliases = {} + let g:snipMate = {} + let g:snipMate.scope_aliases = {} #+end_src ** itchyny/lightline.vim #+begin_src vimrc -function! LightlineObsession() - return '%{ObsessionStatus("")}' -endfunction + 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': "|" } -\ } + " \ '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': "|" } + \ } #+end_src ** Autopairs #+begin_src vimrc -" Incompatibilité entre auto-pairs et clang-complete -let g:AutoPairsMapCR = 0 -imap AutoPairsReturn + " Incompatibilité entre auto-pairs et clang-complete + let g:AutoPairsMapCR = 0 + imap AutoPairsReturn #+end_src ** Yggdroot/indentLine #+begin_src vimrc -" :IndentLinesToggle toggles lines on and off. -let g:indentLine_color_term = 239 + " :IndentLinesToggle toggles lines on and off. + let g:indentLine_color_term = 239 #+end_src ** ryanoasis/vim-devicons #+begin_src vimrc -let g:webdevicons_enable_ctrlp = 1 + let g:webdevicons_enable_ctrlp = 1 #+end_src ** junegunn/goyo.vim @@ -842,8 +841,6 @@ let g:webdevicons_enable_ctrlp = 1 This is for soft line breaks #+begin_src vimrc function! s:goyo_enter() - set wrap linebreak nolist textwidth=0 wrapmargin=0 - let b:quitting = 0 let b:quitting_bang = 0 autocmd QuitPre let b:quitting = 1 @@ -854,13 +851,13 @@ This is for soft line breaks Quit Vim if this is the only remaining buffer #+begin_src vimrc 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 + if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 + if b:quitting_bang + qa! + else + qa + endif + endif endfunction #+end_src @@ -871,20 +868,20 @@ Quit Vim if this is the only remaining buffer ** tpope/vim-surround #+begin_src vimrc -vmap Si S(i_f) -au FileType mako vmap Si S"i${ _(2f"a) } -" surroung un visual mode : use S, then b to make the text bold in markdown -let g:surround_{char2nr('b')} = "__\r__" + vmap Si S(i_f) + au FileType mako vmap Si S"i${ _(2f"a) } + " surroung un visual mode : use S, then b to make the text bold in markdown + let g:surround_{char2nr('b')} = "__\r__" #+end_src ** Vim-Markdown #+begin_src vimrc -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 + 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 -let g:tex_conceal = "" + let g:tex_conceal = "" #+end_src ** Neomake @@ -907,12 +904,12 @@ let g:tex_conceal = "" " 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,', - \ } + \ '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'] #+end_src @@ -926,9 +923,9 @@ let g:tex_conceal = "" ** jpalardy/vim-slime #+begin_src vimrc 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 + 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 #+end_src @@ -945,11 +942,6 @@ let g:tex_conceal = "" let g:EditorConfig_exclude_patterns = ['fugitive://.*'] #+end_src -** Polyglot -#+begin_src vimrc - let g:polyglot_disabled = ['latex'] -#+end_src - * Bindings ** Vim Which Key #+begin_src vimrc @@ -1004,7 +996,7 @@ let g:tex_conceal = "" " Find File corresping to Word nnoremap fw - \ :call fzf#vim#files('.', fzf#vim#with_preview({'options': ['--query', expand('')]})) + \ :call fzf#vim#files('.', fzf#vim#with_preview({'options': ['--query', expand('')]})) let g:which_key_map.f.w = 'find-file-word' #+end_src @@ -1153,19 +1145,19 @@ let g:tex_conceal = "" 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 + 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 #+end_src @@ -1303,170 +1295,170 @@ let g:tex_conceal = "" ** Errors #+begin_src vimrc -let g:which_key_map.e = { 'name' : '+errors' } + let g:which_key_map.e = { 'name' : '+errors' } -function! s:GetBufferList() - redir =>buflist - silent! ls - redir END - return buflist -endfunction + 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 + 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 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 + 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 ee :call ToggleLocationList() -let g:which_key_map.e.e = 'error-toggle' + " Error Toggle + nnoremap ee :call ToggleLocationList() + let g:which_key_map.e.e = 'error-toggle' -" Error Open -nnoremap eo :lopen -let g:which_key_map.e.o = 'error-open' + " Error Open + nnoremap eo :lopen + let g:which_key_map.e.o = 'error-open' -" Error Close -nnoremap ec :lclose -let g:which_key_map.e.c = 'error-close' + " Error Close + nnoremap ec :lclose + let g:which_key_map.e.c = 'error-close' -" Error Next -nnoremap en :lnext -let g:which_key_map.e.n = 'error-next' + " Error Next + nnoremap en :lnext + let g:which_key_map.e.n = 'error-next' -" Error Previous -nnoremap ep :lprevious -let g:which_key_map.e.p = 'error-previous' + " Error Previous + nnoremap ep :lprevious + let g:which_key_map.e.p = 'error-previous' #+end_src ** Text #+begin_src vimrc -let g:which_key_map.x = { 'name' : '+text' } + let g:which_key_map.x = { 'name' : '+text' } -" Start interactive EasyAlign in visual mode (e.g. vipga) and for a motion -xmap xa (EasyAlign) -nmap xa (EasyAlign) -let g:which_key_map.x.a = 'text-align' + " Start interactive EasyAlign in visual mode (e.g. vipga) and for a motion + xmap xa (EasyAlign) + nmap xa (EasyAlign) + let g:which_key_map.x.a = 'text-align' -" Indent all file -nnoremap x= mzgg=G`z -" let g:which_key_map.x.= = 'text-indent-file' + " Indent all file + nnoremap x= mzgg=G`z + " let g:which_key_map.x.= = 'text-indent-file' -" Custom Multiple Cursor -" http://www.kevinli.co/posts/2017-01-19-multiple-cursors-in-500-bytes-of-vimscript/ -let g:mc = "y/\\V\=escape(@\", '/')\\" + " Custom Multiple Cursor + " http://www.kevinli.co/posts/2017-01-19-multiple-cursors-in-500-bytes-of-vimscript/ + let g:mc = "y/\\V\=escape(@\", '/')\\" -" Multiple Cursor -nnoremap xm *``cgn -vnoremap xm g:mc . "``cgn" -let g:which_key_map.x.m = 'multiple-cursor' + " Multiple Cursor + nnoremap xm *``cgn + vnoremap xm g:mc . "``cgn" + let g:which_key_map.x.m = 'multiple-cursor' -" Multiple Cursor - reserve direction -nnoremap xM *``cgN -vnoremap xM g:mc . "``cgN" -let g:which_key_map.x.M = 'multiple-cursor-reverse' + " Multiple Cursor - reserve direction + nnoremap xM *``cgN + vnoremap xM g:mc . "``cgN" + let g:which_key_map.x.M = 'multiple-cursor-reverse' -" Delete trainling Whitespaces -fun! TrimWhitespace() - let l:save = winsaveview() - keeppatterns %s/\s\+$//e - call winrestview(l:save) -endfun -nnoremap xt :call TrimWhitespace() -let g:which_key_map.x.t = 'delete-trailing-whitespaces' + " Delete trainling Whitespaces + fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) + endfun + nnoremap xt :call TrimWhitespace() + let g:which_key_map.x.t = 'delete-trailing-whitespaces' #+end_src ** Config #+begin_src vimrc -let g:which_key_map.c = { 'name' : '+config' } + 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 + 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 cs :call ToggleSyntaxH() -let g:which_key_map.c.s = 'toggle-syntax-col' + " Toggle Syntax column + nnoremap cs :call ToggleSyntaxH() + 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 + 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 ch :call ToggleH() -let g:which_key_map.c.h = 'toggle-highlight' + " Toggle Highlight + nnoremap ch :call ToggleH() + let g:which_key_map.c.h = 'toggle-highlight' -" Reload vim config -noremap cr :source $MYVIMRC -let g:which_key_map.c.e = 'reload-config' + " Reload vim config + noremap cr :source $MYVIMRC + let g:which_key_map.c.e = 'reload-config' -" Edit vim config -noremap ce :e $MYVIMRC -let g:which_key_map.c.e = 'edit-config' + " Edit vim config + noremap ce :e $MYVIMRC + let g:which_key_map.c.e = 'edit-config' -" Disable highlight -noremap c :noh -let g:which_key_map.c.enter = 'disable-highlight' + " Disable highlight + noremap c :noh + let g:which_key_map.c.enter = 'disable-highlight' -" Theme -noremap ct :noh -let g:which_key_map.c.t = 'choose-theme' + " Theme + noremap ct :noh + let g:which_key_map.c.t = 'choose-theme' #+end_src ** Insert #+begin_src vimrc -let g:which_key_map.i = { 'name' : '+insert' } + let g:which_key_map.i = { 'name' : '+insert' } -" Insert Snippet -noremap is :Snippets -let g:which_key_map.i.s = 'insert-snippet' + " Insert Snippet + noremap is :Snippets + let g:which_key_map.i.s = 'insert-snippet' #+end_src ** Save Which Key Configuration #+begin_src vimrc -call which_key#register('', "g:which_key_map") + call which_key#register('', "g:which_key_map") #+end_src