From 307df21222316d35f32e1597824283797aa6a74c Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 15 Jan 2025 11:44:13 +0100 Subject: update --- .bashrc | 5 +- .vim/pack/mvertes/install.sh | 17 +++-- .vim/plugin/cscope_maps.vim | 167 ------------------------------------------- .vimrc | 105 +++++++++++++-------------- bin/cursor | 2 +- bin/tc | 14 ++-- bin/tf | 5 +- 7 files changed, 75 insertions(+), 240 deletions(-) delete mode 100644 .vim/plugin/cscope_maps.vim diff --git a/.bashrc b/.bashrc index 97d766f..296640f 100644 --- a/.bashrc +++ b/.bashrc @@ -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 macro use '^$': this is so - " that searches over '#include " 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 s :cs find s =expand("") - nmap g :cs find g =expand("") - nmap c :cs find c =expand("") - nmap t :cs find t =expand("") - nmap e :cs find e =expand("") - nmap f :cs find f =expand("") - nmap i :cs find i ^=expand("")$ - nmap d :cs find d =expand("") - - - " 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 s :cs find s =expand("") - - " MV: replace C-@ by C-; - nmap s :scs find s =expand("") - nmap g :scs find g =expand("") - nmap c :scs find c =expand("") - nmap t :scs find t =expand("") - nmap e :scs find e =expand("") - nmap f :scs find f =expand("") - nmap i :scs find i ^=expand("")$ - nmap d :scs find d =expand("") - - - " 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 s :vert scs find s =expand("") - nmap g :vert scs find g =expand("") - nmap c :vert scs find c =expand("") - nmap t :vert scs find t =expand("") - nmap e :vert scs find e =expand("") - nmap f :vert scs find f =expand("") - nmap i :vert scs find i ^=expand("")$ - nmap d :vert scs find d =expand("") - - - """"""""""""" 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 ), 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 ). - " - "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 - - diff --git a/.vimrc b/.vimrc index 7ce1619..08f71e4 100644 --- a/.vimrc +++ b/.vimrc @@ -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 z :FZF ~/Wiki " 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 b (go-build) -autocmd FileType go nmap i (go-info) -autocmd FileType go nmap l (go-meta-lint) -autocmd FileType go nmap r (go-run) -autocmd FileType go nmap t (go-test) -" the following collides with reformat -"autocmd FileType go nmap f (go-test-func) -autocmd FileType go nmap v (go-referrers) -autocmd FileType go nmap n :cnext -autocmd FileType go nmap p :cprevious -autocmd FileType go nmap a :cclose -" 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 = "" 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 o :!open & noremap :tag noremap :Files -""""""""""""" 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 s :cs find s =expand("") -noremap g :cs find g =expand("") -noremap c :cs find c =expand("") -noremap t :cs find t =expand("") -noremap e :cs find e =expand("") -noremap i :cs find i =expand("") -" noremap f :cs find f =expand("") -noremap d :cs find d =expand("") - " MacOS: Open QuickLook on current file (for markdown preview mainly) noremap w :!ql % @@ -153,9 +108,49 @@ endfunction noremap :call CloseOnLast() -" NERDTree settings -let g:NERDTreeNodeDelimiter = "\u00a0" -" autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif -nnoremap n :NERDTreeFocus -" nnoremap :NERDTreeFind -nnoremap :NERDTreeMirror:NERDTreeFocus +" 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 gd (lsp-definition) + nmap gs (lsp-document-symbol-search) + nmap gS (lsp-workspace-symbol-search) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap rn (lsp-rename) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap K (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('%'):let @b=line('.'):new:set bt=nofile:%!git blame -wM --date=short a:b diff --git a/bin/cursor b/bin/cursor index 537c164..2ae069b 100755 --- a/bin/cursor +++ b/bin/cursor @@ -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' ;; diff --git a/bin/tc b/bin/tc index 278ca3f..e2e34a4 100755 --- a/bin/tc +++ b/bin/tc @@ -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\' diff --git a/bin/tf b/bin/tf index e0f18bf..a566233 100755 --- a/bin/tf +++ b/bin/tf @@ -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 -- cgit v1.2.3