Skip to content

Commit

Permalink
new features, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
mipmip committed Mar 7, 2023
1 parent 404db6d commit 268d007
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
## Next
- add copy document menu action

## 0.7.1 - 5 mar 2023

- new action: set taxonomy
- new action: remove taxonomy
- make ONLY config AND not OR
- replace - for space in GROUP_BY

## 0.7.0 - 17 feb 2023
- fix DIR and FILE wikitags on non macOS machines
- improve help
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Using vim-plug:
Plug 'linden-project/linny.vim'
```

## Install fred

Some features for linny require [fred](https://github.com/linden-project/fred).

Install the latest version on your system. Linny will show the version in the
linny menu.

# Documentation

The official manual can be read directly in Vim:
Expand Down
162 changes: 151 additions & 11 deletions autoload/linny_menu.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let t:linny_menu_view = ""
let t:linny_menu_taxonomy = ""
let t:linny_menu_term = ""
let t:linny_menu_current_menu_type = "not_set"
let t:linny_menu_repeat_last_taxo_term = []

" INTERNAL STATE
function! linny_menu#tabInitState()
Expand Down Expand Up @@ -436,7 +437,7 @@ function! s:menu_level1(tax)

if(has_key(termslistDict[val], group_by))

let group_by_val = tolower(get(termslistDict[val], group_by))
let group_by_val = substitute(tolower(get(termslistDict[val], group_by)), '-', ' ', 'g')

if !has_key(term_menu,group_by_val)
let term_menu[group_by_val] = []
Expand All @@ -462,7 +463,7 @@ function! s:menu_level1(tax)
endfor

for group in sort(keys(term_menu))
call s:add_item_section("### " . linny_menu#string_capitalize(group) )
call s:add_item_section("### " . linny_menu#string_capitalize( substitute(group, '-', ' ', 'g') ) )

for val in term_menu[group]
call s:add_item_document_taxo_key_val(a:tax, val, 0)
Expand Down Expand Up @@ -800,7 +801,8 @@ function! s:menu_level2(tax, term)
let group_by = get(view_props,'group_by')

if has_key(files_index[file_in_menu], group_by)
let group_by_val = tolower(get(files_index[file_in_menu], group_by))
"let group_by_val = tolower(get(files_index[file_in_menu], group_by))
let group_by_val = substitute(tolower(get(files_index[file_in_menu], group_by)), '-', ' ', 'g')

if !has_key(files_menu,group_by_val)
let files_menu[group_by_val] = []
Expand Down Expand Up @@ -889,13 +891,19 @@ function! s:displayFileAskViewProps(view_props, file_dict)
endif

if has_key(a:view_props, 'only')
let onlystatus = 0
let onlycount = 0
for only_dict in a:view_props.only
if s:testFileWithDisplayExpression(a:file_dict, only_dict)
let onlystatus = 1
end
let onlycount += 1
endif
endfor
return onlystatus

if onlycount == len(a:view_props.only)
return 1
else
return 0
endif

endif

return 1
Expand Down Expand Up @@ -1600,7 +1608,13 @@ function! linny_menu#dropdown_item()
let t:linny_menu_dropdownviews = ["archive"]
let name = t:linny_menu_item_for_dropdown.option_data.taxo_term
elseif t:linny_menu_item_for_dropdown.option_type == 'document'
let t:linny_menu_dropdownviews = ["copy", "archive"]

let t:linny_menu_dropdownviews = ["copy", "------", "archive", "set taxonomy", "remove taxonomy"]

if len(t:linny_menu_repeat_last_taxo_term) > 0
let t:linny_menu_dropdownviews += ["set " . t:linny_menu_repeat_last_taxo_term[0] .": ". t:linny_menu_repeat_last_taxo_term[1]]
endif

let name = trim(split(t:linny_menu_item_for_dropdown.text,']')[1])
else
return
Expand All @@ -1624,10 +1638,71 @@ function! linny_menu#dropdown_item()
endfunction

function! linny_menu#dropdown_item_callcack(id, result)

if a:result != -1
call linny_menu#exec_content_menu(t:linny_menu_dropdownviews[a:result-1],t:linny_menu_item_for_dropdown)
else
let t:linny_menu_item_for_dropdown = 0
endif

endfunction

function! linny_menu#dropdown_taxo_item_callcack(id, result)

if a:result != -1

let name = trim(split(t:linny_menu_item_for_dropdown.text,']')[1])
let t:linny_menu_set_taxo = t:linny_menu_taxo_items_for_dropdown[a:result-1]

let termslistDict = linny#parse_json_file(linny#l1_index_filepath(t:linny_menu_set_taxo), [] )
let t:linny_menu_term_items_for_dropdown = sort(keys(termslistDict))

call popup_create(t:linny_menu_term_items_for_dropdown, #{
\ zindex: 400,
\ drag: 0,
\ line: t:linny_menu_line + 1,
\ title: name . ': ' . t:linny_menu_set_taxo . ' > Set Term',
\ col: 10,
\ wrap: 0,
\ border: [],
\ cursorline: 1,
\ padding: [0,1,0,1],
\ filter: 'popup_filter_menu',
\ mapping: 0,
\ callback: 'linny_menu#dropdown_term_item_callcack',
\ })
return
endif
return
endfunction

function! linny_menu#dropdown_remove_taxo_item_callcack(id, result)

if a:result != -1

let item = t:linny_menu_item_for_dropdown
let unset_taxo = t:linny_menu_taxo_items_for_dropdown[a:result-1]

call job_start( ["fred" ,'unset_key', item.option_data.abs_path, unset_taxo])
echo "Removed ". unset_taxo . " from " . item.option_data.abs_path

return
endif
let t:linny_menu_item_for_dropdown = 0
return
endfunction

function! linny_menu#dropdown_term_item_callcack(id, result)

if a:result != -1

let item = t:linny_menu_item_for_dropdown
let taxo_item = t:linny_menu_set_taxo
let term_item = t:linny_menu_term_items_for_dropdown[a:result-1]

call job_start( ["fred" ,'set_string_val', item.option_data.abs_path, taxo_item, term_item])
let t:linny_menu_repeat_last_taxo_term = [taxo_item, term_item]
endif

endfunction

function! linny_menu#exec_content_menu(action, item)
Expand All @@ -1640,8 +1715,12 @@ function! linny_menu#exec_content_menu(action, item)

elseif a:item.option_type == 'document'

if a:action == "archive"
call job_start( ["fred" ,'set_key_val', a:item.option_data.abs_path, 'archive', 'true'])
if a:action == "set archive"
call job_start( ["fred" ,'set_bool_val', a:item.option_data.abs_path, 'archive', 'true'])
return

elseif a:action == "toggle starred"
call job_start( ["fred" ,'toggle_bool_val', a:item.option_data.abs_path, 'starred'])
return

elseif a:action == "copy"
Expand All @@ -1650,7 +1729,68 @@ function! linny_menu#exec_content_menu(action, item)
call inputrestore()
call linny_menu#copy_document(a:item.option_data.abs_path, name)
return

elseif a:action == "set taxonomy"

let index_keys_list = linny#parse_json_file(g:linny_index_path . '/_index_taxonomies.json', [])
for k in sort(index_keys_list)
call s:add_item_document_taxo_key(k)
endfor

let t:linny_menu_taxo_items_for_dropdown = sort(index_keys_list)
let name = trim(split(t:linny_menu_item_for_dropdown.text,']')[1])

call popup_create(t:linny_menu_taxo_items_for_dropdown, #{
\ zindex: 300,
\ drag: 0,
\ line: t:linny_menu_line + 1,
\ title: name . ': Set Taxonomy',
\ col: 10,
\ wrap: 0,
\ border: [],
\ cursorline: 1,
\ padding: [0,1,0,1],
\ filter: 'popup_filter_menu',
\ mapping: 0,
\ callback: 'linny_menu#dropdown_taxo_item_callcack',
\ })

return

elseif a:action == "remove taxonomy"

let index_keys_list = linny#parse_json_file(g:linny_index_path . '/_index_taxonomies.json', [])
for k in sort(index_keys_list)
call s:add_item_document_taxo_key(k)
endfor

let t:linny_menu_taxo_items_for_dropdown = sort(index_keys_list)
let name = trim(split(t:linny_menu_item_for_dropdown.text,']')[1])

call popup_create(t:linny_menu_taxo_items_for_dropdown, #{
\ zindex: 300,
\ drag: 0,
\ line: t:linny_menu_line + 1,
\ title: name . ': Remove Taxonomy',
\ col: 10,
\ wrap: 0,
\ border: [],
\ cursorline: 1,
\ padding: [0,1,0,1],
\ filter: 'popup_filter_menu',
\ mapping: 0,
\ callback: 'linny_menu#dropdown_remove_taxo_item_callcack',
\ })

return

elseif a:action =~ "set "

let taxo_and_term = split(a:action[4:-1],': ')
call job_start( ["fred" ,'set_string_val', a:item.option_data.abs_path, taxo_and_term[0], taxo_and_term[1]])

endif

endif

endfunction
Expand Down
2 changes: 1 addition & 1 deletion autoload/linny_version.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" Copyright (c) Pim Snel 2019-2023

function! linny_version#PluginVersion()
return '0.7.0'
return '0.7.1'
endfunction

0 comments on commit 268d007

Please sign in to comment.