Skip to content
Merged

Dev #18

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp_config
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ To display a tip (and not a quote) in your vim-startify you can include the foll

You'll probably also want to deactivate the basic tip display at startup.

## Add your own tips

If you want, you can add your own tips by modifying the files in the tips folder.
You may find them on your own system (probably in your plugin manager's files), but to simplify that I suggest forking my repo and adding your own changes in a version controlled repo.

Tips must not exceed 70 characters

## Important note

Expand Down
12 changes: 12 additions & 0 deletions convert_file_to_vim_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys

if len(sys.argv) != 2:
print("This script requires an argument corresponding to the file path to listify")

filepath = sys.argv[1]

with open(filepath, 'r') as f:
print("[", end="")
for line in f.readlines():
print("\"" + line.strip("\n") + "\",", end="")
print("]")
3 changes: 2 additions & 1 deletion plugin/tips/miscallenous.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ gt : show next tab
C-w : (in insert mode) erases word from start to position
C-u : (in insert mode) erases line from start to position
// : run your previous search
CTRL + w + x : exchange with next window
C-w-x : exchange with next window
set <option> ? : see the value of a config option
19 changes: 19 additions & 0 deletions plugin/tips/othermodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
C-k (+characters) : insert digraphs (æ,π...) in insert mode
C-K * p : insert π (in insert mode)
C-K Eu : insert € (in insert mode)
C-K +- : insert ± (in insert mode)
C-K OK : insert ✓ (in insert mode)
C-K XX : insert ✗ (in insert mode)
C-K AN : insert ∧ ('and' symbol) (in insert mode)
C-K OR : insert ∨ ('or' symbol) (in insert mode)
C-K (- : insert ∈ (in insert mode)
C-a : insert the last content inserted (in insert mode)
C-@ : insert the last content insert and quit insert mode (in insert mode)
C-h : delete character before the cursor (in insert mode)
C-l : delete character after the cursor (like Del) (in insert mode)
C-w : delete word under cursor (in insert mode)
C-o : execute one normal or command-mode and return to insert (in insert mode)
o : move cursor to opposite side of selection (in visual mode)
U : Uppercase the selection
C-v : Change to visual-bloc mode (from visual mode)
S-v : Change to visual mode (from visual-bloc mode)
72 changes: 66 additions & 6 deletions plugin/vim-tips.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ let s:vimrc = $MYVIMRC


function Rand()
"ok-tier rng
return str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:])
endfunction



function GetTip()
let s:random_number = Rand()
let s:number_categories = 9
let s:number_categories = 10
let s:chosen_category = s:random_number % s:number_categories

let s:tip = ""
Expand All @@ -42,6 +43,8 @@ function GetTip()
let s:tip = GetPhrases()
elseif s:chosen_category == 8
let s:tip = GetSelection()
elseif s:chosen_category == 9
let s:tip = GetOtherModes()
endif
return s:tip
endfunction
Expand Down Expand Up @@ -77,6 +80,11 @@ function GetMarkers()
return s:tiplist[s:index]
endfunction

function GetOtherModes()
let s:tiplist = ["C-k (+characters) : insert digraphs (æ,π...) in insert mode","C-K * p : insert π (in insert mode)","C-K Eu : insert € (in insert mode)","C-K +- : insert ± (in insert mode)","C-K OK : insert ✓ (in insert mode)","C-K XX : insert ✗ (in insert mode)","C-K AN : insert ∧ ('and' symbol) (in insert mode)","C-K OR : insert ∨ ('or' symbol) (in insert mode)","C-K (- : insert ∈ (in insert mode)","C-a : insert the last content inserted (in insert mode)","C-@ : insert the last content insert and quit insert mode (in insert mode)","C-h : delete character before the cursor (in insert mode)","C-l : delete character after the cursor (like Del) (in insert mode)","C-w : delete word under cursor (in insert mode)","C-o : execute one normal or command-mode and return to insert (in insert mode)","o : move cursor to opposite side of selection (in visual mode)","U : Uppercase the selection","C-v : Change to visual-bloc mode (from visual mode)","S-v : Change to visual mode (from visual-bloc mode)",]
let s:index = Rand() % len(s:tiplist)
return s:tiplist[s:index]
endfunction



Expand All @@ -88,7 +96,7 @@ endfunction


function GetMiscallenous()
let s:tiplist =[":w! sudo tee % :write as root (ask password)","CTRL + w + = :resize splits equally","[[ : jump to function start",":new file.txt : open file.txt in new split","gt : show next tab","=% : indent code between parenthesis","C-w : (in insert mode) erases word from start to position","C-u : (in insert mode) erases line from start to position","// : run your previous search","CTRL + w + x : exchange with next window",]
let s:tiplist =[":w! sudo tee % :write as root (ask password)","CTRL + w + = :resize splits equally","[[ : jump to function start",":new file.txt : open file.txt in new split","gt : show next tab","=% : indent code between parenthesis","C-w : (in insert mode) erases word from start to position","C-u : (in insert mode) erases line from start to position","// : run your previous search","CTRL + w + x : exchange with next window", "set <option> ? : see the value of a config option", "C-k (+characters) : insert digraphs (æ,π...) in insert mode","C-K-*-p : insert π (in insert mode)",]
let s:index = Rand() % len(s:tiplist)
return s:tiplist[s:index]
endfunction
Expand Down Expand Up @@ -116,13 +124,65 @@ function GetSelection()
return s:tiplist[s:index]
endfunction

function DisplayTip()

let s:prefix = "Tip => "
echo s:prefix.g:GetTip()
function GetPathTmpFile()
if has('win32')
let tmpfilepath = resolve(expand('<sfile>:p:h')).'\tmp_config'
else
let tmpfilepath = resolve(expand('<sfile>:p:h')).'/tmp_config'
endif
return tmpfilepath
endfunction

function GetConfig()
try
let tmpfilepath =GetPathTmpFile()
let s:configlist = readfile(tmpfilepath)
let s:config= s:configlist[0]
catch
return ""
endtry
return s:config
endfunction


function PrepareNextConfig()
let tmpfilepath = GetPathTmpFile()
if has('win32')
"nothing yet
else
" on UNIX-like OS
silent !sleep 5 &
"instead, start here a bash/python script in background (&) that remove the first line
"of the tmpfile and if it is empty, populate it with the config fetched
endif
endfunction




function DisplayTipOrConfig()
let s:very_random_float = (Rand() % 100) +150
if s:vim_tips_tips_frequency * 100> s:very_random_float
let s:prefix = "Tip => "
echo s:prefix.g:GetTip()
else
let s:configtip = GetConfig()
if s:configtip == "" "failed to get a proper mapping, return a normal tip instead
let s:prefix = "Tip => "
echo s:prefix.g:GetTip()
return
endif


"got a proper mapping
let s:prefix = "Config =>"
echo s:prefix.s:configtip
call PrepareNextConfig()
endif
endfunction


if s:vim_tips_display_at_startup
autocmd VimEnter * call DisplayTip()
autocmd VimEnter * call DisplayTipOrConfig()
endif