mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
Compare commits
4 commits
8b7c15df50
...
4303d5fabe
Author | SHA1 | Date | |
---|---|---|---|
|
4303d5fabe | ||
|
c98d336b83 | ||
|
14db5e1902 | ||
|
d27aa86af0 |
8 changed files with 28 additions and 25 deletions
|
@ -9,7 +9,7 @@ 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) abort
|
||||||
let fg = s:colors[a:fg]
|
let fg = s:colors[a:fg]
|
||||||
let bg = s:colors[a:bg]
|
let bg = s:colors[a:bg]
|
||||||
return [fg.gui, bg.gui, fg.cterm, bg.cterm]
|
return [fg.gui, bg.gui, fg.cterm, bg.cterm]
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" The highlighting function {{{
|
" The highlighting function {{{
|
||||||
function s:is_number(value)
|
function! s:is_number(value) abort
|
||||||
return type(a:value) == v:t_number
|
return type(a:value) == v:t_number
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:colors = g:dotfiles_colorscheme_base16_colors
|
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 fg = {}
|
||||||
let bg = {}
|
let bg = {}
|
||||||
let attr = 'NONE'
|
let attr = 'NONE'
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
if !g:vim_ide
|
if !g:vim_ide
|
||||||
function IsCocEnabled()
|
function! IsCocEnabled() abort
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
finish
|
finish
|
||||||
|
@ -17,7 +17,7 @@ endif
|
||||||
" coc mappings are enabled
|
" coc mappings are enabled
|
||||||
let g:coc_filetypes = []
|
let g:coc_filetypes = []
|
||||||
|
|
||||||
function IsCocEnabled()
|
function! IsCocEnabled() abort
|
||||||
return index(g:coc_filetypes, &filetype) >= 0
|
return index(g:coc_filetypes, &filetype) >= 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ endif
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" CocFormat {{{
|
" CocFormat {{{
|
||||||
function s:CocFormat(range, line1, line2) abort
|
function! s:CocFormat(range, line1, line2) abort
|
||||||
if a:range == 0
|
if a:range == 0
|
||||||
call CocAction('format')
|
call CocAction('format')
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,7 +12,7 @@ set commentstring=//%s
|
||||||
|
|
||||||
" Indentination {{{
|
" Indentination {{{
|
||||||
|
|
||||||
function SetIndent(expandtab, shiftwidth)
|
function! SetIndent(expandtab, shiftwidth) abort
|
||||||
let &l:expandtab = a:expandtab
|
let &l:expandtab = a:expandtab
|
||||||
let &l:shiftwidth = str2nr(a:shiftwidth)
|
let &l:shiftwidth = str2nr(a:shiftwidth)
|
||||||
let &l:tabstop = &l:shiftwidth
|
let &l:tabstop = &l:shiftwidth
|
||||||
|
@ -78,7 +78,7 @@ set commentstring=//%s
|
||||||
nmap <silent> <leader>] m'yygccp`'j
|
nmap <silent> <leader>] m'yygccp`'j
|
||||||
nmap <silent> <leader>[ m'yygccP`'k
|
nmap <silent> <leader>[ m'yygccP`'k
|
||||||
|
|
||||||
function! PutOutput(cmd)
|
function! PutOutput(cmd) abort
|
||||||
let output = execute(a:cmd)
|
let output = execute(a:cmd)
|
||||||
execute "noswapfile pedit" "+" . fnameescape("setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile") fnameescape("preview://" . a:cmd)
|
execute "noswapfile pedit" "+" . fnameescape("setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile") fnameescape("preview://" . a:cmd)
|
||||||
wincmd P
|
wincmd P
|
||||||
|
@ -179,7 +179,7 @@ set commentstring=//%s
|
||||||
xnoremap ? <Esc>?\%><C-R>=line("'<")-1<CR>l\%<<C-R>=line("'>")+1<CR>l
|
xnoremap ? <Esc>?\%><C-R>=line("'<")-1<CR>l\%<<C-R>=line("'>")+1<CR>l
|
||||||
|
|
||||||
" * 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) abort
|
||||||
let tmp = @"
|
let 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')
|
||||||
|
|
|
@ -23,13 +23,13 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
||||||
|
|
||||||
nnoremap <leader>/ :<C-u>grep<space>
|
nnoremap <leader>/ :<C-u>grep<space>
|
||||||
|
|
||||||
function! s:grep_mapping_star_normal()
|
function! s:grep_mapping_star_normal() abort
|
||||||
let word = expand("<cword>")
|
let word = expand("<cword>")
|
||||||
if !empty(word)
|
if !empty(word)
|
||||||
call feedkeys(":\<C-u>grep " . shellescape('\b' . word . '\b', 1), 'n')
|
call feedkeys(":\<C-u>grep " . shellescape('\b' . word . '\b', 1), 'n')
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
function! s:grep_mapping_star_visual()
|
function! s:grep_mapping_star_visual() abort
|
||||||
let tmp = @"
|
let tmp = @"
|
||||||
normal! y
|
normal! y
|
||||||
call feedkeys(":\<C-u>grep " . shellescape(@", 1), 'n')
|
call feedkeys(":\<C-u>grep " . shellescape(@", 1), 'n')
|
||||||
|
@ -71,7 +71,7 @@ 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() abort
|
||||||
let filetype = &filetype
|
let filetype = &filetype
|
||||||
diffthis
|
diffthis
|
||||||
vnew | read # | normal! ggdd
|
vnew | read # | normal! ggdd
|
||||||
|
@ -84,7 +84,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
||||||
|
|
||||||
" Reveal {{{
|
" Reveal {{{
|
||||||
" Reveal file in the system file explorer
|
" Reveal file in the system file explorer
|
||||||
function s:Reveal(path)
|
function! s:Reveal(path) abort
|
||||||
if has('macunix')
|
if has('macunix')
|
||||||
" only macOS has functionality to really 'reveal' a file, that is, to open
|
" only macOS has functionality to really 'reveal' a file, that is, to open
|
||||||
" its parent directory in Finder and select this file
|
" 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 {{{
|
" Open {{{
|
||||||
" opens file or URL with a system program
|
" 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
|
" 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
|
" 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
|
" 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
|
" 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
|
" 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(...) abort
|
||||||
for glob in a:000
|
for glob in a:000
|
||||||
for name in glob(glob, 0, 1)
|
for name in glob(glob, 0, 1)
|
||||||
execute 'edit' fnameescape(name)
|
execute 'edit' fnameescape(name)
|
||||||
|
@ -131,7 +131,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
||||||
|
|
||||||
" DragOut {{{
|
" DragOut {{{
|
||||||
" Shows a window for draging (-and-dropping) the currently opened file out.
|
" 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 empty(a:path) | return | endif
|
||||||
if !executable('dragon-drag-and-drop')
|
if !executable('dragon-drag-and-drop')
|
||||||
echoerr "Please install <https://github.com/mwh/dragon> for the DragOut command to work."
|
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) {{{
|
" on save (BufWritePre) {{{
|
||||||
|
|
||||||
function s:IsUrl(str)
|
function! s:IsUrl(str) abort
|
||||||
return a:str =~# '\v^\w+://'
|
return a:str =~# '\v^\w+://'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" 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() abort
|
||||||
let file = expand('<afile>')
|
let 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(file)
|
||||||
|
@ -165,7 +165,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" fix whitespace {{{
|
" fix whitespace {{{
|
||||||
function s:FixWhitespaceOnSave()
|
function! s:FixWhitespaceOnSave() abort
|
||||||
let pos = getpos('.')
|
let pos = getpos('.')
|
||||||
" remove trailing whitespace
|
" remove trailing whitespace
|
||||||
keeppatterns %s/\s\+$//e
|
keeppatterns %s/\s\+$//e
|
||||||
|
@ -177,7 +177,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
||||||
|
|
||||||
" 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() abort
|
||||||
let file = expand('<afile>')
|
let file = expand('<afile>')
|
||||||
if IsCocEnabled() && !s:IsUrl(file) && index(g:coc_format_on_save_ignore, &filetype) < 0
|
if IsCocEnabled() && !s:IsUrl(file) && index(g:coc_format_on_save_ignore, &filetype) < 0
|
||||||
silent CocFormat
|
silent CocFormat
|
||||||
|
@ -185,7 +185,7 @@ nnoremap <silent><expr> <CR> empty(&buftype) ? ":write<bar>wall\<CR>" : "\<CR>"
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
function s:OnSave()
|
function! s:OnSave() abort
|
||||||
call s:FixWhitespaceOnSave()
|
call s:FixWhitespaceOnSave()
|
||||||
call s:FormatOnSave()
|
call s:FormatOnSave()
|
||||||
call s:CreateDirOnSave()
|
call s:CreateDirOnSave()
|
||||||
|
|
|
@ -40,7 +40,7 @@ endif
|
||||||
set confirm
|
set confirm
|
||||||
|
|
||||||
" 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 cmd = a:cmd
|
||||||
if &modified
|
if &modified
|
||||||
" <https://github.com/neovim/neovim/blob/a282a177d3320db25fa8f854cbcdbe0bc6abde7f/src/nvim/ex_cmds2.c#L1400>
|
" <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
|
" Based on <https://stackoverflow.com/a/1330556/12005228>, inspired by
|
||||||
" <https://gist.github.com/romainl/f7e2e506dc4d7827004e4994f1be2df6>.
|
" <https://gist.github.com/romainl/f7e2e506dc4d7827004e4994f1be2df6>.
|
||||||
" But apparently `vimgrep /pattern/ %` can be used instead?
|
" 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 pattern = substitute(a:pattern, "/.*$", "", "")
|
||||||
let matches = []
|
let matches = []
|
||||||
execute "g" . (a:bang ? "!" : "") . "/" . pattern . "/call add(matches, expand(\"%\").\":\".line(\".\").\":\".col(\".\").\":\".getline(\".\"))"
|
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
|
fi
|
||||||
|
|
||||||
alias gtime="command time -v"
|
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
|
# strangely enough, Zsh doesn't save command history by default
|
||||||
HISTFILE="${HISTFILE:-$HOME/.zsh_history}"
|
HISTFILE="${HISTFILE:-$HOME/.zsh_history}"
|
||||||
# max number of entries stored in memory
|
# max number of entries stored in memory
|
||||||
HISTSIZE=50000
|
HISTSIZE=100000
|
||||||
# max number of entries in the HISTFILE
|
# max number of entries in the HISTFILE
|
||||||
SAVEHIST=10000
|
SAVEHIST=80000
|
||||||
# record timestamps in the history
|
# record timestamps in the history
|
||||||
setopt extended_history
|
setopt extended_history
|
||||||
# delete duplicates first when HISTFILE size exceeds HISTSIZE
|
# delete duplicates first when HISTFILE size exceeds HISTSIZE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue