mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
Merge pull request #296 from dmitmel/master
[pull] master from dmitmel:master
This commit is contained in:
commit
4303d5fabe
8 changed files with 28 additions and 25 deletions
|
@ -9,7 +9,7 @@ let s:palette = {
|
|||
\ }
|
||||
|
||||
let s:colors = g:dotfiles_colorscheme_base16_colors
|
||||
function! s:base16_color(fg, bg)
|
||||
function! s:base16_color(fg, bg) abort
|
||||
let fg = s:colors[a:fg]
|
||||
let bg = s:colors[a:bg]
|
||||
return [fg.gui, bg.gui, fg.cterm, bg.cterm]
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
" }}}
|
||||
|
||||
" The highlighting function {{{
|
||||
function s:is_number(value)
|
||||
function! s:is_number(value) abort
|
||||
return type(a:value) == v:t_number
|
||||
endfunction
|
||||
|
||||
let s:colors = g:dotfiles_colorscheme_base16_colors
|
||||
function s:hi(group, fg, bg, attr, sp)
|
||||
function! s:hi(group, fg, bg, attr, sp) abort
|
||||
let fg = {}
|
||||
let bg = {}
|
||||
let attr = 'NONE'
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
" }}}
|
||||
|
||||
if !g:vim_ide
|
||||
function IsCocEnabled()
|
||||
function! IsCocEnabled() abort
|
||||
return 0
|
||||
endfunction
|
||||
finish
|
||||
|
@ -17,7 +17,7 @@ endif
|
|||
" coc mappings are enabled
|
||||
let g:coc_filetypes = []
|
||||
|
||||
function IsCocEnabled()
|
||||
function! IsCocEnabled() abort
|
||||
return index(g:coc_filetypes, &filetype) >= 0
|
||||
endfunction
|
||||
|
||||
|
@ -64,7 +64,7 @@ endif
|
|||
" }}}
|
||||
|
||||
" CocFormat {{{
|
||||
function s:CocFormat(range, line1, line2) abort
|
||||
function! s:CocFormat(range, line1, line2) abort
|
||||
if a:range == 0
|
||||
call CocAction('format')
|
||||
else
|
||||
|
|
|
@ -12,7 +12,7 @@ set commentstring=//%s
|
|||
|
||||
" Indentination {{{
|
||||
|
||||
function SetIndent(expandtab, shiftwidth)
|
||||
function! SetIndent(expandtab, shiftwidth) abort
|
||||
let &l:expandtab = a:expandtab
|
||||
let &l:shiftwidth = str2nr(a:shiftwidth)
|
||||
let &l:tabstop = &l:shiftwidth
|
||||
|
@ -78,7 +78,7 @@ set commentstring=//%s
|
|||
nmap <silent> <leader>] m'yygccp`'j
|
||||
nmap <silent> <leader>[ m'yygccP`'k
|
||||
|
||||
function! PutOutput(cmd)
|
||||
function! PutOutput(cmd) abort
|
||||
let output = execute(a:cmd)
|
||||
execute "noswapfile pedit" "+" . fnameescape("setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile") fnameescape("preview://" . a:cmd)
|
||||
wincmd P
|
||||
|
@ -179,7 +179,7 @@ set commentstring=//%s
|
|||
xnoremap ? <Esc>?\%><C-R>=line("'<")-1<CR>l\%<<C-R>=line("'>")+1<CR>l
|
||||
|
||||
" * and # in the Visual mode will search the selected text
|
||||
function! s:VisualStarSearch(search_cmd)
|
||||
function! s:VisualStarSearch(search_cmd) abort
|
||||
let tmp = @"
|
||||
normal! y
|
||||
let @/ = '\V' . substitute(escape(@", a:search_cmd . '\'), '\n', '\\n', 'g')
|
||||
|
|
|
@ -23,13 +23,13 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
nnoremap <leader>/ :<C-u>grep<space>
|
||||
|
||||
function! s:grep_mapping_star_normal()
|
||||
function! s:grep_mapping_star_normal() abort
|
||||
let word = expand("<cword>")
|
||||
if !empty(word)
|
||||
call feedkeys(":\<C-u>grep " . shellescape('\b' . word . '\b', 1), 'n')
|
||||
endif
|
||||
endfunction
|
||||
function! s:grep_mapping_star_visual()
|
||||
function! s:grep_mapping_star_visual() abort
|
||||
let tmp = @"
|
||||
normal! y
|
||||
call feedkeys(":\<C-u>grep " . shellescape(@", 1), 'n')
|
||||
|
@ -71,7 +71,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
" DiffWithSaved {{{
|
||||
" Compare current buffer with the actual (saved) file on disk
|
||||
function s:DiffWithSaved()
|
||||
function! s:DiffWithSaved() abort
|
||||
let filetype = &filetype
|
||||
diffthis
|
||||
vnew | read # | normal! ggdd
|
||||
|
@ -84,7 +84,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
" Reveal {{{
|
||||
" Reveal file in the system file explorer
|
||||
function s:Reveal(path)
|
||||
function! s:Reveal(path) abort
|
||||
if has('macunix')
|
||||
" only macOS has functionality to really 'reveal' a file, that is, to open
|
||||
" its parent directory in Finder and select this file
|
||||
|
@ -101,7 +101,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
" Open {{{
|
||||
" opens file or URL with a system program
|
||||
function s:Open(path)
|
||||
function! s:Open(path) abort
|
||||
" HACK: 2nd parameter of this function is called 'remote', it tells
|
||||
" whether to open a remote (1) or local (0) file. However, it doesn't work
|
||||
" as expected in this context, because it uses the 'gf' command if it's
|
||||
|
@ -119,7 +119,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
" Yes, I know about the existence of :args, however it modifies the
|
||||
" argument list, so it doesn't play well with Obsession.vim because it
|
||||
" saves the argument list in the session file.
|
||||
function s:EditGlob(...)
|
||||
function! s:EditGlob(...) abort
|
||||
for glob in a:000
|
||||
for name in glob(glob, 0, 1)
|
||||
execute 'edit' fnameescape(name)
|
||||
|
@ -131,7 +131,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
" DragOut {{{
|
||||
" Shows a window for draging (-and-dropping) the currently opened file out.
|
||||
function s:DragOut(path)
|
||||
function! s:DragOut(path) abort
|
||||
if empty(a:path) | return | endif
|
||||
if !executable('dragon-drag-and-drop')
|
||||
echoerr "Please install <https://github.com/mwh/dragon> for the DragOut command to work."
|
||||
|
@ -148,13 +148,13 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
" on save (BufWritePre) {{{
|
||||
|
||||
function s:IsUrl(str)
|
||||
function! s:IsUrl(str) abort
|
||||
return a:str =~# '\v^\w+://'
|
||||
endfunction
|
||||
|
||||
" create directory {{{
|
||||
" Creates the parent directory of the file if it doesn't exist
|
||||
function s:CreateDirOnSave()
|
||||
function! s:CreateDirOnSave() abort
|
||||
let file = expand('<afile>')
|
||||
" check if this is a regular file and its path is not a URL
|
||||
if empty(&buftype) && !s:IsUrl(file)
|
||||
|
@ -165,7 +165,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
" }}}
|
||||
|
||||
" fix whitespace {{{
|
||||
function s:FixWhitespaceOnSave()
|
||||
function! s:FixWhitespaceOnSave() abort
|
||||
let pos = getpos('.')
|
||||
" remove trailing whitespace
|
||||
keeppatterns %s/\s\+$//e
|
||||
|
@ -177,7 +177,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
|
||||
" auto-format with Coc.nvim {{{
|
||||
let g:coc_format_on_save_ignore = []
|
||||
function s:FormatOnSave()
|
||||
function! s:FormatOnSave() abort
|
||||
let file = expand('<afile>')
|
||||
if IsCocEnabled() && !s:IsUrl(file) && index(g:coc_format_on_save_ignore, &filetype) < 0
|
||||
silent CocFormat
|
||||
|
@ -185,7 +185,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
|||
endfunction
|
||||
" }}}
|
||||
|
||||
function s:OnSave()
|
||||
function! s:OnSave() abort
|
||||
call s:FixWhitespaceOnSave()
|
||||
call s:FormatOnSave()
|
||||
call s:CreateDirOnSave()
|
||||
|
|
|
@ -40,7 +40,7 @@ endif
|
|||
set confirm
|
||||
|
||||
" Bbye with confirmation, or fancy buffer closer {{{
|
||||
function s:CloseBuffer(cmd) abort
|
||||
function! s:CloseBuffer(cmd) abort
|
||||
let cmd = a:cmd
|
||||
if &modified
|
||||
" <https://github.com/neovim/neovim/blob/a282a177d3320db25fa8f854cbcdbe0bc6abde7f/src/nvim/ex_cmds2.c#L1400>
|
||||
|
@ -141,7 +141,7 @@ endif
|
|||
" Based on <https://stackoverflow.com/a/1330556/12005228>, inspired by
|
||||
" <https://gist.github.com/romainl/f7e2e506dc4d7827004e4994f1be2df6>.
|
||||
" But apparently `vimgrep /pattern/ %` can be used instead?
|
||||
function! s:CmdGlobal(pattern, bang)
|
||||
function! s:CmdGlobal(pattern, bang) abort
|
||||
let pattern = substitute(a:pattern, "/.*$", "", "")
|
||||
let matches = []
|
||||
execute "g" . (a:bang ? "!" : "") . "/" . pattern . "/call add(matches, expand(\"%\").\":\".line(\".\").\":\".col(\".\").\":\".getline(\".\"))"
|
||||
|
|
|
@ -120,3 +120,6 @@ if command_exists dragon-drag-and-drop && ! command_exists dragon; then
|
|||
fi
|
||||
|
||||
alias gtime="command time -v"
|
||||
|
||||
# Inspired by <https://github.com/junghans/cwdiff/blob/de56a73f37eb72edfb78ea610798a5744b8dcf10/cwdiff#L54-L61>.
|
||||
alias cwdiff='wdiff --start-delete="${fg[red]}[-" --end-delete="-]${reset_color}" --start-insert="${fg[green]}{+" --end-insert "+}${reset_color}"'
|
||||
|
|
|
@ -40,9 +40,9 @@ setopt complete_in_word
|
|||
# strangely enough, Zsh doesn't save command history by default
|
||||
HISTFILE="${HISTFILE:-$HOME/.zsh_history}"
|
||||
# max number of entries stored in memory
|
||||
HISTSIZE=50000
|
||||
HISTSIZE=100000
|
||||
# max number of entries in the HISTFILE
|
||||
SAVEHIST=10000
|
||||
SAVEHIST=80000
|
||||
# record timestamps in the history
|
||||
setopt extended_history
|
||||
# delete duplicates first when HISTFILE size exceeds HISTSIZE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue