Compare commits
6 Commits
8202d991df
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
955ceb2f61 | ||
|
|
83b45009e3 | ||
|
|
d8d0c45bc3 | ||
|
|
bd8f338b4a | ||
|
|
00cbb851ec | ||
|
|
e9a0809911 |
3
init.lua
3
init.lua
@@ -1,6 +1,6 @@
|
||||
-- adjust proxy on Windows
|
||||
if vim.loop.os_environ().OS == 'Windows_NT' then
|
||||
-- TODO move out of the tree and do not check in
|
||||
-- TODO move out of the tree
|
||||
vim.fn.setenv("http_proxy", "http://10.167.16.21:80")
|
||||
vim.fn.setenv("https_proxy", "http://10.167.16.21:80")
|
||||
end
|
||||
@@ -14,7 +14,6 @@ require('colorscheme')
|
||||
require('lsp')
|
||||
require('keybindings')
|
||||
require('layout')
|
||||
require('stopwatch').setup({})
|
||||
|
||||
if vim.loop.os_gethostname() == 'slaptop' then
|
||||
require('diary')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- define your colorscheme here
|
||||
local colorscheme = 'lunaperche-sl'
|
||||
local COLORSCHEME = 'lunaperche-sl'
|
||||
|
||||
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. COLORSCHEME)
|
||||
if not is_ok then
|
||||
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
|
||||
vim.notify('colorscheme ' .. COLORSCHEME .. ' not found!')
|
||||
return
|
||||
end
|
||||
|
||||
@@ -89,7 +89,7 @@ local buttons = {
|
||||
dashboard.button('q', ' Quit', '<cmd>qa<CR>'),
|
||||
}
|
||||
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
if vim.loop.os_gethostname() == 'slaptop' then
|
||||
table.insert(buttons, 1,
|
||||
dashboard.button('d', ' Diary Entry', '<cmd>Diary<CR>'))
|
||||
end
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
local DIARY_FOLDER = vim.fs.joinpath(vim.env.HOME, '.diary/asciidoc')
|
||||
|
||||
local diary_open = function(opts)
|
||||
local date = opts.args ~= '' and opts.args or os.date('%Y-%m-%d')
|
||||
local year, month = date:match('(%d%d%d%d)-(%d%d)')
|
||||
local folder = vim.fs.joinpath(vim.env.HOME, string.format('.diary/asciidoc/%s', year))
|
||||
local folder = vim.fs.joinpath(DIARY_FOLDER, string.format('%s', year))
|
||||
vim.fn.mkdir(folder, "p")
|
||||
local file = string.format('%s/diary-%s-%s.adoc', folder, year, month)
|
||||
print("file is:", file)
|
||||
|
||||
@@ -19,7 +19,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||
vim.keymap.set("n", '<space>F', ":silent !dx fmt --file %<cr>", { desc = "DX format rsx! regions", unpack(bufopts) })
|
||||
vim.keymap.set("v", "<space>f", LSPRangeFormatFunction, { desc = "LSP Format region" })
|
||||
|
||||
-- 2024-09-09 - some ccflow commands for diagnostics, symbols and code actions
|
||||
-- 2024-09-09 - some commands for diagnostics, symbols and code actions
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<space>d', fzf.diagnostics_document, { desc = "Document diagnostics" })
|
||||
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
|
||||
@@ -67,7 +67,7 @@ function LSPRangeFormatFunction()
|
||||
end
|
||||
|
||||
local enable_this_lsp = {}
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
if vim.loop.os_gethostname() == 'slaptop' then
|
||||
-- VUE and Typescript as of vue-language-server 3.0.x
|
||||
-- taken from:
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#vtsls
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
---------------------------------------------------
|
||||
|
||||
-- this is specific for a machine
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
_G.ORG_BASE_FOLDER = '~/Documents/Eigene (Briefe etc.)/org'
|
||||
else
|
||||
_G.ORG_BASE_FOLDER = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles'
|
||||
local ORG_BASE_FOLDER = '~/Documents/Eigene (Briefe etc.)/org'
|
||||
if vim.loop.os_gethostname() != 'slaptop' then
|
||||
ORG_BASE_FOLDER = '~/OneDrive/Desktop/orgfiles'
|
||||
end
|
||||
sl_opt = {
|
||||
org_base_folder = ORG_BASE_FOLDER,
|
||||
|
||||
@@ -209,7 +209,7 @@ require("lazy").setup({
|
||||
org_default_notes_file = sl_opt.org_default_notes_file,
|
||||
org_archive_location = sl_opt.org_archive_location,
|
||||
org_capture_templates = {
|
||||
t = { description = 'Task', template = "* TODO %?\n %u" },
|
||||
t = { description = 'Task', template = "* TODO %u %?" },
|
||||
i = { description = 'Interruption', template = "* STARTED [#A] %^{Working on}\n %U\n %a\n" },
|
||||
},
|
||||
org_todo_keywords = { 'TODO(t)', 'STARTED(s)', 'PLANNED(p)', '|', 'DONE(d)', 'UNPLANNED(u)' },
|
||||
@@ -566,6 +566,8 @@ require("lazy").setup({
|
||||
-- },
|
||||
-- },
|
||||
|
||||
-- 2026-04-20 this is a very nice plugin, a good candidate to replace
|
||||
-- nvim-tree if only it would have some easy "follow file" mode
|
||||
{
|
||||
"A7Lavinraj/fyler.nvim",
|
||||
dependencies = { "nvim-mini/mini.icons" },
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
-- ~/.config/nvim/lua/stopwatch.lua
|
||||
-- Simple visible stopwatch for Neovim
|
||||
local M = {}
|
||||
local uv = vim.loop
|
||||
|
||||
local state = {
|
||||
running = false,
|
||||
start_hr = 0, -- hrtime at start (nanoseconds)
|
||||
elapsed_ns = 0, -- accumulated nanoseconds when stopped
|
||||
name = nil,
|
||||
timer = nil,
|
||||
bufnr = nil,
|
||||
win = nil,
|
||||
opts = nil,
|
||||
}
|
||||
|
||||
local function ns_to_time(ns)
|
||||
local s = ns / 1e9
|
||||
local h = math.floor(s / 3600)
|
||||
s = s - h * 3600
|
||||
local m = math.floor(s / 60)
|
||||
local sec = s - m * 60
|
||||
local secs = math.floor(sec)
|
||||
local ms = math.floor((sec - secs) * 1000)
|
||||
if h > 0 then
|
||||
return string.format("%02d:%02d:%02d.%03d", h, m, secs, ms)
|
||||
else
|
||||
return string.format("%02d:%02d.%03d", m, secs, ms)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_elapsed_ns()
|
||||
if state.running then
|
||||
return state.elapsed_ns + (uv.hrtime() - state.start_hr)
|
||||
else
|
||||
return state.elapsed_ns
|
||||
end
|
||||
end
|
||||
|
||||
local function ensure_win()
|
||||
if state.win and vim.api.nvim_win_is_valid(state.win) then return end
|
||||
if not state.bufnr or not vim.api.nvim_buf_is_valid(state.bufnr) then
|
||||
state.bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_option(state.bufnr, "bufhidden", "wipe")
|
||||
vim.api.nvim_buf_set_option(state.bufnr, "modifiable", false)
|
||||
vim.api.nvim_buf_set_option(state.bufnr, "filetype", "stopwatch")
|
||||
end
|
||||
|
||||
local width = state.opts.width or 24
|
||||
local height = 1
|
||||
local col = (vim.o.columns - width) - (state.opts.margin_right or 2)
|
||||
local row = state.opts.row or 1
|
||||
|
||||
local win_opts = {
|
||||
relative = "editor",
|
||||
anchor = "NW",
|
||||
row = row,
|
||||
col = col,
|
||||
width = width,
|
||||
height = height,
|
||||
style = "minimal",
|
||||
focusable = false,
|
||||
noautocmd = true,
|
||||
}
|
||||
state.win = vim.api.nvim_open_win(state.bufnr, false, win_opts)
|
||||
vim.api.nvim_win_set_option(state.win, "winblend", state.opts.winblend or 5)
|
||||
end
|
||||
|
||||
local function close_win()
|
||||
if state.win and vim.api.nvim_win_is_valid(state.win) then
|
||||
pcall(vim.api.nvim_win_close, state.win, true)
|
||||
end
|
||||
state.win = nil
|
||||
-- keep buf so it can be reused
|
||||
end
|
||||
|
||||
local function update_win()
|
||||
if not state.opts.visible then return end
|
||||
ensure_win()
|
||||
if not state.bufnr or not vim.api.nvim_buf_is_valid(state.bufnr) then return end
|
||||
|
||||
local label = state.name and ("[" .. state.name .. "] ") or ""
|
||||
local status_sym = state.running and "⏱ " or "⏸ "
|
||||
local txt = status_sym .. " " .. label .. ns_to_time(get_elapsed_ns())
|
||||
vim.api.nvim_buf_set_option(state.bufnr, "modifiable", true)
|
||||
vim.api.nvim_buf_set_lines(state.bufnr, 0, -1, false, {txt})
|
||||
vim.api.nvim_buf_set_option(state.bufnr, "modifiable", false)
|
||||
end
|
||||
|
||||
local function start_timer_loop()
|
||||
if state.timer then return end
|
||||
state.timer = uv.new_timer()
|
||||
state.timer:start(0, state.opts.update_ms or 250, vim.schedule_wrap(function()
|
||||
if state.win and not vim.api.nvim_win_is_valid(state.win) then
|
||||
state.win = nil
|
||||
end
|
||||
update_win()
|
||||
end))
|
||||
end
|
||||
|
||||
local function stop_timer_loop()
|
||||
if state.timer then
|
||||
pcall(function() state.timer:stop() end)
|
||||
state.timer:close()
|
||||
state.timer = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Public API
|
||||
function M.start(name)
|
||||
if state.running then return end
|
||||
state.name = name or state.name
|
||||
state.start_hr = uv.hrtime() - state.elapsed_ns
|
||||
state.running = true
|
||||
if state.opts.visible then
|
||||
ensure_win()
|
||||
end
|
||||
start_timer_loop()
|
||||
update_win()
|
||||
end
|
||||
|
||||
function M.stop()
|
||||
if not state.running then return end
|
||||
state.elapsed_ns = get_elapsed_ns()
|
||||
state.running = false
|
||||
stop_timer_loop()
|
||||
update_win()
|
||||
if state.opts.log_on_stop then
|
||||
local log_path = state.opts.log_path or (vim.fn.stdpath("data") .. "/stopwatch_log.md")
|
||||
local time_str = os.date("%Y-%m-%d %H:%M:%S")
|
||||
local name = state.name or "-"
|
||||
local duration = ns_to_time(state.elapsed_ns)
|
||||
local line = string.format("- %s | %s | %s\n", time_str, name, duration)
|
||||
local f = io.open(log_path, "a")
|
||||
if f then
|
||||
f:write(line)
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.toggle(name)
|
||||
if state.running then
|
||||
M.stop()
|
||||
else
|
||||
M.start(name)
|
||||
end
|
||||
end
|
||||
|
||||
function M.reset()
|
||||
state.running = false
|
||||
state.elapsed_ns = 0
|
||||
state.start_hr = 0
|
||||
stop_timer_loop()
|
||||
update_win()
|
||||
end
|
||||
|
||||
function M.show()
|
||||
state.opts.visible = true
|
||||
ensure_win()
|
||||
start_timer_loop()
|
||||
update_win()
|
||||
end
|
||||
|
||||
function M.hide()
|
||||
state.opts.visible = false
|
||||
close_win()
|
||||
stop_timer_loop()
|
||||
end
|
||||
|
||||
function M.log_now()
|
||||
local log_path = state.opts.log_path or (vim.fn.stdpath("data") .. "/stopwatch_log.md")
|
||||
local time_str = os.date("%Y-%m-%d %H:%M:%S")
|
||||
local name = state.name or "-"
|
||||
local duration = ns_to_time(get_elapsed_ns())
|
||||
local line = string.format("- %s | %s | %s\n", time_str, name, duration)
|
||||
local f = io.open(log_path, "a")
|
||||
if f then
|
||||
f:write(line)
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
function M.status()
|
||||
-- returns a short string for statusline
|
||||
local elapsed = get_elapsed_ns()
|
||||
local prefix = state.running and "⏱" or "⏸"
|
||||
local name = state.name and (" " .. state.name) or ""
|
||||
return prefix .. name .. " " .. ns_to_time(elapsed)
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
state.opts = vim.tbl_extend("keep", opts, {
|
||||
visible = true,
|
||||
update_ms = 250,
|
||||
width = 28,
|
||||
row = 1,
|
||||
margin_right = 2,
|
||||
winblend = 5,
|
||||
log_on_stop = false,
|
||||
log_path = nil,
|
||||
})
|
||||
|
||||
-- Create user commands
|
||||
vim.api.nvim_create_user_command("StopwatchStart", function(opts)
|
||||
M.start(opts.args ~= "" and opts.args or nil)
|
||||
end, { nargs = "?" })
|
||||
|
||||
vim.api.nvim_create_user_command("StopwatchStop", function()
|
||||
M.stop()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command("StopwatchToggle", function(opts)
|
||||
M.toggle(opts.args ~= "" and opts.args or nil)
|
||||
end, { nargs = "?" })
|
||||
|
||||
vim.api.nvim_create_user_command("StopwatchReset", function() M.reset() end, {})
|
||||
vim.api.nvim_create_user_command("StopwatchShow", function() M.show() end, {})
|
||||
vim.api.nvim_create_user_command("StopwatchHide", function() M.hide() end, {})
|
||||
vim.api.nvim_create_user_command("StopwatchLog", function() M.log_now() end, {})
|
||||
|
||||
-- optionally show initially
|
||||
if state.opts.visible then
|
||||
ensure_win()
|
||||
update_win()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ccflow local snippets for all modes
|
||||
# local snippets for all modes
|
||||
|
||||
snippet todo "Add a TODO marker"
|
||||
// TODO.`strftime("%Y-%m-%d -")`
|
||||
|
||||
Reference in New Issue
Block a user