diff options
author | Vikas Kushwaha <dev@vikas.rocks> | 2024-11-21 13:30:52 +0530 |
---|---|---|
committer | Vikas Kushwaha <dev@vikas.rocks> | 2024-11-21 13:30:52 +0530 |
commit | 5c916d69d457101326803eb076a746060e3618cf (patch) | |
tree | d6fce3256eede1c1bf78fb6a1be75b9cc4b84cee /.config/nvim |
Moved from github
Diffstat (limited to '.config/nvim')
-rw-r--r-- | .config/nvim/autoload/airline/themes/onedark.vim | 130 | ||||
-rw-r--r-- | .config/nvim/autoload/lightline/colorscheme/onedark.vim | 58 | ||||
-rw-r--r-- | .config/nvim/autoload/onedark.vim | 29 | ||||
-rw-r--r-- | .config/nvim/autoload/plug.vim | 2863 | ||||
-rw-r--r-- | .config/nvim/autoload/scratch.vim | 49 | ||||
-rw-r--r-- | .config/nvim/coc/coc-onload.vim | 144 | ||||
-rw-r--r-- | .config/nvim/coc/coc-settings.json | 6 | ||||
-rw-r--r-- | .config/nvim/colors/onedark.vim | 713 | ||||
-rw-r--r-- | .config/nvim/dev.vim | 93 | ||||
-rw-r--r-- | .config/nvim/init.bak.vim | 225 | ||||
-rw-r--r-- | .config/nvim/init.vim | 178 | ||||
-rw-r--r-- | .config/nvim/onedark.vim | 713 | ||||
-rw-r--r-- | .config/nvim/other/fzf.vim | 19 | ||||
-rw-r--r-- | .config/nvim/other/learn.vim | 649 | ||||
-rw-r--r-- | .config/nvim/out.vim | 36 | ||||
m--------- | .config/nvim/pack/colors/opt/onedark.vim | 0 | ||||
-rw-r--r-- | .config/nvim/templates/_default.c | 5 | ||||
-rw-r--r-- | .config/nvim/templates/_default.html | 13 | ||||
-rw-r--r-- | .config/nvim/templates/_default.tex | 7 | ||||
-rw-r--r-- | .config/nvim/templates/article.tex | 11 | ||||
-rw-r--r-- | .config/nvim/vim.log | 170 | ||||
-rw-r--r-- | .config/nvim/vimspector/python.json | 31 |
22 files changed, 6142 insertions, 0 deletions
diff --git a/.config/nvim/autoload/airline/themes/onedark.vim b/.config/nvim/autoload/airline/themes/onedark.vim new file mode 100644 index 0000000..65181dd --- /dev/null +++ b/.config/nvim/autoload/airline/themes/onedark.vim @@ -0,0 +1,130 @@ +" [onedark.vim](https://github.com/joshdick/onedark.vim/) + +" This is a [vim-airline](https://github.com/vim-airline/vim-airline) theme for use with +" the [onedark.vim](https://github.com/joshdick/onedark.vim) colorscheme. + +" It is based on vim-airline's ["tomorrow" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/tomorrow.vim). +function! airline#themes#onedark#refresh() + let s:colors = onedark#GetColors() + + if get(g:, 'onedark_termcolors', 256) == 16 + let s:term_red = s:colors.red.cterm16 + let s:term_green = s:colors.green.cterm16 + let s:term_yellow = s:colors.yellow.cterm16 + let s:term_blue = s:colors.blue.cterm16 + let s:term_purple = s:colors.purple.cterm16 + let s:term_white = s:colors.white.cterm16 + let s:term_cursor_grey = s:colors.cursor_grey.cterm16 + let s:term_visual_grey = s:colors.visual_grey.cterm16 + else + let s:term_red = s:colors.red.cterm + let s:term_green = s:colors.green.cterm + let s:term_yellow = s:colors.yellow.cterm + let s:term_blue = s:colors.blue.cterm + let s:term_purple = s:colors.purple.cterm + let s:term_white = s:colors.white.cterm + let s:term_cursor_grey = s:colors.cursor_grey.cterm + let s:term_visual_grey = s:colors.visual_grey.cterm + endif + + let g:airline#themes#onedark#palette = {} + + let g:airline#themes#onedark#palette.accents = { + \ 'red': [ s:colors.red.gui, '', s:term_red, 0 ] + \ } + + let s:N1 = [ s:colors.cursor_grey.gui, s:colors.green.gui, s:term_cursor_grey, s:term_green ] + let s:N2 = [ s:colors.white.gui, s:colors.visual_grey.gui, s:term_white, s:term_visual_grey ] + let s:N3 = [ s:colors.green.gui, s:colors.cursor_grey.gui, s:term_green, s:term_cursor_grey ] + let g:airline#themes#onedark#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + + let group = airline#themes#get_highlight('vimCommand') + let g:airline#themes#onedark#palette.normal_modified = { + \ 'airline_c': [ group[0], '', group[2], '', '' ] + \ } + + let s:I1 = [ s:colors.cursor_grey.gui, s:colors.blue.gui, s:term_cursor_grey, s:term_blue ] + let s:I2 = s:N2 + let s:I3 = [ s:colors.blue.gui, s:colors.cursor_grey.gui, s:term_blue, '' ] + let g:airline#themes#onedark#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#onedark#palette.insert_modified = g:airline#themes#onedark#palette.normal_modified + + let s:R1 = [ s:colors.cursor_grey.gui, s:colors.red.gui, s:term_cursor_grey, s:term_red ] + let s:R2 = s:N2 + let s:R3 = [ s:colors.red.gui, s:colors.cursor_grey.gui, s:term_red, '' ] + let g:airline#themes#onedark#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#onedark#palette.replace_modified = g:airline#themes#onedark#palette.normal_modified + + let s:V1 = [ s:colors.cursor_grey.gui, s:colors.purple.gui, s:term_cursor_grey, s:term_purple ] + let s:V2 = s:N2 + let s:V3 = [ s:colors.purple.gui, s:colors.cursor_grey.gui, s:term_purple, '' ] + let g:airline#themes#onedark#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#onedark#palette.visual_modified = g:airline#themes#onedark#palette.normal_modified + + let s:IA1 = [ s:colors.cursor_grey.gui, s:colors.white.gui, s:term_cursor_grey, s:term_white ] + let s:IA2 = [ s:colors.white.gui, s:colors.visual_grey.gui, s:term_white, s:term_visual_grey ] + let s:IA3 = s:N2 + let g:airline#themes#onedark#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) + let g:airline#themes#onedark#palette.inactive_modified = { + \ 'airline_c': [ group[0], '', group[2], '', '' ] + \ } + + " Warning/Error styling code from vim-airline's ["base16" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/base16.vim) + + " Warnings + let s:WI = [ s:colors.cursor_grey.gui, s:colors.yellow.gui, s:term_cursor_grey, s:term_yellow ] + let g:airline#themes#onedark#palette.normal.airline_warning = [ + \ s:WI[0], s:WI[1], s:WI[2], s:WI[3] + \ ] + + let g:airline#themes#onedark#palette.normal_modified.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + let g:airline#themes#onedark#palette.insert.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + let g:airline#themes#onedark#palette.insert_modified.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + let g:airline#themes#onedark#palette.visual.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + let g:airline#themes#onedark#palette.visual_modified.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + let g:airline#themes#onedark#palette.replace.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + let g:airline#themes#onedark#palette.replace_modified.airline_warning = + \ g:airline#themes#onedark#palette.normal.airline_warning + + " Errors + let s:ER = [ s:colors.cursor_grey.gui, s:colors.red.gui, s:term_cursor_grey, s:term_red ] + let g:airline#themes#onedark#palette.normal.airline_error = [ + \ s:ER[0], s:ER[1], s:ER[2], s:ER[3] + \ ] + + let g:airline#themes#onedark#palette.normal_modified.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + + let g:airline#themes#onedark#palette.insert.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + + let g:airline#themes#onedark#palette.insert_modified.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + + let g:airline#themes#onedark#palette.visual.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + + let g:airline#themes#onedark#palette.visual_modified.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + + let g:airline#themes#onedark#palette.replace.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + + let g:airline#themes#onedark#palette.replace_modified.airline_error = + \ g:airline#themes#onedark#palette.normal.airline_error + +endfunction + +call airline#themes#onedark#refresh() diff --git a/.config/nvim/autoload/lightline/colorscheme/onedark.vim b/.config/nvim/autoload/lightline/colorscheme/onedark.vim new file mode 100644 index 0000000..d04a501 --- /dev/null +++ b/.config/nvim/autoload/lightline/colorscheme/onedark.vim @@ -0,0 +1,58 @@ +" [onedark.vim](https://github.com/joshdick/onedark.vim/) + +" This is a [lightline.vim](https://github.com/itchyny/lightline.vim) colorscheme for use with +" the [onedark.vim](https://github.com/joshdick/onedark.vim) colorscheme. + +let s:colors = onedark#GetColors() + +if get(g:, 'onedark_termcolors', 256) == 16 + let s:term_red = s:colors.red.cterm16 + let s:term_green = s:colors.green.cterm16 + let s:term_yellow = s:colors.yellow.cterm16 + let s:term_blue = s:colors.blue.cterm16 + let s:term_purple = s:colors.purple.cterm16 + let s:term_white = s:colors.white.cterm16 + let s:term_cursor_grey = s:colors.cursor_grey.cterm16 + let s:term_visual_grey = s:colors.visual_grey.cterm16 +else + let s:term_red = s:colors.red.cterm + let s:term_green = s:colors.green.cterm + let s:term_yellow = s:colors.yellow.cterm + let s:term_blue = s:colors.blue.cterm + let s:term_purple = s:colors.purple.cterm + let s:term_white = s:colors.white.cterm + let s:term_cursor_grey = s:colors.cursor_grey.cterm + let s:term_visual_grey = s:colors.visual_grey.cterm +endif + +let s:red = [ s:colors.red.gui, s:term_red ] +let s:green = [ s:colors.green.gui, s:term_green ] +let s:yellow = [ s:colors.yellow.gui, s:term_yellow ] +let s:blue = [ s:colors.blue.gui, s:term_blue ] +let s:purple = [ s:colors.purple.gui, s:term_purple ] +let s:white = [ s:colors.white.gui, s:term_white ] +let s:cursor_grey = [ s:colors.cursor_grey.gui, s:term_cursor_grey ] +let s:visual_grey = [ s:colors.visual_grey.gui, s:term_visual_grey ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:cursor_grey, s:green ], [ s:white, s:visual_grey ] ] +let s:p.normal.right = [ [ s:cursor_grey, s:green ], [ s:white, s:visual_grey ] ] +let s:p.inactive.left = [ [ s:white, s:visual_grey ], [ s:white, s:visual_grey ] ] +let s:p.inactive.right = [ [ s:cursor_grey, s:white ], [ s:cursor_grey, s:white ] ] +let s:p.insert.left = [ [ s:cursor_grey, s:blue ], [ s:white, s:visual_grey ] ] +let s:p.insert.right = [ [ s:cursor_grey, s:blue ], [ s:white, s:visual_grey ] ] +let s:p.replace.left = [ [ s:cursor_grey, s:red ], [ s:white, s:visual_grey ] ] +let s:p.replace.right = [ [ s:cursor_grey, s:red ], [ s:white, s:visual_grey ] ] +let s:p.visual.left = [ [ s:cursor_grey, s:purple ], [ s:white, s:visual_grey ] ] +let s:p.visual.right = [ [ s:cursor_grey, s:purple ], [ s:white, s:visual_grey ] ] +let s:p.normal.middle = [ [ s:white, s:cursor_grey ] ] +let s:p.inactive.middle = [ [ s:white, s:visual_grey ] ] +let s:p.tabline.left = [ [ s:white, s:visual_grey ] ] +let s:p.tabline.tabsel = [ [ s:cursor_grey, s:white ] ] +let s:p.tabline.middle = [ [ s:white, s:cursor_grey ] ] +let s:p.tabline.right = [ [ s:white, s:visual_grey ] ] +let s:p.normal.error = [ [ s:cursor_grey, s:red ] ] +let s:p.normal.warning = [ [ s:cursor_grey, s:yellow ] ] + +let g:lightline#colorscheme#onedark#palette = lightline#colorscheme#flatten(s:p) + diff --git a/.config/nvim/autoload/onedark.vim b/.config/nvim/autoload/onedark.vim new file mode 100644 index 0000000..4630ff4 --- /dev/null +++ b/.config/nvim/autoload/onedark.vim @@ -0,0 +1,29 @@ +" [onedark.vim](https://github.com/joshdick/onedark.vim/) + +let s:overrides = get(g:, "onedark_color_overrides", {}) + +let s:colors = { + \ "red": get(s:overrides, "red", { "gui": "#E06C75", "cterm": "204", "cterm16": "1" }), + \ "dark_red": get(s:overrides, "dark_red", { "gui": "#BE5046", "cterm": "196", "cterm16": "9" }), + \ "green": get(s:overrides, "green", { "gui": "#98C379", "cterm": "114", "cterm16": "2" }), + \ "yellow": get(s:overrides, "yellow", { "gui": "#E5C07B", "cterm": "180", "cterm16": "3" }), + \ "dark_yellow": get(s:overrides, "dark_yellow", { "gui": "#D19A66", "cterm": "173", "cterm16": "11" }), + \ "blue": get(s:overrides, "blue", { "gui": "#61AFEF", "cterm": "39", "cterm16": "4" }), + \ "purple": get(s:overrides, "purple", { "gui": "#C678DD", "cterm": "170", "cterm16": "5" }), + \ "cyan": get(s:overrides, "cyan", { "gui": "#56B6C2", "cterm": "38", "cterm16": "6" }), + \ "white": get(s:overrides, "white", { "gui": "#ABB2BF", "cterm": "145", "cterm16": "15" }), + \ "black": get(s:overrides, "black", { "gui": "#282C34", "cterm": "235", "cterm16": "0" }), + \ "foreground": get(s:overrides, "foreground", { "gui": "#ABB2BF", "cterm": "145", "cterm16": "NONE" }), + \ "background": get(s:overrides, "background", { "gui": "#282C34", "cterm": "235", "cterm16": "NONE" }), + \ "comment_grey": get(s:overrides, "comment_grey", { "gui": "#5C6370", "cterm": "59", "cterm16": "7" }), + \ "gutter_fg_grey": get(s:overrides, "gutter_fg_grey", { "gui": "#4B5263", "cterm": "238", "cterm16": "8" }), + \ "cursor_grey": get(s:overrides, "cursor_grey", { "gui": "#2C323C", "cterm": "236", "cterm16": "0" }), + \ "visual_grey": get(s:overrides, "visual_grey", { "gui": "#3E4452", "cterm": "237", "cterm16": "8" }), + \ "menu_grey": get(s:overrides, "menu_grey", { "gui": "#3E4452", "cterm": "237", "cterm16": "7" }), + \ "special_grey": get(s:overrides, "special_grey", { "gui": "#3B4048", "cterm": "238", "cterm16": "7" }), + \ "vertsplit": get(s:overrides, "vertsplit", { "gui": "#3E4452", "cterm": "59", "cterm16": "7" }), + \} + +function! onedark#GetColors() + return s:colors +endfunction diff --git a/.config/nvim/autoload/plug.vim b/.config/nvim/autoload/plug.vim new file mode 100644 index 0000000..5c910ca --- /dev/null +++ b/.config/nvim/autoload/plug.vim @@ -0,0 +1,2863 @@ +" vim-plug: Vim plugin manager +" ============================ +" +" 1. Download plug.vim and put it in 'autoload' directory +" +" # Vim +" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ +" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" +" # Neovim +" sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ +" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' +" +" 2. Add a vim-plug section to your ~/.vimrc (or ~/.config/nvim/init.vim for Neovim) +" +" call plug#begin() +" +" " List your plugins here +" Plug 'tpope/vim-sensible' +" +" call plug#end() +" +" 3. Reload the file or restart Vim, then you can, +" +" :PlugInstall to install plugins +" :PlugUpdate to update plugins +" :PlugDiff to review the changes from the last update +" :PlugClean to remove plugins no longer in the list +" +" For more information, see https://github.com/junegunn/vim-plug +" +" +" Copyright (c) 2024 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_plug') + finish +endif +let g:loaded_plug = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let s:plug_src = 'https://github.com/junegunn/vim-plug.git' +let s:plug_tab = get(s:, 'plug_tab', -1) +let s:plug_buf = get(s:, 'plug_buf', -1) +let s:mac_gui = has('gui_macvim') && has('gui_running') +let s:is_win = has('win32') +let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') +if s:is_win && &shellslash + set noshellslash + let s:me = resolve(expand('<sfile>:p')) + set shellslash +else + let s:me = resolve(expand('<sfile>:p')) +endif +let s:base_spec = { 'branch': '', 'frozen': 0 } +let s:TYPE = { +\ 'string': type(''), +\ 'list': type([]), +\ 'dict': type({}), +\ 'funcref': type(function('call')) +\ } +let s:loaded = get(s:, 'loaded', {}) +let s:triggers = get(s:, 'triggers', {}) + +function! s:is_powershell(shell) + return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$' +endfunction + +function! s:isabsolute(dir) abort + return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') +endfunction + +function! s:git_dir(dir) abort + let gitdir = s:trim(a:dir) . '/.git' + if isdirectory(gitdir) + return gitdir + endif + if !filereadable(gitdir) + return '' + endif + let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*') + if len(gitdir) && !s:isabsolute(gitdir) + let gitdir = a:dir . '/' . gitdir + endif + return isdirectory(gitdir) ? gitdir : '' +endfunction + +function! s:git_origin_url(dir) abort + let gitdir = s:git_dir(a:dir) + let config = gitdir . '/config' + if empty(gitdir) || !filereadable(config) + return '' + endif + return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze') +endfunction + +function! s:git_revision(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + + let line = get(readfile(head), 0, '') + let ref = matchstr(line, '^ref: \zs.*') + if empty(ref) + return line + endif + + if filereadable(gitdir . '/' . ref) + return get(readfile(gitdir . '/' . ref), 0, '') + endif + + if filereadable(gitdir . '/packed-refs') + for line in readfile(gitdir . '/packed-refs') + if line =~# ' ' . ref + return matchstr(line, '^[0-9a-f]*') + endif + endfor + endif + + return '' +endfunction + +function! s:git_local_branch(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*') + return len(branch) ? branch : 'HEAD' +endfunction + +function! s:git_origin_branch(spec) + if len(a:spec.branch) + return a:spec.branch + endif + + " The file may not be present if this is a local repository + let gitdir = s:git_dir(a:spec.dir) + let origin_head = gitdir.'/refs/remotes/origin/HEAD' + if len(gitdir) && filereadable(origin_head) + return matchstr(get(readfile(origin_head), 0, ''), + \ '^ref: refs/remotes/origin/\zs.*') + endif + + " The command may not return the name of a branch in detached HEAD state + let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir)) + return v:shell_error ? '' : result[-1] +endfunction + +if s:is_win + function! s:plug_call(fn, ...) + let shellslash = &shellslash + try + set noshellslash + return call(a:fn, a:000) + finally + let &shellslash = shellslash + endtry + endfunction +else + function! s:plug_call(fn, ...) + return call(a:fn, a:000) + endfunction +endif + +function! s:plug_getcwd() + return s:plug_call('getcwd') +endfunction + +function! s:plug_fnamemodify(fname, mods) + return s:plug_call('fnamemodify', a:fname, a:mods) +endfunction + +function! s:plug_expand(fmt) + return s:plug_call('expand', a:fmt, 1) +endfunction + +function! s:plug_tempname() + return s:plug_call('tempname') +endfunction + +function! plug#begin(...) + if a:0 > 0 + let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif has('nvim') + let home = stdpath('data') . '/plugged' + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if s:plug_fnamemodify(home, ':t') ==# 'plugin' && s:plug_fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + let g:plugs_order = [] + let s:triggers = {} + + call s:define_commands() + return 1 +endfunction + +function! s:define_commands() + command! -nargs=+ -bar Plug call plug#(<args>) + if !executable('git') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') + endif + if has('win32') + \ && &shellslash + \ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell)) + return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') + endif + if !has('nvim') + \ && (has('win32') || has('win32unix')) + \ && !has('multi_byte') + return s:err('Vim needs +multi_byte feature on Windows to run shell commands. Enable +iconv for best results.') + endif + command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(<bang>0, [<f-args>]) + command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(<bang>0, [<f-args>]) + command! -nargs=0 -bar -bang PlugClean call s:clean(<bang>0) + command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif + command! -nargs=0 -bar PlugStatus call s:status() + command! -nargs=0 -bar PlugDiff call s:diff() + command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(<bang>0, <f-args>) +endfunction + +function! s:to_a(v) + return type(a:v) == s:TYPE.list ? a:v : [a:v] +endfunction + +function! s:to_s(v) + return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n" +endfunction + +function! s:glob(from, pattern) + return s:lines(globpath(a:from, a:pattern)) +endfunction + +function! s:source(from, ...) + let found = 0 + for pattern in a:000 + for vim in s:glob(a:from, pattern) + execute 'source' s:esc(vim) + let found = 1 + endfor + endfor + return found +endfunction + +function! s:assoc(dict, key, val) + let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) +endfunction + +function! s:ask(message, ...) + call inputsave() + echohl WarningMsg + let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + echohl None + call inputrestore() + echo "\r" + return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 +endfunction + +function! s:ask_no_interrupt(...) + try + return call('s:ask', a:000) + catch + return 0 + endtry +endfunction + +function! s:lazy(plug, opt) + return has_key(a:plug, a:opt) && + \ (empty(s:to_a(a:plug[a:opt])) || + \ !isdirectory(a:plug.dir) || + \ len(s:glob(s:rtp(a:plug), 'plugin')) || + \ len(s:glob(s:rtp(a:plug), 'after/plugin'))) +endfunction + +function! plug#end() + if !exists('g:plugs') + return s:err('plug#end() called without calling plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if get(g:, 'did_load_filetypes', 0) + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^<Plug>.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or `<Plug>`.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + if has('nvim-0.5.0') + call s:source(s:rtp(plug), 'ftdetect/**/*.lua', 'after/ftdetect/**/*.lua') + endif + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '<C-\><C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, %s, "%s")<CR>', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call <SID>lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') + if has('nvim-0.5.0') + call s:source(s:rtp(a:spec), 'plugin/**/*.lua', 'after/plugin/**/*.lua') + endif +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system(['git', '--version']))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) +endfunction + +if s:is_win + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction + + " Copied from fzf + function! s:wrap_cmds(cmds) + let cmds = [ + \ '@echo off', + \ 'setlocal enabledelayedexpansion'] + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + ['endlocal'] + if has('iconv') + if !exists('s:codepage') + let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0) + endif + return map(cmds, printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage)) + endif + return map(cmds, 'v:val."\r"') + endfunction + + function! s:batchfile(cmd) + let batchfile = s:plug_tempname().'.bat' + call writefile(s:wrap_cmds(a:cmd), batchfile) + let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) + if s:is_powershell(&shell) + let cmd = '& ' . cmd + endif + return [batchfile, cmd] + endfunction +else + function! s:path(path) + return s:trim(a:path) + endfunction + + function! s:dirpath(path) + return substitute(a:path, '[/\\]*$', '/', '') + endfunction + + function! s:is_local_plug(repo) + return a:repo[0] =~ '[/$~]' + endfunction +endif + +function! s:err(msg) + echohl ErrorMsg + echom '[vim-plug] '.a:msg + echohl None +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None +endfunction + +function! s:esc(path) + return escape(a:path, ' ') +endfunction + +function! s:escrtp(path) + return escape(a:path, ' ,') +endfunction + +function! s:remove_rtp() + for name in s:loaded_names() + let rtp = s:rtp(g:plugs[name]) + execute 'set rtp-='.s:escrtp(rtp) + let after = globpath(rtp, 'after') + if isdirectory(after) + execute 'set rtp-='.s:escrtp(after) + endif + endfor +endfunction + +function! s:reorg_rtp() + if !empty(s:first_rtp) + execute 'set rtp-='.s:first_rtp + execute 'set rtp-='.s:last_rtp + endif + + " &rtp is modified from outside + if exists('s:prtp') && s:prtp !=# &rtp + call s:remove_rtp() + unlet! s:middle + endif + + let s:middle = get(s:, 'middle', &rtp) + let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') + \ . ','.s:middle.',' + \ . join(map(afters, 'escape(v:val, ",")'), ',') + let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g') + let s:prtp = &rtp + + if !empty(s:first_rtp) + execute 'set rtp^='.s:first_rtp + execute 'set rtp+='.s:last_rtp + endif +endfunction + +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]) + for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + +function! plug#load(...) + if a:0 == 0 + return s:err('Argument missing: plugin name(s) required') + endif + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') + if !empty(unknowns) + let s = len(unknowns) > 1 ? 's' : '' + return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) + end + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 +endfunction + +function! s:remove_triggers(name) + if !has_key(s:triggers, a:name) + return + endif + for cmd in s:triggers[a:name].cmd + execute 'silent! delc' cmd + endfor + for map in s:triggers[a:name].map + execute 'silent! unmap' map + execute 'silent! iunmap' map + endfor + call remove(s:triggers, a:name) +endfunction + +function! s:lod(names, types, ...) + for name in a:names + call s:remove_triggers(name) + let s:loaded[name] = 1 + endfor + call s:reorg_rtp() + + for name in a:names + let rtp = s:rtp(g:plugs[name]) + for dir in a:types + call s:source(rtp, dir.'/**/*.vim') + if has('nvim-0.5.0') " see neovim#14686 + call s:source(rtp, dir.'/**/*.lua') + endif + endfor + if a:0 + if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2)) + execute 'runtime' a:1 + endif + call s:source(rtp, a:2) + endif + call s:doautocmd('User', name) + endfor +endfunction + +function! s:lod_ft(pat, names) + let syn = 'syntax/'.a:pat.'.vim' + call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) + execute 'autocmd! PlugLOD FileType' a:pat + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') +endfunction + +function! s:lod_cmd(cmd, bang, l1, l2, args, names) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) +endfunction + +function! s:lod_map(map, names, with_prefix, prefix) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + let extra = '' + while 1 + let c = getchar(0) + if c == 0 + break + endif + let extra .= nr2char(c) + endwhile + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\<esc>" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') + endif + call feedkeys(substitute(a:map, '^<Plug>', "\<Plug>", '') . extra) +endfunction + +function! plug#(repo, ...) + if a:0 > 1 + return s:err('Invalid number of arguments (1..2)') + endif + + try + let repo = s:trim(a:repo) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', s:plug_fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) + if !has_key(g:plugs, name) + call add(g:plugs_order, name) + endif + let g:plugs[name] = spec + let s:loaded[name] = get(s:loaded, name, 0) + catch + return s:err(repo . ' ' . v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)' + if type == s:TYPE.string + if empty(a:arg) + throw printf(opt_errfmt, 'tag', 'string') + endif + let opts.tag = a:arg + elseif type == s:TYPE.dict + for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] + if has_key(a:arg, opt) + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string') + endif + endfor + for opt in ['on', 'for'] + if has_key(a:arg, opt) + \ && type(a:arg[opt]) != s:TYPE.list + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string or list') + endif + endfor + if has_key(a:arg, 'do') + \ && type(a:arg.do) != s:TYPE.funcref + \ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do)) + throw printf(opt_errfmt, 'do', 'string or funcref') + endif + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(s:plug_expand(opts.dir)) + endif + else + throw 'Invalid argument type (expected: string or dictionary)' + endif + return opts +endfunction + +function! s:infer_properties(name, repo) + let repo = a:repo + if s:is_local_plug(repo) + return { 'dir': s:dirpath(s:plug_expand(repo)) } + else + if repo =~ ':' + let uri = repo + else + if repo !~ '/' + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) + endif + let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') + let uri = printf(fmt, repo) + endif + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } + endif +endfunction + +function! s:install(force, names) + call s:update_impl(0, a:force, a:names) +endfunction + +function! s:update(force, names) + call s:update_impl(1, a:force, a:names) +endfunction + +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + for spec in values(g:plugs) + let docd = join([s:rtp(spec), 'doc'], '/') + if isdirectory(docd) + silent! execute 'helptags' s:esc(docd) + endif + endfor + return 1 +endfunction + +function! s:syntax() + syntax clear + syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber + syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX,plugAbort + syn match plugNumber /[0-9]\+[0-9.]*/ contained + syn match plugBracket /[[\]]/ contained + syn match plugX /x/ contained + syn match plugAbort /\~/ contained + syn match plugDash /^-\{1}\ / + syn match plugPlus /^+/ + syn match plugStar /^*/ + syn match plugMessage /\(^- \)\@<=.*/ + syn match plugName /\(^- \)\@<=[^ ]*:/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ + syn match plugTag /(tag: [^)]\+)/ + syn match plugInstall /\(^+ \)\@<=[^:]*/ + syn match plugUpdate /\(^* \)\@<=[^:]*/ + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugEdge /^ \X\+$/ + syn match plugEdge /^ \X*/ contained nextgroup=plugSha + syn match plugSha /[0-9a-f]\{7,9}/ contained + syn match plugRelDate /([^)]*)$/ contained + syn match plugNotLoaded /(not loaded)$/ + syn match plugError /^x.*/ + syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ + syn match plugH2 /^.*:\n-\+$/ + syn match plugH2 /^-\{2,}/ + syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean + hi def link plug1 Title + hi def link plug2 Repeat + hi def link plugH2 Type + hi def link plugX Exception + hi def link plugAbort Ignore + hi def link plugBracket Structure + hi def link plugNumber Number + + hi def link plugDash Special + hi def link plugPlus Constant + hi def link plugStar Boolean + + hi def link plugMessage Function + hi def link plugName Label + hi def link plugInstall Function + hi def link plugUpdate Type + + hi def link plugError Error + hi def link plugDeleted Ignore + hi def link plugRelDate Comment + hi def link plugEdge PreProc + hi def link plugSha Identifier + hi def link plugTag Constant + + hi def link plugNotLoaded Comment +endfunction + +function! s:lpad(str, len) + return a:str . repeat(' ', a:len - len(a:str)) +endfunction + +function! s:lines(msg) + return split(a:msg, "[\r\n]") +endfunction + +function! s:lastline(msg) + return get(s:lines(a:msg), -1, '') +endfunction + +function! s:new_window() + execute get(g:, 'plug_window', '-tabnew') +endfunction + +function! s:plug_window_exists() + let buflist = tabpagebuflist(s:plug_tab) + return !empty(buflist) && index(buflist, s:plug_buf) >= 0 +endfunction + +function! s:switch_in() + if !s:plug_window_exists() + return 0 + endif + + if winbufnr(0) != s:plug_buf + let s:pos = [tabpagenr(), winnr(), winsaveview()] + execute 'normal!' s:plug_tab.'gt' + let winnr = bufwinnr(s:plug_buf) + execute winnr.'wincmd w' + call add(s:pos, winsaveview()) + else + let s:pos = [winsaveview()] + endif + + setlocal modifiable + return 1 +endfunction + +function! s:switch_out(...) + call winrestview(s:pos[-1]) + setlocal nomodifiable + if a:0 > 0 + execute a:1 + endif + + if len(s:pos) > 1 + execute 'normal!' s:pos[0].'gt' + execute s:pos[1] 'wincmd w' + call winrestview(s:pos[2]) + endif +endfunction + +function! s:finish_bindings() + nnoremap <silent> <buffer> R :call <SID>retry()<cr> + nnoremap <silent> <buffer> D :PlugDiff<cr> + nnoremap <silent> <buffer> S :PlugStatus<cr> + nnoremap <silent> <buffer> U :call <SID>status_update()<cr> + xnoremap <silent> <buffer> U :call <SID>status_update()<cr> + nnoremap <silent> <buffer> ]] :silent! call <SID>section('')<cr> + nnoremap <silent> <buffer> [[ :silent! call <SID>section('b')<cr> +endfunction + +function! s:prepare(...) + if empty(s:plug_getcwd()) + throw 'Invalid current working directory. Cannot proceed.' + endif + + for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] + if exists(evar) + throw evar.' detected. Cannot proceed.' + endif + endfor + + call s:job_abort(0) + if s:switch_in() + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() + endif + + nnoremap <silent> <buffer> q :call <SID>close_pane()<cr> + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + + for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap <buffer>' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell + if exists('+colorcolumn') + setlocal colorcolumn= + endif + setf vim-plug + if exists('g:syntax_on') + call s:syntax() + endif +endfunction + +function! s:close_pane() + if b:plug_preview == 1 + pc + let b:plug_preview = -1 + elseif exists('s:jobs') && !empty(s:jobs) + call s:job_abort(1) + else + bd + endif +endfunction + +function! s:assign_name() + " Assign buffer name + let prefix = '[Plugins]' + let name = prefix + let idx = 2 + while bufexists(name) + let name = printf('%s (%s)', prefix, idx) + let idx = idx + 1 + endwhile + silent! execute 'f' fnameescape(name) +endfunction + +function! s:chsh(swap) + let prev = [&shell, &shellcmdflag, &shellredir] + if !s:is_win + set shell=sh + endif + if a:swap + if s:is_powershell(&shell) + let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' + elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' + set shellredir=>%s\ 2>&1 + endif + endif + return prev +endfunction + +function! s:bang(cmd, ...) + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\<cr>\<cr>" + finally + unlet g:_plug_bang + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp(['git', 'log', '--pretty=format:%h', 'HEAD...HEAD@{1}'], a:dir)) +endfunction + +function! s:do(pull, force, todo) + if has('nvim') + " Reset &rtp to invalidate Neovim cache of loaded Lua modules + " See https://github.com/junegunn/vim-plug/pull/1157#issuecomment-1809226110 + let &rtp = &rtp + endif + for [name, spec] in items(a:todo) + if !isdirectory(spec.dir) + continue + endif + let installed = has_key(s:update.new, name) + let updated = installed ? 0 : + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) + if a:force || installed || updated + execute 'cd' s:esc(spec.dir) + call append(3, '- Post-update hook for '. name .' ... ') + let error = '' + let type = type(spec.do) + if type == s:TYPE.string + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif + else + let error = s:bang(spec.do) + endif + elseif type == s:TYPE.funcref + try + call s:load_plugin(spec) + let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') + call spec.do({ 'name': name, 'status': status, 'force': a:force }) + catch + let error = v:exception + endtry + else + let error = 'Invalid hook type' + endif + call s:switch_in() + call setline(4, empty(error) ? (getline(4) . 'OK') + \ : ('x' . getline(4)[1:] . error)) + if !empty(error) + call add(s:update.errors, name) + call s:regress_bar() + endif + cd - + endif + endfor +endfunction + +function! s:hash_match(a, b) + return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 +endfunction + +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:git_revision(a:spec.dir) + let error = 0 + if !empty(output) && !s:hash_match(sha, s:lines(output)[0]) + let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : '' + let output = s:system( + \ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir) + let error = v:shell_error + endif + return [output, error] +endfunction + +function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif + call append(3, '- Finishing ... ') | 4 + redraw + call plug#helptags() + call plug#end() + call setline(4, getline(4) . 'Done!') + redraw + let msgs = [] + if !empty(s:update.errors) + call add(msgs, "Press 'R' to retry.") + endif + if a:pull && len(s:update.new) < len(filter(getline(5, '$'), + \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'")) + call add(msgs, "Press 'D' to see the updated changes.") + endif + echo join(msgs, ' ') + call s:finish_bindings() +endfunction + +function! s:retry() + if empty(s:update.errors) + return + endif + echo + call s:update_impl(s:update.pull, s:update.force, + \ extend(copy(s:update.errors), [s:update.threads])) +endfunction + +function! s:is_managed(name) + return has_key(g:plugs[a:name], 'uri') +endfunction + +function! s:names(...) + return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) +endfunction + +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + +function! s:update_impl(pull, force, args) abort + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') + let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? + \ remove(args, -1) : get(g:, 'plug_threads', 16) + + let managed = filter(deepcopy(g:plugs), 's:is_managed(v:key)') + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : + \ filter(managed, 'index(args, v:key) >= 0') + + if empty(todo) + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) + endif + + if !s:is_win && s:git_version_requirement(2, 3) + let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : '' + let $GIT_TERMINAL_PROMPT = 0 + for plug in values(todo) + let plug.uri = substitute(plug.uri, + \ '^https://git::@github\.com', 'https://github.com', '') + endfor + endif + + if !isdirectory(g:plug_home) + try + call mkdir(g:plug_home, 'p') + catch + return s:err(printf('Invalid plug directory: %s. '. + \ 'Try to call plug#begin with a valid directory', g:plug_home)) + endtry + endif + + if has('nvim') && !exists('*jobwait') && threads > 1 + call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') + endif + + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby() + + let s:update = { + \ 'start': reltime(), + \ 'all': todo, + \ 'todo': copy(todo), + \ 'errors': [], + \ 'pull': a:pull, + \ 'force': a:force, + \ 'new': {}, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, + \ 'bar': '', + \ 'fin': 0 + \ } + + call s:prepare(1) + call append(0, ['', '']) + normal! 2G + silent! redraw + + " Set remote name, overriding a possible user git config's clone.defaultRemoteName + let s:clone_opt = ['--origin', 'origin'] + if get(g:, 'plug_shallow', 1) + call extend(s:clone_opt, ['--depth', '1']) + if s:git_version_requirement(1, 7, 10) + call add(s:clone_opt, '--no-single-branch') + endif + endif + + if has('win32unix') || has('wsl') + call extend(s:clone_opt, ['-c', 'core.eol=lf', '-c', 'core.autocrlf=input']) + endif + + let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : '' + + " Python version requirement (>= 2.7) + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 + redir => pyv + silent python import platform; print platform.python_version() + redir END + let python = s:version_requirement( + \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) + endif + + if (python || ruby) && s:update.threads > 1 + try + let imd = &imd + if s:mac_gui + set noimd + endif + if ruby + call s:update_ruby() + else + call s:update_python() + endif + catch + let lines = getline(4, '$') + let printed = {} + silent! 4,$d _ + for line in lines + let name = s:extract_name(line, '.', '') + if empty(name) || !has_key(printed, name) + call append('$', line) + if !empty(name) + let printed[name] = 1 + if line[0] == 'x' && index(s:update.errors, name) < 0 + call add(s:update.errors, name) + end + endif + endif + endfor + finally + let &imd = imd + call s:update_finish() + endtry + else + call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile + endif +endfunction + +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + +function! s:update_finish() + if exists('s:git_terminal_prompt') + let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt + endif + if s:switch_in() + call append(3, '- Updating ...') | 4 + for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) + let [pos, _] = s:logpos(name) + if !pos + continue + endif + let out = '' + let error = 0 + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let [out, error] = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.plug#shellescape(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir) + let error = v:shell_error + endif + if !error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir) + let error = v:shell_error + endif + let msg = s:format_message(v:shell_error ? 'x': '-', name, out) + if error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + try + call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry + call s:finish(s:update.pull) + call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') + call s:switch_out('normal! gg') + endif +endfunction + +function! s:mark_aborted(name, message) + let attrs = { 'running': 0, 'error': 1, 'abort': 1, 'lines': [a:message] } + let s:jobs[a:name] = extend(get(s:jobs, a:name, {}), attrs) +endfunction + +function! s:job_abort(cancel) + if (!s:nvim && !s:vim8) || !exists('s:jobs') + return + endif + + for [name, j] in items(s:jobs) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif + if j.new + call s:rm_rf(g:plugs[name].dir) + endif + if a:cancel + call s:mark_aborted(name, 'Aborted') + endif + endfor + + if a:cancel + for todo in values(s:update.todo) + let todo.abort = 1 + endfor + else + let s:jobs = {} + endif +endfunction + +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + +function! s:bullet_for(job, ...) + if a:job.running + return a:job.new ? '+' : '*' + endif + if get(a:job, 'abort', 0) + return '~' + endif + return a:job.error ? 'x' : get(a:000, 0, '-') +endfunction + +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if !self.running || self.tick % len(s:jobs) == 0 + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + if len(result) + call s:log(s:bullet_for(self), self.name, result) + endif + endif +endfunction + +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort(0) + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) dict abort + return (a:event == 'stdout' || a:event == 'stderr') ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + +function! s:spawn(name, spec, queue, opts) + let job = { 'name': a:name, 'spec': a:spec, 'running': 1, 'error': 0, 'lines': [''], + \ 'new': get(a:opts, 'new', 0), 'queue': copy(a:queue) } + let Item = remove(job.queue, 0) + let argv = type(Item) == s:TYPE.funcref ? call(Item, [a:spec]) : Item + let s:jobs[a:name] = job + + if s:nvim + if has_key(a:opts, 'dir') + let job.cwd = a:opts.dir + endif + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_stderr': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = s:plug_call('jobstart', argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let cmd = join(map(copy(argv), 'plug#shellescape(v:val, {"script": 0})')) + if has_key(a:opts, 'dir') + let cmd = s:with_cd(cmd, a:opts.dir, 0) + endif + let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd] + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'err_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'err_mode': 'raw', + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [argv, a:opts.dir] : [argv])) + let job.error = v:shell_error != 0 + let job.running = 0 + endif +endfunction + +function! s:reap(name) + let job = remove(s:jobs, a:name) + if job.error + call add(s:update.errors, a:name) + elseif get(job, 'new', 0) + let s:update.new[a:name] = 1 + endif + + let more = len(get(job, 'queue', [])) + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + if len(result) + call s:log(s:bullet_for(job), a:name, result) + endif + + if !job.error && more + let job.spec.queue = job.queue + let s:update.todo[a:name] = job.spec + else + let s:update.bar .= s:bullet_for(job, '=') + call s:bar() + endif +endfunction + +function! s:bar() + if s:switch_in() + let total = len(s:update.all) + call setline(1, (s:update.pull ? 'Updating' : 'Installing'). + \ ' plugins ('.len(s:update.bar).'/'.total.')') + call s:progress_bar(2, s:update.bar, total) + call s:switch_out() + endif +endfunction + +function! s:logpos(name) + let max = line('$') + for i in range(4, max > 4 ? max : 4) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, max > 5 ? max : 5) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 + endif + else + let b = 4 + endif + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) + call s:switch_out() + endif +endfunction + +function! s:update_vim() + let s:jobs = {} + + call s:bar() + call s:tick() +endfunction + +function! s:checkout_command(spec) + let a:spec.branch = s:git_origin_branch(a:spec) + return ['git', 'checkout', '-q', a:spec.branch, '--'] +endfunction + +function! s:merge_command(spec) + let a:spec.branch = s:git_origin_branch(a:spec) + return ['git', 'merge', '--ff-only', 'origin/'.a:spec.branch] +endfunction + +function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim || s:vim8) +while 1 " Without TCO, Vim stack is bound to explode + if empty(s:update.todo) + if empty(s:jobs) && !s:update.fin + call s:update_finish() + let s:update.fin = 1 + endif + return + endif + + let name = keys(s:update.todo)[0] + let spec = remove(s:update.todo, name) + if get(spec, 'abort', 0) + call s:mark_aborted(name, 'Skipped') + call s:reap(name) + continue + endif + + let queue = get(spec, 'queue', []) + let new = empty(globpath(spec.dir, '.git', 1)) + + if empty(queue) + call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') + redraw + endif + + let has_tag = has_key(spec, 'tag') + if len(queue) + call s:spawn(name, spec, queue, { 'dir': spec.dir }) + elseif !new + let [error, _] = s:git_validate(spec, 0) + if empty(error) + if pull + let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch'] + if has_tag && !empty(globpath(spec.dir, '.git/shallow')) + call extend(cmd, ['--depth', '99999999']) + endif + if !empty(prog) + call add(cmd, prog) + endif + let queue = [cmd, split('git remote set-head origin -a')] + if !has_tag && !has_key(spec, 'commit') + call extend(queue, [function('s:checkout_command'), function('s:merge_command')]) + endif + call s:spawn(name, spec, queue, { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + let cmd = ['git', 'clone'] + if !has_tag + call extend(cmd, s:clone_opt) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, spec, [extend(cmd, [spec.uri, s:trim(spec.dir)]), function('s:checkout_command'), function('s:merge_command')], { 'new': 1 }) + endif + + if !s:jobs[name].running + call s:reap(name) + endif + if len(s:jobs) >= s:update.threads + break + endif +endwhile +endfunction + +function! s:update_python() +let py_exe = has('python') ? 'python' : 'python3' +execute py_exe "<< EOF" +import datetime +import functools +import os +try: + import queue +except ImportError: + import Queue as queue +import random +import re +import shutil +import signal +import subprocess +import tempfile +import threading as thr +import time +import traceback +import vim + +G_NVIM = vim.eval("has('nvim')") == '1' +G_PULL = vim.eval('s:update.pull') == '1' +G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 +G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) +G_CLONE_OPT = ' '.join(vim.eval('s:clone_opt')) +G_PROGRESS = vim.eval('s:progress_opt(1)') +G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) +G_STOP = thr.Event() +G_IS_WIN = vim.eval('s:is_win') == '1' + +class PlugError(Exception): + def __init__(self, msg): + self.msg = msg +class CmdTimedOut(PlugError): + pass +class CmdFailed(PlugError): + pass +class InvalidURI(PlugError): + pass +class Action(object): + INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] + +class Buffer(object): + def __init__(self, lock, num_plugs, is_pull): + self.bar = '' + self.event = 'Updating' if is_pull else 'Installing' + self.lock = lock + self.maxy = int(vim.eval('winheight(".")')) + self.num_plugs = num_plugs + + def __where(self, name): + """ Find first line with name in current buffer. Return line num. """ + found, lnum = False, 0 + matcher = re.compile('^[-+x*] {0}:'.format(name)) + for line in vim.current.buffer: + if matcher.search(line) is not None: + found = True + break + lnum += 1 + + if not found: + lnum = -1 + return lnum + + def header(self): + curbuf = vim.current.buffer + curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs) + + num_spaces = self.num_plugs - len(self.bar) + curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') + + with self.lock: + vim.command('normal! 2G') + vim.command('redraw') + + def write(self, action, name, lines): + first, rest = lines[0], lines[1:] + msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] + msg.extend([' ' + line for line in rest]) + + try: + if action == Action.ERROR: + self.bar += 'x' + vim.command("call add(s:update.errors, '{0}')".format(name)) + elif action == Action.DONE: + self.bar += '=' + + curbuf = vim.current.buffer + lnum = self.__where(name) + if lnum != -1: # Found matching line num + del curbuf[lnum] + if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]): + lnum = 3 + else: + lnum = 3 + curbuf.append(msg, lnum) + + self.header() + except vim.error: + pass + +class Command(object): + CD = 'cd /d' if G_IS_WIN else 'cd' + + def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None): + self.cmd = cmd + if cmd_dir: + self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd) + self.timeout = timeout + self.callback = cb if cb else (lambda msg: None) + self.clean = clean if clean else (lambda: None) + self.proc = None + + @property + def alive(self): + """ Returns true only if command still running. """ + return self.proc and self.proc.poll() is None + + def execute(self, ntries=3): + """ Execute the command with ntries if CmdTimedOut. + Returns the output of the command if no Exception. + """ + attempt, finished, limit = 0, False, self.timeout + + while not finished: + try: + attempt += 1 + result = self.try_command() + finished = True + return result + except CmdTimedOut: + if attempt != ntries: + self.notify_retry() + self.timeout += limit + else: + raise + + def notify_retry(self): + """ Retry required for command, notify user. """ + for count in range(3, 0, -1): + if G_STOP.is_set(): + raise KeyboardInterrupt + msg = 'Timeout. Will retry in {0} second{1} ...'.format( + count, 's' if count != 1 else '') + self.callback([msg]) + time.sleep(1) + self.callback(['Retrying ...']) + + def try_command(self): + """ Execute a cmd & poll for callback. Returns list of output. + Raises CmdFailed -> return code for Popen isn't 0 + Raises CmdTimedOut -> command exceeded timeout without new output + """ + first_line = True + + try: + tfile = tempfile.NamedTemporaryFile(mode='w+b') + preexec_fn = not G_IS_WIN and os.setsid or None + self.proc = subprocess.Popen(self.cmd, stdout=tfile, + stderr=subprocess.STDOUT, + stdin=subprocess.PIPE, shell=True, + preexec_fn=preexec_fn) + thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,)) + thrd.start() + + thread_not_started = True + while thread_not_started: + try: + thrd.join(0.1) + thread_not_started = False + except RuntimeError: + pass + + while self.alive: + if G_STOP.is_set(): + raise KeyboardInterrupt + + if first_line or random.random() < G_LOG_PROB: + first_line = False + line = '' if G_IS_WIN else nonblock_read(tfile.name) + if line: + self.callback([line]) + + time_diff = time.time() - os.path.getmtime(tfile.name) + if time_diff > self.timeout: + raise CmdTimedOut(['Timeout!']) + + thrd.join(0.5) + + tfile.seek(0) + result = [line.decode('utf-8', 'replace').rstrip() for line in tfile] + + if self.proc.returncode != 0: + raise CmdFailed([''] + result) + + return result + except: + self.terminate() + raise + + def terminate(self): + """ Terminate process and cleanup. """ + if self.alive: + if G_IS_WIN: + os.kill(self.proc.pid, signal.SIGINT) + else: + os.killpg(self.proc.pid, signal.SIGTERM) + self.clean() + +class Plugin(object): + def __init__(self, name, args, buf_q, lock): + self.name = name + self.args = args + self.buf_q = buf_q + self.lock = lock + self.tag = args.get('tag', 0) + + def manage(self): + try: + if os.path.exists(self.args['dir']): + self.update() + else: + self.install() + with self.lock: + thread_vim_command("let s:update.new['{0}'] = 1".format(self.name)) + except PlugError as exc: + self.write(Action.ERROR, self.name, exc.msg) + except KeyboardInterrupt: + G_STOP.set() + self.write(Action.ERROR, self.name, ['Interrupted!']) + except: + # Any exception except those above print stack trace + msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip()) + self.write(Action.ERROR, self.name, msg.split('\n')) + raise + + def install(self): + target = self.args['dir'] + if target[-1] == '\\': + target = target[0:-1] + + def clean(target): + def _clean(): + try: + shutil.rmtree(target) + except OSError: + pass + return _clean + + self.write(Action.INSTALL, self.name, ['Installing ...']) + callback = functools.partial(self.write, Action.INSTALL, self.name) + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( + '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], + esc(target)) + com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + + def repo_uri(self): + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' + command = Command(cmd, self.args['dir'], G_TIMEOUT,) + result = command.execute(G_RETRIES) + return result[-1] + + def update(self): + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): + msg = ['', + 'Invalid URI: {0}'.format(actual_uri), + 'Expected {0}'.format(expect_uri), + 'PlugClean required.'] + raise InvalidURI(msg) + + if G_PULL: + self.write(Action.UPDATE, self.name, ['Updating ...']) + callback = functools.partial(self.write, Action.UPDATE, self.name) + fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) + com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + else: + self.write(Action.DONE, self.name, ['Already installed']) + + def write(self, action, name, msg): + self.buf_q.put((action, name, msg)) + +class PlugThread(thr.Thread): + def __init__(self, tname, args): + super(PlugThread, self).__init__() + self.tname = tname + self.args = args + + def run(self): + thr.current_thread().name = self.tname + buf_q, work_q, lock = self.args + + try: + while not G_STOP.is_set(): + name, args = work_q.get_nowait() + plug = Plugin(name, args, buf_q, lock) + plug.manage() + work_q.task_done() + except queue.Empty: + pass + +class RefreshThread(thr.Thread): + def __init__(self, lock): + super(RefreshThread, self).__init__() + self.lock = lock + self.running = True + + def run(self): + while self.running: + with self.lock: + thread_vim_command('noautocmd normal! a') + time.sleep(0.33) + + def stop(self): + self.running = False + +if G_NVIM: + def thread_vim_command(cmd): + vim.session.threadsafe_call(lambda: vim.command(cmd)) +else: + def thread_vim_command(cmd): + vim.command(cmd) + +def esc(name): + return '"' + name.replace('"', '\"') + '"' + +def nonblock_read(fname): + """ Read a file with nonblock flag. Return the last line. """ + fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) + buf = os.read(fread, 100000).decode('utf-8', 'replace') + os.close(fread) + + line = buf.rstrip('\r\n') + left = max(line.rfind('\r'), line.rfind('\n')) + if left != -1: + left += 1 + line = line[left:] + + return line + +def main(): + thr.current_thread().name = 'main' + nthreads = int(vim.eval('s:update.threads')) + plugs = vim.eval('s:update.todo') + mac_gui = vim.eval('s:mac_gui') == '1' + + lock = thr.Lock() + buf = Buffer(lock, len(plugs), G_PULL) + buf_q, work_q = queue.Queue(), queue.Queue() + for work in plugs.items(): + work_q.put(work) + + start_cnt = thr.active_count() + for num in range(nthreads): + tname = 'PlugT-{0:02}'.format(num) + thread = PlugThread(tname, (buf_q, work_q, lock)) + thread.start() + if mac_gui: + rthread = RefreshThread(lock) + rthread.start() + + while not buf_q.empty() or thr.active_count() != start_cnt: + try: + action, name, msg = buf_q.get(True, 0.25) + buf.write(action, name, ['OK'] if not msg else msg) + buf_q.task_done() + except queue.Empty: + pass + except KeyboardInterrupt: + G_STOP.set() + + if mac_gui: + rthread.stop() + rthread.join() + +main() +EOF +endfunction + +function! s:update_ruby() + ruby << EOF + module PlugStream + SEP = ["\r", "\n", nil] + def get_line + buffer = '' + loop do + char = readchar rescue return + if SEP.include? char.chr + buffer << $/ + break + else + buffer << char + end + end + buffer + end + end unless defined?(PlugStream) + + def esc arg + %["#{arg.gsub('"', '\"')}"] + end + + def killall pid + pids = [pid] + if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM + pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil } + else + unless `which pgrep 2> /dev/null`.empty? + children = pids + until children.empty? + children = children.map { |pid| + `pgrep -P #{pid}`.lines.map { |l| l.chomp } + }.flatten + pids += children + end + end + pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil } + end + end + + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + + require 'thread' + require 'fileutils' + require 'timeout' + running = true + iswin = VIM::evaluate('s:is_win').to_i == 1 + pull = VIM::evaluate('s:update.pull').to_i == 1 + base = VIM::evaluate('g:plug_home') + all = VIM::evaluate('s:update.todo') + limit = VIM::evaluate('get(g:, "plug_timeout", 60)') + tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 + nthr = VIM::evaluate('s:update.threads').to_i + maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ + cd = iswin ? 'cd /d' : 'cd' + tot = VIM::evaluate('len(s:update.todo)') || 0 + bar = '' + skip = 'Already installed' + mtx = Mutex.new + take1 = proc { mtx.synchronize { running && all.shift } } + logh = proc { + cnt = bar.length + $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})" + $curbuf[2] = '[' + bar.ljust(tot) + ']' + VIM::command('normal! 2G') + VIM::command('redraw') + } + where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } } + log = proc { |name, result, type| + mtx.synchronize do + ing = ![true, false].include?(type) + bar += type ? '=' : 'x' unless ing + b = case type + when :install then '+' when :update then '*' + when true, nil then '-' else + VIM::command("call add(s:update.errors, '#{name}')") + 'x' + end + result = + if type || type.nil? + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] + elsif result =~ /^Interrupted|^Timeout/ + ["#{b} #{name}: #{result}"] + else + ["#{b} #{name}"] + result.lines.map { |l| " " << l } + end + if lnum = where.call(name) + $curbuf.delete lnum + lnum = 4 if ing && lnum > maxy + end + result.each_with_index do |line, offset| + $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp) + end + logh.call + end + } + bt = proc { |cmd, name, type, cleanup| + tried = timeout = 0 + begin + tried += 1 + timeout += limit + fd = nil + data = '' + if iswin + Timeout::timeout(timeout) do + tmp = VIM::evaluate('tempname()') + system("(#{cmd}) > #{tmp}") + data = File.read(tmp).chomp + File.unlink tmp rescue nil + end + else + fd = IO.popen(cmd).extend(PlugStream) + first_line = true + log_prob = 1.0 / nthr + while line = Timeout::timeout(timeout) { fd.get_line } + data << line + log.call name, line.chomp, type if name && (first_line || rand < log_prob) + first_line = false + end + fd.close + end + [$? == 0, data.chomp] + rescue Timeout::Error, Interrupt => e + if fd && !fd.closed? + killall fd.pid + fd.close + end + cleanup.call if cleanup + if e.is_a?(Timeout::Error) && tried < tries + 3.downto(1) do |countdown| + s = countdown > 1 ? 's' : '' + log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type + sleep 1 + end + log.call name, 'Retrying ...', type + retry + end + [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"] + end + } + main = Thread.current + threads = [] + watcher = Thread.new { + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr + end + mtx.synchronize do + running = false + threads.each { |t| t.raise Interrupt } unless vim7 + end + threads.each { |t| t.join rescue nil } + main.kill + } + refresh = Thread.new { + while true + mtx.synchronize do + break unless running + VIM::command('noautocmd normal! a') + end + sleep 0.2 + end + } if VIM::evaluate('s:mac_gui') == 1 + + clone_opt = VIM::evaluate('s:clone_opt').join(' ') + progress = VIM::evaluate('s:progress_opt(1)') + nthr.times do + mtx.synchronize do + threads << Thread.new { + while pair = take1.call + name = pair.first + dir, uri, tag = pair.last.values_at *%w[dir uri tag] + exists = File.directory? dir + ok, result = + if exists + chdir = "#{cd} #{iswin ? dir : esc(dir)}" + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil + current_uri = data.lines.to_a.last + if !ret + if data =~ /^Interrupted|^Timeout/ + [false, data] + else + [false, [data.chomp, "PlugClean required."].join($/)] + end + elsif !compare_git_uri(current_uri, uri) + [false, ["Invalid URI: #{current_uri}", + "Expected: #{uri}", + "PlugClean required."].join($/)] + else + if pull + log.call name, 'Updating ...', :update + fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil + else + [true, skip] + end + end + else + d = esc dir.sub(%r{[\\/]+$}, '') + log.call name, 'Installing ...', :install + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { + FileUtils.rm_rf dir + } + end + mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok + log.call name, result, ok + end + } if running + end + end + threads.each { |t| t.join rescue nil } + logh.call + refresh.kill if refresh + watcher.kill +EOF +endfunction + +function! s:shellesc_cmd(arg, script) + let escaped = substitute('"'.a:arg.'"', '[&|<>()@^!"]', '^&', 'g') + return substitute(escaped, '%', (a:script ? '%' : '^') . '&', 'g') +endfunction + +function! s:shellesc_ps1(arg) + return "'".substitute(escape(a:arg, '\"'), "'", "''", 'g')."'" +endfunction + +function! s:shellesc_sh(arg) + return "'".substitute(a:arg, "'", "'\\\\''", 'g')."'" +endfunction + +" Escape the shell argument based on the shell. +" Vim and Neovim's shellescape() are insufficient. +" 1. shellslash determines whether to use single/double quotes. +" Double-quote escaping is fragile for cmd.exe. +" 2. It does not work for powershell. +" 3. It does not work for *sh shells if the command is executed +" via cmd.exe (ie. cmd.exe /c sh -c command command_args) +" 4. It does not support batchfile syntax. +" +" Accepts an optional dictionary with the following keys: +" - shell: same as Vim/Neovim 'shell' option. +" If unset, fallback to 'cmd.exe' on Windows or 'sh'. +" - script: If truthy and shell is cmd.exe, escape for batchfile syntax. +function! plug#shellescape(arg, ...) + if a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + endif + let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {} + let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh') + let script = get(opts, 'script', 1) + if shell =~# 'cmd\(\.exe\)\?$' + return s:shellesc_cmd(a:arg, script) + elseif s:is_powershell(shell) + return s:shellesc_ps1(a:arg) + endif + return s:shellesc_sh(a:arg) +endfunction + +function! s:glob_dir(path) + return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)') +endfunction + +function! s:progress_bar(line, bar, total) + call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']') +endfunction + +function! s:compare_git_uri(a, b) + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] +endfunction + +function! s:format_message(bullet, name, message) + if a:bullet != 'x' + return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))] + else + let lines = map(s:lines(a:message), '" ".v:val') + return extend([printf('x %s:', a:name)], lines) + endif +endfunction + +function! s:with_cd(cmd, dir, ...) + let script = a:0 > 0 ? a:1 : 1 + let pwsh = s:is_powershell(&shell) + let cd = s:is_win && !pwsh ? 'cd /d' : 'cd' + let sep = pwsh ? ';' : '&&' + return printf('%s %s %s %s', cd, plug#shellescape(a:dir, {'script': script, 'shell': &shell}), sep, a:cmd) +endfunction + +function! s:system(cmd, ...) + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + if type(a:cmd) == s:TYPE.list + " Neovim's system() supports list argument to bypass the shell + " but it cannot set the working directory for the command. + " Assume that the command does not rely on the shell. + if has('nvim') && a:0 == 0 + return system(a:cmd) + endif + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) + if s:is_powershell(&shell) + let cmd = '& ' . cmd + endif + else + let cmd = a:cmd + endif + if a:0 > 0 + let cmd = s:with_cd(cmd, a:1, type(a:cmd) != s:TYPE.list) + endif + if s:is_win && type(a:cmd) != s:TYPE.list + let [batchfile, cmd] = s:batchfile(cmd) + endif + return system(cmd) + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry +endfunction + +function! s:system_chomp(...) + let ret = call('s:system', a:000) + return v:shell_error ? '' : substitute(ret, '\n$', '', '') +endfunction + +function! s:git_validate(spec, check_branch) + let err = '' + if isdirectory(a:spec.dir) + let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)] + let remote = result[-1] + if empty(remote) + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + let err = join(['Invalid URI: '.remote, + \ 'Expected: '.a:spec.uri, + \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let sha = s:git_revision(a:spec.dir) + if empty(sha) + let err = join(add(result, 'PlugClean required.'), "\n") + elseif !s:hash_match(sha, a:spec.commit) + let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', + \ a:spec.commit[:6], sha[:6]), + \ 'PlugUpdate required.'], "\n") + endif + elseif a:check_branch + let current_branch = result[0] + " Check tag + let origin_branch = s:git_origin_branch(a:spec) + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && a:spec.tag !~ '\*' + let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', + \ (empty(tag) ? 'N/A' : tag), a:spec.tag) + endif + " Check branch + elseif origin_branch !=# current_branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ current_branch, origin_branch) + endif + if empty(err) + let ahead_behind = split(s:lastline(s:system([ + \ 'git', 'rev-list', '--count', '--left-right', + \ printf('HEAD...origin/%s', origin_branch) + \ ], a:spec.dir)), '\t') + if v:shell_error || len(ahead_behind) != 2 + let err = "Failed to compare with the origin. The default branch might have changed.\nPlugClean required." + else + let [ahead, behind] = ahead_behind + if ahead && behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind) + elseif ahead + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ origin_branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + return s:system(s:is_win + \ ? 'rmdir /S /Q '.plug#shellescape(a:dir) + \ : ['rm', '-rf', a:dir]) + endif +endfunction + +function! s:clean(force) + call s:prepare() + call append(0, 'Searching for invalid plugins in '.g:plug_home) + call append(1, '') + + " List of valid directories + let dirs = [] + let errs = {} + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if !s:is_managed(name) || get(spec, 'frozen', 0) + call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif + endif + let cnt += 1 + call s:progress_bar(2, repeat('=', cnt), total) + normal! 2G + redraw + endfor + + let allowed = {} + for dir in dirs + let allowed[s:dirpath(s:plug_fnamemodify(dir, ':h:h'))] = 1 + let allowed[dir] = 1 + for child in s:glob_dir(dir) + let allowed[child] = 1 + endfor + endfor + + let todo = [] + let found = sort(s:glob_dir(g:plug_home)) + while !empty(found) + let f = remove(found, 0) + if !has_key(allowed, f) && isdirectory(f) + call add(todo, f) + call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif + let found = filter(found, 'stridx(v:val, f) != 0') + end + endwhile + + 4 + redraw + if empty(todo) + call append(line('$'), 'Already clean.') + else + let s:clean_count = 0 + call append(3, ['Directories to delete:', '']) + redraw! + if a:force || s:ask_no_interrupt('Delete all directories?') + call s:delete([6, line('$')], 1) + else + call setline(4, 'Cancelled.') + nnoremap <silent> <buffer> d :set opfunc=<sid>delete_op<cr>g@ + nmap <silent> <buffer> dd d_ + xnoremap <silent> <buffer> d :<c-u>call <sid>delete_op(visualmode(), 1)<cr> + echo 'Delete the lines (d{motion}) to delete the corresponding directories' + endif + endif + 4 + setlocal nomodifiable +endfunction + +function! s:delete_op(type, ...) + call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0) +endfunction + +function! s:delete(range, force) + let [l1, l2] = a:range + let force = a:force + let err_count = 0 + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + let err = s:rm_rf(line[2:]) + setlocal modifiable + if empty(err) + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + else + delete _ + call append(l1 - 1, s:format_message('x', line[1:], err)) + let l2 += len(s:lines(err)) + let err_count += 1 + endif + let msg = printf('Removed %d directories.', s:clean_count) + if err_count > 0 + let msg .= printf(' Failed to remove %d directories.', err_count) + endif + call setline(4, msg) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = s:plug_tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(['git', 'clone', '--depth', '1', s:plug_src, tmp]) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) + if has_key(spec, 'uri') + if is_dir + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if is_dir + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if is_dir && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap <silent> <buffer> L :call <SID>status_load(line('.'))<cr> + xnoremap <silent> <buffer> L :call <SID>status_load(line('.'))<cr> + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$') + if empty(name) + return + endif + let title = 'HEAD@{1}..' + let command = 'git diff --no-color HEAD@{1}' + else + let title = sha + let command = 'git show --no-color --pretty=medium '.sha + let name = s:find_name(line('.')) + endif + + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if !s:is_preview_window_open() + execute get(g:, 'plug_pwindow', 'vertical rightbelow new') + execute 'e' title + else + execute 'pedit' title + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + setlocal nomodifiable + nnoremap <silent> <buffer> q :q<cr> + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let branch = s:git_origin_branch(v) + if len(branch) + let range = origin ? '..origin/'.branch : 'HEAD@{1}..' + let cmd = ['git', 'log', '--graph', '--color=never'] + if s:git_version_requirement(2, 10, 0) + call add(cmd, '--no-show-signature') + endif + call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range]) + if has_key(v, 'rtp') + call extend(cmd, ['--', v.rtp]) + endif + let diff = s:system_chomp(cmd, v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif + endif + let bar .= '=' + call s:progress_bar(2, bar, len(total)) + normal! 2G + redraw + endfor + if !cnts[origin] + call append(5, ['', 'N/A']) + endif + endfor + call setline(1, printf('%d plugin(s) updated.', cnts[0]) + \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : '')) + + if cnts[0] || cnts[1] + nnoremap <silent> <buffer> <plug>(plug-preview) :silent! call <SID>preview_commit()<cr> + if empty(maparg("\<cr>", 'n')) + nmap <buffer> <cr> <plug>(plug-preview) + endif + if empty(maparg('o', 'n')) + nmap <buffer> o <plug>(plug-preview) + endif + endif + if cnts[0] + nnoremap <silent> <buffer> X :call <SID>revert()<cr> + echo "Press 'X' on each block to revert the update" + endif + normal! gg + setlocal nomodifiable +endfunction + +function! s:revert() + if search('^Pending updates', 'bnW') + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || + \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' + return + endif + + call s:system('git reset --hard HEAD@{1} && git checkout '.plug#shellescape(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir) + if !empty(sha) + call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) + redraw + endif + endfor + + if a:0 > 0 + let fn = s:plug_expand(a:1) + if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) + return + endif + call writefile(getline(1, '$'), fn) + echo 'Saved as '.a:1 + silent execute 'e' s:esc(fn) + setf vim + endif +endfunction + +function! s:split_rtp() + return split(&rtp, '\\\@<!,') +endfunction + +let s:first_rtp = s:escrtp(get(s:split_rtp(), 0, '')) +let s:last_rtp = s:escrtp(get(s:split_rtp(), -1, '')) + +if exists('g:plugs') + let g:plugs_order = get(g:, 'plugs_order', keys(g:plugs)) + call s:upgrade_specs() + call s:define_commands() +endif + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/.config/nvim/autoload/scratch.vim b/.config/nvim/autoload/scratch.vim new file mode 100644 index 0000000..0a06cdc --- /dev/null +++ b/.config/nvim/autoload/scratch.vim @@ -0,0 +1,49 @@ +" Source: https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7 +function! scratch#open(cmd, mods) abort + for win in filter(range(1, winnr('$')), 'getwinvar(v:val, "scratch")') + execute win . 'windo close' + endfor + if a:cmd =~# '^!' + let cmd = a:cmd =~# ' %' ? substitute(a:cmd, ' %', ' ' . expand('%:p'), '') : a:cmd + let output = systemlist(matchstr(cmd, '^!\zs.*')) + elseif a:cmd =~# '^@' + let output = getreg(a:cmd[1], 1, 1) + else + let output = split(execute(a:cmd), "\n") + endif + execute a:mods . ' new' + let w:scratch = 1 + call setline(1, output) + nnoremap <buffer> q <C-W>q + setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nomodifiable + call s:highlight(a:cmd) + + augroup scratch + autocmd BufEnter <buffer> ++nested if winnr('$') < 2 | q | endif + augroup END +endfunction + +" Highlight scratch buffer to match native command output for certain commands +function! s:highlight(cmd) abort + let firstline = getline(1) + if firstline =~# '^--- Registers ---\|Type Name Content$' + call matchaddpos('Title', [1]) + call matchadd('SpecialKey', '\^\S\|<[^>]\{2}>') + elseif firstline =~# '^\%(mark\|change\| jump\) line col \%(file/\)\?text$' + call matchaddpos('Title', [1]) + elseif firstline =~# '^\w\+\s\+xxx \%(links\|cleared\|cterm\|gui\|term\)' + syntax match Keyword /\v%(c?term%([fb]g)?|gui%([fb]g)?)\=/ + syntax keyword Keyword links to + for linenr in range(1, line('$')) + let line = getline(linenr) + let syn = matchstr(line, '^\w\+') + let col = match(line, '\<xxx\>') + call matchaddpos(syn, [[linenr, col + 1, 3]]) + endfor + elseif search('\v^(E[0-9]+:|line\s+[0-9]+:)', 'cnW') + call matchadd('ErrorMsg', '^E[0-9]\+: .\+$') + call matchadd('LineNr', '^line\s\+[0-9]\+:$') + elseif a:cmd =~# '^dig' + call matchadd('SpecialKey', '[A-Za-z0-9[:graph:]]\{2}\s\+\zs\S\+\ze\s\+\d\+') + endif +endfunction diff --git a/.config/nvim/coc/coc-onload.vim b/.config/nvim/coc/coc-onload.vim new file mode 100644 index 0000000..c2835cc --- /dev/null +++ b/.config/nvim/coc/coc-onload.vim @@ -0,0 +1,144 @@ + +" May need for Vim (not Neovim) since coc.nvim calculates byte offset by count +" utf-8 byte sequence +set encoding=utf-8 +" Some servers have issues with backup files, see #649 +set nobackup +set nowritebackup + +" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable +" delays and poor user experience +set updatetime=1000 + +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate +" NOTE: There's always complete item selected by default, you may want to enable +" no select by `"suggest.noselect": true` in your configuration file +" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by +" other plugin before putting this into your config + inoremap <silent><expr> <TAB> + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\<Tab>" : + \ coc#refresh() + inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" + +" Make <CR> to accept selected completion item or notify coc.nvim to format +" <C-g>u breaks current undo, please make your own choice +inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() + \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" + +function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use <c-space> to trigger completion +if has('nvim') + inoremap <silent><expr> <c-space> coc#refresh() +else + inoremap <silent><expr> <c-@> coc#refresh() +endif + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +nmap <silent> [g <Plug>(coc-diagnostic-prev) +nmap <silent> ]g <Plug>(coc-diagnostic-next) + +" GoTo code navigation +nmap <silent> gd <Plug>(coc-definition) +nmap <silent> gy <Plug>(coc-type-definition) +nmap <silent> gi <Plug>(coc-implementation) +nmap <silent> gr <Plug>(coc-references) + +" Use K to show documentation in preview window +nnoremap <silent> <C-k> :call ShowDocumentation()<CR> + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap <leader>rn <Plug>(coc-rename) + +" Formatting selected code +xmap <leader>cf <Plug>(coc-format-selected) +nmap <leader>cf <Plug>(coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s) + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying code actions to the selected code block +" Example: `<leader>aap` for current paragraph +xmap <leader>aa <Plug>(coc-codeaction-selected) +nmap <leader>aa <Plug>(coc-codeaction-selected) + +" Remap keys for applying code actions at the cursor position +nmap <leader>ac <Plug>(coc-codeaction-cursor) +" Remap keys for apply code actions affect whole buffer +nmap <leader>as <Plug>(coc-codeaction-source) +" Apply the most preferred quickfix action to fix diagnostic on the current line +nmap <leader>aq <Plug>(coc-fix-current) + +" Remap keys for applying refactor code actions +nmap <silent> <leader>re <Plug>(coc-codeaction-refactor) +xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) +nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) + +" Run the Code Lens action on the current line +nmap <leader>cl <Plug>(coc-codelens-action) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server +xmap if <Plug>(coc-funcobj-i) +omap if <Plug>(coc-funcobj-i) +xmap af <Plug>(coc-funcobj-a) +omap af <Plug>(coc-funcobj-a) +xmap ic <Plug>(coc-classobj-i) +omap ic <Plug>(coc-classobj-i) +xmap ac <Plug>(coc-classobj-a) +omap ac <Plug>(coc-classobj-a) + +" Remap <C-f> and <C-b> to scroll float windows/popups +if has('nvim-0.4.0') || has('patch-8.2.0750') + nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" + nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" + inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" + inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" + vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" + vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" +endif + +" Use CTRL-S for selections ranges +" Requires 'textDocument/selectionRange' support of language server +nmap <silent> <C-s> <Plug>(coc-range-select) +xmap <silent> <C-s> <Plug>(coc-range-select) + +" Add `:Format` command to format current buffer +command! -nargs=0 Format :call CocActionAsync('format') + +" Add `:Fold` command to fold current buffer +command! -nargs=? Fold :call CocAction('fold', <f-args>) + +" Add `:OR` command for organize imports of the current buffer +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + diff --git a/.config/nvim/coc/coc-settings.json b/.config/nvim/coc/coc-settings.json new file mode 100644 index 0000000..f90bc38 --- /dev/null +++ b/.config/nvim/coc/coc-settings.json @@ -0,0 +1,6 @@ +{ + "suggest.autoTrigger": "always", + "diagnostic.enable": true, + "python.linting.pycodestyleEnabled": true, + "html.autoCreateQuotes": false +} diff --git a/.config/nvim/colors/onedark.vim b/.config/nvim/colors/onedark.vim new file mode 100644 index 0000000..6769d6c --- /dev/null +++ b/.config/nvim/colors/onedark.vim @@ -0,0 +1,713 @@ +" vim:fdm=marker +" Vim Color File +" Name: onedark.vim +" Maintainer: https://github.com/joshdick/onedark.vim/ +" License: The MIT License (MIT) +" Based On: https://github.com/MaxSt/FlatColor/ + +" Companion statusline plugin and terminal themes are included with onedark.vim: +" * https://github.com/joshdick/onedark.vim#lightlinevim-colorscheme +" * https://github.com/joshdick/onedark.vim#vim-airline-theme +" * https://github.com/joshdick/onedark.vim/tree/main/term + +" Color Reference {{{ + +" The following colors were measured inside Atom using its built-in inspector. + +" +---------------------------------------------+ +" | Color Name | RGB | Hex | +" |--------------+--------------------+---------| +" | Black | rgb(40, 44, 52) | #282c34 | +" |--------------+--------------------+---------| +" | White | rgb(171, 178, 191) | #abb2bf | +" |--------------+--------------------+---------| +" | Light Red | rgb(224, 108, 117) | #e06c75 | +" |--------------+--------------------+---------| +" | Dark Red | rgb(190, 80, 70) | #be5046 | +" |--------------+--------------------+---------| +" | Green | rgb(152, 195, 121) | #98c379 | +" |--------------+--------------------+---------| +" | Light Yellow | rgb(229, 192, 123) | #e5c07b | +" |--------------+--------------------+---------| +" | Dark Yellow | rgb(209, 154, 102) | #d19a66 | +" |--------------+--------------------+---------| +" | Blue | rgb(97, 175, 239) | #61afef | +" |--------------+--------------------+---------| +" | Magenta | rgb(198, 120, 221) | #c678dd | +" |--------------+--------------------+---------| +" | Cyan | rgb(86, 182, 194) | #56b6c2 | +" |--------------+--------------------+---------| +" | Gutter Grey | rgb(76, 82, 99) | #4b5263 | +" |--------------+--------------------+---------| +" | Comment Grey | rgb(92, 99, 112) | #5c6370 | +" +---------------------------------------------+ + +" }}} + +" Initialization {{{ + +highlight clear + +if exists("syntax_on") + syntax reset +endif + +set t_Co=256 + +let g:colors_name="onedark" + +" Set to "256" for 256-color terminals, or +" set to "16" to use your terminal emulator's native colors +" (a 16-color palette for this color scheme is available; see +" < https://github.com/joshdick/onedark.vim/blob/main/README.md > +" for more information.) +if !exists("g:onedark_termcolors") + let g:onedark_termcolors = 256 +endif + +" Not all terminals support italics properly. If yours does, opt-in. +if !exists("g:onedark_terminal_italics") + let g:onedark_terminal_italics = 0 +endif + +" This function is based on one from FlatColor: https://github.com/MaxSt/FlatColor/ +" Which in turn was based on one found in hemisu: https://github.com/noahfrederick/vim-hemisu/ +let s:group_colors = {} " Cache of default highlight group settings, for later reference via `onedark#extend_highlight` +function! s:h(group, style, ...) + if (a:0 > 0) " Will be true if we got here from onedark#extend_highlight + let s:highlight = s:group_colors[a:group] + for style_type in ["fg", "bg", "sp"] + if (has_key(a:style, style_type)) + let l:default_style = (has_key(s:highlight, style_type) ? copy(s:highlight[style_type]) : { "cterm16": "NONE", "cterm": "NONE", "gui": "NONE" }) + let s:highlight[style_type] = extend(l:default_style, a:style[style_type]) + endif + endfor + if (has_key(a:style, "gui")) + let s:highlight.gui = a:style.gui + endif + if (has_key(a:style, "cterm")) + let s:highlight.cterm = a:style.cterm + endif + else + let s:highlight = a:style + let s:group_colors[a:group] = s:highlight " Cache default highlight group settings + endif + + if g:onedark_terminal_italics == 0 + if has_key(s:highlight, "cterm") && s:highlight["cterm"] == "italic" + unlet s:highlight.cterm + endif + if has_key(s:highlight, "gui") && s:highlight["gui"] == "italic" + unlet s:highlight.gui + endif + endif + + if g:onedark_termcolors == 16 + let l:ctermfg = (has_key(s:highlight, "fg") ? s:highlight.fg.cterm16 : "NONE") + let l:ctermbg = (has_key(s:highlight, "bg") ? s:highlight.bg.cterm16 : "NONE") + else + let l:ctermfg = (has_key(s:highlight, "fg") ? s:highlight.fg.cterm : "NONE") + let l:ctermbg = (has_key(s:highlight, "bg") ? s:highlight.bg.cterm : "NONE") + endif + + execute "highlight" a:group + \ "guifg=" (has_key(s:highlight, "fg") ? s:highlight.fg.gui : "NONE") + \ "guibg=" (has_key(s:highlight, "bg") ? s:highlight.bg.gui : "NONE") + \ "guisp=" (has_key(s:highlight, "sp") ? s:highlight.sp.gui : "NONE") + \ "gui=" (has_key(s:highlight, "gui") ? s:highlight.gui : "NONE") + \ "ctermfg=" . l:ctermfg + \ "ctermbg=" . l:ctermbg + \ "cterm=" (has_key(s:highlight, "cterm") ? s:highlight.cterm : "NONE") +endfunction + +" public {{{ + +function! onedark#set_highlight(group, style) + call s:h(a:group, a:style) +endfunction + +function! onedark#extend_highlight(group, style) + call s:h(a:group, a:style, 1) +endfunction + +" }}} + +" }}} + +" Color Variables {{{ + +let s:colors = onedark#GetColors() + +let s:red = s:colors.red +let s:dark_red = s:colors.dark_red +let s:green = s:colors.green +let s:yellow = s:colors.yellow +let s:dark_yellow = s:colors.dark_yellow +let s:blue = s:colors.blue +let s:purple = s:colors.purple +let s:cyan = s:colors.cyan +let s:white = s:colors.white +let s:black = s:colors.black +let s:foreground = s:colors.foreground +let s:background = s:colors.background +let s:comment_grey = s:colors.comment_grey +let s:gutter_fg_grey = s:colors.gutter_fg_grey +let s:cursor_grey = s:colors.cursor_grey +let s:visual_grey = s:colors.visual_grey +let s:menu_grey = s:colors.menu_grey +let s:special_grey = s:colors.special_grey +let s:vertsplit = s:colors.vertsplit + +" }}} + +" Terminal Colors {{{ + +if has('nvim') + let g:terminal_color_0 = s:black.gui + let g:terminal_color_1 = s:red.gui + let g:terminal_color_2 = s:green.gui + let g:terminal_color_3 = s:yellow.gui + let g:terminal_color_4 = s:blue.gui + let g:terminal_color_5 = s:purple.gui + let g:terminal_color_6 = s:cyan.gui + let g:terminal_color_7 = s:comment_grey.gui + let g:terminal_color_8 = s:visual_grey.gui + let g:terminal_color_9 = s:red.gui + let g:terminal_color_10 = s:green.gui + let g:terminal_color_11 = s:yellow.gui + let g:terminal_color_12 = s:blue.gui + let g:terminal_color_13 = s:purple.gui + let g:terminal_color_14 = s:cyan.gui + let g:terminal_color_15 = s:white.gui +else + let g:terminal_ansi_colors = [ + \ s:black.gui, s:red.gui, s:green.gui, s:yellow.gui, + \ s:blue.gui, s:purple.gui, s:cyan.gui, s:comment_grey.gui, + \ s:visual_grey.gui, s:red.gui, s:green.gui, s:yellow.gui, + \ s:blue.gui, s:purple.gui, s:cyan.gui, s:white.gui + \] +endif + +" }}} + +" Syntax Groups (descriptions and ordering from `:h w18`) {{{ + +call s:h("Comment", { "fg": s:comment_grey, "gui": "italic", "cterm": "italic" }) " any comment +call s:h("Constant", { "fg": s:cyan }) " any constant +call s:h("String", { "fg": s:green }) " a string constant: "this is a string" +call s:h("Character", { "fg": s:green }) " a character constant: 'c', '\n' +call s:h("Number", { "fg": s:dark_yellow }) " a number constant: 234, 0xff +call s:h("Boolean", { "fg": s:dark_yellow }) " a boolean constant: TRUE, false +call s:h("Float", { "fg": s:dark_yellow }) " a floating point constant: 2.3e10 +call s:h("Identifier", { "fg": s:red }) " any variable name +call s:h("Function", { "fg": s:blue }) " function name (also: methods for classes) +call s:h("Statement", { "fg": s:purple }) " any statement +call s:h("Conditional", { "fg": s:purple }) " if, then, else, endif, switch, etc. +call s:h("Repeat", { "fg": s:purple }) " for, do, while, etc. +call s:h("Label", { "fg": s:purple }) " case, default, etc. +call s:h("Operator", { "fg": s:purple }) " sizeof", "+", "*", etc. +call s:h("Keyword", { "fg": s:purple }) " any other keyword +call s:h("Exception", { "fg": s:purple }) " try, catch, throw +call s:h("PreProc", { "fg": s:yellow }) " generic Preprocessor +call s:h("Include", { "fg": s:blue }) " preprocessor #include +call s:h("Define", { "fg": s:purple }) " preprocessor #define +call s:h("Macro", { "fg": s:purple }) " same as Define +call s:h("PreCondit", { "fg": s:yellow }) " preprocessor #if, #else, #endif, etc. +call s:h("Type", { "fg": s:yellow }) " int, long, char, etc. +call s:h("StorageClass", { "fg": s:yellow }) " static, register, volatile, etc. +call s:h("Structure", { "fg": s:yellow }) " struct, union, enum, etc. +call s:h("Typedef", { "fg": s:yellow }) " A typedef +call s:h("Special", { "fg": s:blue }) " any special symbol +call s:h("SpecialChar", { "fg": s:dark_yellow }) " special character in a constant +call s:h("Tag", {}) " you can use CTRL-] on this +call s:h("Delimiter", {}) " character that needs attention +call s:h("SpecialComment", { "fg": s:comment_grey }) " special things inside a comment +call s:h("Debug", {}) " debugging statements +call s:h("Underlined", { "gui": "underline", "cterm": "underline" }) " text that stands out, HTML links +call s:h("Ignore", {}) " left blank, hidden +call s:h("Error", { "fg": s:red }) " any erroneous construct +call s:h("Todo", { "fg": s:purple }) " anything that needs extra attention; mostly the keywords TODO FIXME and XXX + +" }}} + +" Highlighting Groups (descriptions and ordering from `:h highlight-groups`) {{{ +call s:h("ColorColumn", { "bg": s:cursor_grey }) " used for the columns set with 'colorcolumn' +call s:h("Conceal", {}) " placeholder characters substituted for concealed text (see 'conceallevel') +call s:h("Cursor", { "fg": s:black, "bg": s:blue }) " the character under the cursor +call s:h("CursorIM", {}) " like Cursor, but used when in IME mode +call s:h("CursorColumn", { "bg": s:cursor_grey }) " the screen column that the cursor is in when 'cursorcolumn' is set +if &diff + " Don't change the background color in diff mode + call s:h("CursorLine", { "gui": "underline" }) " the screen line that the cursor is in when 'cursorline' is set +else + call s:h("CursorLine", { "bg": s:cursor_grey }) " the screen line that the cursor is in when 'cursorline' is set +endif +call s:h("Directory", { "fg": s:blue }) " directory names (and other special names in listings) +call s:h("DiffAdd", { "bg": s:green, "fg": s:black }) " diff mode: Added line +call s:h("DiffChange", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) " diff mode: Changed line +call s:h("DiffDelete", { "bg": s:red, "fg": s:black }) " diff mode: Deleted line +call s:h("DiffText", { "bg": s:yellow, "fg": s:black }) " diff mode: Changed text within a changed line +if get(g:, 'onedark_hide_endofbuffer', 0) + " If enabled, will style end-of-buffer filler lines (~) to appear to be hidden. + call s:h("EndOfBuffer", { "fg": s:black }) " filler lines (~) after the last line in the buffer +endif +call s:h("ErrorMsg", { "fg": s:red }) " error messages on the command line +call s:h("VertSplit", { "fg": s:vertsplit }) " the column separating vertically split windows +call s:h("Folded", { "fg": s:comment_grey }) " line used for closed folds +call s:h("FoldColumn", {}) " 'foldcolumn' +call s:h("SignColumn", {}) " column where signs are displayed +call s:h("IncSearch", { "fg": s:yellow, "bg": s:comment_grey }) " 'incsearch' highlighting; also used for the text replaced with ":s///c" +call s:h("LineNr", { "fg": s:gutter_fg_grey }) " Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. +call s:h("CursorLineNr", {}) " Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. +call s:h("MatchParen", { "fg": s:blue, "gui": "underline", "cterm": "underline" }) " The character under the cursor or just before it, if it is a paired bracket, and its match. +call s:h("ModeMsg", {}) " 'showmode' message (e.g., "-- INSERT --") +call s:h("MoreMsg", {}) " more-prompt +call s:h("NonText", { "fg": s:special_grey }) " '~' and '@' at the end of the window, characters from 'showbreak' and other characters that do not really exist in the text (e.g., ">" displayed when a double-wide character doesn't fit at the end of the line). +call s:h("Normal", { "fg": s:foreground, "bg": s:background }) " normal text +call s:h("Pmenu", { "fg": s:white, "bg": s:menu_grey }) " Popup menu: normal item. +call s:h("PmenuSel", { "fg": s:cursor_grey, "bg": s:blue }) " Popup menu: selected item. +call s:h("PmenuSbar", { "bg": s:cursor_grey }) " Popup menu: scrollbar. +call s:h("PmenuThumb", { "bg": s:white }) " Popup menu: Thumb of the scrollbar. +call s:h("Question", { "fg": s:purple }) " hit-enter prompt and yes/no questions +call s:h("QuickFixLine", { "fg": s:black, "bg": s:yellow }) " Current quickfix item in the quickfix window. +call s:h("Search", { "fg": s:black, "bg": s:yellow }) " Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out. +call s:h("SpecialKey", { "fg": s:special_grey }) " Meta and special keys listed with ":map", also for text used to show unprintable characters in the text, 'listchars'. Generally: text that is displayed differently from what it really is. +call s:h("SpellBad", { "fg": s:red, "gui": "underline", "cterm": "underline" }) " Word that is not recognized by the spellchecker. This will be combined with the highlighting used otherwise. +call s:h("SpellCap", { "fg": s:dark_yellow }) " Word that should start with a capital. This will be combined with the highlighting used otherwise. +call s:h("SpellLocal", { "fg": s:dark_yellow }) " Word that is recognized by the spellchecker as one that is used in another region. This will be combined with the highlighting used otherwise. +call s:h("SpellRare", { "fg": s:dark_yellow }) " Word that is recognized by the spellchecker as one that is hardly ever used. spell This will be combined with the highlighting used otherwise. +call s:h("StatusLine", { "fg": s:white, "bg": s:cursor_grey }) " status line of current window +call s:h("StatusLineNC", { "fg": s:comment_grey }) " status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window. +call s:h("StatusLineTerm", { "fg": s:white, "bg": s:cursor_grey }) " status line of current :terminal window +call s:h("StatusLineTermNC", { "fg": s:comment_grey }) " status line of non-current :terminal window +call s:h("TabLine", { "fg": s:comment_grey }) " tab pages line, not active tab page label +call s:h("TabLineFill", {}) " tab pages line, where there are no labels +call s:h("TabLineSel", { "fg": s:white }) " tab pages line, active tab page label +call s:h("Terminal", { "fg": s:white, "bg": s:black }) " terminal window (see terminal-size-color) +call s:h("Title", { "fg": s:green }) " titles for output from ":set all", ":autocmd" etc. +call s:h("Visual", { "bg": s:visual_grey }) " Visual mode selection +call s:h("VisualNOS", { "bg": s:visual_grey }) " Visual mode selection when vim is "Not Owning the Selection". Only X11 Gui's gui-x11 and xterm-clipboard supports this. +call s:h("WarningMsg", { "fg": s:yellow }) " warning messages +call s:h("WildMenu", { "fg": s:black, "bg": s:blue }) " current match in 'wildmenu' completion + +" }}} + +" Termdebug highlighting for Vim 8.1+ {{{ + +" See `:h hl-debugPC` and `:h hl-debugBreakpoint`. +call s:h("debugPC", { "bg": s:special_grey }) " the current position +call s:h("debugBreakpoint", { "fg": s:black, "bg": s:red }) " a breakpoint + +" }}} + +" Language-Specific Highlighting {{{ + +" CSS +call s:h("cssAttrComma", { "fg": s:purple }) +call s:h("cssAttributeSelector", { "fg": s:green }) +call s:h("cssBraces", { "fg": s:white }) +call s:h("cssClassName", { "fg": s:dark_yellow }) +call s:h("cssClassNameDot", { "fg": s:dark_yellow }) +call s:h("cssDefinition", { "fg": s:purple }) +call s:h("cssFontAttr", { "fg": s:dark_yellow }) +call s:h("cssFontDescriptor", { "fg": s:purple }) +call s:h("cssFunctionName", { "fg": s:blue }) +call s:h("cssIdentifier", { "fg": s:blue }) +call s:h("cssImportant", { "fg": s:purple }) +call s:h("cssInclude", { "fg": s:white }) +call s:h("cssIncludeKeyword", { "fg": s:purple }) +call s:h("cssMediaType", { "fg": s:dark_yellow }) +call s:h("cssProp", { "fg": s:white }) +call s:h("cssPseudoClassId", { "fg": s:dark_yellow }) +call s:h("cssSelectorOp", { "fg": s:purple }) +call s:h("cssSelectorOp2", { "fg": s:purple }) +call s:h("cssTagName", { "fg": s:red }) + +" Fish Shell +call s:h("fishKeyword", { "fg": s:purple }) +call s:h("fishConditional", { "fg": s:purple }) + +" Go +call s:h("goDeclaration", { "fg": s:purple }) +call s:h("goBuiltins", { "fg": s:cyan }) +call s:h("goFunctionCall", { "fg": s:blue }) +call s:h("goVarDefs", { "fg": s:red }) +call s:h("goVarAssign", { "fg": s:red }) +call s:h("goVar", { "fg": s:purple }) +call s:h("goConst", { "fg": s:purple }) +call s:h("goType", { "fg": s:yellow }) +call s:h("goTypeName", { "fg": s:yellow }) +call s:h("goDeclType", { "fg": s:cyan }) +call s:h("goTypeDecl", { "fg": s:purple }) + +" HTML (keep consistent with Markdown, below) +call s:h("htmlArg", { "fg": s:dark_yellow }) +call s:h("htmlBold", { "fg": s:dark_yellow, "gui": "bold", "cterm": "bold" }) +call s:h("htmlBoldItalic", { "fg": s:green, "gui": "bold,italic", "cterm": "bold,italic" }) +call s:h("htmlEndTag", { "fg": s:white }) +call s:h("htmlH1", { "fg": s:red }) +call s:h("htmlH2", { "fg": s:red }) +call s:h("htmlH3", { "fg": s:red }) +call s:h("htmlH4", { "fg": s:red }) +call s:h("htmlH5", { "fg": s:red }) +call s:h("htmlH6", { "fg": s:red }) +call s:h("htmlItalic", { "fg": s:purple, "gui": "italic", "cterm": "italic" }) +call s:h("htmlLink", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) +call s:h("htmlSpecialChar", { "fg": s:dark_yellow }) +call s:h("htmlSpecialTagName", { "fg": s:red }) +call s:h("htmlTag", { "fg": s:white }) +call s:h("htmlTagN", { "fg": s:red }) +call s:h("htmlTagName", { "fg": s:red }) +call s:h("htmlTitle", { "fg": s:white }) + +" JavaScript +call s:h("javaScriptBraces", { "fg": s:white }) +call s:h("javaScriptFunction", { "fg": s:purple }) +call s:h("javaScriptIdentifier", { "fg": s:purple }) +call s:h("javaScriptNull", { "fg": s:dark_yellow }) +call s:h("javaScriptNumber", { "fg": s:dark_yellow }) +call s:h("javaScriptRequire", { "fg": s:cyan }) +call s:h("javaScriptReserved", { "fg": s:purple }) +" https://github.com/pangloss/vim-javascript +call s:h("jsArrowFunction", { "fg": s:purple }) +call s:h("jsClassKeyword", { "fg": s:purple }) +call s:h("jsClassMethodType", { "fg": s:purple }) +call s:h("jsDocParam", { "fg": s:blue }) +call s:h("jsDocTags", { "fg": s:purple }) +call s:h("jsExport", { "fg": s:purple }) +call s:h("jsExportDefault", { "fg": s:purple }) +call s:h("jsExtendsKeyword", { "fg": s:purple }) +call s:h("jsFrom", { "fg": s:purple }) +call s:h("jsFuncCall", { "fg": s:blue }) +call s:h("jsFunction", { "fg": s:purple }) +call s:h("jsGenerator", { "fg": s:yellow }) +call s:h("jsGlobalObjects", { "fg": s:yellow }) +call s:h("jsImport", { "fg": s:purple }) +call s:h("jsModuleAs", { "fg": s:purple }) +call s:h("jsModuleWords", { "fg": s:purple }) +call s:h("jsModules", { "fg": s:purple }) +call s:h("jsNull", { "fg": s:dark_yellow }) +call s:h("jsOperator", { "fg": s:purple }) +call s:h("jsStorageClass", { "fg": s:purple }) +call s:h("jsSuper", { "fg": s:red }) +call s:h("jsTemplateBraces", { "fg": s:dark_red }) +call s:h("jsTemplateVar", { "fg": s:green }) +call s:h("jsThis", { "fg": s:red }) +call s:h("jsUndefined", { "fg": s:dark_yellow }) +" https://github.com/othree/yajs.vim +call s:h("javascriptArrowFunc", { "fg": s:purple }) +call s:h("javascriptClassExtends", { "fg": s:purple }) +call s:h("javascriptClassKeyword", { "fg": s:purple }) +call s:h("javascriptDocNotation", { "fg": s:purple }) +call s:h("javascriptDocParamName", { "fg": s:blue }) +call s:h("javascriptDocTags", { "fg": s:purple }) +call s:h("javascriptEndColons", { "fg": s:white }) +call s:h("javascriptExport", { "fg": s:purple }) +call s:h("javascriptFuncArg", { "fg": s:white }) +call s:h("javascriptFuncKeyword", { "fg": s:purple }) +call s:h("javascriptIdentifier", { "fg": s:red }) +call s:h("javascriptImport", { "fg": s:purple }) +call s:h("javascriptMethodName", { "fg": s:white }) +call s:h("javascriptObjectLabel", { "fg": s:white }) +call s:h("javascriptOpSymbol", { "fg": s:cyan }) +call s:h("javascriptOpSymbols", { "fg": s:cyan }) +call s:h("javascriptPropertyName", { "fg": s:green }) +call s:h("javascriptTemplateSB", { "fg": s:dark_red }) +call s:h("javascriptVariable", { "fg": s:purple }) + +" JSON +call s:h("jsonCommentError", { "fg": s:white }) +call s:h("jsonKeyword", { "fg": s:red }) +call s:h("jsonBoolean", { "fg": s:dark_yellow }) +call s:h("jsonNumber", { "fg": s:dark_yellow }) +call s:h("jsonQuote", { "fg": s:white }) +call s:h("jsonMissingCommaError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonNoQuotesError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonNumError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonString", { "fg": s:green }) +call s:h("jsonStringSQError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonSemicolonError", { "fg": s:red, "gui": "reverse" }) + +" LESS +call s:h("lessVariable", { "fg": s:purple }) +call s:h("lessAmpersandChar", { "fg": s:white }) +call s:h("lessClass", { "fg": s:dark_yellow }) + +" Markdown (keep consistent with HTML, above) +call s:h("markdownBlockquote", { "fg": s:comment_grey }) +call s:h("markdownBold", { "fg": s:dark_yellow, "gui": "bold", "cterm": "bold" }) +call s:h("markdownBoldItalic", { "fg": s:green, "gui": "bold,italic", "cterm": "bold,italic" }) +call s:h("markdownCode", { "fg": s:green }) +call s:h("markdownCodeBlock", { "fg": s:green }) +call s:h("markdownCodeDelimiter", { "fg": s:green }) +call s:h("markdownH1", { "fg": s:red }) +call s:h("markdownH2", { "fg": s:red }) +call s:h("markdownH3", { "fg": s:red }) +call s:h("markdownH4", { "fg": s:red }) +call s:h("markdownH5", { "fg": s:red }) +call s:h("markdownH6", { "fg": s:red }) +call s:h("markdownHeadingDelimiter", { "fg": s:red }) +call s:h("markdownHeadingRule", { "fg": s:comment_grey }) +call s:h("markdownId", { "fg": s:purple }) +call s:h("markdownIdDeclaration", { "fg": s:blue }) +call s:h("markdownIdDelimiter", { "fg": s:purple }) +call s:h("markdownItalic", { "fg": s:purple, "gui": "italic", "cterm": "italic" }) +call s:h("markdownLinkDelimiter", { "fg": s:purple }) +call s:h("markdownLinkText", { "fg": s:blue }) +call s:h("markdownListMarker", { "fg": s:red }) +call s:h("markdownOrderedListMarker", { "fg": s:red }) +call s:h("markdownRule", { "fg": s:comment_grey }) +call s:h("markdownUrl", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) + +" Perl +call s:h("perlFiledescRead", { "fg": s:green }) +call s:h("perlFunction", { "fg": s:purple }) +call s:h("perlMatchStartEnd",{ "fg": s:blue }) +call s:h("perlMethod", { "fg": s:purple }) +call s:h("perlPOD", { "fg": s:comment_grey }) +call s:h("perlSharpBang", { "fg": s:comment_grey }) +call s:h("perlSpecialString",{ "fg": s:dark_yellow }) +call s:h("perlStatementFiledesc", { "fg": s:red }) +call s:h("perlStatementFlow",{ "fg": s:red }) +call s:h("perlStatementInclude", { "fg": s:purple }) +call s:h("perlStatementScalar",{ "fg": s:purple }) +call s:h("perlStatementStorage", { "fg": s:purple }) +call s:h("perlSubName",{ "fg": s:yellow }) +call s:h("perlVarPlain",{ "fg": s:blue }) + +" PHP +call s:h("phpVarSelector", { "fg": s:red }) +call s:h("phpOperator", { "fg": s:white }) +call s:h("phpParent", { "fg": s:white }) +call s:h("phpMemberSelector", { "fg": s:white }) +call s:h("phpType", { "fg": s:purple }) +call s:h("phpKeyword", { "fg": s:purple }) +call s:h("phpClass", { "fg": s:yellow }) +call s:h("phpUseClass", { "fg": s:white }) +call s:h("phpUseAlias", { "fg": s:white }) +call s:h("phpInclude", { "fg": s:purple }) +call s:h("phpClassExtends", { "fg": s:green }) +call s:h("phpDocTags", { "fg": s:white }) +call s:h("phpFunction", { "fg": s:blue }) +call s:h("phpFunctions", { "fg": s:cyan }) +call s:h("phpMethodsVar", { "fg": s:dark_yellow }) +call s:h("phpMagicConstants", { "fg": s:dark_yellow }) +call s:h("phpSuperglobals", { "fg": s:red }) +call s:h("phpConstants", { "fg": s:dark_yellow }) + +" Ruby +call s:h("rubyBlockParameter", { "fg": s:red}) +call s:h("rubyBlockParameterList", { "fg": s:red }) +call s:h("rubyClass", { "fg": s:purple}) +call s:h("rubyConstant", { "fg": s:yellow}) +call s:h("rubyControl", { "fg": s:purple }) +call s:h("rubyEscape", { "fg": s:red}) +call s:h("rubyFunction", { "fg": s:blue}) +call s:h("rubyGlobalVariable", { "fg": s:red}) +call s:h("rubyInclude", { "fg": s:blue}) +call s:h("rubyIncluderubyGlobalVariable", { "fg": s:red}) +call s:h("rubyInstanceVariable", { "fg": s:red}) +call s:h("rubyInterpolation", { "fg": s:cyan }) +call s:h("rubyInterpolationDelimiter", { "fg": s:red }) +call s:h("rubyInterpolationDelimiter", { "fg": s:red}) +call s:h("rubyRegexp", { "fg": s:cyan}) +call s:h("rubyRegexpDelimiter", { "fg": s:cyan}) +call s:h("rubyStringDelimiter", { "fg": s:green}) +call s:h("rubySymbol", { "fg": s:cyan}) + +" Sass +" https://github.com/tpope/vim-haml +call s:h("sassAmpersand", { "fg": s:red }) +call s:h("sassClass", { "fg": s:dark_yellow }) +call s:h("sassControl", { "fg": s:purple }) +call s:h("sassExtend", { "fg": s:purple }) +call s:h("sassFor", { "fg": s:white }) +call s:h("sassFunction", { "fg": s:cyan }) +call s:h("sassId", { "fg": s:blue }) +call s:h("sassInclude", { "fg": s:purple }) +call s:h("sassMedia", { "fg": s:purple }) +call s:h("sassMediaOperators", { "fg": s:white }) +call s:h("sassMixin", { "fg": s:purple }) +call s:h("sassMixinName", { "fg": s:blue }) +call s:h("sassMixing", { "fg": s:purple }) +call s:h("sassVariable", { "fg": s:purple }) +" https://github.com/cakebaker/scss-syntax.vim +call s:h("scssExtend", { "fg": s:purple }) +call s:h("scssImport", { "fg": s:purple }) +call s:h("scssInclude", { "fg": s:purple }) +call s:h("scssMixin", { "fg": s:purple }) +call s:h("scssSelectorName", { "fg": s:dark_yellow }) +call s:h("scssVariable", { "fg": s:purple }) + +" TeX +call s:h("texStatement", { "fg": s:purple }) +call s:h("texSubscripts", { "fg": s:dark_yellow }) +call s:h("texSuperscripts", { "fg": s:dark_yellow }) +call s:h("texTodo", { "fg": s:dark_red }) +call s:h("texBeginEnd", { "fg": s:purple }) +call s:h("texBeginEndName", { "fg": s:blue }) +call s:h("texMathMatcher", { "fg": s:blue }) +call s:h("texMathDelim", { "fg": s:blue }) +call s:h("texDelimiter", { "fg": s:dark_yellow }) +call s:h("texSpecialChar", { "fg": s:dark_yellow }) +call s:h("texCite", { "fg": s:blue }) +call s:h("texRefZone", { "fg": s:blue }) + +" TypeScript +call s:h("typescriptReserved", { "fg": s:purple }) +call s:h("typescriptEndColons", { "fg": s:white }) +call s:h("typescriptBraces", { "fg": s:white }) + +" XML +call s:h("xmlAttrib", { "fg": s:dark_yellow }) +call s:h("xmlEndTag", { "fg": s:red }) +call s:h("xmlTag", { "fg": s:red }) +call s:h("xmlTagName", { "fg": s:red }) + +" }}} + +" Plugin Highlighting {{{ + +" airblade/vim-gitgutter +call s:h("GitGutterAdd", { "fg": s:green }) +call s:h("GitGutterChange", { "fg": s:yellow }) +call s:h("GitGutterDelete", { "fg": s:red }) + +" dense-analysis/ale +call s:h("ALEError", { "fg": s:red, "gui": "underline", "cterm": "underline" }) +call s:h("ALEWarning", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) +call s:h("ALEInfo", { "gui": "underline", "cterm": "underline" }) +call s:h("ALEErrorSign", { "fg": s:red }) +call s:h("ALEWarningSign", { "fg": s:yellow }) +call s:h("ALEInfoSign", { }) + +" easymotion/vim-easymotion +call s:h("EasyMotionTarget", { "fg": s:red, "gui": "bold", "cterm": "bold" }) +call s:h("EasyMotionTarget2First", { "fg": s:yellow, "gui": "bold", "cterm": "bold" }) +call s:h("EasyMotionTarget2Second", { "fg": s:dark_yellow, "gui": "bold", "cterm": "bold" }) +call s:h("EasyMotionShade", { "fg": s:comment_grey }) + +" lewis6991/gitsigns.nvim +hi link GitSignsAdd GitGutterAdd +hi link GitSignsChange GitGutterChange +hi link GitSignsDelete GitGutterDelete + +" mhinz/vim-signify +hi link SignifySignAdd GitGutterAdd +hi link SignifySignChange GitGutterChange +hi link SignifySignDelete GitGutterDelete + +" neoclide/coc.nvim +call s:h("CocErrorSign", { "fg": s:red }) +call s:h("CocWarningSign", { "fg": s:yellow }) +call s:h("CocInfoSign", { "fg": s:blue }) +call s:h("CocHintSign", { "fg": s:cyan }) +call s:h("CocFadeOut", { "fg": s:comment_grey }) +" https://github.com/joshdick/onedark.vim/issues/313 +highlight! link CocMenuSel PmenuSel + +" neomake/neomake +call s:h("NeomakeErrorSign", { "fg": s:red }) +call s:h("NeomakeWarningSign", { "fg": s:yellow }) +call s:h("NeomakeInfoSign", { "fg": s:blue }) + +" plasticboy/vim-markdown (keep consistent with Markdown, above) +call s:h("mkdDelimiter", { "fg": s:purple }) +call s:h("mkdHeading", { "fg": s:red }) +call s:h("mkdLink", { "fg": s:blue }) +call s:h("mkdURL", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) + +" prabirshrestha/vim-lsp +call s:h("LspErrorText", { "fg": s:red }) +call s:h("LspWarningText", { "fg": s:yellow }) +call s:h("LspInformationText", { "fg":s:blue }) +call s:h("LspHintText", { "fg":s:cyan }) +call s:h("LspErrorHighlight", { "fg": s:red, "gui": "underline", "cterm": "underline" }) +call s:h("LspWarningHighlight", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) +call s:h("LspInformationHighlight", { "fg":s:blue, "gui": "underline", "cterm": "underline" }) +call s:h("LspHintHighlight", { "fg":s:cyan, "gui": "underline", "cterm": "underline" }) + +" tpope/vim-fugitive +call s:h("diffAdded", { "fg": s:green }) +call s:h("diffRemoved", { "fg": s:red }) + +" }}} + +" Git Highlighting {{{ + +call s:h("gitcommitComment", { "fg": s:comment_grey }) +call s:h("gitcommitUnmerged", { "fg": s:green }) +call s:h("gitcommitOnBranch", {}) +call s:h("gitcommitBranch", { "fg": s:purple }) +call s:h("gitcommitDiscardedType", { "fg": s:red }) +call s:h("gitcommitSelectedType", { "fg": s:green }) +call s:h("gitcommitHeader", {}) +call s:h("gitcommitUntrackedFile", { "fg": s:cyan }) +call s:h("gitcommitDiscardedFile", { "fg": s:red }) +call s:h("gitcommitSelectedFile", { "fg": s:green }) +call s:h("gitcommitUnmergedFile", { "fg": s:yellow }) +call s:h("gitcommitFile", {}) +call s:h("gitcommitSummary", { "fg": s:white }) +call s:h("gitcommitOverflow", { "fg": s:red }) +hi link gitcommitNoBranch gitcommitBranch +hi link gitcommitUntracked gitcommitComment +hi link gitcommitDiscarded gitcommitComment +hi link gitcommitSelected gitcommitComment +hi link gitcommitDiscardedArrow gitcommitDiscardedFile +hi link gitcommitSelectedArrow gitcommitSelectedFile +hi link gitcommitUnmergedArrow gitcommitUnmergedFile + +" }}} + +" Neovim-Specific Highlighting {{{ + +if has("nvim") + " Neovim terminal colors {{{ + let g:terminal_color_0 = s:black.gui + let g:terminal_color_1 = s:red.gui + let g:terminal_color_2 = s:green.gui + let g:terminal_color_3 = s:yellow.gui + let g:terminal_color_4 = s:blue.gui + let g:terminal_color_5 = s:purple.gui + let g:terminal_color_6 = s:cyan.gui + let g:terminal_color_7 = s:white.gui + let g:terminal_color_8 = s:visual_grey.gui + let g:terminal_color_9 = s:dark_red.gui + let g:terminal_color_10 = s:green.gui " No dark version + let g:terminal_color_11 = s:dark_yellow.gui + let g:terminal_color_12 = s:blue.gui " No dark version + let g:terminal_color_13 = s:purple.gui " No dark version + let g:terminal_color_14 = s:cyan.gui " No dark version + let g:terminal_color_15 = s:comment_grey.gui + let g:terminal_color_background = s:background.gui + let g:terminal_color_foreground = s:foreground.gui + " }}} + + " Neovim Diagnostics {{{ + call s:h("DiagnosticError", { "fg": s:red }) + call s:h("DiagnosticWarn", { "fg": s:yellow }) + call s:h("DiagnosticInfo", { "fg": s:blue }) + call s:h("DiagnosticHint", { "fg": s:cyan }) + call s:h("DiagnosticUnderlineError", { "fg": s:red, "gui": "underline", "cterm": "underline" }) + call s:h("DiagnosticUnderlineWarn", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) + call s:h("DiagnosticUnderlineInfo", { "fg": s:blue, "gui": "underline", "cterm": "underline" }) + call s:h("DiagnosticUnderlineHint", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) + " }}} + + " Neovim LSP (for versions < 0.5.1) {{{ + hi link LspDiagnosticsDefaultError DiagnosticError + hi link LspDiagnosticsDefaultWarning DiagnosticWarn + hi link LspDiagnosticsDefaultInformation DiagnosticInfo + hi link LspDiagnosticsDefaultHint DiagnosticHint + hi link LspDiagnosticsUnderlineError DiagnosticUnderlineError + hi link LspDiagnosticsUnderlineWarning DiagnosticUnderlineWarn + hi link LspDiagnosticsUnderlineInformation DiagnosticUnderlineInfo + hi link LspDiagnosticsUnderlineHint DiagnosticUnderlineHint + " }}} +endif + +" }}} + +" Must appear at the end of the file to work around this oddity: +" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ +set background=dark diff --git a/.config/nvim/dev.vim b/.config/nvim/dev.vim new file mode 100644 index 0000000..89b8eca --- /dev/null +++ b/.config/nvim/dev.vim @@ -0,0 +1,93 @@ +source ~/.config/nvim/init.vim + +packadd! onedark.vim + +" --> Zeal docs +let g:zv_disable_mapping = 1 +nmap <leader>z <Plug>Zeavim +vmap <leader>z <Plug>ZVVisSelection +nmap gz <Plug>ZVOperator +nmap <leader><leader>z <Plug>ZVKeyDocset + +" --> COC +autocmd! User coc.nvim source $HOME/.config/nvim/coc/coc-onload.vim +let g:coc_config_home = '$HOME/.config/nvim/coc' +let g:coc_data_home = '$HOME/.local/share/nvim/site/coc' +let g:coc_global_extensions = [ + \ 'coc-json', + \ 'coc-marketplace', + \ 'coc-css', + \ 'coc-tsserver', + \ 'coc-pyright', + \ 'coc-java', + \ 'coc-sh', + \ ] +nnoremap <silent><nowait> <leader>ca :<C-u>CocList diagnostics<cr> +nnoremap <silent><nowait> <leader>ce :<C-u>CocList extensions<cr> +nnoremap <silent><nowait> <leader>cc :<C-u>CocList commands<cr> +nnoremap <silent><nowait> <leader>co :<C-u>CocList outline<cr> +nnoremap <silent><nowait> <leader>cs :<C-u>CocList -I symbols<cr> +nnoremap <silent><nowait> <leader>cj :<C-u>CocNext<CR> +nnoremap <silent><nowait> <leader>ck :<C-u>CocPrev<CR> +nnoremap <silent><nowait> <leader>cp :<C-u>CocListResume<CR> +nnoremap <leader>cm :CocList marketplace<CR> + +" --> Vimspector +let g:vimspector_base_dir = expand('$HOME/.local/share/nvim/vimspector') +let g:vimspector_enable_mappings = 'HUMAN' +nnoremap <leader>dc <Plug>VimspectorContinue +nnoremap <leader>ds <Plug>VimspectorStop +nnoremap <leader>dr <Plug>VimspectorRestart +nnoremap <leader>dp <Plug>VimspectorPause +nnoremap <leader>dl <Plug>VimspectorBreakpoints +nnoremap <leader>dd <Plug>VimspectorToggleBreakpoint +nnoremap <leader>db <Plug>VimspectorToggleConditionalBreakpoint +nnoremap <leader>df <Plug>VimspectorAddFunctionBreakpoint +nnoremap <leader>dg <Plug>VimspectorGoToCurrentLine +nnoremap <leader>dx :call vimspector#ClearBreakpoints()<CR> +nnoremap <leader>dq :VimspectorReset<CR> +nnoremap <A-C> <Plug>VimspectorContinue +nnoremap <A-n> <Plug>VimspectorStepOver +nnoremap <A-i> <Plug>VimspectorStepInto +nnoremap <A-o> <Plug>VimspectorStepOut +nnoremap <A-b> <Plug>VimspectorToggleBreakpoint +nnoremap <A-c> <Plug>VimspectorRunToCursor + +" --> onedark theme +if exists('+termguicolors') + let g:airline_theme = 'onedark' + let g:onedark_terminal_italics = 1 + let g:onedark_color_overrides = { + \ "foreground": { "gui": "#BBC2CF", "cterm": "145", "cterm16": "NONE" }, + \ "background": { "gui": "#181C24", "cterm": "235", "cterm16": "NONE" }, + \ "comment_grey": { "gui": "#6C7380", "cterm": "59", "cterm16": "7" }, + \ "gutter_fg_grey": { "gui": "#6272A4", "cterm": "238", "cterm16": "8" }, + \ "special_grey": { "gui": "#5Ba078", "cterm": "238", "cterm16": "7" }, + \ } + " \ "background": { "gui": "#202426", "cterm": "235", "cterm16": "NONE" }, + " + " \ "red": { "gui": "#E06C75", "cterm": "204", "cterm16": "1" }, + " \ "dark_red": { "gui": "#BE5046", "cterm": "196", "cterm16": "9" }, + " \ "green": { "gui": "#98C379", "cterm": "114", "cterm16": "2" }, + " \ "yellow": { "gui": "#E5C07B", "cterm": "180", "cterm16": "3" }, + " \ "dark_yellow": { "gui": "#D19A66", "cterm": "173", "cterm16": "11" }, + " \ "blue": { "gui": "#61AFEF", "cterm": "39", "cterm16": "4" }, + " \ "purple": { "gui": "#C678DD", "cterm": "170", "cterm16": "5" }, + " \ "cyan": { "gui": "#56B6C2", "cterm": "38", "cterm16": "6" }, + " \ "black": { "gui": "#282C34", "cterm": "235", "cterm16": "0" }, + " \ "white": { "gui": "#ABB2BF", "cterm": "145", "cterm16": "15" }, + " \ "cursor_grey": { "gui": "#2C323C", "cterm": "236", "cterm16": "0" }, + " \ "visual_grey": { "gui": "#3E4452", "cterm": "237", "cterm16": "8" }, + " \ "menu_grey": { "gui": "#3E4452", "cterm": "237", "cterm16": "7" }, + " \ "vertsplit": { "gui": "#3E4452", "cterm": "59", "cterm16": "7" }, + + " autocmd ColorScheme * call onedark#extend_highlight("LineNr", { + " \ "fg": { "gui": "#6272A4", "cterm": "238", "cterm16": "8" }, + " \ }) + let &t_8f="\<Esc>[38;2;%lu;%lu;%lum" + let &t_8b="\<Esc>[48;2;%lu;%lu;%lum" + " set termguicolors noshowmode + colorscheme onedark + " autocmd VimEnter * AirlineTheme +endif + diff --git a/.config/nvim/init.bak.vim b/.config/nvim/init.bak.vim new file mode 100644 index 0000000..6057fe4 --- /dev/null +++ b/.config/nvim/init.bak.vim @@ -0,0 +1,225 @@ +let mapleader=" " + +if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"')) + echo "Downloading junegunn/vim-plug to manage plugins..." + silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/ + silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim + autocmd VimEnter * PlugInstall +endif + +call plug#begin(system('echo -n "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/plugged"')) +Plug 'tpope/vim-surround' +Plug 'tpope/vim-commentary' +Plug 'ptzz/lf.vim' +Plug 'voldikss/vim-floaterm' +Plug 'KabbAmine/zeavim.vim' ", {'on': ['Zeavim', 'ZeavimV', 'ZVVisSelection', 'ZVOperator', 'ZVKeyDocset']} +Plug 'neoclide/coc.nvim', {'on': ['CocList', 'CocConfig'], 'branch': 'release'} +Plug 'ap/vim-css-color' " color code highlighting +Plug 'xuhdev/vim-latex-live-preview', {'for': 'tex'} +Plug 'machakann/vim-verdin', {'for': 'vim'} +Plug 'puremourning/vimspector', {'for': 'python'} +" Plug 'powerman/vim-plugin-AnsiEsc' +" Plug 'junegunn/goyo.vim', {'on': 'Goyo'} +" Plug 'jreybert/vimagit' +" Plug 'lukesmithxyz/vimling' +" Plug 'vimwiki/vimwiki' +Plug 'vim-airline/vim-airline', {'on': 'AirlineTheme'} +Plug 'vim-airline/vim-airline-themes', {'on': 'AirlineTheme'} +Plug 'joshdick/onedark.vim' +call plug#end() + +let g:Verdin#autocomplete = 1 +let g:livepreview_previewer = 'zathura' + +set title showmatch nowrap +set mouse=a +set tabstop=2 shiftwidth=0 +set number relativenumber +set cursorline cursorcolumn +set cc=80 +set scrolloff=5 +set splitbelow splitright +set updatetime=500 + +syntax on +filetype plugin indent on +autocmd FileType text setlocal tabstop=8 shiftwidth=4 +autocmd FileType html setlocal tabstop=2 shiftwidth=2 +autocmd FileType sql setlocal commentstring=--\ %s +autocmd BufEnter bm-files,bm-dirs setlocal tabstop=8 shiftwidth=8 +autocmd BufWritePost bm-files,bm-dirs silent !shortcuts +autocmd BufWritePost config.h,config.def.h !cd "%:h"; sudo make clean install +autocmd BufWritePre * %s/\s\+$//e +au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + +autocmd BufWritePost */Documents/Notes/*.md silent !pandoc % -o "$HOME/Documents/Notes/.out/$(basename % .md).html" +autocmd BufWritePost .Xresources silent !xrdb "%" +autocmd BufRead,BufNewFile *.yt* set filetype=conf + +autocmd TermOpen * startinsert +command! -nargs=* T split | terminal <args> + +" --> Scratch buffer +if exists('g:loaded_scratch') + finish +endif +let g:loaded_scratch = 1 +command! -nargs=1 -complete=command D call scratch#open(<q-args>, <q-mods>) + +" --> Zeal docs +let g:zv_disable_mapping = 1 +nmap <leader>z <Plug>Zeavim +vmap <leader>z <Plug>ZVVisSelection +nmap gz <Plug>ZVOperator +nmap <leader><leader>z <Plug>ZVKeyDocset + +" --> COC +autocmd! User coc.nvim source $HOME/.config/nvim/coc/coc-onload.vim +let g:coc_config_home = '$HOME/.config/nvim/coc' +let g:coc_data_home = '$HOME/.local/share/nvim/site/coc' +let g:coc_global_extensions = [ + \ 'coc-json', + \ 'coc-marketplace', + \ 'coc-css', + \ 'coc-tsserver', + \ 'coc-pyright', + \ 'coc-java', + \ 'coc-sh', + \ ] +nnoremap <silent><nowait> <leader>ca :<C-u>CocList diagnostics<cr> +nnoremap <silent><nowait> <leader>ce :<C-u>CocList extensions<cr> +nnoremap <silent><nowait> <leader>cc :<C-u>CocList commands<cr> +nnoremap <silent><nowait> <leader>co :<C-u>CocList outline<cr> +nnoremap <silent><nowait> <leader>cs :<C-u>CocList -I symbols<cr> +nnoremap <silent><nowait> <leader>cj :<C-u>CocNext<CR> +nnoremap <silent><nowait> <leader>ck :<C-u>CocPrev<CR> +nnoremap <silent><nowait> <leader>cp :<C-u>CocListResume<CR> +nnoremap <leader>cm :CocList marketplace<CR> + +" --> Vimspector +let g:vimspector_base_dir = expand('$HOME/.local/share/nvim/vimspector') +let g:vimspector_enable_mappings = 'HUMAN' +nnoremap <leader>dc <Plug>VimspectorContinue +nnoremap <leader>ds <Plug>VimspectorStop +nnoremap <leader>dr <Plug>VimspectorRestart +nnoremap <leader>dp <Plug>VimspectorPause +nnoremap <leader>dl <Plug>VimspectorBreakpoints +nnoremap <leader>dd <Plug>VimspectorToggleBreakpoint +nnoremap <leader>db <Plug>VimspectorToggleConditionalBreakpoint +nnoremap <leader>df <Plug>VimspectorAddFunctionBreakpoint +nnoremap <leader>dg <Plug>VimspectorGoToCurrentLine +nnoremap <leader>dx :call vimspector#ClearBreakpoints()<CR> +nnoremap <leader>dq :VimspectorReset<CR> +nnoremap <A-C> <Plug>VimspectorContinue +nnoremap <A-n> <Plug>VimspectorStepOver +nnoremap <A-i> <Plug>VimspectorStepInto +nnoremap <A-o> <Plug>VimspectorStepOut +nnoremap <A-b> <Plug>VimspectorToggleBreakpoint +nnoremap <A-c> <Plug>VimspectorRunToCursor + +" --> Lf +" let g:lf_command_override = 'lf -command ...' +let g:NERDTreeHijackNetrw = 0 +" let g:lf_replace_netrw = 1 +let g:lf_width = 1.0 +let g:lf_height = 1.0 +let g:lf_map_keys = 0 +nnoremap <Esc>o :LfCurrentFile<CR> +nnoremap <Esc>l :LfWorkingDirectory<CR> +nnoremap <leader>o :LfCurrentFileNewTab<CR> +nnoremap <leader>l :LfWorkingDirectoryExistingOrNewTab<CR> + +" --> onedark theme +if exists('+termguicolors') && filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/onedark.vim"')) + let g:airline_theme = 'onedark' + let g:onedark_terminal_italics = 1 + let g:onedark_color_overrides = { + \ "foreground": { "gui": "#BBC2CF", "cterm": "145", "cterm16": "NONE" }, + \ "background": { "gui": "#181C24", "cterm": "235", "cterm16": "NONE" }, + \ "comment_grey": { "gui": "#6C7380", "cterm": "59", "cterm16": "7" }, + \ "gutter_fg_grey": { "gui": "#6272A4", "cterm": "238", "cterm16": "8" }, + \ "special_grey": { "gui": "#5Ba078", "cterm": "238", "cterm16": "7" }, + \ } + " \ "background": { "gui": "#202426", "cterm": "235", "cterm16": "NONE" }, + " + " \ "red": { "gui": "#E06C75", "cterm": "204", "cterm16": "1" }, + " \ "dark_red": { "gui": "#BE5046", "cterm": "196", "cterm16": "9" }, + " \ "green": { "gui": "#98C379", "cterm": "114", "cterm16": "2" }, + " \ "yellow": { "gui": "#E5C07B", "cterm": "180", "cterm16": "3" }, + " \ "dark_yellow": { "gui": "#D19A66", "cterm": "173", "cterm16": "11" }, + " \ "blue": { "gui": "#61AFEF", "cterm": "39", "cterm16": "4" }, + " \ "purple": { "gui": "#C678DD", "cterm": "170", "cterm16": "5" }, + " \ "cyan": { "gui": "#56B6C2", "cterm": "38", "cterm16": "6" }, + " \ "black": { "gui": "#282C34", "cterm": "235", "cterm16": "0" }, + " \ "white": { "gui": "#ABB2BF", "cterm": "145", "cterm16": "15" }, + " \ "cursor_grey": { "gui": "#2C323C", "cterm": "236", "cterm16": "0" }, + " \ "visual_grey": { "gui": "#3E4452", "cterm": "237", "cterm16": "8" }, + " \ "menu_grey": { "gui": "#3E4452", "cterm": "237", "cterm16": "7" }, + " \ "vertsplit": { "gui": "#3E4452", "cterm": "59", "cterm16": "7" }, + + " autocmd ColorScheme * call onedark#extend_highlight("LineNr", { + " \ "fg": { "gui": "#6272A4", "cterm": "238", "cterm16": "8" }, + " \ }) + let &t_8f="\<Esc>[38;2;%lu;%lu;%lum" + let &t_8b="\<Esc>[48;2;%lu;%lu;%lum" + set termguicolors noshowmode + colorscheme onedark + autocmd VimEnter * AirlineTheme +endif + +if !exists('g:lasttab') + let g:lasttab = 1 +endif +nmap g; :exe "tabn ".g:lasttab<CR> +au TabLeave * let g:lasttab = tabpagenr() +nnoremap g1 1gt +nnoremap g2 2gt +nnoremap g3 3gt +nnoremap g4 4gt +nnoremap g5 5gt +nnoremap g6 6gt +nnoremap g7 7gt +nnoremap g8 8gt +nnoremap g9 :tablast<CR> + +vnoremap <C-c> "*y :let @+=@*<CR> +vnoremap <C-A-c> "*d :let @+=@*<CR> +noremap <C-p> "+p +noremap <C-A-p> "+P + +nnoremap c "_c +inoremap jk <Esc> +" map ;n /<++><Enter>c4l +imap ;n <Esc>/<++><Enter>c4l + +autocmd FileType html,markdown inoremap ;s ><Esc>bi<<Esc>ea +autocmd FileType html,markdown inoremap ;c ><Esc>bi</<Esc>ea +autocmd FileType html,markdown inoremap ;i <Esc>b"tywi<<Esc>ea><++></><CR><++><Esc>k$P2F>i +autocmd FileType html,markdown inoremap ;l <Esc>b"tywi<<Esc>ea></><CR><++><Esc>k$PF<i +autocmd FileType html,markdown inoremap ;b <Esc>b"tywi<<Esc>ea><CR><++><CR></><CR><++><Esc>k$P2k$i +autocmd FileType html,markdown inoremap ;ap <p><CR><++><CR></p><CR><++><Esc>3k$i +autocmd FileType html,markdown inoremap ;aa <a href=""><CR><++><CR></a><CR><++><Esc>3k$hi + +nnoremap <leader>fl :w<CR>:!dev lint "%"<CR> +nnoremap <leader>fm :w<CR>:!dev format "%"<CR> +nnoremap <leader>fc :w<CR>:!dev compile "%"<CR> +nnoremap <leader>fr :w<CR>:!dev run "%"<CR> +nnoremap <leader>ft :w<CR>:!dev test "%"<CR> + +autocmd BufEnter * nmap <leader>t :w<CR>:se nornu<CR>:!dev test "%"<CR>:se rnu<CR> +autocmd BufEnter * nmap <leader>T :w<CR>:se nornu<CR>:T dev test "%"<CR> +autocmd BufEnter * imap <F5> <Esc>:w<CR>:se nornu<CR>:T dev test "%"<CR> + +nnoremap <leader>w :set wrap!<CR> +nnoremap <leader>p :!opout "%:p"<CR> +nnoremap <leader>F :Goyo<CR> +nnoremap <leader>O :T mimeopen --ask %<CR> +nnoremap <leader>ec :tabnew ~/.config/nvim/init.vim<CR> +nnoremap <leader><C-r> :source ~/.config/nvim/init.vim<CR> +nnoremap <leader>s :%s//gc<Left><Left><Left> +nnoremap <leader>r :w<CR>:!%:p<CR> +nnoremap <leader>R :w<CR>:T %:p<CR> + +nnoremap <leader>gc :T git add --all && git commit<CR> + +source ~/.config/nvim/shortcuts.vim diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100644 index 0000000..6583a94 --- /dev/null +++ b/.config/nvim/init.vim @@ -0,0 +1,178 @@ +let mapleader=" " +let config_dir = system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/"') + +" if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"')) +" echo "Downloading junegunn/vim-plug to manage plugins..." +" silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/ +" silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim +" autocmd VimEnter * PlugInstall +" endif + +if filereadable(config_dir . "autoload/plug.vim") + call plug#begin(system('echo -n "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/plugged"')) + Plug 'tpope/vim-commentary' + Plug 'tpope/vim-surround' + Plug 'ptzz/lf.vim' + Plug 'voldikss/vim-floaterm' + Plug 'xuhdev/vim-latex-live-preview', {'for': 'tex'} + Plug 'ap/vim-css-color' " color code highlighting + Plug 'neoclide/coc.nvim', {'on': ['CocList', 'CocConfig'], 'branch': 'release'} + " Plug 'KabbAmine/zeavim.vim' ", {'on': ['Zeavim', 'ZeavimV', 'ZVVisSelection', 'ZVOperator', 'ZVKeyDocset']} + " Plug 'machakann/vim-verdin', {'for': 'vim'} + " Plug 'puremourning/vimspector', {'for': 'python'} + " Plug 'powerman/vim-plugin-AnsiEsc' + " Plug 'junegunn/goyo.vim', {'on': 'Goyo'} + " Plug 'jreybert/vimagit' + " Plug 'lukesmithxyz/vimling' + " Plug 'vimwiki/vimwiki' + " Plug 'vim-airline/vim-airline', {'on': 'AirlineTheme'} + " Plug 'vim-airline/vim-airline-themes', {'on': 'AirlineTheme'} + " Plug 'joshdick/onedark.vim' + call plug#end() +endif + +let g:Verdin#autocomplete = 1 +let g:livepreview_previewer = 'zathura' +let g:tex_flavor = 'latex' + +set title showmatch nowrap mouse=a scrolloff=5 +set tabstop=2 shiftwidth=0 +set cursorline linebreak +set number relativenumber +set splitbelow splitright +set updatetime=1000 +set notermguicolors lazyredraw +set listchars=tab:\┆\ "│ + +syntax on +filetype plugin indent on +colorscheme vim +highlight NonText ctermfg=242 +highlight ColorColumn ctermbg=238 +highlight! link CursorColumn ColorColumn +autocmd FileType text,fstab setlocal tabstop=8 shiftwidth=8 +autocmd FileType html setlocal tabstop=2 shiftwidth=2 list nolinebreak +autocmd FileType sql setlocal commentstring=--\ %s +autocmd BufEnter bm-files,bm-dirs setlocal tabstop=8 shiftwidth=8 +autocmd BufWritePost bm-files,bm-dirs silent !shortcuts +autocmd VimLeave *.tex !dev clean "%" +" autocmd BufWritePost config.h,config.def.h !cd "%:h"; rm -f config.h; sudo make install +autocmd BufWritePre * %s/\s\+$//e +au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + +autocmd BufWritePost */Documents/Notes/*.md silent !pandoc % -o "$HOME/Documents/Notes/.out/$(basename % .md).html" +" autocmd BufWritePost */Documents/latex/resume/resume.tex !cd "%:h"; pdflatex resume.tex; cp -v resume.pdf ~/Dev/vikas.rocks/static/dox/ +autocmd BufWritePost *Xresources silent !xrdb "%" +autocmd BufRead,BufNewFile *.yt* set filetype=conf + +function SourceTemplate() + let b:template = glob("${XDG_CONFIG_HOME:-$HOME/.config}/nvim/templates/_default." . expand('%:e')) + if !empty(b:template) + execute('0r' . b:template) + endif +endfunction + +autocmd BufNewFile * call SourceTemplate() + +autocmd TermOpen * startinsert +command! -nargs=* T split | terminal <args> + +" --> Scratch buffer +if exists('g:loaded_scratch') + finish +endif +let g:loaded_scratch = 1 +command! -nargs=1 -complete=command D call scratch#open(<q-args>, <q-mods>) + +" --> Lf +" let g:lf_command_override = 'lf -command ...' +let g:NERDTreeHijackNetrw = 0 +" let g:lf_replace_netrw = 1 +let g:lf_width = 1.0 +let g:lf_height = 1.0 +let g:lf_map_keys = 0 +nnoremap <Esc>o :LfCurrentFile<CR> +nnoremap <Esc>l :LfWorkingDirectory<CR> +nnoremap <leader>o :LfCurrentFileNewTab<CR> +nnoremap <leader>l :LfWorkingDirectoryExistingOrNewTab<CR> + +if !exists('g:lasttab') + let g:lasttab = 1 +endif +nmap g; :exe "tabn ".g:lasttab<CR> +au TabLeave * let g:lasttab = tabpagenr() +nnoremap g1 1gt +nnoremap g2 2gt +nnoremap g3 3gt +nnoremap g4 4gt +nnoremap g5 5gt +nnoremap g6 6gt +nnoremap g7 7gt +nnoremap g8 8gt +nnoremap g9 :tablast<CR> + +vnoremap <C-c> "*y :let @+=@*<CR> +vnoremap <C-A-c> "*d :let @+=@*<CR> +noremap <C-p> "+p +noremap <C-A-p> "+P + +nnoremap c "_c +inoremap jk <Esc> +" map ;n /<++><Enter>c4l +inoremap ;n <Esc>/<++><Enter>c4l +nnoremap <leader>n /<++><Enter>c4l + +autocmd FileType html,markdown inoremap ;s ><Esc>bi<<Esc>ea +autocmd FileType html,markdown inoremap ;c ><Esc>bi</<Esc>ea +autocmd FileType html,markdown inoremap ;i <Esc>b"tywi<<Esc>ea></><Esc>PF<i +autocmd FileType html,markdown inoremap ;I <Esc>b"tywi<<Esc>ea><++></><Esc>P2F>i<Space> +autocmd FileType html,markdown inoremap ;b <Esc>b"tywi<<Esc>ea><CR></<Esc>"tpa><CR><++><Esc>kO +autocmd FileType html,markdown inoremap ;B <Esc>b"tywi<<Esc>ea><CR><++><CR></<Esc>"tpa><CR><++><Esc>3k$i<Space> +autocmd FileType html,markdown inoremap ;ap <p><CR><++><CR></p><CR><++><Esc>3k$i +autocmd FileType html,markdown inoremap ;aa <a href=""><CR><++><CR></a><CR><++><Esc>3k$hi + +autocmd FileType tex inoremap ;b <Esc>b"tywi\begin{<Esc>ea}<CR>\end{<Esc>"tpa}<Esc>kA +autocmd FileType tex inoremap ;s \section{}<Esc>i +autocmd FileType tex inoremap ;at \begin{tikzpicture}<CR>\end{tikzpicture}<Esc>O +autocmd FileType tex inoremap ;ap \usepackage{}<Esc>i +autocmd FileType tex inoremap ;aP \usepackage[]{}<Esc>F[a +autocmd FileType tex inoremap ;ab \textbf{}<Esc>i +autocmd FileType tex inoremap ;ai \textit{}<Esc>i +autocmd FileType tex inoremap ;au \underline{}<Esc>i + +autocmd FileType go inoremap ;ae err<Space>:=<Space><++><CR>if<Space>err<Space>!=<Space>nil<Space>{<CR>return<Space>err<CR>}<Esc>3kI + +nnoremap <leader>fl :w<CR>:!dev lint "%"<CR> +nnoremap <leader>fm :w<CR>:%!dev format "%"<CR> +nnoremap <leader>fc :w<CR>:!dev compile "%"<CR> +nnoremap <leader>fe :w<CR>:!dev run "%"<CR> +nnoremap <leader>ft :w<CR>:!dev test "%"<CR> +nnoremap <leader>fr :w<CR>:!dev clean "%"<CR> + +nnoremap <leader>Fl :w<CR>:T dev lint "%"<CR> +nnoremap <leader>Fm :w<CR>:T dev format "%"<CR> +nnoremap <leader>Fc :w<CR>:T dev compile "%"<CR> +nnoremap <leader>Fe :w<CR>:T dev run "%"<CR> +nnoremap <leader>Ft :w<CR>:T dev test "%"<CR> +nnoremap <leader>Fr :w<CR>:T dev clean "%"<CR> + +autocmd BufEnter * nmap <leader>t :w<CR>:se nornu<CR>:!dev test "%"<CR>:se rnu<CR> +autocmd BufEnter * nmap <leader>T :w<CR>:se nornu<CR>:T dev test "%"<CR> +autocmd BufEnter * imap <F5> <Esc>:w<CR>:se nornu<CR>:T dev test "%"<CR> + +autocmd BufEnter vartak-results-data.pl nmap <leader>t :w<CR>:se nornu<CR>:!vartak-results-data.pl ~/GDrive/vartak/results/university/1S002557.pdf<CR>:se rnu<CR> + +nnoremap <leader>w :set wrap!<CR> +nnoremap <leader>fo :!opout "%:p"<CR> +nnoremap <leader>ec :tabnew ~/.config/nvim/init.vim<CR> +nnoremap <leader><C-r> :source ~/.config/nvim/init.vim<CR> +nnoremap <leader>s :%s//gc<Left><Left><Left> +nnoremap <leader>r :w<CR>:!%:p<CR> +nnoremap <leader>R :w<CR>:T %:p<CR> + +nnoremap <leader>gc :T git add --all && git commit<CR> + +let shortcuts = config_dir . "shortcuts.vim" +if filereadable(shortcuts) + execute "source " . shortcuts +endif diff --git a/.config/nvim/onedark.vim b/.config/nvim/onedark.vim new file mode 100644 index 0000000..6769d6c --- /dev/null +++ b/.config/nvim/onedark.vim @@ -0,0 +1,713 @@ +" vim:fdm=marker +" Vim Color File +" Name: onedark.vim +" Maintainer: https://github.com/joshdick/onedark.vim/ +" License: The MIT License (MIT) +" Based On: https://github.com/MaxSt/FlatColor/ + +" Companion statusline plugin and terminal themes are included with onedark.vim: +" * https://github.com/joshdick/onedark.vim#lightlinevim-colorscheme +" * https://github.com/joshdick/onedark.vim#vim-airline-theme +" * https://github.com/joshdick/onedark.vim/tree/main/term + +" Color Reference {{{ + +" The following colors were measured inside Atom using its built-in inspector. + +" +---------------------------------------------+ +" | Color Name | RGB | Hex | +" |--------------+--------------------+---------| +" | Black | rgb(40, 44, 52) | #282c34 | +" |--------------+--------------------+---------| +" | White | rgb(171, 178, 191) | #abb2bf | +" |--------------+--------------------+---------| +" | Light Red | rgb(224, 108, 117) | #e06c75 | +" |--------------+--------------------+---------| +" | Dark Red | rgb(190, 80, 70) | #be5046 | +" |--------------+--------------------+---------| +" | Green | rgb(152, 195, 121) | #98c379 | +" |--------------+--------------------+---------| +" | Light Yellow | rgb(229, 192, 123) | #e5c07b | +" |--------------+--------------------+---------| +" | Dark Yellow | rgb(209, 154, 102) | #d19a66 | +" |--------------+--------------------+---------| +" | Blue | rgb(97, 175, 239) | #61afef | +" |--------------+--------------------+---------| +" | Magenta | rgb(198, 120, 221) | #c678dd | +" |--------------+--------------------+---------| +" | Cyan | rgb(86, 182, 194) | #56b6c2 | +" |--------------+--------------------+---------| +" | Gutter Grey | rgb(76, 82, 99) | #4b5263 | +" |--------------+--------------------+---------| +" | Comment Grey | rgb(92, 99, 112) | #5c6370 | +" +---------------------------------------------+ + +" }}} + +" Initialization {{{ + +highlight clear + +if exists("syntax_on") + syntax reset +endif + +set t_Co=256 + +let g:colors_name="onedark" + +" Set to "256" for 256-color terminals, or +" set to "16" to use your terminal emulator's native colors +" (a 16-color palette for this color scheme is available; see +" < https://github.com/joshdick/onedark.vim/blob/main/README.md > +" for more information.) +if !exists("g:onedark_termcolors") + let g:onedark_termcolors = 256 +endif + +" Not all terminals support italics properly. If yours does, opt-in. +if !exists("g:onedark_terminal_italics") + let g:onedark_terminal_italics = 0 +endif + +" This function is based on one from FlatColor: https://github.com/MaxSt/FlatColor/ +" Which in turn was based on one found in hemisu: https://github.com/noahfrederick/vim-hemisu/ +let s:group_colors = {} " Cache of default highlight group settings, for later reference via `onedark#extend_highlight` +function! s:h(group, style, ...) + if (a:0 > 0) " Will be true if we got here from onedark#extend_highlight + let s:highlight = s:group_colors[a:group] + for style_type in ["fg", "bg", "sp"] + if (has_key(a:style, style_type)) + let l:default_style = (has_key(s:highlight, style_type) ? copy(s:highlight[style_type]) : { "cterm16": "NONE", "cterm": "NONE", "gui": "NONE" }) + let s:highlight[style_type] = extend(l:default_style, a:style[style_type]) + endif + endfor + if (has_key(a:style, "gui")) + let s:highlight.gui = a:style.gui + endif + if (has_key(a:style, "cterm")) + let s:highlight.cterm = a:style.cterm + endif + else + let s:highlight = a:style + let s:group_colors[a:group] = s:highlight " Cache default highlight group settings + endif + + if g:onedark_terminal_italics == 0 + if has_key(s:highlight, "cterm") && s:highlight["cterm"] == "italic" + unlet s:highlight.cterm + endif + if has_key(s:highlight, "gui") && s:highlight["gui"] == "italic" + unlet s:highlight.gui + endif + endif + + if g:onedark_termcolors == 16 + let l:ctermfg = (has_key(s:highlight, "fg") ? s:highlight.fg.cterm16 : "NONE") + let l:ctermbg = (has_key(s:highlight, "bg") ? s:highlight.bg.cterm16 : "NONE") + else + let l:ctermfg = (has_key(s:highlight, "fg") ? s:highlight.fg.cterm : "NONE") + let l:ctermbg = (has_key(s:highlight, "bg") ? s:highlight.bg.cterm : "NONE") + endif + + execute "highlight" a:group + \ "guifg=" (has_key(s:highlight, "fg") ? s:highlight.fg.gui : "NONE") + \ "guibg=" (has_key(s:highlight, "bg") ? s:highlight.bg.gui : "NONE") + \ "guisp=" (has_key(s:highlight, "sp") ? s:highlight.sp.gui : "NONE") + \ "gui=" (has_key(s:highlight, "gui") ? s:highlight.gui : "NONE") + \ "ctermfg=" . l:ctermfg + \ "ctermbg=" . l:ctermbg + \ "cterm=" (has_key(s:highlight, "cterm") ? s:highlight.cterm : "NONE") +endfunction + +" public {{{ + +function! onedark#set_highlight(group, style) + call s:h(a:group, a:style) +endfunction + +function! onedark#extend_highlight(group, style) + call s:h(a:group, a:style, 1) +endfunction + +" }}} + +" }}} + +" Color Variables {{{ + +let s:colors = onedark#GetColors() + +let s:red = s:colors.red +let s:dark_red = s:colors.dark_red +let s:green = s:colors.green +let s:yellow = s:colors.yellow +let s:dark_yellow = s:colors.dark_yellow +let s:blue = s:colors.blue +let s:purple = s:colors.purple +let s:cyan = s:colors.cyan +let s:white = s:colors.white +let s:black = s:colors.black +let s:foreground = s:colors.foreground +let s:background = s:colors.background +let s:comment_grey = s:colors.comment_grey +let s:gutter_fg_grey = s:colors.gutter_fg_grey +let s:cursor_grey = s:colors.cursor_grey +let s:visual_grey = s:colors.visual_grey +let s:menu_grey = s:colors.menu_grey +let s:special_grey = s:colors.special_grey +let s:vertsplit = s:colors.vertsplit + +" }}} + +" Terminal Colors {{{ + +if has('nvim') + let g:terminal_color_0 = s:black.gui + let g:terminal_color_1 = s:red.gui + let g:terminal_color_2 = s:green.gui + let g:terminal_color_3 = s:yellow.gui + let g:terminal_color_4 = s:blue.gui + let g:terminal_color_5 = s:purple.gui + let g:terminal_color_6 = s:cyan.gui + let g:terminal_color_7 = s:comment_grey.gui + let g:terminal_color_8 = s:visual_grey.gui + let g:terminal_color_9 = s:red.gui + let g:terminal_color_10 = s:green.gui + let g:terminal_color_11 = s:yellow.gui + let g:terminal_color_12 = s:blue.gui + let g:terminal_color_13 = s:purple.gui + let g:terminal_color_14 = s:cyan.gui + let g:terminal_color_15 = s:white.gui +else + let g:terminal_ansi_colors = [ + \ s:black.gui, s:red.gui, s:green.gui, s:yellow.gui, + \ s:blue.gui, s:purple.gui, s:cyan.gui, s:comment_grey.gui, + \ s:visual_grey.gui, s:red.gui, s:green.gui, s:yellow.gui, + \ s:blue.gui, s:purple.gui, s:cyan.gui, s:white.gui + \] +endif + +" }}} + +" Syntax Groups (descriptions and ordering from `:h w18`) {{{ + +call s:h("Comment", { "fg": s:comment_grey, "gui": "italic", "cterm": "italic" }) " any comment +call s:h("Constant", { "fg": s:cyan }) " any constant +call s:h("String", { "fg": s:green }) " a string constant: "this is a string" +call s:h("Character", { "fg": s:green }) " a character constant: 'c', '\n' +call s:h("Number", { "fg": s:dark_yellow }) " a number constant: 234, 0xff +call s:h("Boolean", { "fg": s:dark_yellow }) " a boolean constant: TRUE, false +call s:h("Float", { "fg": s:dark_yellow }) " a floating point constant: 2.3e10 +call s:h("Identifier", { "fg": s:red }) " any variable name +call s:h("Function", { "fg": s:blue }) " function name (also: methods for classes) +call s:h("Statement", { "fg": s:purple }) " any statement +call s:h("Conditional", { "fg": s:purple }) " if, then, else, endif, switch, etc. +call s:h("Repeat", { "fg": s:purple }) " for, do, while, etc. +call s:h("Label", { "fg": s:purple }) " case, default, etc. +call s:h("Operator", { "fg": s:purple }) " sizeof", "+", "*", etc. +call s:h("Keyword", { "fg": s:purple }) " any other keyword +call s:h("Exception", { "fg": s:purple }) " try, catch, throw +call s:h("PreProc", { "fg": s:yellow }) " generic Preprocessor +call s:h("Include", { "fg": s:blue }) " preprocessor #include +call s:h("Define", { "fg": s:purple }) " preprocessor #define +call s:h("Macro", { "fg": s:purple }) " same as Define +call s:h("PreCondit", { "fg": s:yellow }) " preprocessor #if, #else, #endif, etc. +call s:h("Type", { "fg": s:yellow }) " int, long, char, etc. +call s:h("StorageClass", { "fg": s:yellow }) " static, register, volatile, etc. +call s:h("Structure", { "fg": s:yellow }) " struct, union, enum, etc. +call s:h("Typedef", { "fg": s:yellow }) " A typedef +call s:h("Special", { "fg": s:blue }) " any special symbol +call s:h("SpecialChar", { "fg": s:dark_yellow }) " special character in a constant +call s:h("Tag", {}) " you can use CTRL-] on this +call s:h("Delimiter", {}) " character that needs attention +call s:h("SpecialComment", { "fg": s:comment_grey }) " special things inside a comment +call s:h("Debug", {}) " debugging statements +call s:h("Underlined", { "gui": "underline", "cterm": "underline" }) " text that stands out, HTML links +call s:h("Ignore", {}) " left blank, hidden +call s:h("Error", { "fg": s:red }) " any erroneous construct +call s:h("Todo", { "fg": s:purple }) " anything that needs extra attention; mostly the keywords TODO FIXME and XXX + +" }}} + +" Highlighting Groups (descriptions and ordering from `:h highlight-groups`) {{{ +call s:h("ColorColumn", { "bg": s:cursor_grey }) " used for the columns set with 'colorcolumn' +call s:h("Conceal", {}) " placeholder characters substituted for concealed text (see 'conceallevel') +call s:h("Cursor", { "fg": s:black, "bg": s:blue }) " the character under the cursor +call s:h("CursorIM", {}) " like Cursor, but used when in IME mode +call s:h("CursorColumn", { "bg": s:cursor_grey }) " the screen column that the cursor is in when 'cursorcolumn' is set +if &diff + " Don't change the background color in diff mode + call s:h("CursorLine", { "gui": "underline" }) " the screen line that the cursor is in when 'cursorline' is set +else + call s:h("CursorLine", { "bg": s:cursor_grey }) " the screen line that the cursor is in when 'cursorline' is set +endif +call s:h("Directory", { "fg": s:blue }) " directory names (and other special names in listings) +call s:h("DiffAdd", { "bg": s:green, "fg": s:black }) " diff mode: Added line +call s:h("DiffChange", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) " diff mode: Changed line +call s:h("DiffDelete", { "bg": s:red, "fg": s:black }) " diff mode: Deleted line +call s:h("DiffText", { "bg": s:yellow, "fg": s:black }) " diff mode: Changed text within a changed line +if get(g:, 'onedark_hide_endofbuffer', 0) + " If enabled, will style end-of-buffer filler lines (~) to appear to be hidden. + call s:h("EndOfBuffer", { "fg": s:black }) " filler lines (~) after the last line in the buffer +endif +call s:h("ErrorMsg", { "fg": s:red }) " error messages on the command line +call s:h("VertSplit", { "fg": s:vertsplit }) " the column separating vertically split windows +call s:h("Folded", { "fg": s:comment_grey }) " line used for closed folds +call s:h("FoldColumn", {}) " 'foldcolumn' +call s:h("SignColumn", {}) " column where signs are displayed +call s:h("IncSearch", { "fg": s:yellow, "bg": s:comment_grey }) " 'incsearch' highlighting; also used for the text replaced with ":s///c" +call s:h("LineNr", { "fg": s:gutter_fg_grey }) " Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. +call s:h("CursorLineNr", {}) " Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. +call s:h("MatchParen", { "fg": s:blue, "gui": "underline", "cterm": "underline" }) " The character under the cursor or just before it, if it is a paired bracket, and its match. +call s:h("ModeMsg", {}) " 'showmode' message (e.g., "-- INSERT --") +call s:h("MoreMsg", {}) " more-prompt +call s:h("NonText", { "fg": s:special_grey }) " '~' and '@' at the end of the window, characters from 'showbreak' and other characters that do not really exist in the text (e.g., ">" displayed when a double-wide character doesn't fit at the end of the line). +call s:h("Normal", { "fg": s:foreground, "bg": s:background }) " normal text +call s:h("Pmenu", { "fg": s:white, "bg": s:menu_grey }) " Popup menu: normal item. +call s:h("PmenuSel", { "fg": s:cursor_grey, "bg": s:blue }) " Popup menu: selected item. +call s:h("PmenuSbar", { "bg": s:cursor_grey }) " Popup menu: scrollbar. +call s:h("PmenuThumb", { "bg": s:white }) " Popup menu: Thumb of the scrollbar. +call s:h("Question", { "fg": s:purple }) " hit-enter prompt and yes/no questions +call s:h("QuickFixLine", { "fg": s:black, "bg": s:yellow }) " Current quickfix item in the quickfix window. +call s:h("Search", { "fg": s:black, "bg": s:yellow }) " Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out. +call s:h("SpecialKey", { "fg": s:special_grey }) " Meta and special keys listed with ":map", also for text used to show unprintable characters in the text, 'listchars'. Generally: text that is displayed differently from what it really is. +call s:h("SpellBad", { "fg": s:red, "gui": "underline", "cterm": "underline" }) " Word that is not recognized by the spellchecker. This will be combined with the highlighting used otherwise. +call s:h("SpellCap", { "fg": s:dark_yellow }) " Word that should start with a capital. This will be combined with the highlighting used otherwise. +call s:h("SpellLocal", { "fg": s:dark_yellow }) " Word that is recognized by the spellchecker as one that is used in another region. This will be combined with the highlighting used otherwise. +call s:h("SpellRare", { "fg": s:dark_yellow }) " Word that is recognized by the spellchecker as one that is hardly ever used. spell This will be combined with the highlighting used otherwise. +call s:h("StatusLine", { "fg": s:white, "bg": s:cursor_grey }) " status line of current window +call s:h("StatusLineNC", { "fg": s:comment_grey }) " status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window. +call s:h("StatusLineTerm", { "fg": s:white, "bg": s:cursor_grey }) " status line of current :terminal window +call s:h("StatusLineTermNC", { "fg": s:comment_grey }) " status line of non-current :terminal window +call s:h("TabLine", { "fg": s:comment_grey }) " tab pages line, not active tab page label +call s:h("TabLineFill", {}) " tab pages line, where there are no labels +call s:h("TabLineSel", { "fg": s:white }) " tab pages line, active tab page label +call s:h("Terminal", { "fg": s:white, "bg": s:black }) " terminal window (see terminal-size-color) +call s:h("Title", { "fg": s:green }) " titles for output from ":set all", ":autocmd" etc. +call s:h("Visual", { "bg": s:visual_grey }) " Visual mode selection +call s:h("VisualNOS", { "bg": s:visual_grey }) " Visual mode selection when vim is "Not Owning the Selection". Only X11 Gui's gui-x11 and xterm-clipboard supports this. +call s:h("WarningMsg", { "fg": s:yellow }) " warning messages +call s:h("WildMenu", { "fg": s:black, "bg": s:blue }) " current match in 'wildmenu' completion + +" }}} + +" Termdebug highlighting for Vim 8.1+ {{{ + +" See `:h hl-debugPC` and `:h hl-debugBreakpoint`. +call s:h("debugPC", { "bg": s:special_grey }) " the current position +call s:h("debugBreakpoint", { "fg": s:black, "bg": s:red }) " a breakpoint + +" }}} + +" Language-Specific Highlighting {{{ + +" CSS +call s:h("cssAttrComma", { "fg": s:purple }) +call s:h("cssAttributeSelector", { "fg": s:green }) +call s:h("cssBraces", { "fg": s:white }) +call s:h("cssClassName", { "fg": s:dark_yellow }) +call s:h("cssClassNameDot", { "fg": s:dark_yellow }) +call s:h("cssDefinition", { "fg": s:purple }) +call s:h("cssFontAttr", { "fg": s:dark_yellow }) +call s:h("cssFontDescriptor", { "fg": s:purple }) +call s:h("cssFunctionName", { "fg": s:blue }) +call s:h("cssIdentifier", { "fg": s:blue }) +call s:h("cssImportant", { "fg": s:purple }) +call s:h("cssInclude", { "fg": s:white }) +call s:h("cssIncludeKeyword", { "fg": s:purple }) +call s:h("cssMediaType", { "fg": s:dark_yellow }) +call s:h("cssProp", { "fg": s:white }) +call s:h("cssPseudoClassId", { "fg": s:dark_yellow }) +call s:h("cssSelectorOp", { "fg": s:purple }) +call s:h("cssSelectorOp2", { "fg": s:purple }) +call s:h("cssTagName", { "fg": s:red }) + +" Fish Shell +call s:h("fishKeyword", { "fg": s:purple }) +call s:h("fishConditional", { "fg": s:purple }) + +" Go +call s:h("goDeclaration", { "fg": s:purple }) +call s:h("goBuiltins", { "fg": s:cyan }) +call s:h("goFunctionCall", { "fg": s:blue }) +call s:h("goVarDefs", { "fg": s:red }) +call s:h("goVarAssign", { "fg": s:red }) +call s:h("goVar", { "fg": s:purple }) +call s:h("goConst", { "fg": s:purple }) +call s:h("goType", { "fg": s:yellow }) +call s:h("goTypeName", { "fg": s:yellow }) +call s:h("goDeclType", { "fg": s:cyan }) +call s:h("goTypeDecl", { "fg": s:purple }) + +" HTML (keep consistent with Markdown, below) +call s:h("htmlArg", { "fg": s:dark_yellow }) +call s:h("htmlBold", { "fg": s:dark_yellow, "gui": "bold", "cterm": "bold" }) +call s:h("htmlBoldItalic", { "fg": s:green, "gui": "bold,italic", "cterm": "bold,italic" }) +call s:h("htmlEndTag", { "fg": s:white }) +call s:h("htmlH1", { "fg": s:red }) +call s:h("htmlH2", { "fg": s:red }) +call s:h("htmlH3", { "fg": s:red }) +call s:h("htmlH4", { "fg": s:red }) +call s:h("htmlH5", { "fg": s:red }) +call s:h("htmlH6", { "fg": s:red }) +call s:h("htmlItalic", { "fg": s:purple, "gui": "italic", "cterm": "italic" }) +call s:h("htmlLink", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) +call s:h("htmlSpecialChar", { "fg": s:dark_yellow }) +call s:h("htmlSpecialTagName", { "fg": s:red }) +call s:h("htmlTag", { "fg": s:white }) +call s:h("htmlTagN", { "fg": s:red }) +call s:h("htmlTagName", { "fg": s:red }) +call s:h("htmlTitle", { "fg": s:white }) + +" JavaScript +call s:h("javaScriptBraces", { "fg": s:white }) +call s:h("javaScriptFunction", { "fg": s:purple }) +call s:h("javaScriptIdentifier", { "fg": s:purple }) +call s:h("javaScriptNull", { "fg": s:dark_yellow }) +call s:h("javaScriptNumber", { "fg": s:dark_yellow }) +call s:h("javaScriptRequire", { "fg": s:cyan }) +call s:h("javaScriptReserved", { "fg": s:purple }) +" https://github.com/pangloss/vim-javascript +call s:h("jsArrowFunction", { "fg": s:purple }) +call s:h("jsClassKeyword", { "fg": s:purple }) +call s:h("jsClassMethodType", { "fg": s:purple }) +call s:h("jsDocParam", { "fg": s:blue }) +call s:h("jsDocTags", { "fg": s:purple }) +call s:h("jsExport", { "fg": s:purple }) +call s:h("jsExportDefault", { "fg": s:purple }) +call s:h("jsExtendsKeyword", { "fg": s:purple }) +call s:h("jsFrom", { "fg": s:purple }) +call s:h("jsFuncCall", { "fg": s:blue }) +call s:h("jsFunction", { "fg": s:purple }) +call s:h("jsGenerator", { "fg": s:yellow }) +call s:h("jsGlobalObjects", { "fg": s:yellow }) +call s:h("jsImport", { "fg": s:purple }) +call s:h("jsModuleAs", { "fg": s:purple }) +call s:h("jsModuleWords", { "fg": s:purple }) +call s:h("jsModules", { "fg": s:purple }) +call s:h("jsNull", { "fg": s:dark_yellow }) +call s:h("jsOperator", { "fg": s:purple }) +call s:h("jsStorageClass", { "fg": s:purple }) +call s:h("jsSuper", { "fg": s:red }) +call s:h("jsTemplateBraces", { "fg": s:dark_red }) +call s:h("jsTemplateVar", { "fg": s:green }) +call s:h("jsThis", { "fg": s:red }) +call s:h("jsUndefined", { "fg": s:dark_yellow }) +" https://github.com/othree/yajs.vim +call s:h("javascriptArrowFunc", { "fg": s:purple }) +call s:h("javascriptClassExtends", { "fg": s:purple }) +call s:h("javascriptClassKeyword", { "fg": s:purple }) +call s:h("javascriptDocNotation", { "fg": s:purple }) +call s:h("javascriptDocParamName", { "fg": s:blue }) +call s:h("javascriptDocTags", { "fg": s:purple }) +call s:h("javascriptEndColons", { "fg": s:white }) +call s:h("javascriptExport", { "fg": s:purple }) +call s:h("javascriptFuncArg", { "fg": s:white }) +call s:h("javascriptFuncKeyword", { "fg": s:purple }) +call s:h("javascriptIdentifier", { "fg": s:red }) +call s:h("javascriptImport", { "fg": s:purple }) +call s:h("javascriptMethodName", { "fg": s:white }) +call s:h("javascriptObjectLabel", { "fg": s:white }) +call s:h("javascriptOpSymbol", { "fg": s:cyan }) +call s:h("javascriptOpSymbols", { "fg": s:cyan }) +call s:h("javascriptPropertyName", { "fg": s:green }) +call s:h("javascriptTemplateSB", { "fg": s:dark_red }) +call s:h("javascriptVariable", { "fg": s:purple }) + +" JSON +call s:h("jsonCommentError", { "fg": s:white }) +call s:h("jsonKeyword", { "fg": s:red }) +call s:h("jsonBoolean", { "fg": s:dark_yellow }) +call s:h("jsonNumber", { "fg": s:dark_yellow }) +call s:h("jsonQuote", { "fg": s:white }) +call s:h("jsonMissingCommaError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonNoQuotesError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonNumError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonString", { "fg": s:green }) +call s:h("jsonStringSQError", { "fg": s:red, "gui": "reverse" }) +call s:h("jsonSemicolonError", { "fg": s:red, "gui": "reverse" }) + +" LESS +call s:h("lessVariable", { "fg": s:purple }) +call s:h("lessAmpersandChar", { "fg": s:white }) +call s:h("lessClass", { "fg": s:dark_yellow }) + +" Markdown (keep consistent with HTML, above) +call s:h("markdownBlockquote", { "fg": s:comment_grey }) +call s:h("markdownBold", { "fg": s:dark_yellow, "gui": "bold", "cterm": "bold" }) +call s:h("markdownBoldItalic", { "fg": s:green, "gui": "bold,italic", "cterm": "bold,italic" }) +call s:h("markdownCode", { "fg": s:green }) +call s:h("markdownCodeBlock", { "fg": s:green }) +call s:h("markdownCodeDelimiter", { "fg": s:green }) +call s:h("markdownH1", { "fg": s:red }) +call s:h("markdownH2", { "fg": s:red }) +call s:h("markdownH3", { "fg": s:red }) +call s:h("markdownH4", { "fg": s:red }) +call s:h("markdownH5", { "fg": s:red }) +call s:h("markdownH6", { "fg": s:red }) +call s:h("markdownHeadingDelimiter", { "fg": s:red }) +call s:h("markdownHeadingRule", { "fg": s:comment_grey }) +call s:h("markdownId", { "fg": s:purple }) +call s:h("markdownIdDeclaration", { "fg": s:blue }) +call s:h("markdownIdDelimiter", { "fg": s:purple }) +call s:h("markdownItalic", { "fg": s:purple, "gui": "italic", "cterm": "italic" }) +call s:h("markdownLinkDelimiter", { "fg": s:purple }) +call s:h("markdownLinkText", { "fg": s:blue }) +call s:h("markdownListMarker", { "fg": s:red }) +call s:h("markdownOrderedListMarker", { "fg": s:red }) +call s:h("markdownRule", { "fg": s:comment_grey }) +call s:h("markdownUrl", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) + +" Perl +call s:h("perlFiledescRead", { "fg": s:green }) +call s:h("perlFunction", { "fg": s:purple }) +call s:h("perlMatchStartEnd",{ "fg": s:blue }) +call s:h("perlMethod", { "fg": s:purple }) +call s:h("perlPOD", { "fg": s:comment_grey }) +call s:h("perlSharpBang", { "fg": s:comment_grey }) +call s:h("perlSpecialString",{ "fg": s:dark_yellow }) +call s:h("perlStatementFiledesc", { "fg": s:red }) +call s:h("perlStatementFlow",{ "fg": s:red }) +call s:h("perlStatementInclude", { "fg": s:purple }) +call s:h("perlStatementScalar",{ "fg": s:purple }) +call s:h("perlStatementStorage", { "fg": s:purple }) +call s:h("perlSubName",{ "fg": s:yellow }) +call s:h("perlVarPlain",{ "fg": s:blue }) + +" PHP +call s:h("phpVarSelector", { "fg": s:red }) +call s:h("phpOperator", { "fg": s:white }) +call s:h("phpParent", { "fg": s:white }) +call s:h("phpMemberSelector", { "fg": s:white }) +call s:h("phpType", { "fg": s:purple }) +call s:h("phpKeyword", { "fg": s:purple }) +call s:h("phpClass", { "fg": s:yellow }) +call s:h("phpUseClass", { "fg": s:white }) +call s:h("phpUseAlias", { "fg": s:white }) +call s:h("phpInclude", { "fg": s:purple }) +call s:h("phpClassExtends", { "fg": s:green }) +call s:h("phpDocTags", { "fg": s:white }) +call s:h("phpFunction", { "fg": s:blue }) +call s:h("phpFunctions", { "fg": s:cyan }) +call s:h("phpMethodsVar", { "fg": s:dark_yellow }) +call s:h("phpMagicConstants", { "fg": s:dark_yellow }) +call s:h("phpSuperglobals", { "fg": s:red }) +call s:h("phpConstants", { "fg": s:dark_yellow }) + +" Ruby +call s:h("rubyBlockParameter", { "fg": s:red}) +call s:h("rubyBlockParameterList", { "fg": s:red }) +call s:h("rubyClass", { "fg": s:purple}) +call s:h("rubyConstant", { "fg": s:yellow}) +call s:h("rubyControl", { "fg": s:purple }) +call s:h("rubyEscape", { "fg": s:red}) +call s:h("rubyFunction", { "fg": s:blue}) +call s:h("rubyGlobalVariable", { "fg": s:red}) +call s:h("rubyInclude", { "fg": s:blue}) +call s:h("rubyIncluderubyGlobalVariable", { "fg": s:red}) +call s:h("rubyInstanceVariable", { "fg": s:red}) +call s:h("rubyInterpolation", { "fg": s:cyan }) +call s:h("rubyInterpolationDelimiter", { "fg": s:red }) +call s:h("rubyInterpolationDelimiter", { "fg": s:red}) +call s:h("rubyRegexp", { "fg": s:cyan}) +call s:h("rubyRegexpDelimiter", { "fg": s:cyan}) +call s:h("rubyStringDelimiter", { "fg": s:green}) +call s:h("rubySymbol", { "fg": s:cyan}) + +" Sass +" https://github.com/tpope/vim-haml +call s:h("sassAmpersand", { "fg": s:red }) +call s:h("sassClass", { "fg": s:dark_yellow }) +call s:h("sassControl", { "fg": s:purple }) +call s:h("sassExtend", { "fg": s:purple }) +call s:h("sassFor", { "fg": s:white }) +call s:h("sassFunction", { "fg": s:cyan }) +call s:h("sassId", { "fg": s:blue }) +call s:h("sassInclude", { "fg": s:purple }) +call s:h("sassMedia", { "fg": s:purple }) +call s:h("sassMediaOperators", { "fg": s:white }) +call s:h("sassMixin", { "fg": s:purple }) +call s:h("sassMixinName", { "fg": s:blue }) +call s:h("sassMixing", { "fg": s:purple }) +call s:h("sassVariable", { "fg": s:purple }) +" https://github.com/cakebaker/scss-syntax.vim +call s:h("scssExtend", { "fg": s:purple }) +call s:h("scssImport", { "fg": s:purple }) +call s:h("scssInclude", { "fg": s:purple }) +call s:h("scssMixin", { "fg": s:purple }) +call s:h("scssSelectorName", { "fg": s:dark_yellow }) +call s:h("scssVariable", { "fg": s:purple }) + +" TeX +call s:h("texStatement", { "fg": s:purple }) +call s:h("texSubscripts", { "fg": s:dark_yellow }) +call s:h("texSuperscripts", { "fg": s:dark_yellow }) +call s:h("texTodo", { "fg": s:dark_red }) +call s:h("texBeginEnd", { "fg": s:purple }) +call s:h("texBeginEndName", { "fg": s:blue }) +call s:h("texMathMatcher", { "fg": s:blue }) +call s:h("texMathDelim", { "fg": s:blue }) +call s:h("texDelimiter", { "fg": s:dark_yellow }) +call s:h("texSpecialChar", { "fg": s:dark_yellow }) +call s:h("texCite", { "fg": s:blue }) +call s:h("texRefZone", { "fg": s:blue }) + +" TypeScript +call s:h("typescriptReserved", { "fg": s:purple }) +call s:h("typescriptEndColons", { "fg": s:white }) +call s:h("typescriptBraces", { "fg": s:white }) + +" XML +call s:h("xmlAttrib", { "fg": s:dark_yellow }) +call s:h("xmlEndTag", { "fg": s:red }) +call s:h("xmlTag", { "fg": s:red }) +call s:h("xmlTagName", { "fg": s:red }) + +" }}} + +" Plugin Highlighting {{{ + +" airblade/vim-gitgutter +call s:h("GitGutterAdd", { "fg": s:green }) +call s:h("GitGutterChange", { "fg": s:yellow }) +call s:h("GitGutterDelete", { "fg": s:red }) + +" dense-analysis/ale +call s:h("ALEError", { "fg": s:red, "gui": "underline", "cterm": "underline" }) +call s:h("ALEWarning", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) +call s:h("ALEInfo", { "gui": "underline", "cterm": "underline" }) +call s:h("ALEErrorSign", { "fg": s:red }) +call s:h("ALEWarningSign", { "fg": s:yellow }) +call s:h("ALEInfoSign", { }) + +" easymotion/vim-easymotion +call s:h("EasyMotionTarget", { "fg": s:red, "gui": "bold", "cterm": "bold" }) +call s:h("EasyMotionTarget2First", { "fg": s:yellow, "gui": "bold", "cterm": "bold" }) +call s:h("EasyMotionTarget2Second", { "fg": s:dark_yellow, "gui": "bold", "cterm": "bold" }) +call s:h("EasyMotionShade", { "fg": s:comment_grey }) + +" lewis6991/gitsigns.nvim +hi link GitSignsAdd GitGutterAdd +hi link GitSignsChange GitGutterChange +hi link GitSignsDelete GitGutterDelete + +" mhinz/vim-signify +hi link SignifySignAdd GitGutterAdd +hi link SignifySignChange GitGutterChange +hi link SignifySignDelete GitGutterDelete + +" neoclide/coc.nvim +call s:h("CocErrorSign", { "fg": s:red }) +call s:h("CocWarningSign", { "fg": s:yellow }) +call s:h("CocInfoSign", { "fg": s:blue }) +call s:h("CocHintSign", { "fg": s:cyan }) +call s:h("CocFadeOut", { "fg": s:comment_grey }) +" https://github.com/joshdick/onedark.vim/issues/313 +highlight! link CocMenuSel PmenuSel + +" neomake/neomake +call s:h("NeomakeErrorSign", { "fg": s:red }) +call s:h("NeomakeWarningSign", { "fg": s:yellow }) +call s:h("NeomakeInfoSign", { "fg": s:blue }) + +" plasticboy/vim-markdown (keep consistent with Markdown, above) +call s:h("mkdDelimiter", { "fg": s:purple }) +call s:h("mkdHeading", { "fg": s:red }) +call s:h("mkdLink", { "fg": s:blue }) +call s:h("mkdURL", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) + +" prabirshrestha/vim-lsp +call s:h("LspErrorText", { "fg": s:red }) +call s:h("LspWarningText", { "fg": s:yellow }) +call s:h("LspInformationText", { "fg":s:blue }) +call s:h("LspHintText", { "fg":s:cyan }) +call s:h("LspErrorHighlight", { "fg": s:red, "gui": "underline", "cterm": "underline" }) +call s:h("LspWarningHighlight", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) +call s:h("LspInformationHighlight", { "fg":s:blue, "gui": "underline", "cterm": "underline" }) +call s:h("LspHintHighlight", { "fg":s:cyan, "gui": "underline", "cterm": "underline" }) + +" tpope/vim-fugitive +call s:h("diffAdded", { "fg": s:green }) +call s:h("diffRemoved", { "fg": s:red }) + +" }}} + +" Git Highlighting {{{ + +call s:h("gitcommitComment", { "fg": s:comment_grey }) +call s:h("gitcommitUnmerged", { "fg": s:green }) +call s:h("gitcommitOnBranch", {}) +call s:h("gitcommitBranch", { "fg": s:purple }) +call s:h("gitcommitDiscardedType", { "fg": s:red }) +call s:h("gitcommitSelectedType", { "fg": s:green }) +call s:h("gitcommitHeader", {}) +call s:h("gitcommitUntrackedFile", { "fg": s:cyan }) +call s:h("gitcommitDiscardedFile", { "fg": s:red }) +call s:h("gitcommitSelectedFile", { "fg": s:green }) +call s:h("gitcommitUnmergedFile", { "fg": s:yellow }) +call s:h("gitcommitFile", {}) +call s:h("gitcommitSummary", { "fg": s:white }) +call s:h("gitcommitOverflow", { "fg": s:red }) +hi link gitcommitNoBranch gitcommitBranch +hi link gitcommitUntracked gitcommitComment +hi link gitcommitDiscarded gitcommitComment +hi link gitcommitSelected gitcommitComment +hi link gitcommitDiscardedArrow gitcommitDiscardedFile +hi link gitcommitSelectedArrow gitcommitSelectedFile +hi link gitcommitUnmergedArrow gitcommitUnmergedFile + +" }}} + +" Neovim-Specific Highlighting {{{ + +if has("nvim") + " Neovim terminal colors {{{ + let g:terminal_color_0 = s:black.gui + let g:terminal_color_1 = s:red.gui + let g:terminal_color_2 = s:green.gui + let g:terminal_color_3 = s:yellow.gui + let g:terminal_color_4 = s:blue.gui + let g:terminal_color_5 = s:purple.gui + let g:terminal_color_6 = s:cyan.gui + let g:terminal_color_7 = s:white.gui + let g:terminal_color_8 = s:visual_grey.gui + let g:terminal_color_9 = s:dark_red.gui + let g:terminal_color_10 = s:green.gui " No dark version + let g:terminal_color_11 = s:dark_yellow.gui + let g:terminal_color_12 = s:blue.gui " No dark version + let g:terminal_color_13 = s:purple.gui " No dark version + let g:terminal_color_14 = s:cyan.gui " No dark version + let g:terminal_color_15 = s:comment_grey.gui + let g:terminal_color_background = s:background.gui + let g:terminal_color_foreground = s:foreground.gui + " }}} + + " Neovim Diagnostics {{{ + call s:h("DiagnosticError", { "fg": s:red }) + call s:h("DiagnosticWarn", { "fg": s:yellow }) + call s:h("DiagnosticInfo", { "fg": s:blue }) + call s:h("DiagnosticHint", { "fg": s:cyan }) + call s:h("DiagnosticUnderlineError", { "fg": s:red, "gui": "underline", "cterm": "underline" }) + call s:h("DiagnosticUnderlineWarn", { "fg": s:yellow, "gui": "underline", "cterm": "underline" }) + call s:h("DiagnosticUnderlineInfo", { "fg": s:blue, "gui": "underline", "cterm": "underline" }) + call s:h("DiagnosticUnderlineHint", { "fg": s:cyan, "gui": "underline", "cterm": "underline" }) + " }}} + + " Neovim LSP (for versions < 0.5.1) {{{ + hi link LspDiagnosticsDefaultError DiagnosticError + hi link LspDiagnosticsDefaultWarning DiagnosticWarn + hi link LspDiagnosticsDefaultInformation DiagnosticInfo + hi link LspDiagnosticsDefaultHint DiagnosticHint + hi link LspDiagnosticsUnderlineError DiagnosticUnderlineError + hi link LspDiagnosticsUnderlineWarning DiagnosticUnderlineWarn + hi link LspDiagnosticsUnderlineInformation DiagnosticUnderlineInfo + hi link LspDiagnosticsUnderlineHint DiagnosticUnderlineHint + " }}} +endif + +" }}} + +" Must appear at the end of the file to work around this oddity: +" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ +set background=dark diff --git a/.config/nvim/other/fzf.vim b/.config/nvim/other/fzf.vim new file mode 100644 index 0000000..32cb18b --- /dev/null +++ b/.config/nvim/other/fzf.vim @@ -0,0 +1,19 @@ +" --> Fzf +let g:fzf_layout = { 'window': { 'width': 1, 'height': 1 } } +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(<q-args>, {'options': ['--info=inline', '--preview', 'preview {}']}, <bang>0) + +" Mapping selecting mappings +nmap <leader><tab> <plug>(fzf-maps-n) +xmap <leader><tab> <plug>(fzf-maps-x) +omap <leader><tab> <plug>(fzf-maps-o) + +" Insert mode completion +imap <c-x><c-k> <plug>(fzf-complete-word) +imap <c-x><c-f> <plug>(fzf-complete-path) +imap <c-x><c-l> <plug>(fzf-complete-line) + +" Fzf keybindings +nnoremap <leader>ff :Files<CR> +nnoremap <leader>. :Files %:p:h<CR> + diff --git a/.config/nvim/other/learn.vim b/.config/nvim/other/learn.vim new file mode 100644 index 0000000..c3272d9 --- /dev/null +++ b/.config/nvim/other/learn.vim @@ -0,0 +1,649 @@ +" ############## +" Introduction +" ############## +" +" Vim script (also called VimL) is the subset of Vim's ex-commands which +" supplies a number of features one would expect from a scripting language, +" such as values, variables, functions or loops. Always keep in the back of +" your mind that a Vim script file is just a sequence of ex-commands. It is +" very common for a script to mix programming-language features and raw +" ex-commands. +" +" You can run Vim script directly by entering the commands in command-line mode +" (press `:` to enter command-line mode), or you can write them to a file +" (without the leading `:`) and source it in a running Vim instance (`:source +" path/to/file`). Some files are sourced automatically as part of your +" configuration (see |startup|). This guide assumes that you are familiar +" with ex-commands and will only cover the scripting. Help topics to the +" relevant manual sections are included. +" +" See |usr_41.txt| for the official introduction to Vim script. A comment is +" anything following an unmatched `"` until the end of the line, and `|` +" separates instructions (what `;` does in most other languages). References to +" the manual as surrounded with `|`, such as |help.txt|. + +" This is a comment + +" The vertical line '|' (pipe) separates commands +echo 'Hello' | echo 'world!' + +" Putting a comment after a command usually works +pwd " Displays the current working directory + +" Except for some commands it does not; use the command delimiter before the +" comment (echo assumes that the quotation mark begins a string) +echo 'Hello world!' | " Displays a message + +" Line breaks can be escaped by placing a backslash as the first non-whitespace +" character on the *following* line. Only works in script files, not on the +" command line +echo " Hello + \ world " + +echo [1, + \ 2] + +echo { + \ 'a': 1, + \ 'b': 2 +\} + + +" ####### +" Types +" ####### +" +" For an overview of types see |E712|. For an overview of operators see +" |expression-syntax| + +" Numbers (|expr-number|) +" ####### + +echo 123 | " Decimal +echo 0b1111011 | " Binary +echo 0173 | " Octal +echo 0x7B | " Hexadecimal +echo 123.0 | " Floating-point +echo 1.23e2 | " Floating-point (scientific notation) + +" Note that an *integer* number with a leading `0` is in octal notation. The +" usual arithmetic operations are supported. + +echo 1 + 2 | " Addition +echo 1 - 2 | " Subtraction +echo - 1 | " Negation (unary minus) +echo + 1 | " Unary plus (does nothing really, but still legal) +echo 1 * 2 | " Multiplication +echo 1 / 2 | " Division +echo 1 % 2 | " Modulo (remainder) + +" Booleans (|Boolean|) +" ######## +" +" The number 0 is false, every other number is true. Strings are implicitly +" converted to numbers (see below). There are two pre-defined semantic +" constants. + +echo v:true | " Evaluates to 1 or the string 'v:true' +echo v:false | " Evaluates to 0 or the string 'v:false' + +" Boolean values can result from comparison of two objects. + +echo x == y | " Equality by value +echo x != y | " Inequality +echo x > y | " Greater than +echo x >= y | " Greater than or equal +echo x < y | " Smaller than +echo x <= y | " Smaller than or equal +echo x is y | " Instance identity (lists and dictionaries) +echo x isnot y | " Instance non-identity (lists and dictionaries) + +" Strings are compared based on their alphanumerical ordering +" echo 'a' < 'b'. Case sensitivity depends on the setting of 'ignorecase' +" +" Explicit case-sensitivity is specified by appending '#' (match case) or '?' +" (ignore case) to the operator. Prefer explicitly case sensitivity when writing +" portable scripts. + +echo 'a' < 'B' | " True or false depending on 'ignorecase' +echo 'a' <? 'B' | " True +echo 'a' <# 'B' | " False + +" Regular expression matching +echo "hi" =~ "hello" | " Regular expression match, uses 'ignorecase' +echo "hi" =~# "hello" | " Regular expression match, case sensitive +echo "hi" =~? "hello" | " Regular expression match, case insensitive +echo "hi" !~ "hello" | " Regular expression unmatch, use 'ignorecase' +echo "hi" !~# "hello" | " Regular expression unmatch, case sensitive +echo "hi" !~? "hello" | " Regular expression unmatch, case insensitive + +" Boolean operations are possible. + +echo v:true && v:false | " Logical AND +echo v:true || v:false | " Logical OR +echo ! v:true | " Logical NOT +echo v:true ? 'yes' : 'no' | " Ternary operator + + +" Strings (|String|) +" ####### +" +" An ordered zero-indexed sequence of bytes. The encoding of text into bytes +" depends on the option |'encoding'|. + +" Literal constructors +echo "Hello world\n" | " The last two characters stand for newline +echo 'Hello world\n' | " The last two characters are literal +echo 'Let''s go!' | " Two single quotes become one quote character + +" Single-quote strings take all characters are literal, except two single +" quotes, which are taken to be a single quote in the string itself. See +" |expr-quote| for all possible escape sequences. + +" String concatenation +" The .. operator is preferred, but only supported in since Vim 8.1.1114 +echo 'Hello ' . 'world' | " String concatenation +echo 'Hello ' .. 'world' | " String concatenation (new variant) + +" String indexing +echo 'Hello'[0] | " First byte +echo 'Hello'[1] | " Second byte +echo 'Hellö'[4] | " Returns a byte, not the character 'ö' + +" Substrings (second index is inclusive) +echo 'Hello'[:] | " Copy of entire string +echo 'Hello'[1:3] | " Substring, second to fourth byte +echo 'Hello'[1:-2] | " Substring until second to last byte +echo 'Hello'[1:] | " Substring with starting index +echo 'Hello'[:2] | " Substring with ending index +echo 'Hello'[-2:] | " Substring relative to end of string + +" A negative index is relative to the end of the string. See +" |string-functions| for all string-related functions. + +" Lists (|List|) +" ##### +" +" An ordered zero-indexed heterogeneous sequence of arbitrary Vim script +" objects. + +" Literal constructor +echo [] | " Empty list +echo [1, 2, 'Hello'] | " List with elements +echo [1, 2, 'Hello', ] | " Trailing comma permitted +echo [[1, 2], 'Hello'] | " Lists can be nested arbitrarily + +" List concatenation +echo [1, 2] + [3, 4] | " Creates a new list + +" List indexing, negative is relative to end of list (|list-index|) +echo [1, 2, 3, 4][2] | " Third element +echo [1, 2, 3, 4][-1] | " Last element + +" List slicing (|sublist|) +echo [1, 2, 3, 4][:] | " Shallow copy of entire list +echo [1, 2, 3, 4][:2] | " Sublist until third item (inclusive) +echo [1, 2, 3, 4][2:] | " Sublist from third item (inclusive) +echo [1, 2, 3, 4][:-2] | " Sublist until second-to-last item (inclusive) + +" All slicing operations create new lists. To modify a list in-place use list +" functions (|list-functions|) or assign directly to an item (see below about +" variables). + + +" Dictionaries (|Dictionary|) +" ############ +" +" An unordered sequence of key-value pairs, keys are always strings (numbers +" are implicitly converted to strings). + +" Dictionary literal +echo {} | " Empty dictionary +echo {'a': 1, 'b': 2} | " Dictionary literal +echo {'a': 1, 'b': 2, } | " Trailing comma permitted +echo {'x': {'a': 1, 'b': 2}} | " Nested dictionary + +" Indexing a dictionary +echo {'a': 1, 'b': 2}['a'] | " Literal index +echo {'a': 1, 'b': 2}.a | " Syntactic sugar for simple keys + +" See |dict-functions| for dictionary manipulation functions. + + +" Funcref (|Funcref|) +" ####### +" +" Reference to a function, uses the function name as a string for construction. +" When stored in a variable the name of the variable has the same restrictions +" as a function name (see below). + +echo function('type') | " Reference to function type() +" Note that `funcref('type')` will throw an error because the argument must be +" a user-defined function; see further below for defining your own functions. +echo funcref('type') | " Reference by identity, not name +" A lambda (|lambda|) is an anonymous function; it can only contain one +" expression in its body, which is also its implicit return value. +echo {x -> x * x} | " Anonymous function +echo function('substitute', ['hello']) | " Partial function + + +" Regular expression (|regular-expression|) +" ################## +" +" A regular expression pattern is generally a string, but in some cases you can +" also use a regular expression between a pair of delimiters (usually `/`, but +" you can choose anything). + +" Substitute 'hello' for 'Hello' +substitute/hello/Hello/ + + +" ########################### +" Implicit type conversions +" ########################### +" +" Strings are converted to numbers, and numbers to strings when necessary. A +" number becomes its decimal notation as a string. A string becomes its +" numerical value if it can be parsed to a number, otherwise it becomes zero. + +echo "1" + 1 | " Number +echo "1" .. 1 | " String +echo "0xA" + 1 | " Number + +" Strings are treated like numbers when used as booleans +echo "true" ? 1 : 0 | " This string is parsed to 0, which is false + +" ########### +" Variables +" ########### +" +" Variables are bound within a scope; if no scope is provided a default is +" chosen by Vim. Use `:let` and `:const` to bind a value and `:unlet` to unbind +" it. + +let b:my_var = 1 | " Local to current buffer +let w:my_var = 1 | " Local to current window +let t:my_var = 1 | " Local to current tab page +let g:my_var = 1 | " Global variable +let l:my_var = 1 | " Local to current function (see functions below) +let s:my_var = 1 | " Local to current script file +let a:my_arg = 1 | " Function argument (see functions below) + +" The Vim scope is read-only +echo v:true | " Special built-in Vim variables (|v:var|) + +" Access special Vim memory like variables +let @a = 'Hello' | " Register +let $PATH='' | " Environment variable +let &textwidth = 79 | " Option +let &l:textwidth = 79 | " Local option +let &g:textwidth = 79 | " Global option + +" Access scopes as dictionaries (can be modified like all dictionaries) +" See the |dict-functions|, especially |get()|, for access and manipulation +echo b: | " All buffer variables +echo w: | " All window variables +echo t: | " All tab page variables +echo g: | " All global variables +echo l: | " All local variables +echo s: | " All script variables +echo a: | " All function arguments +echo v: | " All Vim variables + +" Constant variables +const x = 10 | " See |:const|, |:lockvar| + +" Function reference variables have the same restrictions as function names +let IsString = {x -> type(x) == type('')} | " Global: capital letter +let s:isNumber = {x -> type(x) == type(0)} | " Local: any name allowed + +" When omitted the scope `g:` is implied, except in functions, there `l:` is +" implied. + + +" Multiple value binding (list unpacking) +" ####################################### +" +" Assign values of list to multiple variables (number of items must match) +let [x, y] = [1, 2] + +" Assign the remainder to a rest variable (note the semicolon) +let [mother, father; children] = ['Alice', 'Bob', 'Carol', 'Dennis', 'Emily'] + + +" ############## +" Flow control +" ############## + +" Conditional (|:if|, |:elseif|, |:else|, |:endif|) +" ########### +" +" Conditions are set between `if` and `endif`. They can be nested. + +let condition = v:true + +if condition + echo 'First condition' +elseif another_condition + echo 'Second condition' +else + echo 'Fail' +endif + +" Loops (|:for|, |:endfor|, |:while|, |:endwhile|, |:break|, |:continue|) +" ##### +" +" Two types of loops: `:for` and `:while`. Use `:continue` to skip to the next +" iteration, `:break` to break out of the loop. + +" For-loop (|:for|, |:endfor|) +" ======== +" +" For-loops iterate over lists and nothing else. If you want to iterate over +" another sequence you need to use a function which will create a list. + +" Iterate over a list +for person in ['Alice', 'Bob', 'Carol', 'Dennis', 'Emily'] + echo 'Hello ' .. person +endfor + +" Iterate over a nested list by unpacking it +for [x, y] in [[1, 0], [0, 1], [-1, 0], [0, -1]] + echo 'Position: x =' .. x .. ', y = ' .. y +endfor + +" Iterate over a range of numbers +for i in range(10, 0, -1) " Count down from 10 + echo 'T minus' .. i +endfor + +" Iterate over the keys of a dictionary +for symbol in keys({'π': 3.14, 'e': 2.71}) + echo 'The constant ' .. symbol .. ' is a transcendent number' +endfor + +" Iterate over the values of a dictionary +for value in values({'π': 3.14, 'e': 2.71}) + echo 'The value ' .. value .. ' approximates a transcendent number' +endfor + +" Iterate over the keys and values of a dictionary +for [symbol, value] in items({'π': 3.14, 'e': 2.71}) + echo 'The number ' .. symbol .. ' is approximately ' .. value +endfor + +" While-loops (|:while|, |:endwhile|) + +let there_yet = v:true +while !there_yet + echo 'Are we there yet?' +endwhile + + +" Exception handling (|exception-handling|) +" ################## +" +" Throw new exceptions as strings, catch them by pattern-matching a regular +" expression against the string + +" Throw new exception +throw "Wrong arguments" + +" Guard against an exception (the second catch matches any exception) +try + source path/to/file +catch /Cannot open/ + echo 'Looks like that file does not exist' +catch /.*/ + echo 'Something went wrong, but I do not know what' +finally + echo 'I am done trying' +endtry + + +" ########## +" Functions +" ########## + +" Defining functions (|:function|, |:endfunction|) +" ################## + +" Unscoped function names have to start with a capital letter +function! AddNumbersLoudly(x, y) + " Use a: scope to access arguments + echo 'Adding' .. a:x .. 'and' .. a:y | " A side effect + return a:x + a:y | " A return value +endfunction + +" Scoped function names may start with a lower-case letter +function! s:addNumbersLoudly(x, y) + echo 'Adding' .. a:x .. 'and' .. a:y + return a:x + a:y +endfunction + +" Without the exclamation mark it would be an error to re-define a function, +" with the exclamation mark the new definition can replace the old one. Since +" Vim script files can be reloaded several times over the course of a session +" it is best to use the exclamation mark unless you really know what you are +" doing. + +" Function definitions can have special qualifiers following the argument list. + +" Range functions define two implicit arguments, which will be set to the range +" of the ex-command +function! FirstAndLastLine() range + echo [a:firstline, a:lastline] +endfunction + +" Prints the first and last line that match a pattern (|cmdline-ranges|) +/^#!/,/!#$/call FirstAndLastLine() + +" Aborting functions, abort once error occurs (|:func-abort|) +function! SourceMyFile() abort + source my-file.vim | " Try sourcing non-existing file + echo 'This will never be printed' +endfunction + +" Closures, functions carrying values from outer scope (|:func-closure|) +function! MakeAdder(x) + function! Adder(n) closure + return a:n + a:x + endfunction + return funcref('Adder') +endfunction +let AddFive = MakeAdder(5) +echo AddFive(3) | " Prints 8 + +" Dictionary functions, poor man's OOP methods (|Dictionary-function|) +function! Mylen() dict + return len(self.data) | " Implicit variable self +endfunction +let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")} +echo mydict.len() + +" Alternatively, more concise +let mydict = {'data': [0, 1, 2, 3]} +function! mydict.len() + return len(self.data) +endfunction + +" Calling functions (|:call|) +" ################# + +" Call a function for its return value, and possibly for its side effects +let animals = keys({'cow': 'moo', 'dog': 'woof', 'cat': 'meow'}) + +" Call a function for its side effects only, ignore potential return value +call sign_undefine() + +" The call() function calls a function reference and passes parameters as a +" list, and returns the function's result. +echo call(function('get'), [{'a': 1, 'b': 2}, 'c', 3]) | " Prints 3 + +" Recall that Vim script is embedded within the ex-commands, that is why we +" cannot just call a function directly, we have to use the `:call` ex-command. + +" Function namespaces (|write-library-script|, |autoload|) +" ################### + +" Must be defined in autoload/foo/bar.vim +" Namspaced function names do not have to start with a capital letter +function! foo#bar#log(value) + echomsg value +endfunction + +call foo#bar#log('Hello') + + +" ############################# +" Frequently used ex-commands +" ############################# + + +" Sourcing runtime files (|'runtimepath'|) +" ###################### + +" Source first match among runtime paths +runtime plugin/my-plugin.vim + + +" Defining new ex-commands (|40.2|, |:command|) +" ######################## + +" First argument here is the name of the command, rest is the command body +command! SwapAdjacentLines normal! ddp + +" The exclamation mark works the same as with `:function`. User-defined +" commands must start with a capital letter. The `:command` command can take a +" number of attributes (some of which have their own parameters with `=`), such +" as `-nargs`, all of them start with a dash to set them apart from the command +" name. + +command! -nargs=1 Error echoerr <args> + + +" Defining auto-commands (|40.3|, |autocmd|, |autocommand-events|) +" ###################### + +" The arguments are "events", "patterns", rest is "commands" +autocmd BufWritePost $MYVIMRC source $MYVIMRC + +" Events and patterns are separated by commas with no space between. See +" |autocmd-events| for standard events, |User| for custom events. Everything +" else are the ex-commands which will be executed. + +" Auto groups +" =========== +" +" When a file is sourced multiple times the auto-commands are defined anew, +" without deleting the old ones, causing auto-commands to pile up over time. +" Use auto-groups and the following ritual to guard against this. + +augroup auto-source | " The name of the group is arbitrary + autocmd! | " Deletes all auto-commands in the current group + autocmd BufWritePost $MYVIMRC source $MYVIMRC +augroup END | " Switch back to default auto-group + +" It is also possible to assign a group directly. This is useful if the +" definition of the group is in one script and the definition of the +" auto-command is in another script. + +" In one file +augroup auto-source + autocmd! +augroup END + +" In another file +autocmd auto-source BufWritePost $MYVIMRC source $MYVIMRC + +" Executing (run-time macros of sorts) +" #################################### + +" Sometimes we need to construct an ex-command where part of the command is not +" known until runtime. + +let line = 3 | " Line number determined at runtime +execute line .. 'delete' | " Delete a line + +" Executing normal-mode commands +" ############################## +" +" Use `:normal` to play back a sequence of normal mode commands from the +" command-line. Add an exclamation mark to ignore user mappings. + +normal! ggddGp | " Transplant first line to end of buffer + +" Window commands can be used with :normal, or with :wincmd if :normal would +" not work +wincmd L | " Move current window all the way to the right + + +" ########################### +" Frequently used functions +" ########################### + +" Feature check +echo has('nvim') | " Running Neovim +echo has('python3') | " Support for Python 3 plugins +echo has('unix') | " Running on a Unix system +echo has('win32') | " Running on a Windows system + + +" Test if something exists +echo exists('&mouse') | " Option (exists only) +echo exists('+mouse') | " Option (exists and works) +echo exists('$HOSTNAME') | " Environment variable +echo exists('*strftime') | " Built-in function +echo exists('**s:MyFunc') | " User-defined function +echo exists('bufcount') | " Variable (scope optional) +echo exists('my_dict["foo"]') | " Variable (dictionary entry) +echo exists('my_dict["foo"]') | " Variable (dictionary entry) +echo exists(':Make') | " Command +echo exists("#CursorHold") | " Auto-command defined for event +echo exists("#BufReadPre#*.gz") | " Event and pattern +echo exists("#filetypeindent") | " Auto-command group +echo exists("##ColorScheme") | " Auto-command supported for event + +" Various dynamic values (see |expand()|) +echo expand('%') | " Current file name +echo expand('<cword>') | " Current word under cursor +echo expand('%:p') | " Modifier are possible + +" Type tests +" There are unique constants defined for the following types. Older versions +" of Vim lack the type variables, see the reference " documentation for a +" workaround +echo type(my_var) == v:t_number | " Number +echo type(my_var) == v:t_string | " String +echo type(my_var) == v:t_func | " Funcref +echo type(my_var) == v:t_list | " List +echo type(my_var) == v:t_dict | " Dictionary +echo type(my_var) == v:t_float | " Float +echo type(my_var) == v:t_bool | " Explicit Boolean +" For the null object should compare it against itself +echo my_var is v:null + +" Format strings +echo printf('%d in hexadecimal is %X', 123, 123) + + +" ##################### +" Tricks of the trade +" ##################### + +" Source guard +" ############ + +" Prevent a file from being sourced multiple times; users can set the variable +" in their configuration to prevent the plugin from loading at all. +if exists('g:loaded_my_plugin') + finish +endif +let g:loaded_my_plugin = v:true + +" Default values +" ############## + +" Get a default value: if the user defines a variable use it, otherwise use a +" hard-coded default. Uses the fact that a scope is also a dictionary. +let s:greeting = get(g:, 'my_plugin_greeting', 'Hello') diff --git a/.config/nvim/out.vim b/.config/nvim/out.vim new file mode 100644 index 0000000..6e4e1f1 --- /dev/null +++ b/.config/nvim/out.vim @@ -0,0 +1,36 @@ +" capture (dump) the (somewhat long) ouput of the commands like `:digraph`, `:map', `:highlight`, `:scripnames` etc. + +function! s:dump(cmd) abort + + " Start a new split or maybe a buffer or a tab + " enew | " open a new buffer + 10split | enew | " open a new split (with 10% height (?)) + " tabnew | " open a new tab + + " Make it a scratch buffer ( `:help special-buffers`) + setlocal + \ bufhidden=wipe + \ buftype=nofile + \ nobuflisted + \ nolist + \ noswapfile + \ norelativenumber + \ nonumber + + " Write the cmd output to the buffer + put =execute(a:cmd) + " There are 2 empty line at the beginning of the buffer before the ouput of + " the cmd. Not sure from where they are comning from. Anyhow I will delete + " them. + norm gg2dd + + " No modifications to this buffer + setlocal readonly nomodifiable nomodified + + " Press escape to close when you're done + nnoremap <buffer><silent> <Esc> :bd<CR> + +endfunction + +" Define a command to use the function easier +command! -nargs=1 Dump execute "call s:dump(" string(<q-args>) ")" diff --git a/.config/nvim/pack/colors/opt/onedark.vim b/.config/nvim/pack/colors/opt/onedark.vim new file mode 160000 +Subproject 390b893d361c356ac1b00778d849815f2aa44ae diff --git a/.config/nvim/templates/_default.c b/.config/nvim/templates/_default.c new file mode 100644 index 0000000..6d8e7c1 --- /dev/null +++ b/.config/nvim/templates/_default.c @@ -0,0 +1,5 @@ +#include <stdio.h> + +int main() { + <++> +} diff --git a/.config/nvim/templates/_default.html b/.config/nvim/templates/_default.html new file mode 100644 index 0000000..4201ee8 --- /dev/null +++ b/.config/nvim/templates/_default.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + +<head> + <title><++></title> + <link rel="stylesheet" href="/style.css"> +</head> + +<body> + <++> +</body> + +</html> diff --git a/.config/nvim/templates/_default.tex b/.config/nvim/templates/_default.tex new file mode 100644 index 0000000..397e28e --- /dev/null +++ b/.config/nvim/templates/_default.tex @@ -0,0 +1,7 @@ +\documentclass{article} + +\begin{document} + +<++> + +\end{document} diff --git a/.config/nvim/templates/article.tex b/.config/nvim/templates/article.tex new file mode 100644 index 0000000..a821909 --- /dev/null +++ b/.config/nvim/templates/article.tex @@ -0,0 +1,11 @@ +\documentclass{article} + +\title{<++>} +\author{<++>} + +\begin{document} +\maketitle + +<++> + +\end{document} diff --git a/.config/nvim/vim.log b/.config/nvim/vim.log new file mode 100644 index 0000000..67ecb5b --- /dev/null +++ b/.config/nvim/vim.log @@ -0,0 +1,170 @@ + + +times in msec + clock self+sourced self: sourced script + clock elapsed: other lines + +000.009 000.009: --- NVIM STARTING --- +000.119 000.110: event init +000.186 000.067: early init +000.230 000.043: locale set +000.260 000.030: init first window +000.469 000.209: inits 1 +000.483 000.014: window checked +000.484 000.001: parsing arguments +000.872 000.051 000.051: require('vim.shared') +000.971 000.034 000.034: require('vim._meta') +000.973 000.095 000.061: require('vim._editor') +000.974 000.190 000.044: require('vim._init_packages') +000.975 000.301: init lua interpreter +001.027 000.053: expanding arguments +001.058 000.031: inits 2 +001.316 000.258: init highlight +001.317 000.001: waiting for UI +001.475 000.157: done waiting for UI +001.481 000.007: clear screen +001.588 000.107: init default mappings & autocommands +001.883 000.041 000.041: sourcing /usr/share/nvim/runtime/ftplugin.vim +001.936 000.022 000.022: sourcing /usr/share/nvim/runtime/indent.vim +001.982 000.009 000.009: sourcing /usr/share/nvim/archlinux.vim +001.985 000.030 000.021: sourcing /etc/xdg/nvim/sysinit.vim +006.183 000.919 000.919: sourcing /home/master/.config/nvim/autoload/plug.vim +012.319 000.007 000.007: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/filetype.vim +012.437 000.007 000.007: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/ftdetect/polyglot.vim +012.556 000.010 000.010: sourcing /usr/share/vim/vimfiles/ftdetect/PKGBUILD.vim +012.580 000.008 000.008: sourcing /usr/share/vim/vimfiles/ftdetect/SRCINFO.vim +012.604 000.007 000.007: sourcing /usr/share/vim/vimfiles/ftdetect/augeas.vim +012.634 000.014 000.014: sourcing /usr/share/vim/vimfiles/ftdetect/conkyrc.vim +012.672 000.022 000.022: sourcing /usr/share/vim/vimfiles/ftdetect/espeakfiletype.vim +012.703 000.015 000.015: sourcing /usr/share/vim/vimfiles/ftdetect/lf.vim +012.755 000.024 000.024: sourcing /usr/share/vim/vimfiles/ftdetect/nginx.vim +023.697 011.642 011.528: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/autoload/polyglot/init.vim +023.708 011.710 000.068: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/filetype.vim +023.840 000.085 000.085: sourcing /usr/share/nvim/runtime/filetype.lua +024.243 000.011 000.011: sourcing /usr/share/nvim/runtime/ftplugin.vim +024.319 000.007 000.007: sourcing /usr/share/nvim/runtime/indent.vim +024.499 000.063 000.063: sourcing /usr/share/nvim/runtime/syntax/synload.vim +024.563 000.201 000.137: sourcing /usr/share/nvim/runtime/syntax/syntax.vim +024.947 000.306 000.306: sourcing /usr/share/nvim/runtime/syntax/nosyntax.vim +025.066 000.054 000.054: sourcing /usr/share/nvim/runtime/syntax/synload.vim +025.118 000.505 000.145: sourcing /usr/share/nvim/runtime/syntax/syntax.vim +025.229 000.008 000.008: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/filetype.vim +025.302 000.053 000.053: sourcing /usr/share/nvim/runtime/filetype.lua +025.391 000.008 000.008: sourcing /usr/share/nvim/runtime/ftplugin.vim +025.499 000.007 000.007: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/filetype.vim +025.566 000.048 000.048: sourcing /usr/share/nvim/runtime/filetype.lua +025.652 000.008 000.008: sourcing /usr/share/nvim/runtime/ftplugin.vim +025.723 000.006 000.006: sourcing /usr/share/nvim/runtime/indent.vim +025.809 023.804 010.228: sourcing /home/master/.config/nvim/init.vim +025.815 000.331: sourcing vimrc file(s) +026.068 000.043 000.043: sourcing /home/master/.config/nvim/plugin/coc.vim +026.166 000.080 000.080: sourcing /home/master/.config/nvim/plugin/debug.vim +026.202 000.018 000.018: sourcing /home/master/.config/nvim/plugin/docs.vim +026.303 000.082 000.082: sourcing /home/master/.config/nvim/plugin/fzf.vim +026.366 000.041 000.041: sourcing /home/master/.config/nvim/plugin/scratch.vim +026.863 000.071 000.071: sourcing /home/master/.config/nvim/autoload/onedark.vim +039.423 012.982 012.912: sourcing /home/master/.config/nvim/colors/onedark.vim +039.454 013.068 000.086: sourcing /home/master/.config/nvim/plugin/ui.vim +039.812 000.227 000.227: sourcing /home/master/.local/share/nvim/plugged/vim-surround/plugin/surround.vim +039.967 000.084 000.084: sourcing /home/master/.local/share/nvim/plugged/vim-commentary/plugin/commentary.vim +040.116 000.063 000.063: sourcing /home/master/.local/share/nvim/plugged/lf.vim/plugin/lf.vim +040.371 000.185 000.185: sourcing /home/master/.local/share/nvim/plugged/vim-floaterm/plugin/floaterm.vim +040.855 000.418 000.418: sourcing /home/master/.local/share/nvim/plugged/fzf/plugin/fzf.vim +041.550 000.617 000.617: sourcing /home/master/.local/share/nvim/plugged/fzf.vim/plugin/fzf.vim +041.693 000.073 000.073: sourcing /home/master/.local/share/nvim/plugged/zeavim.vim/plugin/zeavim.vim +042.133 000.339 000.339: sourcing /home/master/.local/share/nvim/plugged/vim-polyglot/plugin/polyglot.vim +042.506 000.152 000.152: sourcing /usr/share/nvim/runtime/plugin/gzip.vim +042.533 000.007 000.007: sourcing /usr/share/nvim/runtime/plugin/health.vim +042.939 000.118 000.118: sourcing /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim +043.016 000.466 000.348: sourcing /usr/share/nvim/runtime/plugin/matchit.vim +043.131 000.099 000.099: sourcing /usr/share/nvim/runtime/plugin/matchparen.vim +043.494 000.345 000.345: sourcing /usr/share/nvim/runtime/plugin/netrwPlugin.vim +044.073 000.113 000.113: sourcing /usr/share/nvim/runtime/autoload/remote/host.vim +044.305 000.089 000.089: sourcing /usr/share/nvim/runtime/autoload/remote/define.vim +044.761 001.141 000.938: sourcing /home/master/.local/share/nvim/rplugin.vim +044.768 001.244 000.103: sourcing /usr/share/nvim/runtime/plugin/rplugin.vim +044.886 000.091 000.091: sourcing /usr/share/nvim/runtime/plugin/shada.vim +044.928 000.017 000.017: sourcing /usr/share/nvim/runtime/plugin/spellfile.vim +045.070 000.121 000.121: sourcing /usr/share/nvim/runtime/plugin/tarPlugin.vim +045.154 000.058 000.058: sourcing /usr/share/nvim/runtime/plugin/tohtml.vim +045.193 000.013 000.013: sourcing /usr/share/nvim/runtime/plugin/tutor.vim +045.365 000.151 000.151: sourcing /usr/share/nvim/runtime/plugin/zipPlugin.vim +045.471 000.012 000.012: sourcing /usr/share/vim/vimfiles/plugin/fzf.vim +045.579 000.089 000.089: sourcing /usr/share/vim/vimfiles/plugin/redact_pass.vim +046.186 000.100 000.100: sourcing /usr/share/nvim/runtime/plugin/editorconfig.lua +046.313 000.104 000.104: sourcing /usr/share/nvim/runtime/plugin/man.lua +046.371 000.037 000.037: sourcing /usr/share/nvim/runtime/plugin/nvim.lua +046.425 002.166: loading rtp plugins +046.501 000.075: loading packages +046.527 000.027: loading after plugins +046.535 000.007: inits 3 +049.346 002.812: reading ShaDa +049.563 000.216: opening buffers +049.592 000.029: BufEnter autocommands +049.594 000.002: editing files in windows +051.092 000.064 000.064: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/init.vim +051.660 000.278 000.278: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/parts.vim +051.828 000.011 000.011: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/formatter/short_path.vim +052.601 000.102 000.102: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/util.vim +052.898 000.159 000.159: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions.vim +053.025 000.030 000.030: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/quickfix.vim +053.204 000.108 000.108: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline.vim +053.349 000.020 000.020: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/netrw.vim +053.463 000.021 000.021: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/fzf.vim +053.692 000.064 000.064: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/term.vim +055.576 000.118 000.118: require('vim.lsp.log') +056.062 000.483 000.483: require('vim.lsp.protocol') +057.439 000.324 000.324: require('vim.lsp._snippet') +057.532 000.090 000.090: require('vim.highlight') +057.538 000.004 000.004: require('vim.F') +057.556 001.459 001.041: require('vim.lsp.util') +057.570 002.492 000.432: require('vim.lsp.handlers') +057.977 000.405 000.405: require('vim.lsp.rpc') +058.150 000.171 000.171: require('vim.lsp.sync') +058.648 000.496 000.496: require('vim.lsp.semantic_tokens') +059.000 000.349 000.349: require('vim.lsp.buf') +059.135 000.133 000.133: require('vim.lsp.diagnostic') +059.350 000.213 000.213: require('vim.lsp.codelens') +059.382 005.520 001.261: require('vim.lsp') +059.504 000.044 000.044: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/nvimlsp.vim +059.696 000.071 000.071: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/whitespace.vim +059.933 000.037 000.037: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/po.vim +060.085 000.056 000.056: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/wordcount.vim +060.283 000.019 000.019: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/keymap.vim +060.481 000.028 000.028: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/searchcount.vim +064.384 000.073 000.073: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/section.vim +064.878 000.238 000.238: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/highlighter.vim +068.911 000.072 000.072: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/themes.vim +069.476 000.931 000.859: sourcing /home/master/.config/nvim/autoload/airline/themes/onedark.vim +072.884 000.370 000.370: sourcing /home/master/.config/nvim/autoload/airline/themes/onedark.vim +085.154 000.083 000.083: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/builder.vim +085.516 000.050 000.050: sourcing /home/master/.local/share/nvim/plugged/vim-airline/autoload/airline/extensions/default.vim +102.172 051.614 043.237: sourcing /home/master/.local/share/nvim/plugged/vim-airline/plugin/airline.vim +102.485 000.031 000.031: sourcing /home/master/.local/share/nvim/plugged/vim-airline-themes/plugin/airline-themes.vim +103.232 001.993: VimEnter autocommands +103.235 000.003: UIEnter autocommands +103.236 000.001: before starting main loop +103.996 000.760: first screen update +103.998 000.002: --- NVIM STARTED --- + + +times in msec + clock self+sourced self: sourced script + clock elapsed: other lines + +000.009 000.009: --- NVIM STARTING --- +000.188 000.179: event init +000.251 000.063: early init +000.292 000.041: locale set +000.329 000.036: init first window +000.545 000.217: inits 1 +000.551 000.006: window checked +000.553 000.002: parsing arguments +000.937 000.026 000.026: require('vim.shared') +001.012 000.032 000.032: require('vim._meta') +001.014 000.073 000.041: require('vim._editor') +001.015 000.160 000.061: require('vim._init_packages') +001.016 000.302: init lua interpreter +001.515 000.500: expanding arguments +001.559 000.044: inits 2 +001.793 000.233: init highlight diff --git a/.config/nvim/vimspector/python.json b/.config/nvim/vimspector/python.json new file mode 100644 index 0000000..7fff9ab --- /dev/null +++ b/.config/nvim/vimspector/python.json @@ -0,0 +1,31 @@ +{ + "configurations": { + "Python: Launch": { + "adapter": "debugpy", + "filetypes": [ "python" ], + "configuration": { + "name": "python: Launch", + "type": "python", + "request": "launch", + "python": "$HOME/Others/virtualenvs/main/bin/python", + "program": "$file", + "stopOnEntry": true, + "debugOptions": [] + } + }, + "Python: Launch interactive": { + "adapter": "debugpy", + "filetypes": [ "python" ], + "configuration": { + "name": "python: Launch", + "type": "python", + "request": "launch", + "python": "$HOME/Others/virtualenvs/main/bin/python", + "program": "$file", + "console": "externalTerminal", + "stopOnEntry": true, + "debugOptions": [] + } + } + } +} |