# HG changeset patch # User zegervdv # Date 1646386544 -3600 # Node ID 8b04d5ffd2103a03c3de467f6ae1f996f9dabd74 # Parent eb6ebdacf20161e032f5af9beb8c538e7ca2db9f Clean up unused functions and mappings diff -r eb6ebdacf201 -r 8b04d5ffd210 .chezmoitemplates/config.vim --- a/.chezmoitemplates/config.vim Thu Mar 03 10:55:29 2022 +0100 +++ b/.chezmoitemplates/config.vim Fri Mar 04 10:35:44 2022 +0100 @@ -42,8 +42,6 @@ " Highlight VCS conflict markers match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' -" Do not move on * -nnoremap * :let stay_star_view = winsaveview()*:call winrestview(stay_star_view) " Search for selected text, forwards or backwards. vnoremap * : @@ -59,13 +57,6 @@ xnoremap p p:if v:register == '"'let @@=@0endif -" Error navigation -nnoremap :cprev -nnoremap :cnext -nnoremap :cnf -nnoremap :cpf - -nnoremap y :ptjump if has('nvim') tnoremap h @@ -114,116 +105,6 @@ endfunction " -" Convert hex <-> decimal -command! -nargs=? -range Dec2hex call s:Dec2hex(, , '') -function! s:Dec2hex(line1, line2, arg) range - if empty(a:arg) - if histget(':', -1) =~# "^'<,'>" && visualmode() !=# 'V' - let cmd = 's/\%V\<\d\+\>/\=printf("0x%x",submatch(0)+0)/g' - else - let cmd = 's/\<\d\+\>/\=printf("0x%x",submatch(0)+0)/g' - endif - try - execute a:line1 . ',' . a:line2 . cmd - catch - echo 'Error: No decimal number found' - endtry - else - echo printf('%x', a:arg + 0) - endif -endfunction - -command! -nargs=? -range Hex2dec call s:Hex2dec(, , '') -function! s:Hex2dec(line1, line2, arg) range - if empty(a:arg) - if histget(':', -1) =~# "^'<,'>" && visualmode() !=# 'V' - let cmd = 's/\%V0x\x\+/\=submatch(0)+0/g' - else - let cmd = 's/0x\x\+/\=submatch(0)+0/g' - endif - try - execute a:line1 . ',' . a:line2 . cmd - catch - echo 'Error: No hex number starting "0x" found' - endtry - else - echo (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0 - endif -endfunction -" - -" Recognize filetype for dup files -autocmd! BufRead *.dup call DupSetSyntax(@%) - -function! DupSetSyntax(name) - let extension = matchlist(a:name, '\v.+.\.([^\.]+).dup')[1] - if extension == "vhd" - setlocal filetype=vhdl - elseif extension == "v" - setlocal filetype=verilog - elseif extension == "sv" - setlocal filetype=verilog - else - echo "Unknown filetype" - endif -endfunction -" - -" Create arguments list from files in quickfix list -" Allows to Grep for a pattern and apply an argdo command on each of the -" matching files -command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames() -function! QuickfixFilenames() - " Building a hash ensures we get each buffer only once - let buffer_numbers = {} - for quickfix_item in getqflist() - let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr']) - endfor - return join(map(values(buffer_numbers), 'fnameescape(v:val)')) -endfunction -" - -augroup mark_files - au! - au BufLeave test.tcl mark T - au BufLeave case.do mark C - au BufLeave drv_*.tcl mark D - au BufLeave *.rtl.vhd mark R -augroup END - - -" Toggle between opening/closing the quickfix window -function! GetBufferList() - redir =>buflist - silent! ls! - redir END - return buflist -endfunction - -function! ToggleList(bufname, pfx) - let buflist = GetBufferList() - for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))') - if bufwinnr(bufnum) != -1 - exec(a:pfx.'close') - return - endif - endfor - if a:pfx == 'l' && len(getloclist(0)) == 0 - echohl ErrorMsg - echo "Location List is Empty." - return - endif - let winnr = winnr() - exec('botright '.a:pfx.'open') - if winnr() != winnr - wincmd p - endif -endfunction - -nnoremap :call ToggleList("Quickfix List", 'c') -" - - " Make list-like commands more intuitive " Copied from https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86 function! CCR() diff -r eb6ebdacf201 -r 8b04d5ffd210 .chezmoitemplates/init.lua --- a/.chezmoitemplates/init.lua Thu Mar 03 10:55:29 2022 +0100 +++ b/.chezmoitemplates/init.lua Fri Mar 04 10:35:44 2022 +0100 @@ -792,6 +792,18 @@ map('n', '`', "'") map('n', "'", '`') +-- Do not move on * +map('n', '*', function() + local view = vim.fn.winsaveview() + vim.cmd [[ normal! * ]] + vim.fn.winrestview(view) +end, { silent = true, desc = 'Search word under cursor without moving to first results' }) + +map('n', '', ':cprev', { desc = 'Go to previous error/match' }) +map('n', '', ':cnext', { desc = 'Go to next error/match' }) +map('n', '', ':cpf', { desc = 'Go to previous error/match in previous file' }) +map('n', '', ':cnf', { desc = 'Go to next error/match in next file' }) + local au = require 'au' -- Highlight yanked text