Compare commits

..

No commits in common. "5e0633ead5622df7a5300ca8b825ff40086257d8" and "7867a5ddd9bb3b193e24a49fbd51d2d4fdd25342" have entirely different histories.

7 changed files with 73 additions and 73 deletions

View file

@ -10,9 +10,9 @@ let s:palette = {
let s:colors = g:dotfiles_colorscheme_base16_colors let s:colors = g:dotfiles_colorscheme_base16_colors
function! s:base16_color(fg, bg) function! s:base16_color(fg, bg)
let fg = s:colors[a:fg] let l:fg = s:colors[a:fg]
let bg = s:colors[a:bg] let l:bg = s:colors[a:bg]
return [fg.gui, bg.gui, fg.cterm, bg.cterm] return [l:fg.gui, l:bg.gui, l:fg.cterm, l:bg.cterm]
endfunction endfunction
let s:section_a = s:base16_color(0x1, 0xB) let s:section_a = s:base16_color(0x1, 0xB)

View file

@ -2,48 +2,48 @@
" A motion for moving over enclosing indentation blocks. Primarily intended " A motion for moving over enclosing indentation blocks. Primarily intended
" for reverse-engineering CrossCode. " for reverse-engineering CrossCode.
function dotfiles#indent_motion#run(direction) abort function dotfiles#indent_motion#run(direction)
let cursor_linenr = line(".") let l:cursor_linenr = line(".")
let max_linenr = line("$") let l:max_linenr = line("$")
let retry = 0 let l:retry = 0
while retry <# 2 while l:retry <# 2
let retry += 1 let l:retry += 1
let base_linenr = cursor_linenr let l:base_linenr = l:cursor_linenr
let base_indent = 0 let l:base_indent = 0
while 1 <=# base_linenr && base_linenr <=# max_linenr while 1 <=# l:base_linenr && l:base_linenr <=# l:max_linenr
let base_indent = dotfiles#indent_motion#indent_level_of(base_linenr) let l:base_indent = dotfiles#indent_motion#indent_level_of(l:base_linenr)
if base_indent >=# 0 if l:base_indent >=# 0
break break
endif endif
let base_linenr += a:direction let l:base_linenr += a:direction
endwhile endwhile
let target_linenr = base_linenr let l:target_linenr = l:base_linenr
let curr_linenr = base_linenr + a:direction let l:curr_linenr = l:base_linenr + a:direction
let prev_indent = base_indent let l:prev_indent = l:base_indent
while 1 <=# curr_linenr && curr_linenr <=# max_linenr while 1 <=# l:curr_linenr && l:curr_linenr <=# l:max_linenr
let indent = dotfiles#indent_motion#indent_level_of(curr_linenr) let l:indent = dotfiles#indent_motion#indent_level_of(l:curr_linenr)
if indent >=# 0 if l:indent >=# 0
if indent <# base_indent if l:indent <# l:base_indent
break break
else else
let target_linenr = curr_linenr let l:target_linenr = l:curr_linenr
endif endif
elseif base_indent ==# 0 && prev_indent ==# 0 elseif l:base_indent ==# 0 && l:prev_indent ==# 0
break break
endif endif
let prev_indent = indent let l:prev_indent = l:indent
let curr_linenr += a:direction let l:curr_linenr += a:direction
endwhile endwhile
if target_linenr ==# cursor_linenr if l:target_linenr ==# l:cursor_linenr
let cursor_linenr += a:direction let l:cursor_linenr += a:direction
if 1 <=# cursor_linenr && cursor_linenr <=# max_linenr if 1 <=# l:cursor_linenr && l:cursor_linenr <=# l:max_linenr
continue continue
endif endif
endif endif
@ -51,7 +51,7 @@ function dotfiles#indent_motion#run(direction) abort
break break
endwhile endwhile
execute "normal! " . target_linenr . "G^" execute "normal! " . l:target_linenr . "G^"
endfunction endfunction
" <https://github.com/kana/vim-textobj-indent/blob/deb76867c302f933c8f21753806cbf2d8461b548/autoload/textobj/indent.vim#L120-L127> " <https://github.com/kana/vim-textobj-indent/blob/deb76867c302f933c8f21753806cbf2d8461b548/autoload/textobj/indent.vim#L120-L127>

View file

@ -1,6 +1,6 @@
function dotfiles#utils#array_remove_element(array, element) function dotfiles#utils#array_remove_element(array, element)
let index = index(a:array, a:element) let l:index = index(a:array, a:element)
if index >= 0 if l:index >= 0
call remove(a:array, index) call remove(a:array, l:index)
endif endif
endfunction endfunction

View file

@ -24,23 +24,23 @@
let s:colors = g:dotfiles_colorscheme_base16_colors let s:colors = g:dotfiles_colorscheme_base16_colors
function s:hi(group, fg, bg, attr, guisp) function s:hi(group, fg, bg, attr, guisp)
let args = '' let l:args = ''
if a:fg isnot '' if a:fg isnot ''
let fg = s:is_number(a:fg) ? s:colors[a:fg] : {'gui': a:fg, 'cterm': a:fg} let l:fg = s:is_number(a:fg) ? s:colors[a:fg] : {'gui': a:fg, 'cterm': a:fg}
let args .= ' guifg=' . fg.gui . ' ctermfg=' . fg.cterm let l:args .= ' guifg=' . l:fg.gui . ' ctermfg=' . l:fg.cterm
endif endif
if a:bg isnot '' if a:bg isnot ''
let bg = s:is_number(a:bg) ? s:colors[a:bg] : {'gui': a:bg, 'cterm': a:bg} let l:bg = s:is_number(a:bg) ? s:colors[a:bg] : {'gui': a:bg, 'cterm': a:bg}
let args .= ' guibg=' . bg.gui . ' ctermbg=' . bg.cterm let l:args .= ' guibg=' . l:bg.gui . ' ctermbg=' . l:bg.cterm
endif endif
if a:attr isnot '' if a:attr isnot ''
let args .= ' gui=' . a:attr . ' cterm=' . a:attr let l:args .= ' gui=' . a:attr . ' cterm=' . a:attr
endif endif
if a:guisp isnot '' if a:guisp isnot ''
let guisp = s:is_number(a:guisp) ? s:colors[a:guisp].gui : a:guisp let l:guisp = s:is_number(a:guisp) ? s:colors[a:guisp].gui : a:guisp
let args .= ' guisp=' . guisp let l:args .= ' guisp=' . l:guisp
endif endif
exec 'hi' a:group args exec 'hi' a:group l:args
endfunction endfunction
" }}} " }}}

View file

@ -163,10 +163,10 @@ set commentstring=//%s
" * and # in the Visual mode will search the selected text " * and # in the Visual mode will search the selected text
function! s:VisualStarSearch(search_cmd) function! s:VisualStarSearch(search_cmd)
let tmp = @" let l:tmp = @"
normal! y normal! y
let @/ = '\V' . substitute(escape(@", a:search_cmd . '\'), '\n', '\\n', 'g') let @/ = '\V' . substitute(escape(@", a:search_cmd . '\'), '\n', '\\n', 'g')
let @" = tmp let @" = l:tmp
endfunction endfunction
" HACK: my mappings are added on VimEnter to override mappings from the " HACK: my mappings are added on VimEnter to override mappings from the
" vim-indexed-search plugin " vim-indexed-search plugin

View file

@ -52,12 +52,12 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
" DiffWithSaved {{{ " DiffWithSaved {{{
" Compare current buffer with the actual (saved) file on disk " Compare current buffer with the actual (saved) file on disk
function s:DiffWithSaved() function s:DiffWithSaved()
let filetype = &filetype let l:filetype = &filetype
diffthis diffthis
vnew | read # | normal! ggdd vnew | read # | normal! ggdd
diffthis diffthis
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile readonly nomodifiable setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile readonly nomodifiable
let &filetype = filetype let &filetype = l:filetype
endfunction endfunction
command DiffWithSaved call s:DiffWithSaved() command DiffWithSaved call s:DiffWithSaved()
" }}} " }}}
@ -100,9 +100,9 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
" argument list, so it doesn't play well with Obsession.vim because it " argument list, so it doesn't play well with Obsession.vim because it
" saves the argument list in the session file. " saves the argument list in the session file.
function s:EditGlob(...) function s:EditGlob(...)
for glob in a:000 for l:glob in a:000
for name in glob(glob, 0, 1) for l:name in glob(l:glob, 0, 1)
execute 'edit' fnameescape(name) execute 'edit' fnameescape(l:name)
endfor endfor
endfor endfor
endfunction endfunction
@ -135,31 +135,31 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
" create directory {{{ " create directory {{{
" Creates the parent directory of the file if it doesn't exist " Creates the parent directory of the file if it doesn't exist
function s:CreateDirOnSave() function s:CreateDirOnSave()
let file = expand('<afile>') let l:file = expand('<afile>')
" check if this is a regular file and its path is not a URL " check if this is a regular file and its path is not a URL
if empty(&buftype) && !s:IsUrl(file) if empty(&buftype) && !s:IsUrl(l:file)
let dir = fnamemodify(file, ':h') let l:dir = fnamemodify(l:file, ':h')
if !isdirectory(dir) | call mkdir(dir, 'p') | endif if !isdirectory(l:dir) | call mkdir(l:dir, 'p') | endif
endif endif
endfunction endfunction
" }}} " }}}
" fix whitespace {{{ " fix whitespace {{{
function s:FixWhitespaceOnSave() function s:FixWhitespaceOnSave()
let pos = getpos('.') let l:pos = getpos('.')
" remove trailing whitespace " remove trailing whitespace
keeppatterns %s/\s\+$//e keeppatterns %s/\s\+$//e
" remove trailing newlines " remove trailing newlines
keeppatterns %s/\($\n\s*\)\+\%$//e keeppatterns %s/\($\n\s*\)\+\%$//e
call setpos('.', pos) call setpos('.', l:pos)
endfunction endfunction
" }}} " }}}
" auto-format with Coc.nvim {{{ " auto-format with Coc.nvim {{{
let g:coc_format_on_save_ignore = [] let g:coc_format_on_save_ignore = []
function s:FormatOnSave() function s:FormatOnSave()
let file = expand('<afile>') let l:file = expand('<afile>')
if IsCocEnabled() && !s:IsUrl(file) && index(g:coc_format_on_save_ignore, &filetype) < 0 if IsCocEnabled() && !s:IsUrl(l:file) && index(g:coc_format_on_save_ignore, &filetype) < 0
silent CocFormat silent CocFormat
endif endif
endfunction endfunction

View file

@ -41,18 +41,18 @@ endif
" Bbye with confirmation, or fancy buffer closer {{{ " Bbye with confirmation, or fancy buffer closer {{{
function s:CloseBuffer(cmd) abort function s:CloseBuffer(cmd) abort
let cmd = a:cmd let l:cmd = a:cmd
if &modified if &modified
let answer = confirm("Save changes?", "&Yes\n&No\n&Cancel") let l:answer = confirm("Save changes?", "&Yes\n&No\n&Cancel")
if answer ==# 1 " Yes if l:answer ==# 1 " Yes
write write
elseif answer ==# 2 " No elseif l:answer ==# 2 " No
let cmd .= '!' let l:cmd .= '!'
else " Cancel/Other else " Cancel/Other
return return
endif endif
endif endif
execute cmd execute l:cmd
endfunction endfunction
" }}} " }}}
@ -108,19 +108,19 @@ endif
let g:airline#extensions#tabline#left_alt_sep = '' let g:airline#extensions#tabline#left_alt_sep = ''
function StatusLine_filesize() function StatusLine_filesize()
let bytes = getfsize(expand('%')) let l:bytes = getfsize(expand('%'))
if bytes < 0 | return '' | endif if l:bytes < 0 | return '' | endif
let factor = 1 let l:factor = 1
for unit in ['B', 'K', 'M', 'G'] for l:unit in ['B', 'K', 'M', 'G']
let next_factor = factor * 1024 let l:next_factor = l:factor * 1024
if bytes < next_factor if l:bytes < l:next_factor
let number_str = printf('%.2f', (bytes * 1.0) / factor) let l:number_str = printf('%.2f', (l:bytes * 1.0) / l:factor)
" remove trailing zeros " remove trailing zeros
let number_str = substitute(number_str, '\v\.?0+$', '', '') let l:number_str = substitute(l:number_str, '\v\.?0+$', '', '')
return number_str . unit return l:number_str . l:unit
endif endif
let factor = next_factor let l:factor = l:next_factor
endfor endfor
endfunction endfunction
call airline#parts#define('filesize', { 'function': 'StatusLine_filesize' }) call airline#parts#define('filesize', { 'function': 'StatusLine_filesize' })