Skip to content

Commit

Permalink
feat(note-taking): added global-note.nvim plugin (#934)
Browse files Browse the repository at this point in the history
* feat(note-taking): added global-note.nvim plugin

* refactor(note-taking-nvim): Rewrote get_project_name function
  • Loading branch information
Billuc committed May 2, 2024
1 parent a2c1002 commit af44ee3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/astrocommunity/note-taking/global-note-nvim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Global-note.nvim

It's a simple Neovim plugin that provides a global note in a float window.

**Repository:** <https://github.com/backdround/global-note.nvim>

**Notes:** A project local note has also been setup
48 changes: 48 additions & 0 deletions lua/astrocommunity/note-taking/global-note-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local get_project_name = function()
local project_name

local project_directory, err = vim.loop.cwd()
if not project_directory then
vim.notify(err, vim.log.levels.WARN)
else
project_name = vim.fs.basename(project_directory)
end

if not project_name then vim.notify("Unable to get the project name", vim.log.levels.WARN) end

return project_name
end

return {
"backdround/global-note.nvim",
dependencies = {
{ "AstroNvim/astroui", opts = { icons = { Notes = "" } } },
{
"AstroNvim/astrocore",
opts = function(_, opts)
local maps = opts.mappings
local prefix = "<Leader>m"

maps.n[prefix] = { desc = require("astroui").get_icon("Notes", 1, true) .. "Notes" }
maps.n[prefix .. "m"] = {
function() require("global-note").toggle_note() end,
desc = "Toggle global note",
}
maps.n[prefix .. "l"] = {
function() require("global-note").toggle_note "project_local" end,
desc = "Toggle local note",
}
end,
},
},
opts = {
title = " Global note ",
additional_presets = {
project_local = {
command_name = "ProjectNote",
filename = function() return get_project_name() .. ".md" end,
title = function() return " Note for project " .. get_project_name() .. " " end,
},
},
},
}

0 comments on commit af44ee3

Please sign in to comment.