about summary refs log tree commit diff
path: root/lua/quick_note.lua
diff options
context:
space:
mode:
authoriurii plugatarov <[email protected]>2024-08-02 23:19:11 +0200
committeriurii plugatarov <[email protected]>2024-08-02 23:19:11 +0200
commitf24a3ab9744a3f50eb8cacc06d4ef4c5f96875db (patch)
treee53c36d600f9ded45036d3489411cb82f26cb192 /lua/quick_note.lua
parentdfee9611c0134def92d3c254ca4b067338ae7720 (diff)
downloadsketchbook.nvim-f24a3ab9744a3f50eb8cacc06d4ef4c5f96875db.tar.gz
fix
Diffstat (limited to 'lua/quick_note.lua')
-rw-r--r--lua/quick_note.lua91
1 files changed, 0 insertions, 91 deletions
diff --git a/lua/quick_note.lua b/lua/quick_note.lua
deleted file mode 100644
index 1196faf..0000000
--- a/lua/quick_note.lua
+++ /dev/null
@@ -1,91 +0,0 @@
-local M = {}
-local floating_win = nil
-
-local function get_win_config()
-  local width = math.floor(vim.o.columns * 0.8)
-  local height = math.floor(vim.o.lines * 0.8)
-  local row = math.floor((vim.o.lines - height) / 2)
-  local col = math.floor((vim.o.columns - width) / 2)
-  return {
-    relative = "editor",
-    width = width,
-    height = height,
-    row = row,
-    col = col,
-    style = "minimal",
-    border = "rounded",
-  }
-end
-
-function M.create_quick_note_window()
-  if floating_win and vim.api.nvim_win_is_valid(floating_win) then
-    vim.api.nvim_set_current_win(floating_win)
-    return
-  end
-
-  local buf = vim.api.nvim_create_buf(false, true)
-  floating_win = vim.api.nvim_open_win(buf, true, get_win_config())
-
-  vim.api.nvim_buf_set_option(buf, "buftype", "acwrite")
-  vim.api.nvim_buf_set_name(buf, "QuickNote")
-end
-
-function M.toggle_quick_note_window()
-  if floating_win and vim.api.nvim_win_is_valid(floating_win) then
-    M.close_quick_note_window()
-  else
-    M.create_quick_note_window()
-  end
-end
-
-function M.close_quick_note_window()
-  if floating_win and vim.api.nvim_win_is_valid(floating_win) then
-    local buf = vim.api.nvim_win_get_buf(floating_win)
-    M.prepend_to_quick_note()
-    vim.api.nvim_win_close(floating_win, true)
-    vim.api.nvim_buf_delete(buf, { force = true })
-  end
-end
-
-function M.prepend_to_quick_note()
-  local notes_dir = vim.g.notes_directory or "~/notes/"
-  local filepath = vim.fn.expand(notes_dir) .. "/quick_note.md"
-  local buf = vim.api.nvim_win_get_buf(floating_win)
-  local content = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
-
-  -- Add a separator and timestamp before the new content
-  local separator = "------------------------"
-  local timestamp = os.date "%Y-%m-%d %H:%M:%S"
-  table.insert(content, 1, "")
-  table.insert(content, 1, separator)
-  table.insert(content, 1, timestamp)
-  table.insert(content, 1, separator)
-  table.insert(content, 1, "")
-
-  -- Check if quick_note.md exists, create it if it doesn't
-  if vim.fn.filereadable(filepath) == 0 then
-    vim.fn.writefile({}, filepath)
-  end
-
-  local file_content = vim.fn.readfile(filepath)
-  for i = #file_content, 1, -1 do
-    table.insert(content, 1, file_content[i])
-  end
-
-  vim.fn.writefile(content, filepath)
-  print "Prepended content to quick_note.md"
-end
-
-function M.open_entire_quick_note()
-  local notes_dir = vim.g.notes_directory or "~/notes/"
-  local filepath = vim.fn.expand(notes_dir) .. "/quick_note.md"
-
-  if vim.fn.filereadable(filepath) == 0 then
-    print "No quick_note.md file found."
-    return
-  end
-
-  vim.cmd("edit " .. filepath)
-end
-
-return M