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

@ -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,
})

View file

@ -48,12 +48,19 @@ vim.keymap.set("v", ">", ">gv", { silent = true, noremap = true })
local api = vim.api
-- Zen Mode
api.nvim_set_keymap("n", "<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>zm", ":TZMinimalist<CR>", {})
api.nvim_set_keymap("n", "<leader>za", ":TZAtaraxis<CR>", {})
-- api.nvim_set_keymap("n", "<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>zm", ":TZMinimalist<CR>", {})
-- api.nvim_set_keymap("n", "<leader>za", ":TZAtaraxis<CR>", {})
-- Comments
api.nvim_set_keymap("n", "<C-_>", "gtc", { 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 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

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 {
"ellisonleao/gruvbox.nvim", lazy=false,
priority = 1000,
"ellisonleao/gruvbox.nvim",
lazy = true,
priority = 0,
opts = {},
config = function()
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
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" },

View file

@ -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
}

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 = {}
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

View file

@ -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("<leader>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("<leader>fm", "SearchZettelTitle", "Search by zettel title")
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