"===============================================================================
"
" FILE: hmofa.vim
" Date of Creation: Sat 11/23/19 09:41:45
" AUTHOR: Azuhmier
"===============================================================================
let s:dir_setup_FILE = "/Users/Work/.vim/bundle/vim_hmofa/autoload/dir_setup.vim"
augroup hmofa
au!
au BufWritePost /Users/Work/.hmofa/.dirty exe "so " . s:dir_setup_FILE
augroup end
"-----| -= |-----{{{
let g:hmofa_master_dir = 'nada'
nnoremap <leader>= :Goto<enter>
"-----| :Goto |-----"
command! Goto call Goto_fun()
"-----| Goto_fun() |-----"
function! Goto_fun()
" FUN VARS "{{{
let l:library = "/Users/Work/Documents/hmofa/pastebin/Library.txt"
let l:library2 = "/Users/Work/Documents/hmofa/pastebin/code_examples/txt_files/lib_copy.txt"
let l:dir = "/Users/Work/Documents/hmofa/pastebin/code_examples/goto_files*"
let l:dir_2 = '/Users/Work/Documents/hmofa/fics*'
let l:url_dir = "/Users/Work/Documents/hmofa/pastebin/code_examples/goto_files/url.txt"
let l:any = "goto_files*/*"
let l:tag_list = 'tag_names.txt'
let l:tag_bin = 'tag_bin.txt'
let l:op_list = 'op_names.txt'
let l:op_bin = 'ops.txt'
"}}}
"-----| MAIN |-----"
let l:current_file = expand('%:p')
"-----| LIBRARY |-----"
" IF - current file is a library
if l:current_file == l:library || l:current_file == l:library2
" go to alt. file
let l:buf_N = bufnr('%')
execute "normal \<C-^>"
silent execute ":bd".l:buf_N
"-----| TAG AND OP LIST |-----"
" Elseif - current fIle is a tag_list
elseif (l:current_file =~ l:tag_list || l:current_file =~ l:op_list) && l:current_file =~ l:dir
let l:line = getline(".") " get entire line
" get only the numbers from the line
" Template - {number} {tag}
let l:LN = matchstr(l:line,'^\d\+\s\+')
let l:tag = substitute(l:line,l:LN,"","")
let l:LN = substitute(l:LN," ","","g")
let l:alt_file = expand('%:p') " set current file as the alt. file
"-----| TAG_BIN |-----"
if l:current_file =~ l:tag_list
execute "e ".l:tag_bin
else
execute "e ".l:op_bin
endif
let l:buf_N = bufnr('%')
execute "normal ".l:LN."G"
let l:line_2 = getline(".")
" get only the numbers from the line
let l:LN_2 = matchstr(l:line_2,'^\d\+\s\+')
let l:LN_2 = substitute(l:LN_2," ","","g")
"-----| LIBRARYY |-----"
if l:current_file =~ 'goto_files2'
execute "e ".l:library2
else
execute "e ".l:library
endif
silent execute ":bd".l:buf_N
setlocal autowrite
execute "normal ".l:LN_2."G"
let @# = l:alt_file
if l:current_file =~ l:op_list
let @/ = '\]\[.*\].*\zs\V'.l:tag.'\m\ze'
else
let @/ = '\V[\.\*,\s\zs'.l:tag.'\ze?\*,\.\*]
\\|[\zs'.l:tag.'\ze?\*,\.\*\]
\\|[\.\*,\s\zs'.l:tag.'\ze?\*]
\\|[\zs'.l:tag.'\ze?\*]'
let @r = '\V[\.\*\zs,\s'.l:tag.'?\*\ze,\.\*]
\\|[\zs'.l:tag.'?\*,\ze\.\*\]
\\|[\.\*\zs,\s'.l:tag.'?\*\ze]
\\|[\zs'.l:tag.'?\*\ze]'
endif
execute "normal /\<cr>"
"------| FICS/NOTES |------"
elseif l:current_file =~ l:dir_2
let l:url = getline('.')
let l:url = substitute(l:url,'\s','',"g")
let l:url = escape(l:url, '/.')
let l:alt_file = expand('%:p') " set current file as the alt. file
exe "e ".l:url_dir
exe "normal /".l:url."\<enter>"
let l:line = getline(".")
" get only the numbers from the line
let l:LN = matchstr(l:line,'^\d\+\s\+')
let l:tag = substitute(l:line,l:LN,"","")
let l:LN = substitute(l:LN," ","","g")
"------| LIBRARYY |------"
execute "e ".l:library
setlocal autowrite
let @# = l:alt_file
execute "normal ".l:LN."G"
execute "normal 2k"
"------| OTHER |------"
elseif l:current_file =~ "goto_files"
let l:line = getline(".")
"get only the numbers from the line
let l:LN = matchstr(l:line,'^\d\+\s\+')
let l:tag = substitute(l:line,l:LN,"","")
let l:LN = substitute(l:LN," ","","g")
"remember the taglist
let l:alt_file = expand('%:p')
"------| LIBRARY |------"
if l:current_file =~ 'goto_files2'
execute "e ".l:library2
else
execute "e ".l:library
endif
setlocal autowrite
let @# = l:alt_file
execute "normal ".l:LN."G"
else
echoerr "No can do"
endif
endfunction
"}}}
" ----- | Ntk | -----"{{{
vnoremap <esc>b vNNgn
vnoremap <esc>f vngn
"Enter Tag Mode
nnoremap <leader>n :Ntk<enter>
" ---| Ntk |--- "
command Ntk call Ntk_fun()
" ---| Ntk_fun() |--- "
function Ntk_fun()
"Fun Vars"
let l:dir = '/Users/Work/Documents/hmofa/fics*'
let l:cur_dir = expand('%:p')
"Where am I?
"If; cwd eq to l:dir
if l:cur_dir =~ l:dir
"If; Cur_fname Contains the String 'NOTES'
if l:cur_dir =~ 'NOTES'
exe 'noh'
let l:tag = '\[^,]\*'
let @/ = '\%>12l\%<35l\[\@<=\([^,\]]\)\+
\\|\%>12l\%<32l\(\1,\s\)\@<=[^,\]]\+'
exe "normal /<C-r>/"
exe "normal ngn"
endif
else
echo 'No Can Do'
endif
endfunction
" -----| Ntk2 |----- "
"rm tag
"<C-u> is used to delete from cursor to the beginning of the Cmd_Line
vnoremap <esc><down> :<c-u>Ntk2<enter>
" ---| Ntk2 |--- "
command Ntk2 call Ntk2_fun()
" ---| Ntk2_fun() |--- "
function Ntk2_fun()
" GoTo Prev Visl Sel and Copy it
exe "normal gvy"
let l:cur_tag = getreg('"')
"Escape the Fwd Slashes
let l:cur_tag = escape(l:cur_tag, '/')
exe '6s/\V'.l:cur_tag.'?\*,\s
\\|,\s'.l:cur_tag.'?\*\ze]
\\|[\zs'.l:cur_tag.'?\*\ze]//'
exe "normal \<C-o>"
exe "normal gv"
endfunction
" -----| Ntk3 |----- "
"add tag
"<C-u> is used to delete from cursor to the beginning of the cmd_line
vnoremap <esc><up> :<c-u>Ntk3<enter>
" ---| Ntk3 |--- "
command Ntk3 call Ntk3_fun()
" ---| Ntk3_fun() |--- "
function Ntk3_fun()
" go to prev visl sel and copy it
exe "normal gvy"
let l:cur_tag = getreg('"')
let l:line = line(".")
"escape the fwd slashes
let l:cur_tag = escape(l:cur_tag, '/')
let l:tagline = getline(6)
let l:grp_a = substitute(l:tagline, '\[[^\[\]]*\]\zs\[[^\]\[]*\].*',"","")
let l:grp_b = substitute(l:tagline, '\zs\[[^\[\]]*\]\ze\[[^\]\[]*\]',"","")
if l:line == 13 || l:line == 14 || l:line == 19
if l:grp_a =~ '[]'
exe '6s/\(\V[\)/\1'.l:cur_tag.'/'
else
exe '6s/\(\V[\)/\1'.l:cur_tag.', /'
endif
else
if l:grp_b =~ '[]'
exe '6s/\(\V[\.\*][\)/\1'.l:cur_tag.'/'
else
exe '6s/\(\V[\.\*][\)/\1'.l:cur_tag.', /'
endif
endif
exe "normal \<C-o>"
exe "normal gv"
endfunction
"}}}
Comments
0 B
|0 👍
/0 👎
0 B
|0 👍
/0 👎
0 B
|👍
/👎