diff options
author | Matthew Lemon <y@yulqen.org> | 2024-09-01 09:34:31 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-09-01 09:34:31 +0100 |
commit | c4520a9789b99b15d7d49428c515f9c3ddeaf3b9 (patch) | |
tree | 9c9f41a854bf3a70de451c9713ff826ee6426b35 | |
parent | d248a4b9b63e10f2d790a44453a449273f16bf2c (diff) |
Update to vimrc from arch repo
-rw-r--r-- | vim/vimrc | 137 |
1 files changed, 126 insertions, 11 deletions
@@ -8,7 +8,9 @@ runtime macros/matchit.vim "allows jumping between brackets with % in normal mod " Leaders {{{ let maplocalleader = "\\" let mapleader = "," +nnoremap <leader>tsk 0i- [ ] nnoremap <silent> <leader>idate :.!date +"\%F"<CR>Ea<space> +nnoremap <silent> <leader>mdate :.!date -Iminutes<CR>Ea<space> nnoremap <leader>q :call TaskWarriorAddCurrentLine()<CR> " nnoremap <C-h> :tabprevious<cr> " nnoremap <C-l> :tabnext<cr> @@ -25,12 +27,6 @@ if (exists("*strftime")) noremap <silent> <leader>date "=strftime("%F")<CR>p9h noremap <silent> <leader>time "=strftime("%X")<CR>p7h endif - -" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). -if (exists("*strftime")) - noremap <silent> <leader>date "=strftime("%F")<CR>p9h - noremap <silent> <leader>time "=strftime("%X")<CR>p7h -endif " Generate ctags for current working directory nnoremap <leader>tt :silent !ctags -R . <CR>:redraw!<CR> " notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/ @@ -41,7 +37,8 @@ nnoremap <leader>ni :e $NOTES_DIR/index.md<CR>:cd $NOTES_DIR<CR> " clear search highlights nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> nnoremap <leader><C-p> :<C-u>FZF!<CR> -nnoremap <C-p>p :Files<CR> +nnoremap <C-p>g :Files<CR> +nnoremap <C-p>p :GitFiles<CR> nnoremap <leader>o :Tags<CR> nnoremap <leader>h :History<CR> nnoremap <silent> <leader>0 :Files<CR> @@ -56,11 +53,51 @@ nnoremap <silent> <leader>CC :Commands<CR> " Open quickfix list in a right vertical split (good for Ngrep results) command! Vlist botright vertical copen | vertical resize 50 nnoremap <leader>v : Vlist<CR> + +" 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(<q-args>) +" Define a keybinding to call SearchAndAddToQuickfix +nnoremap <leader>f :call SearchAndAddToQuickfix(input('Search term: '))<CR> + " }}} " Options {{{ "set clipboard=unnamed,unnamedplus " just past in with out needing "* set autoread set exrc +set nocuc set secure set scrolloff=1 set history=799 @@ -138,8 +175,10 @@ nnoremap <C-n> :Fern -drawer .<CR> <C-w>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' @@ -164,6 +203,38 @@ Plug 'honza/vim-snippets' Plug 'dense-analysis/ale' call plug#end() " }}} +" Snippets {{{ +" Trigger configuration. You need to change this to something other than +"<tab> if you use one of the following: +" - https://github.com/Valloric/YouCompleteMe +" - https://github.com/nvim-lua/completion-nvim +let g:UltiSnipsExpandTrigger="<S-t>" +let g:UltiSnipsJumpForwardTrigger="<S-f>" +let g:UltiSnipsJumpBackwardTrigger="<S-b>" +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 <tab> <plug>(emmet-expand-abbr) +let g:user_emmet_leader_key = '<C-b>' +let g:user_emmet_expandabbr_key = '<C-b>,' +let g:user_emmet_expandword_key = '<C-b>;' +let g:user_emmet_update_tag = '<C-b>u' +let g:user_emmet_balancetaginward_key = '<C-b>d' +let g:user_emmet_balancetagoutward_key = '<C-b>D' +let g:user_emmet_next_key = '<C-b>n' +let g:user_emmet_prev_key = '<C-b>N' +let g:user_emmet_imagesize_key = '<C-b>i' +let g:user_emmet_togglecomment_key = '<C-b>/' +let g:user_emmet_splitjointag_key = '<C-b>j' +let g:user_emmet_removetag_key = '<C-b>k' +let g:user_emmet_anchorizeurl_key = '<C-b>a' +let g:user_emmet_anchorizesummary_key = '<C-b>A' +let g:user_emmet_mergelines_key = '<C-b>m' +let g:user_emmet_codepretty_key = '<C-b>c' +"}}} " vim-tailwind {{{ function! s:is_tailwind() return !empty(findfile('tailwind.config.js', '.;')) || @@ -219,6 +290,12 @@ let g:ale_python_mypy_options = '--config-file mypy.ini' 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 <silent> <C-k> <Plug>(ale_previous) +" nmap <silent> <C-j> <Plug>(ale_next) +" OR map keys to use wrapping. +nmap <silent> <C-k> <Plug>(ale_previous_wrap) +nmap <silent> <C-j> <Plug>(ale_next_wrap) set omnifunc=ale#completion#OmniFunc " }}} " :grep use ripgrep {{{ @@ -261,7 +338,9 @@ let test#vimterminal#term_position = "belowright" " " sudo write " command! S :w !sudo tee % -nnoremap <Tab> % +"nnoremap <Tab> % +nnoremap <C-@> :call system("wl-copy", @")<CR> +xnoremap <silent> <C-@> :w !wl-copy<CR><CR> " }}} " FZF {{{ " This is the default extra key bindings @@ -323,11 +402,14 @@ 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 = 1 -let g:gruvbox_invert_signs = 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 {{{ @@ -393,4 +475,37 @@ nnoremap <leader><C-f> :GitFZF<CR> " 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 <silent> <localleader>h <Plug>(YCMToggleInlayHints) +"nnoremap gd :YcmCompleter GoToDefinition<CR> +"nnoremap <leader>gr :YcmCompleter GoToReferences<CR> +"nnoremap K :YcmCompleter GetDoc<CR> +"" 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 = ['<C-n>', '<Down>'] +"let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>'] +"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 <leader>jd :YcmCompleter GoTo<CR> +"imap <silent> <C-l> <Plug>(YCMToggleSignatureHelp)'. + +"let g:ycm_enable_inlay_hints = 0 +"" }}} |