mirror of
https://github.com/starr-dusT/dotfiles.git
synced 2025-02-19 19:27:31 -08:00
initial try at 'plugin' for visualizing vim marks
This commit is contained in:
parent
12ed2d1bd0
commit
7e645fb043
@ -67,14 +67,19 @@ map <leader>e :Ex <cr> " open explorer
|
|||||||
" marks
|
" marks
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
" automatically update marks with helper function
|
||||||
|
au CursorHold,CursorHoldI,CursorMoved,CursorMovedI,TextChanged,TextChangedP,CmdlineEnter,CmdlineLeave,CmdlineChanged * silent! call UpdateMarkSigns()
|
||||||
|
|
||||||
" allow only global marks
|
" allow only global marks
|
||||||
noremap <silent> <expr> ' "'".toupper(nr2char(getchar()))
|
noremap <silent> <expr> ' "'".toupper(nr2char(getchar()))
|
||||||
noremap <silent> <expr> m "m".toupper(nr2char(getchar()))
|
noremap <silent> <expr> m "m".toupper(nr2char(getchar()))
|
||||||
sunmap '
|
sunmap '
|
||||||
sunmap m
|
sunmap m
|
||||||
|
|
||||||
nnoremap <silent> ' :call ListSelect("marks", "'")<CR> " list jumps/marks
|
" list jumps/marks
|
||||||
map <leader>md :delmarks A-Z0-9 <cr> " clear marks
|
map <leader>mm :call ListSelect("marks", "'")<CR>
|
||||||
|
" clear marks
|
||||||
|
map <leader>md :delmarks A-Z0-9 <cr>
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" grep
|
" grep
|
||||||
@ -167,3 +172,56 @@ endfunction
|
|||||||
function! Grep(...)
|
function! Grep(...)
|
||||||
return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' '))
|
return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' '))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Check if file is valid and exists
|
||||||
|
" ChatGippity
|
||||||
|
"
|
||||||
|
function! IsValidFilename(filename)
|
||||||
|
let expanded_filename = expand(a:filename)
|
||||||
|
if !empty(expanded_filename) && filereadable(expanded_filename)
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! PlaceSign(id, symbol, prio, line_number)
|
||||||
|
call sign_define(a:symbol, {'text': a:symbol})
|
||||||
|
call sign_place(a:id, '', a:symbol, bufnr(''), {'lnum': a:line_number, 'priority': a:prio, 'text': a:symbol})
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! UpdateMarkSigns()
|
||||||
|
" Reserved unique IDs for marks in case we want to remove in future
|
||||||
|
" without wiping out all signs
|
||||||
|
let resvIDs = range(1000, 1027)
|
||||||
|
|
||||||
|
" wipe out all signs (might improve in future)
|
||||||
|
execute "sign unplace *"
|
||||||
|
|
||||||
|
" get all marks
|
||||||
|
let lines = []
|
||||||
|
redir => lines
|
||||||
|
silent marks
|
||||||
|
redir END
|
||||||
|
|
||||||
|
let lines = split(lines, "\n")[1:]
|
||||||
|
for i in range(len(lines))
|
||||||
|
let line = lines[i]
|
||||||
|
let id = resvIDs[i]
|
||||||
|
|
||||||
|
let splitLine = split(line)
|
||||||
|
let name = splitLine[0]
|
||||||
|
let row = splitLine[1]
|
||||||
|
let col = splitLine[2]
|
||||||
|
try " empty lines at marks will break things
|
||||||
|
let file = splitLine[3]
|
||||||
|
catch
|
||||||
|
let file = ""
|
||||||
|
endtry
|
||||||
|
|
||||||
|
" If marks is in another file we don't need to display it
|
||||||
|
if !IsValidFilename(file)
|
||||||
|
call PlaceSign(id, name, 99, row)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user