From b397e8d4fc8ff5b8dbfb39034ab34c0871315434 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 22 Sep 2024 08:46:37 +0100 Subject: lazy commit - lots of stuff --- fish2024/config.fish | 2 +- fish2024/functions/xupdate.fish | 4 + i3-config | 2 +- vim/vimrc | 511 ++++++++-------------------------------- vim/vimrc-minima-june24 | 194 --------------- vim/vimrc-sept24 | 504 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 611 insertions(+), 606 deletions(-) create mode 100644 fish2024/functions/xupdate.fish delete mode 100644 vim/vimrc-minima-june24 create mode 100644 vim/vimrc-sept24 diff --git a/fish2024/config.fish b/fish2024/config.fish index 7b0981d..edf9773 100644 --- a/fish2024/config.fish +++ b/fish2024/config.fish @@ -15,7 +15,7 @@ if not set -Ux SSH_AUTH_SOCK && not set -Ux SSH_AGENT_PID set -Ux SSH_AGENT_PID $SSH_AGENT_PID end -#. ~/perl5/perlbrew/etc/perlbrew.fish +. ~/perl5/perlbrew/etc/perlbrew.fish #direnv prints all the variables whenever I start a new shell direnv hook fish | source diff --git a/fish2024/functions/xupdate.fish b/fish2024/functions/xupdate.fish new file mode 100644 index 0000000..8cd4cd9 --- /dev/null +++ b/fish2024/functions/xupdate.fish @@ -0,0 +1,4 @@ +function xupdate --wraps='sudo xbps-install -Su' --description 'alias xupdate sudo xbps-install -Su' + sudo xbps-install -Su $argv + +end diff --git a/i3-config b/i3-config index eba0260..69a35b6 100644 --- a/i3-config +++ b/i3-config @@ -84,7 +84,7 @@ exec --no-startup-id /usr/bin/feh --bg-max /home/lemon/Pictures/stable_diffusion exec --no-startup-id /home/lemon/.screenlayout/all_horiz.sh #exec --no-startup-id /usr/bin/clipit exec --no-startup-id /usr/bin/redshift -#exec --no-startup-id /usr/bin/xfce4-clipman +exec --no-startup-id /usr/bin/xfce4-clipman #exec --no-startup-id /usr/bin/emacs --daemon #exec --no-startup-id /usr/bin/copyq #exec --no-startup-id /usr/bin/xfce4-mixer diff --git a/vim/vimrc b/vim/vimrc index 5b98fcb..1ffccc6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1,186 +1,130 @@ -" Setup -set nocompatible -filetype indent on filetype plugin on -" syntax on -runtime macros/matchit.vim "allows jumping between brackets with % in normal mode -" -" Leaders +filetype plugin indent on + +"source ~/.vim/grep.vim + let maplocalleader = "\\" let mapleader = "," -nnoremap tsk 0i- [ ] -nnoremap idate :.!date +"\%F"Ea -nnoremap mdate :.!date -IminutesEa -nnoremap q :call TaskWarriorAddCurrentLine() -" nnoremap :tabprevious -" nnoremap :tabnext -" switch between tabs.... -nnoremap gt -" pandoc command to generate weekly plan page in Firefox (or not, if we just -" wish to refresh) -nnoremap w :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html; firefox /tmp/toss.html & -nnoremap W :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html -" Open vimrc + +set autoread +set foldmethod=manual +set autowrite +set backspace=indent,eol,start +"set colorcolumn=80 +"set cursorline +set completeopt=menuone,longest +set display=truncate +set equalalways +set fileformat=unix +set hidden +set history=1000 +set ignorecase +set incsearch +set infercase +set laststatus=2 +"set list +set listchars=nbsp:%,tab:▸\ ,trail:_,eol:¬,precedes:←,extends:→ +set matchtime=8 +set nobackup +set nocompatible +set nohlsearch +set nojoinspaces +set nomodeline +set noshelltemp +set noswapfile +set noundofile +set nowritebackup +set path+=** +set report=0 +set ruler +set scrolloff=5 +set shell=bash +set shortmess+=c +set showcmd +set showmatch +set showmode +set signcolumn=number +set splitright +set tabstop=4 softtabstop=4 shiftwidth=4 expandtab +set ttimeout +set ttimeoutlen=100 +"set viminfo= +set wildmenu +set wildoptions=pum +set wildmode=full +set wildignore=**/__pycache*/** +set wrap +packadd! matchit + nnoremap ev sjL:e $HOME/.vim/vimrc -" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). if (exists("*strftime")) noremap date "=strftime("%F")p9h noremap time "=strftime("%X")p7h endif -" Generate ctags for current working directory -nnoremap tt :silent !ctags -R . :redraw! -" notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/ -" Go to index of notes and set working directory to my notes -nnoremap ni :e $NOTES_DIR/index.md:cd $NOTES_DIR -" related to https://oleksii.shmalko.com/2014/using-vim-as-c-cpp-ide/ -" to enable putting a config file in the proejct directory -" clear search highlights nnoremap :noh:call clearmatches() +noremap J 10j +noremap K 10k +command! W w +let @x = 'o- [ ] ' + +" FZF + nnoremap :FZF! nnoremap g :Files nnoremap p :GitFiles nnoremap o :Tags nnoremap h :History nnoremap 0 :Files -nnoremap l :BLines -nnoremap ; :Lines +nnoremap ; :BLines +nnoremap l :Lines nnoremap o :BTags nnoremap b :Buffers nnoremap ? :History: nnoremap / :execute 'Ag ' . input('Ag/') nnoremap ft :Filetypes nnoremap CC :Commands -" Open quickfix list in a right vertical split (good for Ngrep results) -command! Vlist botright vertical copen | vertical resize 50 -nnoremap v : Vlist -" In pursuit of the single text file idea, which uses TODO, IDEA, FLAG -" as tags at the start of lines, this function is a vim-native replacement -" for fzf BLines, which does get a bit fuzzy sometimes. Not a biggie. -" Do do a sort of fuzzy line match in the buffer insread -" of BLines - call with :SearchAndAddToQuickfix ^IDEA and it will -" open in quickfix: -function! SearchAndAddToQuickfix(pattern) - " Clear the current quickfix list - call setqflist([]) +" vim-test +nmap tn :TestNearest +nmap tf :TestFile +nmap ts :TestSuite +nmap tl :TestLast +nmap tv :TestVisit +let test#strategy = "basic" +let test#python#pytest#options = '-q -s' +let test#python#runner = 'pytest' +let test#vimterminal#term_position = "belowright" - " Initialize an empty list to store quickfix items - let l:qf_list = [] +" snippets +let g:UltiSnipsEditSplit = "vertical" +let g:UltiSnipsListSnippets = "s" +let g:UltiSnipsExpandTrigger = "" +let g:UltiSnipsJumpForwardTrigger = "" +let g:UltiSnipsJumpBackwardTrigger = "" - " Iterate over each line in the buffer to find matches - for l:num in range(1, line('$')) - let l:line = getline(l:num) - " If the line matches the search pattern, add it to the quickfix list - if l:line =~ a:pattern - call add(l:qf_list, {'filename': expand('%:p'), 'lnum': l:num, 'col': 1, 'text': l:line}) - endif - endfor +if executable('rg') + set grepprg=rg\ --color=never\ --vimgrep +endif - " Set the quickfix list with the collected items - if !empty(l:qf_list) - call setqflist(l:qf_list, 'r') - " Open the quickfix window - copen - else - echo "No matches found for pattern: " . a:pattern - endif -endfunction +" and search with ripgrep +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(), 1, + \ 0 ? fzf#vim#with_preview('up:60%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ 0) -" Command to use the function, :SearchAndAddToQuickfix [pattern] -command! -nargs=1 SearchAndAddToQuickfix call SearchAndAddToQuickfix() -" Define a keybinding to call SearchAndAddToQuickfix -nnoremap f :call SearchAndAddToQuickfix(input('Search term: ')) +nnoremap a :Rg + +augroup textfiles + autocmd! + autocmd filetype markdown setlocal spell spelllang=en +augroup end -" -" Options -set clipboard=unnamed,unnamedplus " just past in with out needing "* -set autoread -set ttyfast -set exrc -set nocuc -set secure -set scrolloff=1 -set history=799 -set encoding=utf-8 -set wrap -set wrapmargin=0 -set wildignore=**/__pycache*/** -set wildoptions=pum -set wildmenu -set wildchar= -set showmatch -set ruler -set showcmd -set nohlsearch -set incsearch -set ignorecase -set smartindent -set smartcase -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 -set splitbelow -set noswapfile -set nobackup -set splitright -set autoindent -set expandtab -set hidden -set path+=** -" set relativenumber -set number -set more -set signcolumn=number -set colorcolumn=0 -set equalalways -set showmode -set nolist -set listchars=tab:»-,trail:␣,leadmultispace:---+,eol:\\U000021b5 -set shortmess+=c -set tags+=./tags -set background=dark -set completeopt=menuone,longest -" -" Folding -if has('folding') - set foldmethod=marker " default - " set foldmethod=syntax -" set foldmarker=#\ ,#\ - set viewoptions=folds,options,cursor,unix,slash -endif -" disable folding by default with vim-markdown -let g:vim_markdown_folding_disabled = 1 -" -" Remaps -let @x = 'o- [ ] ' -noremap J 10j -noremap K 10k -" macro to go to end of sentence and add a line break (for -" one-line-per-sentence vimming...) -let @s = ")i\\\" -" remap :W to :w - :W was previous Windows in fzf -command! W w -" Open Fern with Ctrl-N -nnoremap :Fern -drawer . l -" -" Plugins call plug#begin() -"Plug 'vim-scripts/AutoComplPop' -Plug 'mattn/emmet-vim', -Plug 'lambdalisue/fern.vim', -Plug 'tpope/vim-rails', -" Plug 'ycm-core/YouCompleteMe' -Plug 'vim-ruby/vim-ruby', Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' -Plug 'ayu-theme/ayu-vim' -Plug 'airblade/vim-tailwind' -Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' } -Plug 'morhetz/gruvbox' -Plug 'eemed/sitruuna.vim' -" Plug 'sheerun/vim-polyglot' -Plug 'preservim/vim-markdown' Plug 'mhinz/vim-signify' Plug 'vim-test/vim-test' Plug 'ledger/vim-ledger' @@ -194,53 +138,8 @@ Plug 'SirVer/UltiSnips' Plug 'honza/vim-snippets' Plug 'dense-analysis/ale' call plug#end() -" -" Snippets -" Trigger configuration. You need to change this to something other than -" if you use one of the following: -" - https://github.com/Valloric/YouCompleteMe -" - https://github.com/nvim-lua/completion-nvim -let g:UltiSnipsExpandTrigger="" -"let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" -let g:ycm_key_list_select_completion=[] -let g:ycm_key_list_previous_completion=[] -" -" -" emmet -" being very explicit, which is not required -autocmd FileType css imap html (emmet-expand-abbr) -let g:user_emmet_leader_key = '' -let g:user_emmet_expandabbr_key = ',' -let g:user_emmet_expandword_key = ';' -let g:user_emmet_update_tag = 'u' -let g:user_emmet_balancetaginward_key = 'd' -let g:user_emmet_balancetagoutward_key = 'D' -let g:user_emmet_next_key = 'n' -let g:user_emmet_prev_key = 'N' -let g:user_emmet_imagesize_key = 'i' -let g:user_emmet_togglecomment_key = '/' -let g:user_emmet_splitjointag_key = 'j' -let g:user_emmet_removetag_key = 'k' -let g:user_emmet_anchorizeurl_key = 'a' -let g:user_emmet_anchorizesummary_key = 'A' -let g:user_emmet_mergelines_key = 'm' -let g:user_emmet_codepretty_key = 'c' -" -" vim-tailwind -function! s:is_tailwind() - return !empty(findfile('tailwind.config.js', '.;')) || - \ !empty(findfile('theme/static_src/tailwind.config.js', '.;')) -endfunction -nmap gk (tailwind-lookup) - -autocmd BufEnter *.html,*.slim if s:is_tailwind() | - \ setlocal omnifunc=tailwind#Complete | - \ endif -" -" ALE +" ALE let g:ale_enabled = 1 let g:ale_set_balloons = 0 let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' @@ -260,7 +159,7 @@ let g:ale_echo_msg_error_str = 'ALE Error' let g:ale_echo_msg_format = 'ALE: %linter% - %code: %%s' let g:ale_loclist_msg_format = 'ALE: %linter% - %code: %%s' let g:ale_echo_msg_warning_str = 'ALE Warning' -let g:ale_linters = {'python': ['ruff', 'mypy'], +let g:ale_linters = {'python': ['pyright', 'ruff', 'flake8', 'mypy'], \ 'ocaml': ['merlin'], \ 'javascript': ['eslint'], \ 'cpp': ['clangd'], @@ -269,7 +168,7 @@ let g:ale_linters = {'python': ['ruff', 'mypy'], \ 'go': ['gopls', 'golint', 'gofmt'], \} let g:ale_fixers = { -\ 'python': ['ruff', 'isort', 'yapf'], +\ 'python': ['autoimport', 'ruff', 'isort', 'yapf', 'black'], \ 'javascript': ['eslint'], \ 'go': ['gofmt', 'goimports', 'gopls'], \ 'cpp': ['clang-format'], @@ -289,216 +188,8 @@ let g:ale_completion_enabled = 0 " OR map keys to use wrapping. nmap (ale_previous_wrap) nmap (ale_next_wrap) -set omnifunc=ale#completion#OmniFunc -" -" :grep use ripgrep -if executable('rg') - set grepprg=rg\ --color=never\ --vimgrep -endif -" and search with ripgrep -command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(), 1, - \ 0 ? fzf#vim#with_preview('up:60%') - \ : fzf#vim#with_preview('right:50%:hidden', '?'), - \ 0) - -nnoremap a :Rg -" -" 'Notes Grep' with ripgrep (see grepprg) -" -i case insensitive -" -g glob pattern -" ! to not immediately open first search result -"command! -nargs=1 Ngrep :silent grep! "" -i -g '*.md' $NOTES_DIR | execute ':redraw!' -command! -nargs=1 Ngrep vimgrep "" $NOTES_DIR/**/*.md -nnoremap nn :Ngrep -" -" vim-test -nmap tn :TestNearest -nmap tf :TestFile -nmap ts :TestSuite -nmap tl :TestLast -nmap tv :TestVisit -let test#strategy = "basic" -let test#python#pytest#options = '-q -s' -let test#python#runner = 'pytest' -let test#vimterminal#term_position = "belowright" -" -" Titbits -" " Increment an ordered (numbered) list with -" inoremap yyp -" " sudo write -" command! S :w !sudo tee % - -"nnoremap % -nnoremap :call system("wl-copy", @") -xnoremap :w !wl-copy -" -" FZF -" This is the default extra key bindings -let g:fzf_action = { - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } - -" - FZF Popup window (center of the screen) -let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } - -" Customize fzf colors to match your color scheme -let g:fzf_colors = -\ { 'fg': ['fg', '#f8f8f2'], - \ 'bg': ['bg', '#282a36'], - \ 'hl': ['fg', '#bd93f9'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', '#ffb86c'], - \ 'prompt': ['fg', '#50fa7b'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', '#ffb86c'], - \ 'header': ['fg', '#6272a4'] } -" More fzf settings -" (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187) - let g:fzf_nvim_statusline = 0 " disable statusline overwriting - - nnoremap :GFiles! - imap (fzf-complete-file-ag) - imap (fzf-complete-line) -" -" Colorscheme -" This is imported from the old ephemera.vim file which has now been removed -" -" I got the following from gruvbox docs -"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. -"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support -"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.) -if (has("nvim")) -"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > - let $NVIM_TUI_ENABLE_TRUE_COLOR=1 -endif -"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > -"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > -" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > -if (has("termguicolors")) - set termguicolors -endif - -"ayu theme -" let ayucolor="light" " for light version of theme -" let ayucolor="mirage" " for mirage version of theme -let ayucolor="dark" " for dark version of theme - -"colorscheme gruber-darker -let g:gruvbox_contrast_dark = "hard" -let g:gruvbox_italicize_strings = 1 -let g:gruvbox_improved_strings = 1 -let g:gruvbox_improved_warnings = 1 -let g:gruvbox_invert_indent_guides = 0 -let g:gruvbox_invert_signs = 0 -let g:gruvbox_italic = 0 - -"colorscheme evening -"colorscheme sitruuna -colorscheme ayu -"colorscheme evening -"colorscheme gruvbox -" -" GPG files -" from https://vim.fandom.com/wiki/Edit_gpg_encrypted_files -" Don't save backups of *.gpg files -set backupskip+=*.gpg -" To avoid that parts of the file is saved to .viminfo when yanking or -" deleting, empty the 'viminfo' option. -set viminfo= - -augroup encrypted - au! - " Disable swap files, and set binary file format before reading the file - autocmd BufReadPre,FileReadPre *.gpg - \ setlocal noswapfile bin - " Decrypt the contents after reading the file, reset binary file format - " and run any BufReadPost autocmds matching the file name without the .gpg - " extension - autocmd BufReadPost,FileReadPost *.gpg - \ execute "'[,']!gpg --decrypt --default-recipient-self" | - \ setlocal nobin | - \ execute "doautocmd BufReadPost " . expand("%:r") - " Set binary file format and encrypt the contents before writing the file - autocmd BufWritePre,FileWritePre *.gpg - \ setlocal bin | - \ '[,']!gpg --encrypt --default-recipient-self - " After writing the file, do an :undo to revert the encryption in the - " buffer, and reset binary file format - autocmd BufWritePost,FileWritePost *.gpg - \ silent u | - \ setlocal nobin -augroup END -" -" Golang -augroup golang - autocmd! - autocmd FileType go - \ set tabstop=8 | - \ set softtabstop=8 | - \ set shiftwidth=8 -augroup END -" -" GitFZF -" from https://git.sr.ht/~sircmpwn/dotfiles/tree/master/item/.vimrc -function! GitFZF() - let path = trim(system('cd '.shellescape(expand('%:p:h')).' && git rev-parse --show-toplevel')) - exe 'FZF ' . path -endfunction -command! GitFZF call GitFZF() -nnoremap :GitFZF -" -" Switching off colours +set background=dark +colorscheme koehler "syntax off -" hi Visual term=reverse ctermbg=7 ctermfg=black guifg=black guibg=LightPink -" hi SpellBad term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Red -" hi SpellCap term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Red -" hi SpellRare term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Blue -" hi Search term=reverse ctermbg=11 guifg=black guibg=Green -" -" Turn spelling on for text files -" from - https://dmerej.info/blog/post/syntax-highlighting-is-useless/ -" augroup textfiles -" autocmd! -" autocmd filetype markdown setlocal spell spelllang=en -" augroup end -" -" Read man pages in vim -runtime! ftplugin/man.vim -" -"" YouCompleteMe -"" -"" *** STARTING AND ENABLING *** -"" Don't start on start - or use show_diagnostics below -"let g:loaded_youcompleteme = 1 -"" with this set to 0, YCM doesn't load/start -"let g:ycm_show_diagnostics_ui = 1 -"" ****************************** -"let g:ycm_enable_inlay_hints = 1 -"nnoremap h (YCMToggleInlayHints) -"nnoremap gd :YcmCompleter GoToDefinition -"nnoremap gr :YcmCompleter GoToReferences -"nnoremap K :YcmCompleter GetDoc -"" this will disable tab, allowing it to be used for ultisnips -"" let g:ycm_key_list_select_completion=[] -"" let g:ycm_key_list_previous_completion=[] -"let g:ycm_key_list_select_completion = ['', ''] -"let g:ycm_key_list_previous_completion = ['', ''] -"let g:ycm_python_interpreter_path = '.venv/bin/python3' -"let g:ycm_auto_trigger = 1 -"let g:ycm_python_sys_path = [] -""let g:ycm_extra_conf_vim_data = [ -"" " \ 'g:ycm_python_interpreter_path', -"" " \ 'g:ycm_python_sys_path' -"" \] -""let g:ycm_global_ycm_extra_conf = '~/.global_extra_conf.py' -"nnoremap jd :YcmCompleter GoTo -"imap (YCMToggleSignatureHelp)'. -"let g:ycm_enable_inlay_hints = 0 -"" diff --git a/vim/vimrc-minima-june24 b/vim/vimrc-minima-june24 deleted file mode 100644 index a2578d7..0000000 --- a/vim/vimrc-minima-june24 +++ /dev/null @@ -1,194 +0,0 @@ -filetype plugin on -filetype plugin indent on - -"source ~/.vim/grep.vim - -let maplocalleader = "\\" -let mapleader = "," - -set autoread -set foldmethod=manual -set autowrite -set backspace=indent,eol,start -"set colorcolumn=80 -"set cursorline -set completeopt=menuone,longest -set display=truncate -set equalalways -set fileformat=unix -set hidden -set history=1000 -set ignorecase -set incsearch -set infercase -set laststatus=2 -"set list -set listchars=nbsp:%,tab:▸\ ,trail:_,eol:¬,precedes:←,extends:→ -set matchtime=8 -set nobackup -set nocompatible -set nohlsearch -set nojoinspaces -set nomodeline -set noshelltemp -set noswapfile -set noundofile -set nowritebackup -set path+=** -set report=0 -set ruler -set scrolloff=5 -set shell=bash -set shortmess+=c -set showcmd -set showmatch -set showmode -set signcolumn=number -set splitright -set tabstop=4 softtabstop=4 shiftwidth=4 expandtab -set ttimeout -set ttimeoutlen=100 -"set viminfo= -set wildmenu -set wildoptions=pum -set wildmode=full -set wildignore=**/__pycache*/** -set wrap -packadd! matchit - -nnoremap ev sjL:e $HOME/.vim/vimrc -if (exists("*strftime")) - noremap date "=strftime("%F")p9h - noremap time "=strftime("%X")p7h -endif -nnoremap :noh:call clearmatches() -noremap J 10j -noremap K 10k -command! W w -let @x = 'o- [ ] ' - -" FZF - -nnoremap :FZF! -nnoremap g :Files -nnoremap p :GitFiles -nnoremap o :Tags -nnoremap h :History -nnoremap 0 :Files -nnoremap ; :BLines -nnoremap l :Lines -nnoremap o :BTags -nnoremap b :Buffers -nnoremap ? :History: -nnoremap / :execute 'Ag ' . input('Ag/') -nnoremap ft :Filetypes -nnoremap CC :Commands - -" vim-test -nmap tn :TestNearest -nmap tf :TestFile -nmap ts :TestSuite -nmap tl :TestLast -nmap tv :TestVisit -let test#strategy = "basic" -let test#python#pytest#options = '-q -s' -let test#python#runner = 'pytest' -let test#vimterminal#term_position = "belowright" - -" snippets -let g:UltiSnipsEditSplit = "vertical" -let g:UltiSnipsListSnippets = "s" -let g:UltiSnipsExpandTrigger = "" -let g:UltiSnipsJumpForwardTrigger = "" -let g:UltiSnipsJumpBackwardTrigger = "" - - -if executable('rg') - set grepprg=rg\ --color=never\ --vimgrep -endif - -" and search with ripgrep -command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(), 1, - \ 0 ? fzf#vim#with_preview('up:60%') - \ : fzf#vim#with_preview('right:50%:hidden', '?'), - \ 0) - -nnoremap a :Rg - -augroup textfiles - autocmd! - autocmd filetype markdown setlocal spell spelllang=en -augroup end - -call plug#begin() -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' -Plug 'mhinz/vim-signify' -Plug 'vim-test/vim-test' -Plug 'ledger/vim-ledger' -Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries' } -Plug 'tpope/vim-dispatch' -Plug 'tpope/vim-surround' -Plug 'tpope/vim-commentary' -Plug 'tpope/vim-unimpaired' -Plug 'tpope/vim-fugitive' -Plug 'SirVer/UltiSnips' -Plug 'honza/vim-snippets' -Plug 'dense-analysis/ale' -call plug#end() - -" ALE -let g:ale_enabled = 1 -let g:ale_set_balloons = 0 -let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' -let g:ale_sign_error = '!' -let g:ale_sign_warning = '?' -let g:ale_lint_on_text_changed = 1 -let g:ale_hover_cursor = 1 -let g:ale_virtualtext_cursor = 'disabled' -let g:ale_sign_column_always = 1 -let g:ale_open_list = 0 -let g:ale_set_highlights = 1 -let g:ale_set_signs = 1 -let g:ale_set_loclist = 1 -let g:ale_set_quickfix = 1 -let g:ale_echo_cursor = 1 -let g:ale_echo_msg_error_str = 'ALE Error' -let g:ale_echo_msg_format = 'ALE: %linter% - %code: %%s' -let g:ale_loclist_msg_format = 'ALE: %linter% - %code: %%s' -let g:ale_echo_msg_warning_str = 'ALE Warning' -let g:ale_linters = {'python': ['pyright', 'ruff', 'flake8', 'mypy'], -\ 'ocaml': ['merlin'], -\ 'javascript': ['eslint'], -\ 'cpp': ['clangd'], -\ 'yaml': ['yamllint'], -\ 'c': ['clangd'], -\ 'go': ['gopls', 'golint', 'gofmt'], - \} -let g:ale_fixers = { -\ 'python': ['autoimport', 'ruff', 'isort', 'yapf', 'black'], -\ 'javascript': ['eslint'], -\ 'go': ['gofmt', 'goimports', 'gopls'], -\ 'cpp': ['clang-format'], -\ 'c': ['clang-format'], -\ 'rust': ['rustfmt'] -\ } -let g:ale_python_mypy_ignore_invalid_syntax = 1 -let g:ale_python_mypy_executable = 'mypy' -let g:ale_python_mypy_options = '--config-file mypy.ini' -" let g:ale_sign_error = '>>' -let g:ale_fix_on_save = 1 -let g:ale_linters_explicit = 0 -let g:ale_completion_enabled = 0 -" Map movement through errors without wrapping. -" nmap (ale_previous) -" nmap (ale_next) -" OR map keys to use wrapping. -nmap (ale_previous_wrap) -nmap (ale_next_wrap) - -set background=dark -"syntax off - diff --git a/vim/vimrc-sept24 b/vim/vimrc-sept24 new file mode 100644 index 0000000..5b98fcb --- /dev/null +++ b/vim/vimrc-sept24 @@ -0,0 +1,504 @@ +" Setup +set nocompatible +filetype indent on +filetype plugin on +" syntax on +runtime macros/matchit.vim "allows jumping between brackets with % in normal mode +" +" Leaders +let maplocalleader = "\\" +let mapleader = "," +nnoremap tsk 0i- [ ] +nnoremap idate :.!date +"\%F"Ea +nnoremap mdate :.!date -IminutesEa +nnoremap q :call TaskWarriorAddCurrentLine() +" nnoremap :tabprevious +" nnoremap :tabnext +" switch between tabs.... +nnoremap gt +" pandoc command to generate weekly plan page in Firefox (or not, if we just +" wish to refresh) +nnoremap w :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html; firefox /tmp/toss.html & +nnoremap W :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html +" Open vimrc +nnoremap ev sjL:e $HOME/.vim/vimrc +" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). +if (exists("*strftime")) + noremap date "=strftime("%F")p9h + noremap time "=strftime("%X")p7h +endif +" Generate ctags for current working directory +nnoremap tt :silent !ctags -R . :redraw! +" notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/ +" Go to index of notes and set working directory to my notes +nnoremap ni :e $NOTES_DIR/index.md:cd $NOTES_DIR +" related to https://oleksii.shmalko.com/2014/using-vim-as-c-cpp-ide/ +" to enable putting a config file in the proejct directory +" clear search highlights +nnoremap :noh:call clearmatches() +nnoremap :FZF! +nnoremap g :Files +nnoremap p :GitFiles +nnoremap o :Tags +nnoremap h :History +nnoremap 0 :Files +nnoremap l :BLines +nnoremap ; :Lines +nnoremap o :BTags +nnoremap b :Buffers +nnoremap ? :History: +nnoremap / :execute 'Ag ' . input('Ag/') +nnoremap ft :Filetypes +nnoremap CC :Commands +" Open quickfix list in a right vertical split (good for Ngrep results) +command! Vlist botright vertical copen | vertical resize 50 +nnoremap v : Vlist + +" In pursuit of the single text file idea, which uses TODO, IDEA, FLAG +" as tags at the start of lines, this function is a vim-native replacement +" for fzf BLines, which does get a bit fuzzy sometimes. Not a biggie. +" Do do a sort of fuzzy line match in the buffer insread +" of BLines - call with :SearchAndAddToQuickfix ^IDEA and it will +" open in quickfix: +function! SearchAndAddToQuickfix(pattern) + " Clear the current quickfix list + call setqflist([]) + + " Initialize an empty list to store quickfix items + let l:qf_list = [] + + " Iterate over each line in the buffer to find matches + for l:num in range(1, line('$')) + let l:line = getline(l:num) + + " If the line matches the search pattern, add it to the quickfix list + if l:line =~ a:pattern + call add(l:qf_list, {'filename': expand('%:p'), 'lnum': l:num, 'col': 1, 'text': l:line}) + endif + endfor + + " Set the quickfix list with the collected items + if !empty(l:qf_list) + call setqflist(l:qf_list, 'r') + " Open the quickfix window + copen + else + echo "No matches found for pattern: " . a:pattern + endif +endfunction + +" Command to use the function, :SearchAndAddToQuickfix [pattern] +command! -nargs=1 SearchAndAddToQuickfix call SearchAndAddToQuickfix() +" Define a keybinding to call SearchAndAddToQuickfix +nnoremap f :call SearchAndAddToQuickfix(input('Search term: ')) + +" +" Options +set clipboard=unnamed,unnamedplus " just past in with out needing "* +set autoread +set ttyfast +set exrc +set nocuc +set secure +set scrolloff=1 +set history=799 +set encoding=utf-8 +set wrap +set wrapmargin=0 +set wildignore=**/__pycache*/** +set wildoptions=pum +set wildmenu +set wildchar= +set showmatch +set ruler +set showcmd +set nohlsearch +set incsearch +set ignorecase +set smartindent +set smartcase +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set splitbelow +set noswapfile +set nobackup +set splitright +set autoindent +set expandtab +set hidden +set path+=** +" set relativenumber +set number +set more +set signcolumn=number +set colorcolumn=0 +set equalalways +set showmode +set nolist +set listchars=tab:»-,trail:␣,leadmultispace:---+,eol:\\U000021b5 +set shortmess+=c +set tags+=./tags +set background=dark +set completeopt=menuone,longest +" +" Folding +if has('folding') + set foldmethod=marker " default + " set foldmethod=syntax +" set foldmarker=#\ ,#\ + set viewoptions=folds,options,cursor,unix,slash +endif +" disable folding by default with vim-markdown +let g:vim_markdown_folding_disabled = 1 +" +" Remaps +let @x = 'o- [ ] ' +noremap J 10j +noremap K 10k +" macro to go to end of sentence and add a line break (for +" one-line-per-sentence vimming...) +let @s = ")i\\\" +" remap :W to :w - :W was previous Windows in fzf +command! W w +" Open Fern with Ctrl-N +nnoremap :Fern -drawer . l +" +" Plugins +call plug#begin() +"Plug 'vim-scripts/AutoComplPop' +Plug 'mattn/emmet-vim', +Plug 'lambdalisue/fern.vim', +Plug 'tpope/vim-rails', +" Plug 'ycm-core/YouCompleteMe' +Plug 'vim-ruby/vim-ruby', +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'ayu-theme/ayu-vim' +Plug 'airblade/vim-tailwind' +Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' } +Plug 'morhetz/gruvbox' +Plug 'eemed/sitruuna.vim' +" Plug 'sheerun/vim-polyglot' +Plug 'preservim/vim-markdown' +Plug 'mhinz/vim-signify' +Plug 'vim-test/vim-test' +Plug 'ledger/vim-ledger' +Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries' } +Plug 'tpope/vim-dispatch' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-commentary' +Plug 'tpope/vim-unimpaired' +Plug 'tpope/vim-fugitive' +Plug 'SirVer/UltiSnips' +Plug 'honza/vim-snippets' +Plug 'dense-analysis/ale' +call plug#end() +" +" Snippets +" Trigger configuration. You need to change this to something other than +" if you use one of the following: +" - https://github.com/Valloric/YouCompleteMe +" - https://github.com/nvim-lua/completion-nvim +let g:UltiSnipsExpandTrigger="" +"let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="" +let g:ycm_key_list_select_completion=[] +let g:ycm_key_list_previous_completion=[] +" +" +" emmet +" being very explicit, which is not required +autocmd FileType css imap html (emmet-expand-abbr) +let g:user_emmet_leader_key = '' +let g:user_emmet_expandabbr_key = ',' +let g:user_emmet_expandword_key = ';' +let g:user_emmet_update_tag = 'u' +let g:user_emmet_balancetaginward_key = 'd' +let g:user_emmet_balancetagoutward_key = 'D' +let g:user_emmet_next_key = 'n' +let g:user_emmet_prev_key = 'N' +let g:user_emmet_imagesize_key = 'i' +let g:user_emmet_togglecomment_key = '/' +let g:user_emmet_splitjointag_key = 'j' +let g:user_emmet_removetag_key = 'k' +let g:user_emmet_anchorizeurl_key = 'a' +let g:user_emmet_anchorizesummary_key = 'A' +let g:user_emmet_mergelines_key = 'm' +let g:user_emmet_codepretty_key = 'c' +" +" vim-tailwind +function! s:is_tailwind() + return !empty(findfile('tailwind.config.js', '.;')) || + \ !empty(findfile('theme/static_src/tailwind.config.js', '.;')) +endfunction + +nmap gk (tailwind-lookup) + +autocmd BufEnter *.html,*.slim if s:is_tailwind() | + \ setlocal omnifunc=tailwind#Complete | + \ endif +" +" ALE +let g:ale_enabled = 1 +let g:ale_set_balloons = 0 +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' +let g:ale_sign_error = '!' +let g:ale_sign_warning = '?' +let g:ale_lint_on_text_changed = 1 +let g:ale_hover_cursor = 1 +let g:ale_virtualtext_cursor = 'disabled' +let g:ale_sign_column_always = 1 +let g:ale_open_list = 0 +let g:ale_set_highlights = 1 +let g:ale_set_signs = 1 +let g:ale_set_loclist = 1 +let g:ale_set_quickfix = 1 +let g:ale_echo_cursor = 1 +let g:ale_echo_msg_error_str = 'ALE Error' +let g:ale_echo_msg_format = 'ALE: %linter% - %code: %%s' +let g:ale_loclist_msg_format = 'ALE: %linter% - %code: %%s' +let g:ale_echo_msg_warning_str = 'ALE Warning' +let g:ale_linters = {'python': ['ruff', 'mypy'], +\ 'ocaml': ['merlin'], +\ 'javascript': ['eslint'], +\ 'cpp': ['clangd'], +\ 'yaml': ['yamllint'], +\ 'c': ['clangd'], +\ 'go': ['gopls', 'golint', 'gofmt'], + \} +let g:ale_fixers = { +\ 'python': ['ruff', 'isort', 'yapf'], +\ 'javascript': ['eslint'], +\ 'go': ['gofmt', 'goimports', 'gopls'], +\ 'cpp': ['clang-format'], +\ 'c': ['clang-format'], +\ 'rust': ['rustfmt'] +\ } +let g:ale_python_mypy_ignore_invalid_syntax = 1 +let g:ale_python_mypy_executable = 'mypy' +let g:ale_python_mypy_options = '--config-file mypy.ini' +" let g:ale_sign_error = '>>' +let g:ale_fix_on_save = 1 +let g:ale_linters_explicit = 0 +let g:ale_completion_enabled = 0 +" Map movement through errors without wrapping. +" nmap (ale_previous) +" nmap (ale_next) +" OR map keys to use wrapping. +nmap (ale_previous_wrap) +nmap (ale_next_wrap) +set omnifunc=ale#completion#OmniFunc +" +" :grep use ripgrep +if executable('rg') + set grepprg=rg\ --color=never\ --vimgrep +endif + +" and search with ripgrep +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(), 1, + \ 0 ? fzf#vim#with_preview('up:60%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ 0) + +nnoremap a :Rg +" +" 'Notes Grep' with ripgrep (see grepprg) +" -i case insensitive +" -g glob pattern +" ! to not immediately open first search result +"command! -nargs=1 Ngrep :silent grep! "" -i -g '*.md' $NOTES_DIR | execute ':redraw!' +command! -nargs=1 Ngrep vimgrep "" $NOTES_DIR/**/*.md +nnoremap nn :Ngrep +" +" vim-test +nmap tn :TestNearest +nmap tf :TestFile +nmap ts :TestSuite +nmap tl :TestLast +nmap tv :TestVisit +let test#strategy = "basic" +let test#python#pytest#options = '-q -s' +let test#python#runner = 'pytest' +let test#vimterminal#term_position = "belowright" +" +" Titbits +" " Increment an ordered (numbered) list with +" inoremap yyp +" " sudo write +" command! S :w !sudo tee % + +"nnoremap % +nnoremap :call system("wl-copy", @") +xnoremap :w !wl-copy +" +" FZF +" This is the default extra key bindings +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" - FZF Popup window (center of the screen) +let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } + +" Customize fzf colors to match your color scheme +let g:fzf_colors = +\ { 'fg': ['fg', '#f8f8f2'], + \ 'bg': ['bg', '#282a36'], + \ 'hl': ['fg', '#bd93f9'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', '#ffb86c'], + \ 'prompt': ['fg', '#50fa7b'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', '#ffb86c'], + \ 'header': ['fg', '#6272a4'] } +" More fzf settings +" (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187) + let g:fzf_nvim_statusline = 0 " disable statusline overwriting + + nnoremap :GFiles! + imap (fzf-complete-file-ag) + imap (fzf-complete-line) +" +" Colorscheme +" This is imported from the old ephemera.vim file which has now been removed +" +" I got the following from gruvbox docs +"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. +"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support +"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.) +if (has("nvim")) +"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > + let $NVIM_TUI_ENABLE_TRUE_COLOR=1 +endif +"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > +"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > +" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > +if (has("termguicolors")) + set termguicolors +endif + +"ayu theme +" let ayucolor="light" " for light version of theme +" let ayucolor="mirage" " for mirage version of theme +let ayucolor="dark" " for dark version of theme + +"colorscheme gruber-darker +let g:gruvbox_contrast_dark = "hard" +let g:gruvbox_italicize_strings = 1 +let g:gruvbox_improved_strings = 1 +let g:gruvbox_improved_warnings = 1 +let g:gruvbox_invert_indent_guides = 0 +let g:gruvbox_invert_signs = 0 +let g:gruvbox_italic = 0 + +"colorscheme evening +"colorscheme sitruuna +colorscheme ayu +"colorscheme evening +"colorscheme gruvbox +" +" GPG files +" from https://vim.fandom.com/wiki/Edit_gpg_encrypted_files +" Don't save backups of *.gpg files +set backupskip+=*.gpg +" To avoid that parts of the file is saved to .viminfo when yanking or +" deleting, empty the 'viminfo' option. +set viminfo= + +augroup encrypted + au! + " Disable swap files, and set binary file format before reading the file + autocmd BufReadPre,FileReadPre *.gpg + \ setlocal noswapfile bin + " Decrypt the contents after reading the file, reset binary file format + " and run any BufReadPost autocmds matching the file name without the .gpg + " extension + autocmd BufReadPost,FileReadPost *.gpg + \ execute "'[,']!gpg --decrypt --default-recipient-self" | + \ setlocal nobin | + \ execute "doautocmd BufReadPost " . expand("%:r") + " Set binary file format and encrypt the contents before writing the file + autocmd BufWritePre,FileWritePre *.gpg + \ setlocal bin | + \ '[,']!gpg --encrypt --default-recipient-self + " After writing the file, do an :undo to revert the encryption in the + " buffer, and reset binary file format + autocmd BufWritePost,FileWritePost *.gpg + \ silent u | + \ setlocal nobin +augroup END +" +" Golang +augroup golang + autocmd! + autocmd FileType go + \ set tabstop=8 | + \ set softtabstop=8 | + \ set shiftwidth=8 +augroup END +" +" GitFZF +" from https://git.sr.ht/~sircmpwn/dotfiles/tree/master/item/.vimrc +function! GitFZF() + let path = trim(system('cd '.shellescape(expand('%:p:h')).' && git rev-parse --show-toplevel')) + exe 'FZF ' . path +endfunction +command! GitFZF call GitFZF() +nnoremap :GitFZF +" +" Switching off colours +"syntax off +" hi Visual term=reverse ctermbg=7 ctermfg=black guifg=black guibg=LightPink +" hi SpellBad term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Red +" hi SpellCap term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Red +" hi SpellRare term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Blue +" hi Search term=reverse ctermbg=11 guifg=black guibg=Green +" +" Turn spelling on for text files +" from - https://dmerej.info/blog/post/syntax-highlighting-is-useless/ +" augroup textfiles +" autocmd! +" autocmd filetype markdown setlocal spell spelllang=en +" augroup end +" +" Read man pages in vim +runtime! ftplugin/man.vim +" +"" YouCompleteMe +"" -"" *** STARTING AND ENABLING *** +"" Don't start on start - or use show_diagnostics below +"let g:loaded_youcompleteme = 1 +"" with this set to 0, YCM doesn't load/start +"let g:ycm_show_diagnostics_ui = 1 +"" ****************************** +"let g:ycm_enable_inlay_hints = 1 +"nnoremap h (YCMToggleInlayHints) +"nnoremap gd :YcmCompleter GoToDefinition +"nnoremap gr :YcmCompleter GoToReferences +"nnoremap K :YcmCompleter GetDoc +"" this will disable tab, allowing it to be used for ultisnips +"" let g:ycm_key_list_select_completion=[] +"" let g:ycm_key_list_previous_completion=[] +"let g:ycm_key_list_select_completion = ['', ''] +"let g:ycm_key_list_previous_completion = ['', ''] +"let g:ycm_python_interpreter_path = '.venv/bin/python3' +"let g:ycm_auto_trigger = 1 +"let g:ycm_python_sys_path = [] +""let g:ycm_extra_conf_vim_data = [ +"" " \ 'g:ycm_python_interpreter_path', +"" " \ 'g:ycm_python_sys_path' +"" \] +""let g:ycm_global_ycm_extra_conf = '~/.global_extra_conf.py' +"nnoremap jd :YcmCompleter GoTo +"imap (YCMToggleSignatureHelp)'. + +"let g:ycm_enable_inlay_hints = 0 +"" -- cgit v1.2.3