diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-01-15 11:44:13 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-01-15 11:44:13 +0100 |
| commit | 307df21222316d35f32e1597824283797aa6a74c (patch) | |
| tree | bf6a73f1be8f76cfcb95cde4e48a8ada9ff6bce4 | |
| parent | 137fd617030c85e9eef6858d9d5cd63cdc306ff6 (diff) | |
update
| -rw-r--r-- | .bashrc | 5 | ||||
| -rwxr-xr-x | .vim/pack/mvertes/install.sh | 17 | ||||
| -rw-r--r-- | .vim/plugin/cscope_maps.vim | 167 | ||||
| -rw-r--r-- | .vimrc | 105 | ||||
| -rwxr-xr-x | bin/cursor | 2 | ||||
| -rwxr-xr-x | bin/tc | 14 | ||||
| -rwxr-xr-x | bin/tf | 5 |
7 files changed, 75 insertions, 240 deletions
@@ -5,11 +5,13 @@ export PAGER=less export EDITOR=vim -export HISTIGNORE=2fa:ls:ps:history +export HISTIGNORE=2fa:ls:ps:history:tc:cursor export HISTCONTROL=ignoreboth:erasedups # no start space and duplicate entries export HISTSIZE=100000 # big big history export HISTFILESIZE=100000 # big big history shopt -s histappend # append to history, don't overwrite it +shopt -s globstar +shopt -s dotglob # Disable Ctrl-S stty -ixon @@ -107,7 +109,6 @@ alias y='rlwrap -pblue yaegi' alias dy='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi' alias wai='~/go/src/github.co/traefik/whoami/whoami' -alias ogc='open -a "Google Chrome" --args --silent-debugger-extension-api' # yaegi debug export YAEGI_DOT_CMD="dotty -" export YAEGI_UNSAFE=1 diff --git a/.vim/pack/mvertes/install.sh b/.vim/pack/mvertes/install.sh index 37b1784..fa4f35c 100755 --- a/.vim/pack/mvertes/install.sh +++ b/.vim/pack/mvertes/install.sh @@ -2,12 +2,14 @@ plugins=' git@github.com:mvertes/vimki -git@github.com:fatih/vim-go -git@github.com:othree/xml.vim +#git@github.com:fatih/vim-go +#git@github.com:othree/xml.vim git@github.com:junegunn/fzf.vim -git@github.com:rust-lang/rust.vim -git@github.com:preservim/nerdtree -git@github.com:tpope/vim-fugitive +#git@github.com:rust-lang/rust.vim +#git@github.com:preservim/nerdtree +#git@github.com:tpope/vim-fugitive +git@github.com:prabirshrestha/vim-lsp +#git@github.com:mattn/vim-lsp-settings ' ht='test -d doc && vim -c "helptags doc" -c "q"' @@ -15,12 +17,13 @@ mkdir -p start cd start for p in $plugins do + case $p in ('#'*) continue ;; esac n=${p##*/} if [ -d "$n" ]; then echo "update $p" - (cd $n && git pull && eval "$ht") + (cd "$n" && git pull && eval "$ht") else echo "init $p" - (git clone $p && cd "$n" && eval "$ht") + (git clone "$p" && cd "$n" && eval "$ht") fi done diff --git a/.vim/plugin/cscope_maps.vim b/.vim/plugin/cscope_maps.vim deleted file mode 100644 index abcae71..0000000 --- a/.vim/plugin/cscope_maps.vim +++ /dev/null @@ -1,167 +0,0 @@ -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" CSCOPE settings for vim -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" -" This file contains some boilerplate settings for vim's cscope interface, -" plus some keyboard mappings that I've found useful. -" -" USAGE: -" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a -" 'plugin' directory in some other directory that is in your -" 'runtimepath'. -" -" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from -" your ~/.vimrc file (or cut and paste it into your .vimrc). -" -" NOTE: -" These key maps use multiple keystrokes (2 or 3 keys). If you find that vim -" keeps timing you out before you can complete them, try changing your timeout -" settings, as explained below. -" -" Happy cscoping, -" -" Jason Duell jduell@alumni.princeton.edu 2002/3/7 -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - - -" This tests to see if vim was configured with the '--enable-cscope' option -" when it was compiled. If it wasn't, time to recompile vim... -if has("cscope") - - """"""""""""" Standard cscope/vim boilerplate - - " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' - set cscopetag - - " check cscope for definition of a symbol before checking ctags: set to 1 - " if you want the reverse search order. - set csto=0 - - " add any cscope database in current directory - if filereadable("cscope.out") - cs add cscope.out - " else add the database pointed to by environment variable - elseif $CSCOPE_DB != "" - cs add $CSCOPE_DB - endif - - " show msg when any other cscope db added - set cscopeverbose - - - """"""""""""" My cscope/vim key mappings - " - " The following maps all invoke one of the following cscope search types: - " - " 's' symbol: find all references to the token under cursor - " 'g' global: find global definition(s) of the token under cursor - " 'c' calls: find all calls to the function name under cursor - " 't' text: find all instances of the text under cursor - " 'e' egrep: egrep search for the word under cursor - " 'f' file: open the filename under cursor - " 'i' includes: find files that include the filename under cursor - " 'd' called: find functions that function under cursor calls - " - " Below are three sets of the maps: one set that just jumps to your - " search result, one that splits the existing vim window horizontally and - " diplays your search result in the new window, and one that does the same - " thing, but does a vertical split instead (vim 6 only). - " - " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's - " unlikely that you need their default mappings (CTRL-\'s default use is - " as part of CTRL-\ CTRL-N typemap, which basically just does the same - " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use). - " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all - " of these maps to use other keys. One likely candidate is 'CTRL-_' - " (which also maps to CTRL-/, which is easier to type). By default it is - " used to switch between Hebrew and English keyboard mode. - " - " All of the maps involving the <cfile> macro use '^<cfile>$': this is so - " that searches over '#include <time.h>" return only references to - " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all - " files that contain 'time.h' as part of their name). - - - " To do the first type of search, hit 'CTRL-\', followed by one of the - " cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope - " search will be displayed in the current window. You can use CTRL-T to - " go back to where you were before the search. - " - - " MV: replace C-\ by C-, - nmap <C-,>s :cs find s <C-R>=expand("<cword>")<CR><CR> - nmap <C-,>g :cs find g <C-R>=expand("<cword>")<CR><CR> - nmap <C-,>c :cs find c <C-R>=expand("<cword>")<CR><CR> - nmap <C-,>t :cs find t <C-R>=expand("<cword>")<CR><CR> - nmap <C-,>e :cs find e <C-R>=expand("<cword>")<CR><CR> - nmap <C-,>f :cs find f <C-R>=expand("<cfile>")<CR><CR> - nmap <C-,>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> - nmap <C-,>d :cs find d <C-R>=expand("<cword>")<CR><CR> - - - " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type - " makes the vim window split horizontally, with search result displayed in - " the new window. - " - " (Note: earlier versions of vim may not have the :scs command, but it - " can be simulated roughly via: - " nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR> - - " MV: replace C-@ by C-; - nmap <C-;>s :scs find s <C-R>=expand("<cword>")<CR><CR> - nmap <C-;>g :scs find g <C-R>=expand("<cword>")<CR><CR> - nmap <C-;>c :scs find c <C-R>=expand("<cword>")<CR><CR> - nmap <C-;>t :scs find t <C-R>=expand("<cword>")<CR><CR> - nmap <C-;>e :scs find e <C-R>=expand("<cword>")<CR><CR> - nmap <C-;>f :scs find f <C-R>=expand("<cfile>")<CR><CR> - nmap <C-;>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> - nmap <C-;>d :scs find d <C-R>=expand("<cword>")<CR><CR> - - - " Hitting CTRL-space *twice* before the search type does a vertical - " split instead of a horizontal one (vim 6 and up only) - " - " (Note: you may wish to put a 'set splitright' in your .vimrc - " if you prefer the new window on the right instead of the left - - nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR> - nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR> - nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR> - nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR> - nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR> - nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR> - nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> - nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR> - - - """"""""""""" key map timeouts - " - " By default Vim will only wait 1 second for each keystroke in a mapping. - " You may find that too short with the above typemaps. If so, you should - " either turn off mapping timeouts via 'notimeout'. - " - "set notimeout - " - " Or, you can keep timeouts, by uncommenting the timeoutlen line below, - " with your own personal favorite value (in milliseconds): - " - "set timeoutlen=4000 - " - " Either way, since mapping timeout settings by default also set the - " timeouts for multicharacter 'keys codes' (like <F1>), you should also - " set ttimeout and ttimeoutlen: otherwise, you will experience strange - " delays as vim waits for a keystroke after you hit ESC (it will be - " waiting to see if the ESC is actually part of a key code like <F1>). - " - "set ttimeout - " - " personally, I find a tenth of a second to work well for key code - " timeouts. If you experience problems and have a slow terminal or network - " connection, set it higher. If you don't set ttimeoutlen, the value for - " timeoutlent (default: 1000 = 1 second, which is sluggish) is used. - " - "set ttimeoutlen=100 - -endif - - @@ -18,7 +18,7 @@ set undodir=~/.vim/backup// set undofile set backup -set autochdir +" set autochdir " ignore case when searching, except mixing upper and lower set ignorecase @@ -29,6 +29,7 @@ set belloff=all set guifont=6x13:h13 +" fzf plugin set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' @@ -46,38 +47,14 @@ autocmd filetype vimki set autowrite autocmd filetype vimki nmap <leader>z :FZF ~/Wiki<CR> " autocmd filetype markdown,text,vimki setlocal textwidth=72 -" vim-go plugin -let g:go_gopls_enabled = 1 -let g:go_def_mode = "gopls" -let g:go_info_mode = "gopls" -let g:go_fmt_command = "gopls" -let g:go_gopls_gofumpt = 1 -" let g:go_gopls_enabled = 0 -" let g:go_def_mode = "godef" -" let g:go_fmt_command = "goimports" -let g:go_metalinter_command = "golangci-lint" -let g:go_list_type = "quickfix" - -"autocmd FileType go syntax on -autocmd FileType go nmap <leader>b <Plug>(go-build) -autocmd FileType go nmap <leader>i <Plug>(go-info) -autocmd FileType go nmap <leader>l <Plug>(go-meta-lint) -autocmd FileType go nmap <leader>r <Plug>(go-run) -autocmd FileType go nmap <leader>t <Plug>(go-test) -" the following collides with reformat -"autocmd FileType go nmap <leader>f <Plug>(go-test-func) -autocmd FileType go nmap <leader>v <Plug>(go-referrers) -autocmd FileType go nmap <leader>n :cnext<CR> -autocmd FileType go nmap <leader>p :cprevious<CR> -autocmd FileType go nmap <leader>a :cclose<CR> -" autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 + autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 let g:netrw_browsex_viewer = "open" let g:netrw_gx = "<cWORD>" let g:netrw_banner = 0 " python and yaml formatting: -autocmd filetype python,yaml set ts=2 sts=2 sw=2 et +" autocmd filetype python,yaml set ts=2 sts=2 sw=2 et :set wrap :set linebreak @@ -112,28 +89,6 @@ noremap <leader>o :!open <cWORD>&<cr><cr> noremap <C-g> :tag <c-r><c-w><cr> noremap <C-p> :Files<cr> -""""""""""""" My cscope/vim key mappings -" -" The following maps all invoke one of the following cscope search types: -" -" 's' symbol: find all references to the token under cursor -" 'g' global: find global definition(s) of the token under cursor -" 'c' calls: find all calls to the function name under cursor -" 't' text: find all instances of the text under cursor -" 'e' egrep: egrep search for the word under cursor -" 'f' file: open the filename under cursor -" 'i' includes: find files that include the filename under cursor -" 'd' called: find functions that function under cursor calls - -noremap <leader>s :cs find s <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>g :cs find g <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>c :cs find c <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>t :cs find t <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>e :cs find e <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>i :cs find i <C-R>=expand("<cfile>")<CR><CR><tab> -" noremap <leader>f :cs find f <C-R>=expand("<cfile>")<CR><CR><tab> -noremap <leader>d :cs find d <C-R>=expand("<cword>")<CR><CR><tab> - " MacOS: Open QuickLook on current file (for markdown preview mainly) noremap <leader>w :!ql %<CR><CR> @@ -153,9 +108,49 @@ endfunction noremap <leader><leader> :call CloseOnLast()<cr> -" NERDTree settings -let g:NERDTreeNodeDelimiter = "\u00a0" -" autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif -nnoremap <leader>n :NERDTreeFocus<CR> -" nnoremap <C-r> :NERDTreeFind<CR> -nnoremap <C-n> :NERDTreeMirror<CR>:NERDTreeFocus<CR> +" vim-lsp settings +let g:lsp_diagnostics_enabled = 0 +let g:lsp_document_code_action_signs_enabled = 0 +let g:lsp_document_highlight_enabled = 0 + +if executable('gopls') + au User lsp_setup call lsp#register_server({ + \ 'name': 'gopls', + \ 'cmd': {server_info->['gopls', '-remote=auto']}, + \ 'allowlist': ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'], + \ }) + autocmd BufWritePre *.go + \ call execute('LspDocumentFormatSync') | + \ call execute('LspCodeActionSync source.organizeImports') +endif + +if executable('clangd') + au User lsp_setup call lsp#register_server({ + \ 'name': 'clangd', + \ 'cmd': {server_info->['clangd', '-background-index']}, + \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'], + \ }) +endif + +function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap <buffer> gd <plug>(lsp-definition) + nmap <buffer> gs <plug>(lsp-document-symbol-search) + nmap <buffer> gS <plug>(lsp-workspace-symbol-search) + nmap <buffer> gr <plug>(lsp-references) + nmap <buffer> gi <plug>(lsp-implementation) + nmap <buffer> gt <plug>(lsp-type-definition) + nmap <buffer> <leader>rn <plug>(lsp-rename) + nmap <buffer> [g <plug>(lsp-previous-diagnostic) + nmap <buffer> ]g <plug>(lsp-next-diagnostic) + nmap <buffer> K <plug>(lsp-hover) +endfunction + +augroup lsp_install + au! + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() +augroup END + +" Git blame +command! Blame normal!:let @a=expand('%')<CR>:let @b=line('.')<CR>:new<CR>:set bt=nofile<CR>:%!git blame -wM --date=short <C-R>a<CR>:<C-R>b<CR> @@ -5,7 +5,7 @@ usage="Usage: $0 [black | blue | cyan | gray | green | magenta | orange | red | white | yellow]" cursor() { - case $1 in + case $1 in (0|r|red) set -- '#f00' ;; (1|n|green) set -- '#5f5' ;; (2|b|blue) set -- '#55f' ;; @@ -1,6 +1,8 @@ -#!/bin/bash +#!/bin/sh -# Set terminal color in xterm and compatibles. +# Set terminal color in xterm and compatibles + +usage="Usage: $0 [black | blue | cyan | gray | green | magenta | orange | red | white | yellow]" color() { case $1 in @@ -11,11 +13,11 @@ color() { (4|y|yellow) bg='#ffffe0' ;; (5|n|green) bg='#e0ffe0' ;; (6|o|orange) bg='#fff0f4' ;; - (7|k|black) bg='#111111' fg='#eeeeee' ;; - (*) echo "$0: unknown color $1">&2; exit 1 ;; + (7|k|black) bg='#000000' fg='#eeeeee' ;; esac + printf '\e]11;'${bg:-#ffffff}'\e\' # Set background color. + printf '\e]10;'${fg:-#000000}'\e\' # Set foreground color. } +case $1 in -*) echo "$usage" >&2; exit 1;; esac color ${1:-$((RANDOM % 7))} -printf '\E]11;'${bg:-#ffffff}'\E\' -printf '\E]10;'${fg:-#000000}'\E\' @@ -8,6 +8,7 @@ terminal_font() { case $1 in (m|menlo|mono) fn=menlo fs=$2 ;; (f|fixed|6x13) fn=6x13 fs=13 ;; + (s|sf) fn='SF Mono Light' fs=8 ;; ([0-9]*) fs=$1 ;; (*) fn=$1 fs=$2 ;; esac @@ -26,7 +27,7 @@ iterm2_font() { } case $TERM_PROGRAM in - (Apple_Terminal) terminal_font $@ ;; - (iTerm.app) iterm2_font $@ ;; + (Apple_Terminal) terminal_font "$@" ;; + (iTerm.app) iterm2_font "$@" ;; (*) die 'not supported' ;; esac |
