Compare commits
2 Commits
482f80003c
...
0874c4ad9a
| Author | SHA1 | Date | |
|---|---|---|---|
| 0874c4ad9a | |||
| 869482ba91 |
@@ -194,7 +194,7 @@ end
|
|||||||
|
|
||||||
local last_theme = 'default'
|
local last_theme = 'default'
|
||||||
|
|
||||||
function set_current_theme()
|
local function set_current_theme()
|
||||||
local path = os.getenv('HOME') .. '/.config/xsettingsd/xsettingsd.conf'
|
local path = os.getenv('HOME') .. '/.config/xsettingsd/xsettingsd.conf'
|
||||||
local f = io.open(path)
|
local f = io.open(path)
|
||||||
if f then
|
if f then
|
||||||
@@ -241,6 +241,39 @@ local function close_next_win()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function ensure_last_line_empty()
|
||||||
|
local size = vis.win.file.size
|
||||||
|
if size > 0 then
|
||||||
|
if vis.win.file:content(size - 1, size) ~= '\n' then
|
||||||
|
vis.win.file:insert(size, '\n')
|
||||||
|
end
|
||||||
|
local lines = vis.win.file.lines
|
||||||
|
if string.find(lines[#lines], '%S') then
|
||||||
|
lines[#lines + 1] = ''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function add_note()
|
||||||
|
local path = vis.win.file.path
|
||||||
|
local line = path and path .. ':' .. vis.win.selection.line .. ':' .. vis.win.selection.col .. ': ' .. vis.win.file.lines[vis.win.selection.line]
|
||||||
|
vis:command('o ~/notes/notes.md')
|
||||||
|
ensure_last_line_empty()
|
||||||
|
local lines = vis.win.file.lines
|
||||||
|
lines[#lines + 1] = '## '
|
||||||
|
local pos = vis.win.file.size - 1
|
||||||
|
local code, date, err = vis:pipe("date '+%F %T'")
|
||||||
|
if code ~= 0 then
|
||||||
|
vis:message(err)
|
||||||
|
else
|
||||||
|
lines[#lines + 1] = '* time: ' .. date:gsub('%s+$', '')
|
||||||
|
end
|
||||||
|
if line then
|
||||||
|
lines[#lines + 1] = '* line: ' .. line
|
||||||
|
end
|
||||||
|
vis.win.selection.pos = pos
|
||||||
|
end
|
||||||
|
|
||||||
vis.events.subscribe(vis.events.INIT, function()
|
vis.events.subscribe(vis.events.INIT, function()
|
||||||
vis:command('set autoindent')
|
vis:command('set autoindent')
|
||||||
|
|
||||||
@@ -346,9 +379,7 @@ vis.events.subscribe(vis.events.INIT, function()
|
|||||||
vis:command('o ~/.config/vis/global-marks.txt')
|
vis:command('o ~/.config/vis/global-marks.txt')
|
||||||
end, 'global marks: edit')
|
end, 'global marks: edit')
|
||||||
|
|
||||||
vis:map(vis.modes.NORMAL, ' n', function()
|
vis:map(vis.modes.NORMAL, ' n', add_note)
|
||||||
vis:command('o ~/notes/notes.md')
|
|
||||||
end, 'add note')
|
|
||||||
|
|
||||||
vis:map(vis.modes.NORMAL, ' N', function()
|
vis:map(vis.modes.NORMAL, ' N', function()
|
||||||
search(fzf_reload(ripgrep .. ' --with-filename {q} ~/notes'))
|
search(fzf_reload(ripgrep .. ' --with-filename {q} ~/notes'))
|
||||||
|
|||||||
Reference in New Issue
Block a user