diff --git a/README.md b/README.md index 970275c..36b25e0 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,13 @@ # vim-nano -Mighty nano inside a vim. I wrote this for a parody hackathon. +Is an abomination and thinking about it makes you lose brain cells. # Requirements -- neovim (termopen abused to replicate nano interface) -- python (2 or 3, doesn't matter) +- Rethink your life +- Therapy # Installation -Not yet packaged as a plugin, because you don't need a vimrc anyway. +Don't do it. -``` -$ git clone https://github.com/nims11/vim-nano.git -$ cd vim-nano/ -$ nvim -u nano.vim -``` - -![vim-nano in action](https://raw.githubusercontent.com/nims11/vim-nano/master/screenshot.png) +![regular vim in action](https://cdn-images-1.medium.com/max/2000/1*f2dGSYzu7HjZr8rxPfFTtg.png) diff --git a/botbar.py b/botbar.py deleted file mode 100644 index fa9c5e0..0000000 --- a/botbar.py +++ /dev/null @@ -1,63 +0,0 @@ -import os -import time -import sys -row1 = [ - ("^G", "Get Help"), - ("^O", "Write Out"), - ("^F", "Where Is"), - ("^K", "Cut Text"), - ("^J", "Justify"), - ("^C", "Cur Pos"), - ("^Y", "Prev Page"), - ("M-\\", "First Line"), - ("M-W", "WhereIs Next"), - ('^^', "Mark Text"), - ("M-}", "Indent Text"), -] -row2 = [ - ("^X", "Exit"), - ("^R", "Read File"), - ("^\\", "Replace"), - ("^U", "Uncut Text"), - ("^T", "To Spell"), - ("^_", "Go To Line"), - ("^V", "Next Page"), - ("M-/", "Last Line"), - ("M-]", "To Bracket"), - ("M-C", "Copy Text"), - ("M-{", "Unindent Text"), -] -def generate(cols): - str1, str2 = '', '' - elt_width = max(15, cols//len(row1)) - cnt = 0 - for (k1, v1), (k2, v2) in zip(row1, row2): - cur_str1 = '\033[7m%s\033[0m %s ' % (k1, v1) - cur_str2 = '\033[7m%s\033[0m %s ' % (k2, v2) - cnt += 8 - while len(cur_str1) - 8 < elt_width: - cur_str1 += ' ' - while len(cur_str2) - 8 < elt_width: - cur_str2 += ' ' - if len(cur_str1) - 8 > elt_width: - cur_str1 = cur_str1[:elt_width+8] - if len(cur_str2) - 8 > elt_width and k2 != row2[-1][0]: - cur_str2 = cur_str2[:elt_width+8] - str1 += cur_str1 - str2 += cur_str2 - if len(str1) - cnt >= cols or len(str2) - cnt >= cols: - str1 = str1[:cols+cnt] - str2 = str2[:cols+cnt] - return str1 +'\n'+ str2 + '\n' - - return str1 +'\n'+ str2+'\n' - -prev_cols = -1 -while True: - _, cols = os.popen('stty size', 'r').read().split() - cols = int(cols) - 4 - if cols != prev_cols: - sys.stdout.write(generate(cols)) - sys.stdout.flush() - prev_cols = cols - time.sleep(0.3) diff --git a/nano.vim b/nano.vim deleted file mode 100644 index 6a7d9aa..0000000 --- a/nano.vim +++ /dev/null @@ -1,243 +0,0 @@ -let s:hidden_all = 1 -set noshowmode -set noruler -set laststatus=0 -set noshowcmd -set hlsearch! - -highlight EndOfBuffer ctermfg=black ctermbg=black -set shortmess+=I -highlight StatusLine ctermfg=black ctermbg=black cterm=NONE -highlight StatusLineNC ctermfg=black ctermbg=black cterm=NONE - - -function! DrawLayout() - " Top bar buffer - split - let s:path = expand(':p:h') - enew - resize 1 - call termopen('python '.s:path.'/topbar.py') - - " File display buffer - wincmd j - if @% == "" - enew - endif - - " Bottom bar buffer - split - wincmd j - resize 2 - enew - call termopen('python '.s:path.'/botbar.py') - - " Go back to file display buffer - wincmd k -endfunction - -" Trying to draw earlier messes things up -autocmd VimEnter * call DrawLayout() - - -" Restore input -function! RestoreInput() - startinsert - redraw -endfunction - - -" Handle resize -function! Resize() - wincmd j - resize 2 - wincmd k - - wincmd k - resize 1 - wincmd j -endfunction - -autocmd VimResized * call Resize() - - -" Disable command key -inoremap - - -function! ForceExit() - qa! -endfunction - - -function! PromptSave() - if @% != "" - write - return 1 - endif - let l:name = input('File Name to Write: ') - if (l:name == "") - return 0 - else - execute "write! ".l:name - return 1 - endif -endfunction -" Save file -nnoremap :call PromptSave() -inoremap :call PromptSave() - - -function! OpenFile() - let l:name = input('File to insert [from ./]: ') - if (l:name == "") - else - execute "read ".l:name - endif -endfunction -" Read file -nnoremap :call OpenFile() -inoremap :call OpenFile() - - -function! Exit() - if &mod - call inputsave() - let name = confirm('Save modified buffer? (Answering "No" will DISCARD changes.) ', "Yes\nNo\nCancel") - if (name==3) - elseif (name == 2) - call ForceExit() - else - if PromptSave() == 1 - call ForceExit() - else - endif - endif - - else - call ForceExit() - endif -endfunction -" Exit app -nnoremap :call Exit() -inoremap :call Exit() - - -function! SearchFile() - let l:name = input('Search: ') - if (name == "") - else - call feedkeys("\\/".name."\") - endif -endfunction -" Search file -nnoremap :call SearchFile() -inoremap :call SearchFile() - - -function! ShowInfo() - let curline = line('.') - let totalline = line('$') - let curcol = col('.') - let totalcol = col('$') - let lineperc = 100 * curline / totalline - let colperc = 100 * curcol / totalcol - echo "[ line ". curline . "/". totalline ." (".lineperc."%), col ".curcol. "/".totalcol." (".colperc."%) ]" -endfunction -" Show cursor info -nnoremap :call ShowInfo() -inoremap :call ShowInfo() - - -function! GotoLine() - let name = input('Enter line number, column number: ') - if (name == "") - else - let newlist = split(name, "[ ,]") - let cnt = 0 - let r = line(".") - let c = col(".") - for i in newlist - if i != "" - if cnt == 0 - let r = i - elseif cnt == 1 - let c = i - endif - endif - let cnt += 1 - endfor - call cursor(r, c) - endif -endfunction -" Goto line, col -nnoremap :call GotoLine() -inoremap :call GotoLine() - - -" Page up -nnoremap -inoremap - - -" Page down -nnoremap -inoremap - - -function! FirstLine() - call feedkeys("\\gg") -endfunction - -function! LastLine() - call feedkeys("\\G") -endfunction -" First Line -nnoremap :call FirstLine() -inoremap :call FirstLine() -" Last Line -nnoremap :call LastLine() -inoremap :call LastLine() - - -" Search forward -inoremap n - - -" Match parenthesis -inoremap % - - -function! VisualMode() - call feedkeys("\\v") -endfunction -" Mark Text -nnoremap :call VisualMode() -inoremap :call VisualMode() - - -" Copy Text -vnoremap y - - -" Indent -inoremap >> -inoremap << - - -" Justify -inoremap gqk - - -" Col nav -inoremap l -inoremap h - - -" Word nav -inoremap b -inoremap w - - -" Start insert mode -startinsert diff --git a/screenshot.png b/screenshot.png deleted file mode 100644 index 6d3593d..0000000 Binary files a/screenshot.png and /dev/null differ diff --git a/topbar.py b/topbar.py deleted file mode 100644 index 0b44f2b..0000000 --- a/topbar.py +++ /dev/null @@ -1,12 +0,0 @@ -import os -import time -import sys -while True: - _, cols = os.popen('stty size', 'r').read().split() - cols = int(cols) - prefix = '\r\033[7m GNU nano 6.6.6' - suffix = '' - output = prefix + ' '*(cols - (len(prefix)-5 + len(suffix))) + suffix - sys.stdout.write(output) - sys.stdout.flush() - time.sleep(1)