This commit is contained in:
foozzi 2024-08-18 16:57:33 +02:00
parent 4396724c36
commit bbf6f65419
20 changed files with 359 additions and 114 deletions

View file

@ -8,7 +8,40 @@ vim.api.nvim_set_keymap(
-- formattig a markdown table -- formattig a markdown table
vim.api.nvim_set_keymap("n", "<leader>ftt", ":TableFormat<CR>", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "<leader>ftt", ":TableFormat<CR>", { silent = true, noremap = true })
vim.opt_local.textwidth = 79 -- inserting zettelkasten id (eton)
vim.opt_local.wrap = true vim.api.nvim_set_keymap(
"n",
"<leader>fl",
":lua require('utils.helpers').insert_zk_id()<CR>",
{ silent = true, noremap = true }
)
-- inserting markdown link with uniq name
vim.api.nvim_set_keymap(
"n",
"<leader>vwl",
":lua require('utils.wiki_link').insert_link_with_unique_id()<CR>",
{ silent = true, noremap = true }
)
-- vim.api.nvim_create_user_command("SearchZettelTitle", function()
-- M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/PKM/00-zettelkasten/" })
-- end, {})
-- mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
vim.api.nvim_set_keymap(
"n",
"<leader>fm",
":lua require('utils.telescope_addons').search_raw_title({ search_dir = '/Users/fz0x1/PKM/00-zettelkasten', type = 'zettel' })<CR>",
{ silent = true, noremap = true }
)
vim.api.nvim_set_keymap(
"n",
"<leader>fk",
":lua require('utils.telescope_addons').search_raw_title({ search_dir = '/Users/fz0x1/PKM' })<CR>",
{ silent = true, noremap = true }
)
-- vim.opt_local.textwidth = 80
-- vim.opt_local.wrap = true
-- vim.cmd([[set briopt+=list:-1]]) -- vim.cmd([[set briopt+=list:-1]])

View file

@ -2,47 +2,51 @@
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" },
"bullets.vim": { "branch": "master", "commit": "448ad2a159c5f2540f6c9738f3bb9e6f15a41734" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "25d48271e3d4404ba017cb92a37d3a681c1ad149" }, "conform.nvim": { "branch": "master", "commit": "d31323db3fa4a33d203dcb05150d98bd0153c42c" },
"everforest": { "branch": "master", "commit": "b49ba81e79b20d2b47bb71e98fa984bae90731be" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"gruvbox.nvim": { "branch": "main", "commit": "7a1b23e4edf73a39642e77508ee6b9cbb8c60f9e" }, "gruvbox.nvim": { "branch": "main", "commit": "7a1b23e4edf73a39642e77508ee6b9cbb8c60f9e" },
"hardtime.nvim": { "branch": "main", "commit": "91c6be1a54fa057002e21ae209a49436bd215355" }, "hardtime.nvim": { "branch": "main", "commit": "91c6be1a54fa057002e21ae209a49436bd215355" },
"headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, "indent-blankline.nvim": { "branch": "master", "commit": "dddb5d21811c319eb6e51a993d8fb44b193aae3f" },
"indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"leap.nvim": { "branch": "main", "commit": "3b1d76ee9cd5a12a8f7a42f0e91124332860205c" }, "leap.nvim": { "branch": "main", "commit": "c6bfb191f1161fbabace1f36f578a20ac6c7642c" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" },
"lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "1c55991321d1a861537e32446affc5de5d9a6eaf" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mkdnflow.nvim": { "branch": "main", "commit": "9cdf9658df22c0b650090d9e6b8e72506f34b521" }, "mkdnflow.nvim": { "branch": "main", "commit": "4b8df635b0386d76544af2cbb0848d3d8a9cca8a" },
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
"neoscroll.nvim": { "branch": "master", "commit": "a7f5953dbfbe7069568f2d0ed23a9709a56725ab" }, "neoscroll.nvim": { "branch": "master", "commit": "532dcc8cea4287c4cad6bb77532989a8217cfc7b" },
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, "nvim-autopairs": { "branch": "master", "commit": "48ca9aaee733911424646cb1605f27bc01dedbe3" },
"nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" }, "nvim-lint": { "branch": "master", "commit": "debabca63c0905b59ce596a55a8e33eafdf66342" },
"nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" }, "nvim-lspconfig": { "branch": "master", "commit": "a89de2e049b5f89a0ee55029d5a31213bd4de6f8" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-tree.lua": { "branch": "master", "commit": "48d0e82f9434691cc50d970898142a8c084a49d6" }, "nvim-tree.lua": { "branch": "master", "commit": "ad0b95dee55955817af635fa121f6e2486b10583" },
"nvim-treesitter": { "branch": "master", "commit": "2d5133f67429f82547ea5fad33a0b1e7d4f78a1c" }, "nvim-treesitter": { "branch": "master", "commit": "ec8776ed9ef56ffe7a61e67b64d5d6b6aba2c631" },
"nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, "nvim-treesitter-context": { "branch": "master", "commit": "0f3332788e0bd37716fbd25f39120dcfd557c90f" },
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" }, "nvim-ts-autotag": { "branch": "main", "commit": "0cb76eea80e9c73b88880f0ca78fbd04c5bdcac7" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" },
"nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" }, "peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"render-markdown.nvim": { "branch": "main", "commit": "4c823b1df151dbf1ed3ddaacac517be606b1e145" },
"tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" }, "tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" },
"tagbar": { "branch": "master", "commit": "bc087d88defc0a63df3cd9284c2ecf4fcae42ce9" }, "tagbar": { "branch": "master", "commit": "d55d454bd3d5b027ebf0e8c75b8f88e4eddad8d8" },
"telescope.nvim": { "branch": "master", "commit": "10b8a82b042caf50b78e619d92caf0910211973d" }, "telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" },
"toggleterm.nvim": { "branch": "main", "commit": "8ed0f52006d3207ec6c94de7db62da840937ef2a" }, "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" },
"toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" },
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
"vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" }, "vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" },
"vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" }, "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" },
"which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" } "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" },
"wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" },
"zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" }
} }

View file

@ -1,18 +1,18 @@
-- local helpers = require("core.helpers") -- local helpers = require("core.helpers")
-- auto-format on save -- auto-format on save
local lsp_fmt_group = vim.api.nvim_create_augroup("LspFormattingGroup", {}) -- local lsp_fmt_group = vim.api.nvim_create_augroup("LspFormattingGroup", {})
vim.api.nvim_create_autocmd("BufWritePre", { -- vim.api.nvim_create_autocmd("BufWritePre", {
group = lsp_fmt_group, -- group = lsp_fmt_group,
callback = function() -- callback = function()
local efm = vim.lsp.get_clients({ name = "efm" }) -- local efm = vim.lsp.get_clients({ name = "efm" })
--
if vim.tbl_isempty(efm) then -- if vim.tbl_isempty(efm) then
return -- return
end -- end
--
vim.lsp.buf.format({ name = "efm", async = true }) -- vim.lsp.buf.format({ name = "efm", async = true })
end, -- end,
}) -- })
-- highlight on yank -- highlight on yank
local highlight_yank_group = vim.api.nvim_create_augroup("HighlightYankGroup", {}) local highlight_yank_group = vim.api.nvim_create_augroup("HighlightYankGroup", {})
@ -24,7 +24,7 @@ vim.api.nvim_create_autocmd("TextYankPost", {
}) })
-- https://jrnl.sh/en/stable/privacy-and-security/#neovim -- https://jrnl.sh/en/stable/privacy-and-security/#neovim
vim.api.nvim_create_autocmd( {"BufNewFile","BufReadPre" }, { vim.api.nvim_create_autocmd({ "BufNewFile", "BufReadPre" }, {
group = vim.api.nvim_create_augroup("PrivateJrnl", {}), group = vim.api.nvim_create_augroup("PrivateJrnl", {}),
pattern = "*.jrnl", pattern = "*.jrnl",
callback = function() callback = function()
@ -39,4 +39,3 @@ vim.api.nvim_create_autocmd( {"BufNewFile","BufReadPre" }, {
vim.o.secure = true vim.o.secure = true
end, end,
}) })

View file

@ -48,12 +48,19 @@ vim.keymap.set("v", ">", ">gv", { silent = true, noremap = true })
local api = vim.api local api = vim.api
-- Zen Mode -- Zen Mode
api.nvim_set_keymap("n", "<leader>zn", ":TZNarrow<CR>", {}) -- api.nvim_set_keymap("n", "<leader>zn", ":TZNarrow<CR>", {})
api.nvim_set_keymap("v", "<leader>zn", ":'<,'>TZNarrow<CR>", {}) -- api.nvim_set_keymap("v", "<leader>zn", ":'<,'>TZNarrow<CR>", {})
api.nvim_set_keymap("n", "<leader>sm", ":TZFocus<CR>", {}) -- api.nvim_set_keymap("n", "<leader>sm", ":TZFocus<CR>", {})
api.nvim_set_keymap("n", "<leader>zm", ":TZMinimalist<CR>", {}) -- api.nvim_set_keymap("n", "<leader>zm", ":TZMinimalist<CR>", {})
api.nvim_set_keymap("n", "<leader>za", ":TZAtaraxis<CR>", {}) -- api.nvim_set_keymap("n", "<leader>za", ":TZAtaraxis<CR>", {})
-- Comments -- Comments
api.nvim_set_keymap("n", "<C-_>", "gtc", { noremap = false }) api.nvim_set_keymap("n", "<C-_>", "gtc", { noremap = false })
api.nvim_set_keymap("v", "<C-_>", "goc", { noremap = false }) api.nvim_set_keymap("v", "<C-_>", "goc", { noremap = false })
-- Zen mode
api.nvim_set_keymap("n", "<leader>tw", ":Twilight<CR>", {})
api.nvim_set_keymap("n", "<leader>zm", ":ZenMode<CR>", {})
-- back to the "parent" buffer
api.nvim_set_keymap("n", "<BS>", "<C-^>", { noremap = true, silent = true })

View file

@ -1,6 +1,8 @@
local opt = vim.opt local opt = vim.opt
local api = vim.api local api = vim.api
local M = {}
-- Tab / Indentation -- Tab / Indentation
opt.tabstop = 2 opt.tabstop = 2
opt.shiftwidth = 2 opt.shiftwidth = 2
@ -62,10 +64,75 @@ opt.spell = true
--) --)
vim.opt.langmap = { vim.opt.langmap = {
"йq", "цw", "уe", "кr", "еt", "нy", "гu", "шi", "щo", "зp", "х[", "ъ]", "йq",
"фa", "ыs", "вd", "аf", "пg", "рh", "оj", "лk", "дl", "ж\\;", "э'", "ё\\,", "цw",
"яz", "чx", "сc", "мv", "иb", "тn", "ьm", "б\\,", "ю.", "уe",
"ЙQ", "ЦW", "УE", "КR", "ЕT", "НY", "ГU", "ШI", "ЩO", "ЗP", "Х{", "Ъ}", "кr",
"ФA", "ЫS", "ВD", "АF", "ПG", "РH", "ОJ", "ЛK", "ДL", "Ж:", "Э\"", "ЯZ", "еt",
"ЧX", "СC", "МV", "ИB", "ТN", "ЬM", "Б<", "Ю>", "Ё/" "нy",
"гu",
"шi",
"щo",
"зp",
"х[",
"ъ]",
"фa",
"ыs",
"вd",
"аf",
"пg",
"рh",
"оj",
"лk",
"дl",
"ж\\;",
"э'",
"ё\\,",
"яz",
"чx",
"сc",
"мv",
"иb",
"тn",
"ьm",
"б\\,",
"ю.",
"ЙQ",
"ЦW",
"УE",
"КR",
"ЕT",
"НY",
"ГU",
"ШI",
"ЩO",
"ЗP",
"Х{",
"Ъ}",
"ФA",
"ЫS",
"ВD",
"АF",
"ПG",
"РH",
"ОJ",
"ЛK",
"ДL",
"Ж:",
'Э"',
"ЯZ",
"ЧX",
"СC",
"МV",
"ИB",
"ТN",
"ЬM",
"Б<",
"Ю>",
"Ё/",
} }
M.zettelkasten_dir = "~/PKM/"
M.resources_dir = "~/PKM/30 resources/"
return M

View file

@ -0,0 +1,11 @@
return {
"sainnhe/everforest",
lazy = false,
priority = 1000,
config = function()
-- Optionally configure and load the colorscheme
-- directly inside the plugin declaration.
vim.g.everforest_enable_italic = true
vim.cmd.colorscheme("everforest")
end,
}

View file

@ -1,6 +1,7 @@
return { return {
"ellisonleao/gruvbox.nvim", lazy=false, "ellisonleao/gruvbox.nvim",
priority = 1000, lazy = true,
priority = 0,
opts = {}, opts = {},
config = function() config = function()
vim.cmd("colorscheme gruvbox") vim.cmd("colorscheme gruvbox")

View file

@ -1,10 +0,0 @@
return {
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
opts = {
markdown = {
fat_headline_lower_string = "",
},
},
lazy = false,
}

View file

@ -112,6 +112,7 @@ local config = function()
biome = function() -- use tsserver instead biome = function() -- use tsserver instead
return {} return {}
end, end,
require("lspconfig").marksman.setup({}),
}, },
}) })
@ -130,7 +131,7 @@ local config = function()
completeopt = "menu,menuone,noinsert", completeopt = "menu,menuone,noinsert",
}, },
sources = { sources = {
{ name = "mkdnflow" }, -- { name = "mkdnflow" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "path" }, { name = "path" },
{ name = "nvim_lsp" }, { name = "nvim_lsp" },

View file

@ -1,33 +1,12 @@
return { return {
"foozzi/mkdnflow.nvim", "jakewvincent/mkdnflow.nvim",
lazy = true, -- ft = "markdown",
config = function() config = function()
require("mkdnflow").setup({ require("mkdnflow").setup({
modules = { modules = {
bib = true, cmp = false,
buffers = true,
conceal = true,
cursor = true,
folds = true,
links = true,
lists = true,
maps = true,
paths = true,
tables = true,
yaml = true,
cmp = true,
},
filetypes = { md = true, rmd = true, markdown = true, telekasten = true },
links = {
transform_explicit = function(text)
return text
end,
style = "wiki",
name_is_source = true,
}, },
}) })
end, end,
dependencies = { -- Your other plugins
"bullets-vim/bullets.vim",
},
} }

View file

@ -0,0 +1,8 @@
return {
"MeanderingProgrammer/render-markdown.nvim",
opts = {},
-- dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
lazy = false,
}

View file

@ -0,0 +1,10 @@
return {
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
lazy = false,
}

View file

@ -0,0 +1,3 @@
return {
"folke/twilight.nvim",
}

View file

@ -0,0 +1,7 @@
return {
ft = "markdown",
"andrewferrier/wrapping.nvim",
config = function()
require("wrapping").setup()
end,
}

View file

@ -0,0 +1,22 @@
return {
{
ft = "markdown",
"folke/zen-mode.nvim",
opts = {
window = {
backdrop = 1,
options = {
number = false,
},
},
plugins = {
options = {
laststatus = 1,
},
alacritty = {
enabled = true,
},
},
},
},
}

View file

@ -1,3 +1,5 @@
local mapvimkey = require("utils.keymapper").mapvimkey
local M = {} local M = {}
function M.InsertMarkdownURL() function M.InsertMarkdownURL()
@ -29,4 +31,33 @@ function M.InsertMarkdownURL()
end end
end end
-- inserting zettelkasten link with an id
function M.insert_zk_id()
local handle = io.popen("eton zk id")
local id = handle:read("*a")
handle:close()
id = id:gsub("%s+", "")
local insert_text = string.format("[](%s.md)", id)
vim.api.nvim_put({ insert_text }, "c", true, true)
vim.api.nvim_feedkeys("i", "n", true)
end
function M.get_relative_path(from, to)
local from_dir = vim.fn.fnamemodify(from, ":p:h")
local to_file = vim.fn.fnamemodify(to, ":p")
local from_parts = vim.split(from_dir, "/")
local to_parts = vim.split(to_file, "/")
while #from_parts > 0 and #to_parts > 0 and from_parts[1] == to_parts[1] do
table.remove(from_parts, 1)
table.remove(to_parts, 1)
end
local relative_path = string.rep("../", #from_parts) .. table.concat(to_parts, "/")
return relative_path
end
return M return M

View file

@ -4,19 +4,24 @@ local action_state = require("telescope.actions.state")
local conf = require("telescope.config").values local conf = require("telescope.config").values
local pickers = require("telescope.pickers") local pickers = require("telescope.pickers")
local actions = require("telescope.actions") local actions = require("telescope.actions")
local mapvimkey = require("utils.keymapper").mapvimkey local helpers = require("utils.helpers")
local M = {} local M = {}
local function paste_titled_link() local function paste_titled_link()
return function(prompt_bufnr) return function(prompt_bufnr)
actions.close(prompt_bufnr) actions.close(prompt_bufnr)
local current_file = vim.fn.expand("%:p")
local selection = action_state.get_selected_entry() local selection = action_state.get_selected_entry()
local parts = vim.split(selection.value, ":") local parts = vim.split(selection.value, ":")
local filename_part = parts[1] local filename_part = parts[1]
local filename_and_category = vim.split(filename_part, "/") -- local filename_and_category = vim.split(filename_part, "/")
local relative_path = helpers.get_relative_path(current_file, filename_part)
local title = parts[#parts]:match("^%s*(.-)%s*$") local title = parts[#parts]:match("^%s*(.-)%s*$")
local link = "[" .. title .. "](" .. filename_and_category[#filename_and_category] .. ")" -- remove `#` from header name if it regular wiki
title = title:gsub("^%s*#%s*", "")
relative_path = relative_path:gsub(" ", "%%20")
local link = "[" .. title .. "](" .. relative_path .. ")"
vim.api.nvim_put({ link }, "", true, true) vim.api.nvim_put({ link }, "", true, true)
end end
end end
@ -62,12 +67,25 @@ M.search_raw_title = function(opts)
"--with-filename", "--with-filename",
"--line-number", "--line-number",
"-i", "-i",
"-m",
"1",
"title:.*" .. prompt, "title:.*" .. prompt,
search_dir, search_dir,
} }
if opts.type ~= "zettel" then
cmd[9] = "^#.*" .. prompt
end
return cmd return cmd
end, opts.entry_maker or function(entry) end, opts.entry_maker or function(entry)
local filename, lnum, raw_title = entry:match("([^:]+):(%d+):title:(.*)") local filename, lnum, header
if opts.type ~= "zettel" then
filename, lnum, header = entry:match("([^:]+):(%d+):#%s*(.*)")
else
filename, lnum, header = entry:match("([^:]+):(%d+):title:(.*)")
end
if not filename then if not filename then
return nil return nil
end end
@ -77,8 +95,8 @@ M.search_raw_title = function(opts)
return { return {
value = entry, value = entry,
ordinal = basename .. " " .. (raw_title or ""), ordinal = basename .. " " .. (header or ""),
display = basename .. " - " .. (raw_title or ""), display = basename .. " - " .. (header or ""),
filename = filename, filename = filename,
lnum = tonumber(lnum), lnum = tonumber(lnum),
} }
@ -114,9 +132,9 @@ M.search_raw_title = function(opts)
:find() :find()
end end
vim.api.nvim_create_user_command("SearchZettelTitle", function() -- vim.api.nvim_create_user_command("SearchZettelTitle", function()
M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/NOTES/01-zettel/" }) -- M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/PKM/00-zettelkasten/" })
end, {}) -- end, {})
mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title") -- mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
return M return M

View file

@ -0,0 +1,44 @@
local options = require("core.options")
local M = {}
local function generate_id(length)
local chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
local id = ""
for i = 1, length do
local rand = math.random(#chars)
id = id .. chars:sub(rand, rand)
end
return id
end
local function file_exists(directory, filename)
local filepath = directory .. "/" .. filename
local file = io.open(filepath, "r")
if file then
io.close(file)
return true
else
return false
end
end
local function generate_unique_id(directory, length)
local id
repeat
id = generate_id(length)
until not file_exists(directory, id .. ".md")
return id
end
function M.insert_link_with_unique_id()
local id_length = 8
local unique_id = generate_unique_id(options.resources_dir, id_length)
local link = string.format("[name](%s.md)", unique_id)
vim.api.nvim_put({ link }, "c", true, true)
end
return M

View file

@ -67,16 +67,24 @@ alias ovim='vim' # original vim
alias diary='ovim ~/vimwiki/diary/diary.asc.md' alias diary='ovim ~/vimwiki/diary/diary.asc.md'
## nvim ## nvim
alias evim='nvim ~/.dotfiles/global/.config/nvim/' alias evim='nvim ~/.dotfiles/global/.config/nvim/'
alias kvim='nvim ~/PKM/'
alias cvim='nvim ~/.zshrc'
alias tvim='nvim ~/Dropbox/TODO/'
alias kvimr='nvim ~/PKM/30-resources/'
alias kvimj='nvim ~/PKM/1-journal/'
alias jvim='nvim ~/PKM/1-journal/$(date "+%Y-%m-%d").md'
# alias vim='nvim' # alias vim='nvim'
alias vi='nvim' alias vi='nvim'
alias v='nvim' alias v='nvim'
## string
alias gen8='LC_CTYPE=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 8 | pbcopy'
## wttr.in ## wttr.in
alias wr='curl wttr.in' alias wr='curl wttr.in'
## python ## python
alias python='python3' alias python='python3'
alias py='python' alias py='python'
## todo.txt ## todo.txt
alias todo="todo.sh -d ~/Dropbox/TextSync/TODO/todo.cfg" alias todo="todo.sh -d ~/Dropbox/TODO/todo.cfg"
## eton ## eton
alias et="eton" alias et="eton"
alias zk="eton zk" alias zk="eton zk"
@ -85,6 +93,8 @@ alias to="toipe"
## jrnl.sh ## jrnl.sh
setopt HIST_IGNORE_SPACE setopt HIST_IGNORE_SPACE
alias jrnl=" jrnl" alias jrnl=" jrnl"
## jupyter
alias jup="jupyter lab"
# Preferred editor for local and remote sessions # Preferred editor for local and remote sessions
export EDITOR='nvim' export EDITOR='nvim'

View file

@ -13,7 +13,7 @@
# https://github.com/xwmx/nb # https://github.com/xwmx/nb
############################################################################### ###############################################################################
export NB_DIR="${NB_DIR:-/Users/fz0x1/Dropbox/TextSync/NOTES}" # Set by `nb` • Tue Feb 27 09:55:17 EST 2024 # export NB_DIR="${NB_DIR:-/Users/fz0x1/Dropbox/TextSync/NOTES}" # Set by `nb` • Tue Feb 27 09:55:17 EST 2024
export EDITOR="nvim" # Set by `nb` • Thu Mar 14 11:06:48 PM EDT 2024 export EDITOR="nvim" # Set by `nb` • Thu Mar 14 11:06:48 PM EDT 2024
export NB_PINNED_PATTERN="#pinned" export NB_PINNED_PATTERN="#pinned"