Merge branch 'neovim-0.5.0' of github.com:esensar/dotfiles into neovim-0.5.0
commit
aaa341784e
|
@ -6,4 +6,4 @@ Contains configurations for many applications, most importantly:
|
||||||
- `sway` - Wayland compositor
|
- `sway` - Wayland compositor
|
||||||
- `newsboat` - my RSS reader
|
- `newsboat` - my RSS reader
|
||||||
- `alacritty` - my terminal emulator
|
- `alacritty` - my terminal emulator
|
||||||
- `coc` - `coc.nvim` plugin settings for `neovim`
|
- `coc` - `coc.nvim` plugin settings for `vim`
|
||||||
|
|
|
@ -4,20 +4,20 @@
|
||||||
-- DEPENDS ON VIMWIKI PLUGIN
|
-- DEPENDS ON VIMWIKI PLUGIN
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
vim.cmd[[command! -nargs=? VimwikiWeeklyReview :lua require('vimwiki_reviews').vimwiki_weekly_review(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiWeeklyReview :lua require('vimwiki_reviews').vimwiki_weekly_review(<count>)]]
|
||||||
vim.cmd[[command! -nargs=? VimwikiWeeklyTemplate :lua require('vimwiki_reviews').open_review_weekly_template(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiWeeklyTemplate :lua require('vimwiki_reviews').open_review_weekly_template(<count>)]]
|
||||||
vim.cmd[[command! -nargs=? VimwikiMonthlyReview :lua require('vimwiki_reviews').vimwiki_monthly_review(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiMonthlyReview :lua require('vimwiki_reviews').vimwiki_monthly_review(<count>)]]
|
||||||
vim.cmd[[command! -nargs=? VimwikiMonthlyTemplate :lua require('vimwiki_reviews').open_review_monthly_template(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiMonthlyTemplate :lua require('vimwiki_reviews').open_review_monthly_template(<count>)]]
|
||||||
vim.cmd[[command! -nargs=? VimwikiYearlyReview :lua require('vimwiki_reviews').vimwiki_yearly_review(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiYearlyReview :lua require('vimwiki_reviews').vimwiki_yearly_review(<count>)]]
|
||||||
vim.cmd[[command! -nargs=? VimwikiYearlyTemplate :lua require('vimwiki_reviews').open_review_yearly_template(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiYearlyTemplate :lua require('vimwiki_reviews').open_review_yearly_template(<count>)]]
|
||||||
vim.cmd[[command! -nargs=? VimwikiReviewIndex :lua require('vimwiki_reviews').vimwiki_review_index(<f-args>)]]
|
vim.cmd[[command! -count=0 VimwikiReviewIndex :lua require('vimwiki_reviews').vimwiki_review_index(<count>)]]
|
||||||
|
|
||||||
local default_opts = {noremap=true}
|
local default_opts = {noremap=true}
|
||||||
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
||||||
set_keymap('n', '<Leader>wrw', '<cmd>VimwikiWeeklyReview<CR>', default_opts)
|
set_keymap('n', '<Leader>wrw', "<Cmd>lua require('vimwiki_reviews').vimwiki_weekly_review(vim.v.count)<CR>", default_opts)
|
||||||
set_keymap('n', '<Leader>wrtw', '<cmd>VimwikiWeeklyTemplate<CR>', default_opts)
|
set_keymap('n', '<Leader>wrtw', "<Cmd>lua require('vimwiki_reviews').open_review_weekly_template(vim.v.count)<CR>", default_opts)
|
||||||
set_keymap('n', '<Leader>wrm', '<cmd>VimwikiMonthlyReview<CR>', default_opts)
|
set_keymap('n', '<Leader>wrm', "<Cmd>lua require('vimwiki_reviews').vimwiki_monthly_review(vim.v.count)<CR>", default_opts)
|
||||||
set_keymap('n', '<Leader>wrtm', '<cmd>VimwikiMonthlyTemplate<CR>', default_opts)
|
set_keymap('n', '<Leader>wrtm', "<Cmd>lua require('vimwiki_reviews').open_review_monthly_template(vim.v.count)<CR>", default_opts)
|
||||||
set_keymap('n', '<Leader>wry', '<cmd>VimwikiYearlyReview<CR>', default_opts)
|
set_keymap('n', '<Leader>wry', "<Cmd>lua require('vimwiki_reviews').vimwiki_yearly_review(vim.v.count)<CR>", default_opts)
|
||||||
set_keymap('n', '<Leader>wrty', '<cmd>VimwikiYearlyTemplate<CR>', default_opts)
|
set_keymap('n', '<Leader>wrty', "<Cmd>lua require('vimwiki_reviews').open_review_yearly_template(vim.v.count)<CR>", default_opts)
|
||||||
set_keymap('n', '<Leader>wri', '<cmd>VimwikiReviewIndex<CR>', default_opts)
|
set_keymap('n', '<Leader>wri', "<Cmd>lua require('vimwiki_reviews').vimwiki_review_index(vim.v.count)<CR>", default_opts)
|
||||||
|
|
|
@ -6,13 +6,18 @@ local Path = require('plenary.path')
|
||||||
local scandir = require('plenary.scandir')
|
local scandir = require('plenary.scandir')
|
||||||
|
|
||||||
-- Gets path to reviews dir of provided vimwiki (by index)
|
-- Gets path to reviews dir of provided vimwiki (by index)
|
||||||
local function get_reviews_dir(...)
|
local function get_reviews_dir(vimwiki_index)
|
||||||
local vimwiki = {}
|
local vimwiki = {}
|
||||||
if (select('#', ...) == 0)
|
if (vimwiki_index == 0)
|
||||||
then
|
then
|
||||||
vimwiki = vim.g.vimwiki_list[1]
|
local current_index = vim.fn['vimwiki#vars#get_bufferlocal']('wiki_nr')
|
||||||
|
if (current_index < 0)
|
||||||
|
then
|
||||||
|
current_index = 0
|
||||||
|
end
|
||||||
|
vimwiki = vim.g.vimwiki_list[current_index + 1]
|
||||||
else
|
else
|
||||||
vimwiki = vim.g.vimwiki_list[tonumber(select(1, ...))]
|
vimwiki = vim.g.vimwiki_list[vimwiki_index]
|
||||||
end
|
end
|
||||||
|
|
||||||
return vimwiki.path .. 'reviews/'
|
return vimwiki.path .. 'reviews/'
|
||||||
|
@ -34,7 +39,7 @@ end
|
||||||
-- - %date% (Puts different date based on review type)
|
-- - %date% (Puts different date based on review type)
|
||||||
local function read_review_template_into_buffer(vimwiki_reviews_path, review_type)
|
local function read_review_template_into_buffer(vimwiki_reviews_path, review_type)
|
||||||
local template_path = get_review_template_path(vimwiki_reviews_path, review_type)
|
local template_path = get_review_template_path(vimwiki_reviews_path, review_type)
|
||||||
if (vim.fn.filereadable(vim.fn.glob(template_path)))
|
if (vim.fn.filereadable(vim.fn.glob(template_path)) ~= 0)
|
||||||
then
|
then
|
||||||
vim.cmd('read ' .. template_path)
|
vim.cmd('read ' .. template_path)
|
||||||
vim.cmd('0d')
|
vim.cmd('0d')
|
||||||
|
@ -69,28 +74,28 @@ end
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- Edits weekly review template
|
-- Edits weekly review template
|
||||||
function M.open_review_weekly_template(...)
|
function M.open_review_weekly_template(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
vim.cmd('edit ' .. get_review_template_path(reviews_dir, 'week'))
|
vim.cmd('edit ' .. get_review_template_path(reviews_dir, 'week'))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Edits monthly review template
|
-- Edits monthly review template
|
||||||
function M.open_review_monthly_template(...)
|
function M.open_review_monthly_template(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
vim.cmd('edit ' .. get_review_template_path(reviews_dir, 'month'))
|
vim.cmd('edit ' .. get_review_template_path(reviews_dir, 'month'))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Edits yearly review template
|
-- Edits yearly review template
|
||||||
function M.open_review_yearly_template(...)
|
function M.open_review_yearly_template(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
vim.cmd('edit ' .. get_review_template_path(reviews_dir, 'year'))
|
vim.cmd('edit ' .. get_review_template_path(reviews_dir, 'year'))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open current week weekly review file
|
-- Open current week weekly review file
|
||||||
-- Created buffer is dated to Sunday of current week
|
-- Created buffer is dated to Sunday of current week
|
||||||
-- Opens current week because Sunday is good time to do this review
|
-- Opens current week because Sunday is good time to do this review
|
||||||
function M.vimwiki_weekly_review(...)
|
function M.vimwiki_weekly_review(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
local days_to_sunday = 7 - tonumber(os.date('%u'))
|
local days_to_sunday = 7 - tonumber(os.date('%u'))
|
||||||
local week_date = os.date('%Y-%m-%d', os.time() + days_to_sunday * 24 * 60 * 60)
|
local week_date = os.date('%Y-%m-%d', os.time() + days_to_sunday * 24 * 60 * 60)
|
||||||
local file_name = reviews_dir .. week_date .. '-week.md'
|
local file_name = reviews_dir .. week_date .. '-week.md'
|
||||||
|
@ -108,8 +113,8 @@ end
|
||||||
-- Created buffer is dated to previous month
|
-- Created buffer is dated to previous month
|
||||||
-- Previous month is calculated in an erroneous way
|
-- Previous month is calculated in an erroneous way
|
||||||
-- 28 days are subtracted from current time to get previous month
|
-- 28 days are subtracted from current time to get previous month
|
||||||
function M.vimwiki_monthly_review(...)
|
function M.vimwiki_monthly_review(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
local month_time = os.time() - 28 * 24 * 60 * 60
|
local month_time = os.time() - 28 * 24 * 60 * 60
|
||||||
local month_date = os.date('%Y-%m', month_time)
|
local month_date = os.date('%Y-%m', month_time)
|
||||||
local file_name = reviews_dir .. month_date .. '-month.md'
|
local file_name = reviews_dir .. month_date .. '-month.md'
|
||||||
|
@ -124,8 +129,8 @@ end
|
||||||
|
|
||||||
-- Open past year yearly review file
|
-- Open past year yearly review file
|
||||||
-- Created buffer is dated to previous year
|
-- Created buffer is dated to previous year
|
||||||
function M.vimwiki_yearly_review(...)
|
function M.vimwiki_yearly_review(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
local year_date = (tonumber(os.date('%Y')) - 1)
|
local year_date = (tonumber(os.date('%Y')) - 1)
|
||||||
local file_name = reviews_dir .. year_date .. '-year.md'
|
local file_name = reviews_dir .. year_date .. '-year.md'
|
||||||
local exists = file_exists_or_open(file_name)
|
local exists = file_exists_or_open(file_name)
|
||||||
|
@ -140,8 +145,8 @@ end
|
||||||
-- Generates review index table
|
-- Generates review index table
|
||||||
-- Takes arguments similar to all vimwiki calls
|
-- Takes arguments similar to all vimwiki calls
|
||||||
-- (no args, or 1 arg representing vimwiki index)
|
-- (no args, or 1 arg representing vimwiki index)
|
||||||
function M.get_review_index(...)
|
function M.get_review_index(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
local reviews_path = Path:new(reviews_dir):expand()
|
local reviews_path = Path:new(reviews_dir):expand()
|
||||||
|
|
||||||
local entries = scandir.scan_dir(
|
local entries = scandir.scan_dir(
|
||||||
|
@ -209,11 +214,11 @@ function M.get_review_index(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open reviews index file
|
-- Open reviews index file
|
||||||
function M.vimwiki_review_index(...)
|
function M.vimwiki_review_index(vimwiki_index)
|
||||||
local reviews_dir = get_reviews_dir(...)
|
local reviews_dir = get_reviews_dir(vimwiki_index)
|
||||||
vim.cmd('edit ' .. reviews_dir .. 'reviews.md')
|
vim.cmd('edit ' .. reviews_dir .. 'reviews.md')
|
||||||
|
|
||||||
local index = M.get_review_index(...)
|
local index = M.get_review_index(vimwiki_index)
|
||||||
|
|
||||||
local lines = {
|
local lines = {
|
||||||
'# Reviews',
|
'# Reviews',
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[user]
|
[user]
|
||||||
name = Enasr Sarajčić
|
name = Ensar Sarajčić
|
||||||
email = ensar@optimum.ba
|
email = ensar@optimum.ba
|
||||||
|
|
Loading…
Reference in New Issue