From bbf6f65419baef8151e8c1d066189765b6104436 Mon Sep 17 00:00:00 2001 From: foozzi Date: Sun, 18 Aug 2024 16:57:33 +0200 Subject: [PATCH] 20240818 --- global/.config/nvim/ftplugin/markdown.lua | 37 ++++++++- global/.config/nvim/lazy-lock.json | 50 ++++++------ global/.config/nvim/lua/core/autocmds.lua | 55 +++++++------ global/.config/nvim/lua/core/keymaps.lua | 17 ++-- global/.config/nvim/lua/core/options.lua | 79 +++++++++++++++++-- .../.config/nvim/lua/plugins/everforest.lua | 11 +++ global/.config/nvim/lua/plugins/gruvbox.lua | 5 +- global/.config/nvim/lua/plugins/headlines.lua | 10 --- global/.config/nvim/lua/plugins/lsp.lua | 3 +- global/.config/nvim/lua/plugins/mkdnflow.lua | 29 +------ .../nvim/lua/plugins/render-markdown.lua | 8 ++ .../nvim/lua/plugins/todo-comments.lua | 10 +++ global/.config/nvim/lua/plugins/twilight.lua | 3 + global/.config/nvim/lua/plugins/wrapping.lua | 7 ++ global/.config/nvim/lua/plugins/zen-mode.lua | 22 ++++++ global/.config/nvim/lua/utils/helpers.lua | 31 ++++++++ .../nvim/lua/utils/telescope_addons.lua | 38 ++++++--- global/.config/nvim/lua/utils/wiki_link.lua | 44 +++++++++++ global/.zshrc | 12 ++- macos/.nbrc | 2 +- 20 files changed, 359 insertions(+), 114 deletions(-) create mode 100644 global/.config/nvim/lua/plugins/everforest.lua delete mode 100644 global/.config/nvim/lua/plugins/headlines.lua create mode 100644 global/.config/nvim/lua/plugins/render-markdown.lua create mode 100644 global/.config/nvim/lua/plugins/todo-comments.lua create mode 100644 global/.config/nvim/lua/plugins/twilight.lua create mode 100644 global/.config/nvim/lua/plugins/wrapping.lua create mode 100644 global/.config/nvim/lua/plugins/zen-mode.lua create mode 100644 global/.config/nvim/lua/utils/wiki_link.lua diff --git a/global/.config/nvim/ftplugin/markdown.lua b/global/.config/nvim/ftplugin/markdown.lua index dd98853..3cdd6a9 100644 --- a/global/.config/nvim/ftplugin/markdown.lua +++ b/global/.config/nvim/ftplugin/markdown.lua @@ -8,7 +8,40 @@ vim.api.nvim_set_keymap( -- formattig a markdown table vim.api.nvim_set_keymap("n", "ftt", ":TableFormat", { silent = true, noremap = true }) -vim.opt_local.textwidth = 79 -vim.opt_local.wrap = true +-- inserting zettelkasten id (eton) +vim.api.nvim_set_keymap( + "n", + "fl", + ":lua require('utils.helpers').insert_zk_id()", + { silent = true, noremap = true } +) + +-- inserting markdown link with uniq name +vim.api.nvim_set_keymap( + "n", + "vwl", + ":lua require('utils.wiki_link').insert_link_with_unique_id()", + { 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("fm", "SearchZettelTitle", "Search by zettel title") +vim.api.nvim_set_keymap( + "n", + "fm", + ":lua require('utils.telescope_addons').search_raw_title({ search_dir = '/Users/fz0x1/PKM/00-zettelkasten', type = 'zettel' })", + { silent = true, noremap = true } +) +vim.api.nvim_set_keymap( + "n", + "fk", + ":lua require('utils.telescope_addons').search_raw_title({ search_dir = '/Users/fz0x1/PKM' })", + { silent = true, noremap = true } +) + +-- vim.opt_local.textwidth = 80 +-- vim.opt_local.wrap = true -- vim.cmd([[set briopt+=list:-1]]) diff --git a/global/.config/nvim/lazy-lock.json b/global/.config/nvim/lazy-lock.json index 6c0273f..6b257aa 100644 --- a/global/.config/nvim/lazy-lock.json +++ b/global/.config/nvim/lazy-lock.json @@ -2,47 +2,51 @@ "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, - "bullets.vim": { "branch": "master", "commit": "448ad2a159c5f2540f6c9738f3bb9e6f15a41734" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "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" }, "gruvbox.nvim": { "branch": "main", "commit": "7a1b23e4edf73a39642e77508ee6b9cbb8c60f9e" }, "hardtime.nvim": { "branch": "main", "commit": "91c6be1a54fa057002e21ae209a49436bd215355" }, - "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, - "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, + "indent-blankline.nvim": { "branch": "master", "commit": "dddb5d21811c319eb6e51a993d8fb44b193aae3f" }, "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" }, - "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1c55991321d1a861537e32446affc5de5d9a6eaf" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mkdnflow.nvim": { "branch": "main", "commit": "9cdf9658df22c0b650090d9e6b8e72506f34b521" }, + "mkdnflow.nvim": { "branch": "main", "commit": "4b8df635b0386d76544af2cbb0848d3d8a9cca8a" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, - "neoscroll.nvim": { "branch": "master", "commit": "a7f5953dbfbe7069568f2d0ed23a9709a56725ab" }, + "neoscroll.nvim": { "branch": "master", "commit": "532dcc8cea4287c4cad6bb77532989a8217cfc7b" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, - "nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, - "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, - "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" }, - "nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" }, + "nvim-autopairs": { "branch": "master", "commit": "48ca9aaee733911424646cb1605f27bc01dedbe3" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lint": { "branch": "master", "commit": "debabca63c0905b59ce596a55a8e33eafdf66342" }, + "nvim-lspconfig": { "branch": "master", "commit": "a89de2e049b5f89a0ee55029d5a31213bd4de6f8" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-tree.lua": { "branch": "master", "commit": "48d0e82f9434691cc50d970898142a8c084a49d6" }, - "nvim-treesitter": { "branch": "master", "commit": "2d5133f67429f82547ea5fad33a0b1e7d4f78a1c" }, - "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, - "nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, - "nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" }, + "nvim-tree.lua": { "branch": "master", "commit": "ad0b95dee55955817af635fa121f6e2486b10583" }, + "nvim-treesitter": { "branch": "master", "commit": "ec8776ed9ef56ffe7a61e67b64d5d6b6aba2c631" }, + "nvim-treesitter-context": { "branch": "master", "commit": "0f3332788e0bd37716fbd25f39120dcfd557c90f" }, + "nvim-ts-autotag": { "branch": "main", "commit": "0cb76eea80e9c73b88880f0ca78fbd04c5bdcac7" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "render-markdown.nvim": { "branch": "main", "commit": "4c823b1df151dbf1ed3ddaacac517be606b1e145" }, "tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" }, - "tagbar": { "branch": "master", "commit": "bc087d88defc0a63df3cd9284c2ecf4fcae42ce9" }, - "telescope.nvim": { "branch": "master", "commit": "10b8a82b042caf50b78e619d92caf0910211973d" }, - "toggleterm.nvim": { "branch": "main", "commit": "8ed0f52006d3207ec6c94de7db62da840937ef2a" }, + "tagbar": { "branch": "master", "commit": "d55d454bd3d5b027ebf0e8c75b8f88e4eddad8d8" }, + "telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" }, + "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, + "toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" }, "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" } } diff --git a/global/.config/nvim/lua/core/autocmds.lua b/global/.config/nvim/lua/core/autocmds.lua index 197622e..9c845e3 100644 --- a/global/.config/nvim/lua/core/autocmds.lua +++ b/global/.config/nvim/lua/core/autocmds.lua @@ -1,18 +1,18 @@ -- local helpers = require("core.helpers") -- auto-format on save -local lsp_fmt_group = vim.api.nvim_create_augroup("LspFormattingGroup", {}) -vim.api.nvim_create_autocmd("BufWritePre", { - group = lsp_fmt_group, - callback = function() - local efm = vim.lsp.get_clients({ name = "efm" }) - - if vim.tbl_isempty(efm) then - return - end - - vim.lsp.buf.format({ name = "efm", async = true }) - end, -}) +-- local lsp_fmt_group = vim.api.nvim_create_augroup("LspFormattingGroup", {}) +-- vim.api.nvim_create_autocmd("BufWritePre", { +-- group = lsp_fmt_group, +-- callback = function() +-- local efm = vim.lsp.get_clients({ name = "efm" }) +-- +-- if vim.tbl_isempty(efm) then +-- return +-- end +-- +-- vim.lsp.buf.format({ name = "efm", async = true }) +-- end, +-- }) -- highlight on yank local highlight_yank_group = vim.api.nvim_create_augroup("HighlightYankGroup", {}) @@ -24,19 +24,18 @@ vim.api.nvim_create_autocmd("TextYankPost", { }) -- https://jrnl.sh/en/stable/privacy-and-security/#neovim -vim.api.nvim_create_autocmd( {"BufNewFile","BufReadPre" }, { - group = vim.api.nvim_create_augroup("PrivateJrnl", {}), - pattern = "*.jrnl", - callback = function() - vim.o.shada = "" - vim.o.swapfile = false - vim.o.undofile = false - vim.o.backup = false - vim.o.writebackup = false - vim.o.shelltemp = false - vim.o.history = 0 - vim.o.modeline = false - vim.o.secure = true - end, +vim.api.nvim_create_autocmd({ "BufNewFile", "BufReadPre" }, { + group = vim.api.nvim_create_augroup("PrivateJrnl", {}), + pattern = "*.jrnl", + callback = function() + vim.o.shada = "" + vim.o.swapfile = false + vim.o.undofile = false + vim.o.backup = false + vim.o.writebackup = false + vim.o.shelltemp = false + vim.o.history = 0 + vim.o.modeline = false + vim.o.secure = true + end, }) - diff --git a/global/.config/nvim/lua/core/keymaps.lua b/global/.config/nvim/lua/core/keymaps.lua index 0695137..23f76e8 100644 --- a/global/.config/nvim/lua/core/keymaps.lua +++ b/global/.config/nvim/lua/core/keymaps.lua @@ -48,12 +48,19 @@ vim.keymap.set("v", ">", ">gv", { silent = true, noremap = true }) local api = vim.api -- Zen Mode -api.nvim_set_keymap("n", "zn", ":TZNarrow", {}) -api.nvim_set_keymap("v", "zn", ":'<,'>TZNarrow", {}) -api.nvim_set_keymap("n", "sm", ":TZFocus", {}) -api.nvim_set_keymap("n", "zm", ":TZMinimalist", {}) -api.nvim_set_keymap("n", "za", ":TZAtaraxis", {}) +-- api.nvim_set_keymap("n", "zn", ":TZNarrow", {}) +-- api.nvim_set_keymap("v", "zn", ":'<,'>TZNarrow", {}) +-- api.nvim_set_keymap("n", "sm", ":TZFocus", {}) +-- api.nvim_set_keymap("n", "zm", ":TZMinimalist", {}) +-- api.nvim_set_keymap("n", "za", ":TZAtaraxis", {}) -- Comments api.nvim_set_keymap("n", "", "gtc", { noremap = false }) api.nvim_set_keymap("v", "", "goc", { noremap = false }) + +-- Zen mode +api.nvim_set_keymap("n", "tw", ":Twilight", {}) +api.nvim_set_keymap("n", "zm", ":ZenMode", {}) + +-- back to the "parent" buffer +api.nvim_set_keymap("n", "", "", { noremap = true, silent = true }) diff --git a/global/.config/nvim/lua/core/options.lua b/global/.config/nvim/lua/core/options.lua index 971e2f7..c23b9c5 100644 --- a/global/.config/nvim/lua/core/options.lua +++ b/global/.config/nvim/lua/core/options.lua @@ -1,6 +1,8 @@ local opt = vim.opt local api = vim.api +local M = {} + -- Tab / Indentation opt.tabstop = 2 opt.shiftwidth = 2 @@ -62,10 +64,75 @@ opt.spell = true --) vim.opt.langmap = { - "й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", "б\\,", "ю.", - "Й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", "Б<", "Ю>", "Ё/" + "й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", + "б\\,", + "ю.", + "Й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 diff --git a/global/.config/nvim/lua/plugins/everforest.lua b/global/.config/nvim/lua/plugins/everforest.lua new file mode 100644 index 0000000..5aec9c7 --- /dev/null +++ b/global/.config/nvim/lua/plugins/everforest.lua @@ -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, +} diff --git a/global/.config/nvim/lua/plugins/gruvbox.lua b/global/.config/nvim/lua/plugins/gruvbox.lua index a6d5865..10866cd 100644 --- a/global/.config/nvim/lua/plugins/gruvbox.lua +++ b/global/.config/nvim/lua/plugins/gruvbox.lua @@ -1,6 +1,7 @@ return { - "ellisonleao/gruvbox.nvim", lazy=false, - priority = 1000, + "ellisonleao/gruvbox.nvim", + lazy = true, + priority = 0, opts = {}, config = function() vim.cmd("colorscheme gruvbox") diff --git a/global/.config/nvim/lua/plugins/headlines.lua b/global/.config/nvim/lua/plugins/headlines.lua deleted file mode 100644 index 761f034..0000000 --- a/global/.config/nvim/lua/plugins/headlines.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - "lukas-reineke/headlines.nvim", - dependencies = "nvim-treesitter/nvim-treesitter", - opts = { - markdown = { - fat_headline_lower_string = "▔", - }, - }, - lazy = false, -} diff --git a/global/.config/nvim/lua/plugins/lsp.lua b/global/.config/nvim/lua/plugins/lsp.lua index 4dbd595..041da61 100644 --- a/global/.config/nvim/lua/plugins/lsp.lua +++ b/global/.config/nvim/lua/plugins/lsp.lua @@ -112,6 +112,7 @@ local config = function() biome = function() -- use tsserver instead return {} end, + require("lspconfig").marksman.setup({}), }, }) @@ -130,7 +131,7 @@ local config = function() completeopt = "menu,menuone,noinsert", }, sources = { - { name = "mkdnflow" }, + -- { name = "mkdnflow" }, { name = "luasnip" }, { name = "path" }, { name = "nvim_lsp" }, diff --git a/global/.config/nvim/lua/plugins/mkdnflow.lua b/global/.config/nvim/lua/plugins/mkdnflow.lua index bbe496a..aa2cd04 100644 --- a/global/.config/nvim/lua/plugins/mkdnflow.lua +++ b/global/.config/nvim/lua/plugins/mkdnflow.lua @@ -1,33 +1,12 @@ return { - "foozzi/mkdnflow.nvim", - lazy = true, + "jakewvincent/mkdnflow.nvim", + -- ft = "markdown", config = function() require("mkdnflow").setup({ modules = { - bib = true, - 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, + cmp = false, }, }) end, - dependencies = { - "bullets-vim/bullets.vim", - }, + -- Your other plugins } diff --git a/global/.config/nvim/lua/plugins/render-markdown.lua b/global/.config/nvim/lua/plugins/render-markdown.lua new file mode 100644 index 0000000..30bfb6d --- /dev/null +++ b/global/.config/nvim/lua/plugins/render-markdown.lua @@ -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, +} diff --git a/global/.config/nvim/lua/plugins/todo-comments.lua b/global/.config/nvim/lua/plugins/todo-comments.lua new file mode 100644 index 0000000..010a8bb --- /dev/null +++ b/global/.config/nvim/lua/plugins/todo-comments.lua @@ -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, +} diff --git a/global/.config/nvim/lua/plugins/twilight.lua b/global/.config/nvim/lua/plugins/twilight.lua new file mode 100644 index 0000000..4cd2f57 --- /dev/null +++ b/global/.config/nvim/lua/plugins/twilight.lua @@ -0,0 +1,3 @@ +return { + "folke/twilight.nvim", +} diff --git a/global/.config/nvim/lua/plugins/wrapping.lua b/global/.config/nvim/lua/plugins/wrapping.lua new file mode 100644 index 0000000..b71aadd --- /dev/null +++ b/global/.config/nvim/lua/plugins/wrapping.lua @@ -0,0 +1,7 @@ +return { + ft = "markdown", + "andrewferrier/wrapping.nvim", + config = function() + require("wrapping").setup() + end, +} diff --git a/global/.config/nvim/lua/plugins/zen-mode.lua b/global/.config/nvim/lua/plugins/zen-mode.lua new file mode 100644 index 0000000..ff7cc22 --- /dev/null +++ b/global/.config/nvim/lua/plugins/zen-mode.lua @@ -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, + }, + }, + }, + }, +} diff --git a/global/.config/nvim/lua/utils/helpers.lua b/global/.config/nvim/lua/utils/helpers.lua index 466a280..1cd00a3 100644 --- a/global/.config/nvim/lua/utils/helpers.lua +++ b/global/.config/nvim/lua/utils/helpers.lua @@ -1,3 +1,5 @@ +local mapvimkey = require("utils.keymapper").mapvimkey + local M = {} function M.InsertMarkdownURL() @@ -29,4 +31,33 @@ function M.InsertMarkdownURL() 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 diff --git a/global/.config/nvim/lua/utils/telescope_addons.lua b/global/.config/nvim/lua/utils/telescope_addons.lua index 761823e..59de525 100644 --- a/global/.config/nvim/lua/utils/telescope_addons.lua +++ b/global/.config/nvim/lua/utils/telescope_addons.lua @@ -4,19 +4,24 @@ local action_state = require("telescope.actions.state") local conf = require("telescope.config").values local pickers = require("telescope.pickers") local actions = require("telescope.actions") -local mapvimkey = require("utils.keymapper").mapvimkey +local helpers = require("utils.helpers") local M = {} local function paste_titled_link() return function(prompt_bufnr) actions.close(prompt_bufnr) + local current_file = vim.fn.expand("%:p") local selection = action_state.get_selected_entry() local parts = vim.split(selection.value, ":") 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 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) end end @@ -62,12 +67,25 @@ M.search_raw_title = function(opts) "--with-filename", "--line-number", "-i", + "-m", + "1", "title:.*" .. prompt, search_dir, } + if opts.type ~= "zettel" then + cmd[9] = "^#.*" .. prompt + end + return cmd 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 return nil end @@ -77,8 +95,8 @@ M.search_raw_title = function(opts) return { value = entry, - ordinal = basename .. " " .. (raw_title or ""), - display = basename .. " - " .. (raw_title or ""), + ordinal = basename .. " " .. (header or ""), + display = basename .. " - " .. (header or ""), filename = filename, lnum = tonumber(lnum), } @@ -114,9 +132,9 @@ M.search_raw_title = function(opts) :find() end -vim.api.nvim_create_user_command("SearchZettelTitle", function() - M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/NOTES/01-zettel/" }) -end, {}) -mapvimkey("fm", "SearchZettelTitle", "Search by zettel title") +-- vim.api.nvim_create_user_command("SearchZettelTitle", function() +-- M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/PKM/00-zettelkasten/" }) +-- end, {}) +-- mapvimkey("fm", "SearchZettelTitle", "Search by zettel title") return M diff --git a/global/.config/nvim/lua/utils/wiki_link.lua b/global/.config/nvim/lua/utils/wiki_link.lua new file mode 100644 index 0000000..bc9523e --- /dev/null +++ b/global/.config/nvim/lua/utils/wiki_link.lua @@ -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 diff --git a/global/.zshrc b/global/.zshrc index 5f85a7c..244e43b 100644 --- a/global/.zshrc +++ b/global/.zshrc @@ -67,16 +67,24 @@ alias ovim='vim' # original vim alias diary='ovim ~/vimwiki/diary/diary.asc.md' ## 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 vi='nvim' alias v='nvim' +## string +alias gen8='LC_CTYPE=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 8 | pbcopy' ## wttr.in alias wr='curl wttr.in' ## python alias python='python3' alias py='python' ## todo.txt -alias todo="todo.sh -d ~/Dropbox/TextSync/TODO/todo.cfg" +alias todo="todo.sh -d ~/Dropbox/TODO/todo.cfg" ## eton alias et="eton" alias zk="eton zk" @@ -85,6 +93,8 @@ alias to="toipe" ## jrnl.sh setopt HIST_IGNORE_SPACE alias jrnl=" jrnl" +## jupyter +alias jup="jupyter lab" # Preferred editor for local and remote sessions export EDITOR='nvim' diff --git a/macos/.nbrc b/macos/.nbrc index f4c25c4..f71ca9b 100644 --- a/macos/.nbrc +++ b/macos/.nbrc @@ -13,7 +13,7 @@ # 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 NB_PINNED_PATTERN="#pinned"